akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true)
		{
			int sum = 0;
			int n = sc.nextInt();
			if(n == 0)
				break;
			int max = sc.nextInt();
			int min = sc.nextInt();
			if(max < min)
			{
				int tmp = max;
				max = min;
				min = tmp;
			}
			for(int i = 0 ; i < n - 2 ; i++)
			{
				int x = sc.nextInt();
				if(x > max)
				{
					sum += max;
					max = x;
				}
				else if(x < min)
				{
					sum += min;
					min = x;
				}
				else
					sum += x;
			}
			System.out.println(sum / (n - 2));
		}
	}
}


Measured memory_bytes: 29428
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def calc_cumsum(l):
    cumsum = [l[0]]
    for i in l[1:]:
        cumsum.append(cumsum[-1] + i)
    return cumsum


def main():
    n, m, k = LI()
    a = LI()
    b = LI()
    costs = [float('inf')] * (n + m + 1)
    costs[0] = 0
    # a, b を i 冊読むのにかかる時間の累積
    ruiseki_a = [0] + calc_cumsum(a)
    ruiseki_b = [0] + calc_cumsum(b)
    best_b_num = 0  # 所要時間 k 以下で読める b の冊数の最大値
    for i in range(m + 1):
        if ruiseki_b[i] <= k:
            best_b_num = i

    ans = 0
    j = best_b_num
    for i in range(n + 1):
        # a の最大の冊数まで調べる
        if ruiseki_a[i] > k:
            break

        # a の冊数 i に対する b の冊数 j
        # a が 1冊増えれば b が 1冊減る
        # 全ループの合計で高々 m 回
        while ruiseki_b[j] > k - ruiseki_a[i]:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


main()


Measured memory_bytes: 53528
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAX_X 100000
long long dp[200][MAX_X + 1];

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> S(N);
    for(int i=0; i<N; ++i) cin >> S[i];
    sort(begin(S), end(S));

    for(int j=0; j<=MAX_X; ++j) dp[0][j] = j % S[0];

    for(int i=1; i<N; ++i) {
        for(int j=0; j<=MAX_X; ++j) {
            dp[i][j] = (dp[i-1][j] * i % MOD + dp[i-1][j % S[i]] % MOD) % MOD;
        }
    }

    cout << dp[N-1][X] << endl;
}

Measured memory_bytes: 156544
#include <iostream>
#include <string>
int main()
{
  int N;
  std::cin >> N;
  int ptn[5] = {0}; // M, A, R, C, H
  for (int i = 0; i < N; i++) {
    std::string S;
    std::cin >> S;
    switch (S[0]) {
      case 'M': {ptn[0]++; break;}
      case 'A': {ptn[1]++; break;}
      case 'R': {ptn[2]++; break;}
      case 'C': {ptn[3]++; break;}
      case 'H': {ptn[4]++; break;}
      default: break;
    }
  }
  long long ans = 0;
  for (int i = 0; i <= 2; i++) {
    for (int j = i+1; j <= 3; j++) {
      for (int k = j+1; k <= 4; k++) {
        ans += ((long long)ptn[i]*ptn[j]*ptn[k]);
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
yo=[]
yo0=[]
for __ in range(x):
    a,b=map(int,input().split())
    yo.append(a)
    yo0.append(b)
lol=[0]*(y+1)
lol0=[0]*(y+1)
k=[0]*(y+1)
#print(lol,lol0)
for i in range(1,x+1):
    for j in range(1,y+1):
        if j<yo[i-1]:
            #print(j,lol0[j],lol[j])
            lol0[j]=lol[j]
        else:
            lol0[j]=max(lol[j],yo0[i-1]+lol[j-yo[i-1]])
    lol=lol0[:]
    lol0=k[:]
print(lol[y])            

Measured memory_bytes: 77564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  vector<int> f[n],r[n];
  ll u,v,w;
  
  rep(i,n-1){
    cin>>u>>v>>w;
    u--;
    v--;
    w%=2;
    if(w==1){
      r[u].push_back(v);
      r[v].push_back(u);
    }
    else{
      f[u].push_back(v);
      f[v].push_back(u);
    }
  }
  queue<int> q;
  
  int ans[n];
  rep(i,n) ans[i]=-1;
  
  rep(i,n){
    if(ans[i]==-1){
      q.push(i);
      ans[i]=0;
    }
    
    while(!q.empty()){
      int now=q.front();q.pop();
      for(u:r[now]){
        if(ans[u]!=-1) continue;
        ans[u]=1-ans[now];
        q.push(u);
      }
      
      for(u:f[now]){
        if(ans[u]!=-1) continue;
        ans[u]=ans[now];
        q.push(u);
      }
    }
  }
  
  rep(i,n) cout<<ans[i]<<endl;
}
      

Measured memory_bytes: 9856
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    string s[101];
    for(int i=0; i<n; i++) cin>>s[i];
    int S=n*m, T=n*m+1;
    mf_graph<int> g(n*m+2);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if((i+j)&1) g.add_edge(S, i*m+j, 1);
            else g.add_edge(i*m+j, T, 1);
        }
    }
    int num1[101][101], num2[101][101];
    for(int i=0; i<n; i++){
        for(int j=0; j<m-1; j++){
            if(s[i][j]=='.' && s[i][j+1]=='.'){
                if((i+j)&1) num1[i][j]=g.add_edge(i*m+j, i*m+j+1, 1);
                else num1[i][j]=g.add_edge(i*m+j+1, i*m+j, 1);
            }else{
                num1[i][j]=-1;
            }
        }
    }
    for(int i=0; i<n-1; i++){
        for(int j=0; j<m; j++){
            if(s[i][j]=='.' && s[i+1][j]=='.'){
                if((i+j)&1) num2[i][j]=g.add_edge(i*m+j, (i+1)*m+j, 1);
                else num2[i][j]=g.add_edge((i+1)*m+j, i*m+j, 1);
            }else{
                num2[i][j]=-1;
            }
        }
    }
    printf("%d\n", g.flow(S, T));
    string ans[101];
    for(int i=0; i<n; i++) ans[i]=s[i];
    for(int i=0; i<n; i++){
        for(int j=0; j<m-1; j++){
            if(num1[i][j]>=0 && g.get_edge(num1[i][j]).flow) ans[i][j]='>', ans[i][j+1]='<';
        }
    }
    for(int i=0; i<n-1; i++){
        for(int j=0; j<m; j++){
            if(num2[i][j]>=0 && g.get_edge(num2[i][j]).flow) ans[i][j]='v', ans[i+1][j]='^';
        }
    }
    for(int i=0; i<n; i++) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 5408
n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
    templ,tempr=map(int,input().split())
    l.append(templ)
    r.append(tempr)
l_max=max(l)
r_min=min(r)

if l_max<=r_min:
    print(r_min-l_max+1)
else:
    print(0)    
    

Measured memory_bytes: 16596
#include<stdio.h>
int main(void)
{
	while (1){
		int a[100000]={0},b[100000]={0},c=0,i,j,k,n;
		scanf("%d%d",&n,&k);
		if(n==0 && k==0)
		{
			break;
		}
		for(i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n-k+1;i++)
		{
			for(j=1;j<=k;j++)
			{
				b[i]=b[i]+a[i+j-2];
			}
			if(b[i]>c)
			{
				c=b[i];
			}
		}
		printf("%d\n",c);
	}
	return 0;
}


Measured memory_bytes: 2480
/* ex 9_1
   Stuartyg */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの数(余分に取る)
#define SIZE 20
//プロトタイプ宣言
typedef struct stack stack;
void initialize_stack(stack *stk);
void push(stack *stk, char elem);
void pop(stack *stk);
void print_stuck(stack *stk);

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

int main(void){
    stack stk;
    char mojiretu[20];
    char *str;

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    scanf("%s",mojiretu);
    str = mojiretu;

    //キーボード操作
    while(*str){
        
        if(*str != 'B'){
            //スタックにデータを追加
            push(&stk, *str);
        }
        else{
                if (stk.count >=1){ //->でやると大小比較などの演算子と間違えてエラー
                    //スタックからデータを取り出す
                    pop(&stk);
            }
        }
        str++;
    }
    print_stuck(&stk);
    return 0;
}

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){ //error
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem; //append
        stk->count++; //要素数を1増やす
    }
}

//データの削除
void pop(stack *stk){
    if(stk->count <= 0){ //error
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        stk->top++; //一個前のものにする
        stk->count--; //要素数を1減らす
    }
}

//出力
void print_stuck(stack *stk){
    int i = 0;
    for (;i < stk->count;i++){
        printf("%c",stk->data[SIZE-1-i]); //data[SIZE-1],data[SIZE-2],…と格納されていくので
    }
    printf("\n");
}

Measured memory_bytes: 1636
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<ll> P(A);
	rep(i, A) cin >> P[i];

	vector<ll> Q(B);
	rep(i, B) cin >> Q[i];

	vector<ll> R(C);
	rep(i, C) cin >> R[i];

	sort(all(P), greater<ll>());
	sort(all(Q), greater<ll>());
	sort(all(R), greater<ll>());

	priority_queue<ll, vector<ll>, greater<ll> > q;
	rep(i, X) q.emplace(P[i]);
	rep(i, Y) q.emplace(Q[i]);

	int r = 0;
	ll diff = 0;
	while (!q.empty() && r < C)
	{
		if (q.top() > R[r]) break;

		q.pop();
		diff += R[r];
		r++;
	}

	ll s = 0;

	while (!q.empty())
	{
		s += q.top();
		q.pop();
	}

	cout << s + diff << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> S(N);
    string s;
    int p;
    for (int i=0; i<N; i++) {
        cin >> s >> p;
        S.at(i) = make_pair(make_pair(s, -1*p), i+1);
    }
    sort(S.begin(), S.end());
    for (int i=0; i<N; i++) cout << S.at(i).second << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
  int i,j,n,k[10000],l=0;
  scanf("%d",&n);
  
  for (i=0;i<n;i++){
    scanf("%d",&k[i]);
  }
  for (i=0;i<n;i++){
    for (j=2;j*j<=k[i];j++){
      if (k[i]%j==0){
	l++;
	break;
      }
    }
  }
  printf ("%d\n",n-l);
  return 0;
}



Measured memory_bytes: 2100
#include "bits/stdc++.h"
  using namespace std;
  #define ll long long
  #define mod 998244353

  ll dp[3005][3005];
  
  int main()
  {
    ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    for(ll i=a; i<=c; i++) {
      for(ll j=b; j<=d; j++) {
        if(i==a && j==b) dp[i][j] = 1;
        else if(i == a) dp[i][j] = dp[i][j-1]*a % mod;
        else if (j == b) dp[i][j] = dp[i-1][j]*b % mod;
        else {
          dp[i][j] += ((ll) i*dp[i][j-1]) + ((ll) j*dp[i-1][j]);
          dp[i][j]%=mod;
          dp[i][j] -= dp[i-1][j-1]*(ll) (i-1)*(ll) (j-1) % mod;
          if(dp[i][j]<0) dp[i][j]+=mod;
        }
      }
    }
    cout << dp[c][d] << "\n";

    return 0;
  }

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

int main(){
  long long n = 0;
  long long ans = 0;
  
  cin >> n;
  for(int i=0; i <= n; i++){
    if(i%5!=0 && i%3!=0){
      ans += i;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }else if(a==c){
    cout<<b<<endl;
  }else{
    cout<<a<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
//Goodbye stupid girls & Hello L0u1Za, Codeforces and my friends(nobody)
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <utility>
#include <climits>
#include <functional>
#include <iomanip>
#include <stack>
#include <queue>
#include <type_traits>
#include <deque>
#include <random>
#include <unordered_map>
#include <unordered_set>
//#include <Windows.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
template <class T>
using pt = std::pair<T, T>;
using namespace std;


int main() {
	#ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#else
	#endif
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	char c;
	cin >> c;
	cout << char(c + 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 


const int N_MAX = 301;
//i:1枚の数，j,2枚の数,k3枚の数
double dp[N_MAX][N_MAX][N_MAX];

double dfs(int i, int j, int k, int n){
  if(dp[i][j][k]>=0.0) return dp[i][j][k];
  double ret = (double)n;
  if(i) ret += i*dfs(i-1,j,k,n);
  if(j) ret += j*dfs(i+1,j-1,k,n);
  if(k) ret += k*dfs(i,j+1,k-1,n);
  ret /= (double) i+j+k;
  return dp[i][j][k] = ret;
}

int main(void){
  int N;cin >> N;
  int n[4] = {0};
  REP(i,N){
    int x;
    cin >> x;
    n[x]++;
  }
  REP(i,N_MAX)REP(j,N_MAX)REP(k,N_MAX) dp[i][j][k] = -1.0;
  dp[0][0][0] = 0;
  cout << setprecision(15);
  cout << dfs(n[1],n[2],n[3],N) << endl;
  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NL = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var N = NL[0];
            var L = NL[1];
            

            int[] Ringo = new int[N];
            int[] aji_abs = new int[N];

            for (int i = 0; i < N; i++)
            {
                Ringo[i] = L + i ;
                aji_abs[i] = Math.Abs(Ringo[i]); 
            }

            if (L >= 0)
            {
                Console.WriteLine(Ringo.Sum()-aji_abs.Min());
            }
            else
            {
                Console.WriteLine(Ringo.Sum() + aji_abs.Min());
            }

        }
    }
}


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

struct node{
  char name[11];
  struct node *left;
  struct node *right;
};

struct node *mallocNode(char *n){
  struct node *add;

  add = (struct node*)malloc(sizeof(struct node));
 
  if(add == NULL){ 
    return NULL;
  }
  
  add->left = NULL;
  add->right = NULL;
  strcpy(add->name,n); 
  //cout << add->name << endl;
  //cout << "3" << endl;
  return add;
}

int searchNode(struct node *root,char *n){
  struct node *node;
  node = root;
  int result;
  string str1 = n;
  string str2;
  
  /*if(root == NULL){
    root = mallocNode(n);
    cout << "2" << endl;
    if(root == NULL){
      cout << "malloc error" <<endl;
      exit(1);
      }
      return 1;
   }*/

  //cout << "1" << endl;
  //return 0;
  
  while(1){
    str2 = node->name;
    result = str2.compare(str1);
    //cout << result << endl;
    if(result > 0){ 
      if(node->left == NULL){
        node->left = mallocNode(n);
        return 1;
      }
      node = node->left;
    }
    else if(result < 0){
      if(node->right == NULL){
        node->right = mallocNode(n);
        return 1;
      }
      node = node->right;
    }
    else{
      return (-1);
    }
  }
}

int main() {
  int N;
  int ans = 1;
  struct node *root;
  cin >> N;
  
  root = NULL;
  
  char s[11];
  int y;
  cin >> s;
  
  root = mallocNode(s);
  
  for(int i=1;i<N;i++){
    cin >> s;
    
    y = searchNode(root,s);
    //cout << y << endl;
    
    if(y==1) ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 12960
n,m,x = map(int, input().split())
a = [int(y) for y in input().split()]

c1 = 0
c2 = 0

for i in range(1, x):
  if i in a:
    c1 += 1

for i in range(x + 1, n):
  if i in a:
    c2 += 1

print(min(c1,c2))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
  
double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    // Find the difference between two angles  
    double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

int main(){
    int a,b;
    double h,m;
    cin>>a>>b>>h>>m;
    if(h==0)h=12;
    if(m==0)m=60;
    double angle=calcAngle(h,m);
    double pi = 2 * acos(0.0); 
    double ang=pi;
    ang/=180;
    ang*=angle;
    std::cout << std::fixed;
    std::cout << std::setprecision(20);
    if(angle==0){
        cout<<abs(a-b)<<endl;
    }
    else{
        double ans=2;
        ans*=(a*b);
        ans*=cos(ang);
        ans*=-1;
        ans+=pow(a,2);
        ans+=pow(b,2);
        ans=sqrt(ans);
        std::cout << ans;
    }
    return 0;
}

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

int n[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int totalday(int month, int day){
	int res = 0;
	for(int i=1; i<month; i++){
		res += n[i-1];
	}
	res += day;
	return res;
}

int main(void) {
	int month, day;
	while(cin >> month >> day){
		if(month==0 && day==0) break;
		int total = totalday(month, day);
		total = total % 7;

		switch(total){
		case 1:
			cout << "Thursday" << endl;
			break;
		case 2:
			cout << "Friday" << endl;
			break;
		case 3:
			cout << "Saturday" << endl;
			break;
		case 4:
			cout << "Sunday" << endl;
			break;
		case 5:
			cout << "Monday" << endl;
			break;
		case 6:
			cout << "Tuesday" << endl;
			break;
		case 0:
			cout << "Wednesday" << endl;
			break;
		}
	}
	return 0;
}

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

int main(void)
{
    string s;
    cin >> s;
    int count = 0;
    
    for (int i = 0; i < s.length(); i ++) {
        if (s[i] == s[i + 1]) {
            if (s[i] == '1') {
                s[i + 1] = '0';
            } else if (s[i] == '0') {
                s[i + 1] = '1';
            }
            
            count ++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
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(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,j,k,ans=0,K;
  cin>>K;
  FOR(i,1,K+1)FOR(j,1,K+1)FOR(k,1,K+1)ans+=GCD(i,GCD(j,k));

  cout<<ans<<endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[20],coppy[20]="CODEFESTIVAL2016";
	scanf("%s",s);
	int a=16;
	for(int i=0;i<=15;i++){
			if(s[i]==coppy[i])
			a--;
	}
	cout << a;
	return 0;
}

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

//回文判定
bool judge(string S){
  string T = S;
  reverse(S.begin(), S.end());
  if(S == T) return true;
  return false;
}
     
int main(){
  string S;
  cin >> S;
  
  string a, b;
  a = S.substr(0, (S.size() - 1)/2);
  b = S.substr((S.size() - 1)/2 + 1);
  if(judge(a) && judge(b) && judge(S)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}
  

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

int main(){
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans != "") ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
/*
    BFS(bread-first search，幅優先探索)を用いる
    アリ本pp.87以降にグラフの解説がある
*/
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;

#define repeat(i, n) for (int i = 0; i < (n); i++)
#include<queue>
const int INF = numeric_limits<int>::infinity();

int main(void)
{
    // 部屋数N、通路数M
    int N, M;
    cin >> N >> M;

    vector<vector<int>> to(N, vector<int>());
    repeat(i, M){
        // 互いに通行可能な部屋a-b
        int a, b;
        cin >> a >> b;
        // 配列格納用にデクリメント処理
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;               // プライオリティキュー使おうと思ったけどBFSできなくなるっぽい
    vector<int> dist(N, INF);   // 無限大で初期化
    vector<int> pre(N, -1);     // -1で初期化
    dist[0] = 0;
    q.push(0);
    while (!q.empty())
    {
        int v = q.front();  // 先頭要素の確認、抜き取り
        q.pop();    // 取り出し(pop()はvoid型だった)
        // 拡張for文(だっけ？)
        for (int u : to[v])
        {
            // 既に距離が算出されていれば以降の処理を省く
            if (dist[u] != INF)
            {
                continue;
            }
            // 繋がっている部屋のゴールまでの距離+1がゴールまでの距離
            dist[u] = dist[v] + 1;
            // 道しるべの部屋番号を記録
            pre[u] = v;
            // キューに自身を格納(幅優先探索の処理、これに基づいて子を展開する)
            q.push(u);
        }
    }

    puts("Yes");
    repeat(i, N){
        if (i == 0){
            continue;
        }
        int ans = pre[i];
        printf("%d\n", ans+1);
    }

    return 0;
}

Measured memory_bytes: 10720
import sys

N = int(input())
coordinates = []
for _ in range(N):
    coordinates.append(list(map(int, input().split())))
    
coordinates = sorted(coordinates, key=lambda x:x[2], reverse=True)

for cx in range(100+1):
    for cy in range(100+1):
        x, y, h= coordinates[0]
        H = h + abs(x-cx) + abs(y-cy)
        i = 1
        for x, y, h in coordinates[1:]:
            if not h == max(H - abs(x-cx) - abs(y-cy), 0):
                break
            else:
                i += 1
                if i == N:
                    print(cx, cy, H)
                    sys.exit()               

Measured memory_bytes: 3064
s = input()

if len(s) % 2 != 0:
    print("No")
    exit()
     
for i in range(len(s)):
    if (i % 2 == 0 and s[i] != 'h') or ( i % 2 == 1 and s[i] != 'i'):
        print("No")
        exit()

print("Yes")



Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

//素因数分解
map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

ll div_num(ll n) {
    ll ret = 1;
    auto mp = prime_factor(n);
    for(auto x : mp) {
        ret *= x.second;
    }
    return ret;
}

set<ll> divisor(ll n) {
    set<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.insert(i);
            if(i * i != n)
                ret.insert(n / i);
        }
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    set<ll> div = divisor(N - 1);
    set<ll> res = div;
    res.erase(1);
    div = divisor(N);
    for(auto x : div) {
        if(x == 1)
            continue;
        if(x == N) {
            res.insert(x);
            break;
        }
        ll A = N;
        while(A % x == 0) {
            A /= x;
        }
        if(A % x == 1)
            res.insert(x);
        // set<ll> d = divisor(A - 1);
        // for(auto y : d) {
        //     if(y == 1)
        //         continue;
        //     res.insert(y);
        // }
    }
    cout << res.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N;
	cin >> N;
	vector<int> L(N);
	rep(i, N) cin >> L[i];
	sort(L.begin(), L.end());

	vector<ll> dp; // dp[i]: L[i+2] までの棒を使用する．

	// dp[i+1] = (i+1番目を必ず使用) + dp[i];
	if(L[0]+L[1]>L[2]) dp.push_back(1);
	else dp.push_back(0);

	for(int i=1; i<N-2; i++) {
		int cnt = 0;

		/* 打ち切りや2分探索で高速化できる */
		// for(int j = i-1+2; j>0; j--) {
		// 	if(L[j]+L[j-1]<=L[i+2]) continue; // 打ち切り
		// 	for(int k = j-1; k>=0; k--) {
		// 		if(L[j]+L[k]>L[i+2]) cnt++;
		// 		else break; // 打ち切り
		// 		// cout << "cnt " << cnt << ' ' << L[i+2] << ' '<< L[j] << ' '<< L[k] << endl;
		// 	}
		// }

		/* 2分探索 */
		for(int j = i-1+2; j>0; j--) {

			if(L[j]+L[j-1]<=L[i+2]) continue; // 全てNG
			else if(L[j]+L[0]>L[i+2]) { // 全てOK
				cnt += j;
				continue;
			} else {
				int l = 0, r = j-1; // l: NG, r: OK
				
				while(l+1<r) {
					int mid = (l+r)/2;
					if(L[j]+L[mid]>L[i+2]) {
						r = mid;
					} else {
						l = mid;
					}
				}

				cnt += j-1-l;
			}
		}

		dp.push_back(dp[i-1] + cnt);
		//cout << "dp[i]: " << dp[i] << endl;
	}

	cout << dp[N-3] << endl;

	return 0;
}

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

using namespace std;

int main() {
  int x, y, s;
  while (true) {
    scanf("%d %d %d", &x, &y, &s);
    if (x == 0 && y == 0 && s == 0) break;
    int max_sum = 0;
    for (int c1=1;c1<=s/2;c1++) {
      const int c2x = s-c1*(100+x)/100;
      if (c2x <= 0) continue;
      int c2 = c2x*100/(100+x);
      while (c2*(100+x)/100 < c2x) c2++;
      if (c2*(100+x)/100 != c2x) continue;
      if (c2 < 1 || c2 > s-1) continue;
      max_sum = max(max_sum, c1*(100+y)/100+c2*(100+y)/100);
    }
    printf("%d\n", max_sum);
  }
  return 0;
}

Measured memory_bytes: 2572
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Long[] data = new Long[N];
		for(int i=0;i<N ;i++) {
			data[i]= sc.nextLong();
		}
		int count =0;
		long t =1;
		for(int i=0;i<N;i++) {
			if(data[i]== t) {
				t++;
			}else {
				count++;
				
			}
		}
		if(t==1) {
			System.out.print("-1");
		}else {
		System.out.print(count);
	    }
	}
		
}


Measured memory_bytes: 97104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2)
 
int main() {
  int N;
  cin >> N;
  REP(i,N) {
    int A;
    cin >> A;
    if(A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

LL patty(int level) {
  LL res = 1;
  for (int i=0; i<level; ++i) {
    res = 2*res + 1;
  }
  return res;
}

LL count(LL ind, int level) {
  if (level==0) return 1;
  LL thkness = 1;
  for (int i=0; i < level; ++i) {
    thkness = 2*thkness + 3;
  }

  if (ind == 0) return 0;
  if (ind == thkness - 1) return patty(level);
  if (ind > (thkness-1)/2) {
    return patty(level-1) + count(ind - (thkness-1)/2 - 1, level-1) + 1;
  } else if (ind == (thkness-1)/2) {
    return patty(level-1) + 1;
  } else {
    return count(ind-1, level-1);
  }
}

int main() {
  LL N, X;
  cin >> N >> X;
  X -= 1;

  cout << count(X, N) << endl;

  return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
 
        if (s.indexOf("9") != -1) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
 
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




void solve(){
	int x, y , z ;cin >> x >> y >> z ;
	swap(x,y);
	swap(x,z);
	cout << x <<' ' <<  y <<' ' << z ;
	 

}


signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3648
# b = input()
# if b == 'A':
#     print('T')
# elif b == 'T':
#     print('A')
# elif b == 'G':
#     print('C')
# else:
#     print('G')
b = input()
c = []
for i in range(len(b)):
  if b[i] == 'A':
    c.append('T')
  elif b[i] == 'T':
    c.append('A')
  elif b[i] == 'G':
    c.append('C')
  else:
    c.append('G')
print(''.join(c))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
string k;
lli d,i,j,l;
cin>>k;
cin>>d;
lli dp[k.length()+1][d][2];
memset(dp,0,sizeof(dp));
dp[0][0][0]=1;
for(i=1;i<=k.length();i++){
    for(j=0;j<d;j++){
            for(bool small:{false,true}){
        for(l=0;l<=9;l++){
                if(!small&&k[i-1]-48<l)
                break;
                int x=j-l;
                while(x<0)
                    x+=d;
                dp[i][j][small||l<k[i-1]-'0']=(dp[i][j][small||l<k[i-1]-'0']+dp[i-1][x][small])%mod;
                //dp[i][(j+l)%d][small||l<k[i-1]-'0']=dp[i-1][j][small]+dp[i][(j+l)%d][small||l<k[i-1]-'0'];
        }
        }
    }
}
lli ans=(dp[k.length()][0][false]+dp[k.length()][0][true])%mod;
ans--;
if(ans<0)
    ans+=mod;
cout<<ans<<endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    ll n,m,ans=0;
    cin >> n >> m;
    vector<ll> x(m),sa(m-1);
    for(ll i=0;i<m;i++) cin >> x[i];
    sort(x.begin(),x.end());
    for(ll i=0;i<m-1;i++){
        sa[i]=x[i+1]-x[i];
    }
    sort(sa.begin(),sa.end());
    for(ll i=0;i<m-n;i++){
        ans+=sa[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int n, k;
	cin >> n >> k;
	VI v(n);
	
	loop(i, n){
		cin >> v[i];
	}
	
	sort(all(v));
	
	cout << accumulate(v.begin(), v.begin() + k, 0);
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3604
// Frog-1   --   Educational DP Contest 

#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1e9+5
using namespace std;

int main(){

      int n; cin >> n;
      
      vector <int> h(n);
      for(int i=0; i<n; i++){
            cin >> h[i];
      }

      // dp vai armazenar quando de altura foi 'gasto' ate o momento
      vector <int> dp(n, INF);
      dp[0] = 0;

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

      cout << dp[n-1];

      return 0;
}

Measured memory_bytes: 1024
#include<iostream>
 
using namespace std;
 
int main() {
	long long A, B;
	cin >> A >> B;
 
	if (A % 2 != B % 2) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (A + B) / 2 << endl;
	}
 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, k;
	cin>>n>>k;
	vector<int>x(n);for(auto &v : x) cin >> v;
	int ans = INT_MAX;
	for (int l = 0; l <= n - k; l++) {
		int r = l + k - 1;
		ans = min(ans, x[r] - x[l] + min(abs(x[l]), abs(x[r])));
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int K;
    int N;
    int arr[200002];
    cin>>K>>N;
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        cin>>arr[i];
    }
    sort(arr,arr+N);
    int k=arr[0];
    int res=0;
    for(int i=1;i<N;i++){
        res=max(res,(arr[i]-k));
        k=arr[i];
    }
    res=max(res,K-(arr[N-1]-arr[0]));
    cout<<K-res<<endl;
}


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

int main()
{
	int i,j,k;
	int n;
	int b,f,r,v;
	int house[4][3][10];
	string space = "####################";
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				house[i][j][k] = 0;
			}
		}
	}
	
	cin >> n;
	
	for(i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		house[b - 1][f - 1][r - 1] += v;
	}
	
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				cout << " " << house[i][j][k];
			}
			cout << endl;
		}
		if(i < 3)
		{
			cout << space << endl;
		}
	}
}


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

int main(){
    string S;
      cin >> S;
      int a =(int)(S.length());
      
      rep(i,a){
    
          cout << 'x';
      }
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	h := scanInt(sc)
	w := scanInt(sc)

	cnt := 0
	for i := 0; i < n; i++ {
		a := scanInt(sc)
		b := scanInt(sc)
		if a >= h && b >= w {
			cnt += 1
		}
	}

	fmt.Println(cnt)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K;

  std::string S;

  std::cin >> N >> K >> S;

  K --;

  S[K] = tolower(S[K]);

  std::cout << S << std::endl;
  
  return 0;
}


Measured memory_bytes: 888
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	ll k, a, b,ans=0,inc;
	cin >> k >> a >> b;
	if ((b - a) < 3) {
		cout << k + 1 << endl;
	}
	else {
		if (a > (k - 1)) { cout << k + 1 << endl; }
		else {
			inc = b - a;
			ans = a;
			k = k - (a - 1);
			if (k % 2 == 1)ans++;
			k = k / 2;
			ans += k * inc;
			cout << ans << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;

int n;
const int nx = 1e5+5;
int ac[nx][3];
int dp[3][nx];
int go(int a, int i){
	if(i == n) return 0;
	if(dp[a][i] != -1) return dp[a][i];
	int& ans = dp[a][i];
	
	if(a==0){
		ans=max(ans, go(1, i+1)+ac[i][0]);
		ans=max(ans, go(2, i+1)+ac[i][0]);
	}
	if(a==1){
		ans=max(ans, go(0, i+1)+ac[i][1]);
		ans=max(ans, go(2, i+1)+ac[i][1]);
	}
	if(a==2){
		ans=max(ans, go(0, i+1)+ac[i][2]);
		ans=max(ans, go(1, i+1)+ac[i][2]);
	}
	
	return ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
	memset(dp, -1, sizeof dp);
	cout<<max(go(0,0),max(go(1,0),go(2,0)))<<"\n";
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> b;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        if(i==0)b.push_back(k);
        else if(b.back()!=k)b.push_back(k);
    }
    int res=1;
    bool up=(b[0]<b[1]);
    for(int i=1;i<b.size();i++){
        if((b[i]>b[i-1]&&up)||(b[i]<b[i-1]&&!up))continue;
        res++;
        up=(b[i]<b[i+1]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;

LL gcd(LL a, LL b) { while (b) { int t = a%b; a = b; b = t; } return a; }

map<LL, LL> mp;

void init(LL n) {
	LL tmp = n;
	for (LL i = 2; i*i <= tmp; ++i) {
		while (n%i == 0) {
			n /= i;
			mp[i]++;
		}
	}
	if (n != 1) mp[n]++;
}
int main(void)
{
	LL n, p;
	sci(n); sci(p);
	init(p);
	LL ret = 1;
	for (auto iter = mp.begin(); iter != mp.end(); iter++) {
		(*iter).second /= n;
		ret *= (LL)pow((*iter).first, (*iter).second);
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    a := make([]int, n)
    for i:=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    ok := true
    ans := 0
    b := make([]bool, n)
    next := 0
    for{
        if next == 1{
            break
        }
        if b[next]{
            ok = false
            break
        }
        b[next]=true
        next=a[next]-1
        ans++
    }
    if !ok{
        ans = -1
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 5504