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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, ll L, vector<ll> a) {
    int fst = -1;
    for (int i = 0; i + 1 < a.size(); i++) {
        if (a[i] + a[i + 1] >= L) {
            fst = i;
            break;
        }
    }
    if (fst == -1) {
        cout << "Impossible" << endl;
        return;
    }
    cout << "Possible" << endl;
    vector<int> ord;
    ord.push_back(fst);
    for (int i = fst - 1; i >= 0; i--) {
        ord.push_back(i);
    }
    for (int i = fst + 1; i < N - 1; i++) {
        ord.push_back(i);
    }


    reverse(ord.begin(), ord.end());
    for (int i = 0; i < ord.size(); i++) cout << ord[i] + 1 << endl;

}


void main_(istream &cin) {
    ll N;
    ll L;
    cin >> N;
    vector<ll> a(N - 1 + 1);
    cin >> L;
    for (int i = 0; i <= N - 1; i++) {
        cin >> a[i];
    }
    solve(N, L, a);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, B;
  	char op;
 	cin >> A >> op >> B;
  
	if (op == '+') {
    	cout << A + B << endl;
    }else {
    	cout << A - B << endl;
    }
  
  
  
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner stdin=new Scanner(System.in);
		int H;
		int W;
		
		while(true){
			H=stdin.nextInt();
			W=stdin.nextInt();
			if(H==0 && W==0) {break;}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					System.out.print("#");
					}
				System.out.print("\n");
		}
		System.out.print("\n");
	}
	}
}



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

using ll=long long;
const ll MOD=1000000007;

int main() {
  string s,k="keyence";
  cin >> s;
  int t=s.size();
  int a=0;
  int i=0;
  int j=0;
    while(i<7){
      if(s[i]==k[i]){
        i++;
      }
      else
      break;
    }
    while(j<7){
      if(s[t-1-j]==k[6-j]){
        j++;
      }
      else
      break;
    }
    if(i+j>=7){
      a=1;
    }
    if(a==1){
      cout << "YES" << endl;
    }
    else
      cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int e1,e2,e3,e4;
	scanf("%d%d%d%d",&e1,&e2,&e3,&e4);
	if((e1==e2&&e3==e4)||(e1==e3&&e2==e4)||(e1==e4&&e3==e2))
		printf("yes\n");
	else
		printf("no\n");
	return 0;
}


Measured memory_bytes: 2044
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    priority_queue<ll> pq;

    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        pq.push(A[i]);
    }

    for (ll i = 0; i < M; i++) {
        ll t = pq.top();
        pq.pop();
        pq.push(t / 2);
    }

    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 2168
from copy import deepcopy
N, K = map(int, input().split())
V = list(map(int, input().split()))
Lsum = [0]
Rsum = [0]
Lnegs = [[]]
Rnegs = [[]]
for i in range(N):
    Lsum.append(Lsum[i]+V[i])
    Rsum.append(Rsum[i]+V[N-i-1])
    Lnegs_cp = deepcopy(Lnegs[i])
    if V[i] < 0:
        Lnegs_cp.append(V[i])
        # Lnegs_cp = sorted(Lnegs_cp)
    Lnegs.append(Lnegs_cp)
    Rnegs_cp = deepcopy(Rnegs[i])
    if V[N-i-1] < 0:
        Rnegs_cp.append(V[N-i-1])
        # Rnegs_cp = sorted(Rnegs_cp)
    Rnegs.append(Rnegs_cp)

ans = 0

for dig in range(min(N+1, K+1)):
    n_del = K - dig
    for ldig in range(dig+1):
        rdig = dig - ldig
        LRsum = Lsum[ldig] + Rsum[rdig]
        negs = []
        for neg in Lnegs[ldig]:
            negs.append(neg)
        for neg in Rnegs[rdig]:
            negs.append(neg)
        negs = sorted(negs)
        for i in range(min(n_del, len(negs))):
            LRsum -= negs[i]
        ans = max(ans, LRsum)

print(ans)

# for llim in range(N+1):
#     rlim = N - llim
#     lmax = -1001001001
#     for k0 in range(min(K, llim)):
#         kh = min(K, llim) - k0
#         s0 = Lsum[k0]
#         s1 = 0
#         for l in range(min(len(Lnegs[k0]),kh)):
#             s1 -= Lnegs[k0][l]
#         lmax = max(lmax, s0+s1)
#         rmax = -1001001001
#         for k1 in range(min(K - k0, rlim)):
#             kh = min(K - k0, rlim) - k1
#             s0 = Rsum[k1]
#             s1 = 0
#             for l in range(min(len(Rnegs[k1]),kh)):
#                 s1 -= Rnegs[k1][l]
#             rmax = max(rmax, s0+s1)
#         ans = max(ans, lmax + rmax)

# print(ans)

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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 100000000009;
    ll money;

    if (x > y)
    {
        rep(i, x + 1)
        {
            if (i < y)
            {
                money = 2 * c * i + a * (x - i) + b * (y - i);
            }
            else if (i >= y && i < x)
            {
                money = 2 * c * i + a * (x - i);
            }
            else
            {
                money = 2 * c * i;
            }
            ans = min(ans, money);
        }
    }

    else
    {
        rep(i, y + 1)
        {
            if (i < x)
            {
                money = 2 * c * i + a * (x - i) + b * (y - i);
            }
            else if (i >= x && i < y)
            {
                money = 2 * c * i + b * (y - i);
            }
            else
            {
                money = 2 * c * i;
            }
            ans = min(ans, money);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int a, b;

   scanf("%d", &a);
   scanf("%d", &b);

   if(a>b){
      printf("a > b\n");
   }

   else if(a<b){
      printf("a < b\n");
   }

   else if(a==b){
      printf("a == b\n");
   }

   return 0;
}

Measured memory_bytes: 1748
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE LambdaCase, DeriveFunctor #-}

import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           Data.Bits
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord

twice f x = f x x

both :: Arrow a => a b c -> a (b, b) (c, c)
both = twice (***)

readsLn :: Read a => IO [a]
readsLn = mapM readIO . words =<< getLine

main = do
  a <- sum . map digitToInt <$> getLine
  putStrLn $ if a `mod` 9 == 0 then "Yes" else "No"


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> l(n+2, 0);
	vector<ll> r(n+2, 0);
	ll ans = 0ll;
	rep(i, n){
	    cin >> a[i];
	}
	for(int i = 0; i < n; ++i){
	    l[i+1] = gcd(l[i], a[i]);
	}
	for(int i = n-1; i >= 0; --i){
		r[i+1] = gcd(r[i+2], a[i]);
	}
	rep(i, n){
	    ans = max(ans, gcd(l[i], r[i+2]));
	}
	ppp(ans);

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string.h>

using namespace std;

#define BUF_SIZE 1024

int count = 0;

void insertionSort(int array[],int n,int g){
	int v,j;
	for(int i = g;i < n; i++){
		v = array[i];
		j = i - g;
		while(j >= 0 && array[j] > v){
			array[j+g] = array[j];	//??°??????????????§???????????????
			j = j - g;
			count++;
		}
		array[j+g] = v;
	}
}

void shellSort(int array[],int n){
	int m = 0;
	int s = 1;

	while((n/s) > 0){
		s *= 2;
		m++;	//2^(mult-1)?????§?????????????????¨???????¨?
	}

	int G[20];

	for(int k = 0,t = 1; k < m; k++){
		G[k] = n/t;
		t *= 2;
	}

	for(int i = 0; i < m;i++){
		insertionSort(array,n,G[i]);
	}

	printf("%d\n",m);
	for(int i = 0; i < m; i++){
		if(i != m-1){
			printf("%d ",G[i]);
		}else{
			printf("%d\n",G[i]);
		}
	}
	printf("%d\n",count);
	for(int i = 0; i < n; i++){
		printf("%d\n",array[i]);
	}

}

int main(int argc,char* argv[]){
	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[1000000];

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

	shellSort(array,n);

}


Measured memory_bytes: 7064
import sys
from copy import deepcopy
from collections import deque
from itertools import chain

chain_from_iterable = chain.from_iterable
inputs = sys.stdin.readlines()
h, w = map(int, inputs[0].split())
S = [list(map(lambda x: int(x=='.'), x)) for x in inputs[1:]]
S.insert(0, [0]*w)
S.append([0]*w)
for row in S:
    row.insert(0, 0)
    row.append(0)

max_dist = 0
for y in range(1, h+1):
    for x in range(1, w+1):
        if S[y][x] == 0:
            continue
        maze = deepcopy(S)
        maze_d = [[0]*(w+2) for _ in range(h+2)]
        queue = deque([(x, y, 0)])
        d = 0
        while queue:
            x, y, d = queue.popleft()
            d += 1
            maze[y][x] = 0
            if maze[y-1][x]:
                queue.append((x, y-1, d))
                maze[y-1][x] = 0
                maze_d[y-1][x] = d
            if maze[y][x-1]:
                queue.append((x-1, y, d))
                maze[y][x-1] = 0
                maze_d[y][x-1] = d
            if maze[y+1][x]:
                queue.append((x, y+1, d))
                maze[y+1][x] = 0
                maze_d[y+1][x] = d
            if maze[y][x+1]:
                queue.append((x+1, y, d))
                maze[y][x+1] = 0
                maze_d[y][x+1] = d
        max_dist = max(max_dist, max(chain_from_iterable(maze_d)))
print(max_dist)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if 	  (a+b < c+d) cout << "Right"  	 << endl;
  else if (a+b > c+d) cout << "Left" 	 << endl;
  else				  cout << "Balanced" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  string s; cin>>s;
  int k; cin>>k;
  int sz = s.size();
  rep(i,sz) {
    if(s[i] == 'a') continue;
    int diff = 'z' + 1 - s[i];
    if(diff <= k) {
      s[i] = 'a';
      k -= diff;
    }
  }
  s[sz-1] += k % 26;
  cout << s << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 592
// https://atcoder.jp/contests/abc164/tasks/abc164_e

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 0
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " "); cout << endl
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 50;
const int M_MAX = 100;
const int S_MAX = 1e9;
const int A_I_MAX = 50;
const int B_I_MAX = 1e9;
const int C_I_MAX = 1e9;
const int D_I_MAX = 1e9;
const ll INF = 1e13;
const int COIN_MAX = 2450;

struct edge {
  int to;
  int coin;
  ll time;
  friend ostream& operator<<(ostream& os, const edge& e) {
    os << '(' << e.to << ',' << e.coin << ',' << e.time << ')';
    return os;
  }
};

using P = pair<ll, pair<int, int>>;

int N, M, S;

int cx;
vector<vector<edge>> G;

int main() {
  cin >> N >> M >> S;
  cx = 0;
  G = vector<vector<edge>>(N);
  REP(i, M) {
    int U, V, A, B;
    cin >> U >> V >> A >> B;
    U--; V--;
    G[U].push_back({V, -A, B});
    G[V].push_back({U, -A, B});
    cx += A;
  }
  REP(v, N) {
    int C, D;
    cin >> C >> D;
    G[v].push_back({v, C, D});
  }

  cx = min(cx, COIN_MAX);
  DUMP2D(G);

  vector<vector<ll>> dp = vector<vector<ll>>(N, vector<ll>(cx + 1, INF));
  priority_queue<P, vector<P>, greater<P>> que;
  int c0 = min(S, cx);
  dp[0][c0] = 0;
  que.push({0, {0, c0}});

  while (!que.empty()) {
    auto p = que.top(); que.pop();
    ll time = p.first;
    int v = p.second.first;
    int coin = p.second.second;
    if (dp[v][coin] < time) continue;
    for (edge &e : G[v]) {
      int coin2 = min(coin + e.coin, cx);
      if (coin2 < 0) continue;
      ll time2 = time + e.time;
      int v2 = e.to;
      if (dp[v2][coin2] > time2) {
        dp[v2][coin2] = time2;
        que.push({time2, {v2, coin2}});
      }
    }
  }

  DUMP2D(d);

  FOR(v, 1, N - 1) {
    ll ans = *min_element(dp[v].begin(), dp[v].end());
    cout << ans << endl;
  }
}


Measured memory_bytes: 6132
#include <stdio.h>

int main (void)
{
	int a = 1, b = 1, box;
	
	while(scanf("%d %d" , &a , &b))
	{
		if(a == 0 && b == 0)
		{
			break;
		}
		if(a > b)
		{
			box = b;
			b = a;
			a =box;
		}
		printf("%d %d\n" , a , b );
	}
	return 0;
} 


Measured memory_bytes: 2028
#include <stdio.h>

int main(void) {
	int a,b,c,d;
	scanf("%d",&a);
	b=a/3600;
	c=a%3600;
	c=c/60;
	d=a%60;
	printf("%d:%d:%d\n",b,c,d);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb push_back
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
 
void solve()
{
	int n, x, t;
	long long int ans=0;
	vector<int> a;
	cin>>n>>x>>t;
	// F0R(i, n) {
	// 	cin>>x;
	// 	a.pb(x);
	// }
	ans = ceil(n*1.0/x)*t;
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
#include <cstdio>
#include <string>

using namespace std;

int main(){
    string alphabet;
    alphabet = "abcdefghijklmnopqrstuvwxyz";
    char c;
    cin >> c;
    for(int i = 0; i <= 24; i++){
        if(alphabet[i] == c){
            cout << alphabet[i+1];
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string O,E; cin >> O >> E;
    string out="";
    for(int i=0;i<O.size();i++){
        out += O[i];
        if(i==E.size())break;
        out += E[i];
        //cerr << out << endl;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2018-12-18.
//

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

    P((a + b + 1) / 2);
}


Measured memory_bytes: 256
def calc_xor(i):
	if i % 4 == 0:
		return i
	elif i % 4 == 1:
		return 1
	elif i % 4 == 2:
		return i + 1
	elif i % 4 == 3:
		return 0
	else:
		print("error")

a, b = list(map(int, input().split()))

print(calc_xor(b) ^ calc_xor(a - 1))

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

N,K = map(int, input().split())
xN = list(map(int, input().split()))

ans = float('inf')
for i in range(N-K+1):
    tmp = float('inf')
    # 範囲が0を含む
    if xN[i] <= 0 <= xN[i+K-1]:
        # 距離の短い方を往復する
        if abs(xN[i]) <= abs(xN[i+K-1]):
            tmp = abs(xN[i])*2 + abs(xN[i+K-1])
        else:
            tmp = abs(xN[i]) + abs(xN[i+K-1])*2
    # 範囲が全て0より大きい
    elif xN[i] > 0:
        tmp = abs(xN[i+K-1])
    # 範囲が全て0より小さい
    elif xN[i+K-1] < 0:
        tmp = abs(xN[i])
    ans = min(tmp, ans)

print(ans)

Measured memory_bytes: 14532
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int Q; cin >> Q;
  deque<ll> deq;
  vector<ll> ans;
  REP(i, Q){
    int q; cin >> q;
    if(q == 0){
      int d; cin >> d;
      ll x; cin >> x;
      if(d == 0) deq.push_front(x);
      if(d == 1) deq.push_back(x); 
    }else if(q == 1){
      int p; cin >> p;
      ans.push_back(deq[p]);
    }else{
      int d; cin >> d;
      if(d == 0) deq.pop_front();
      if(d == 1) deq.pop_back();
    }
  }
  for(auto &i : ans) cout << i << endl;
}


Measured memory_bytes: 6376
charactors="ABCDEF"
a, b = map(str, input().split())
aNum=0
bNum=0

i=0
j=0

while i<7:
    if charactors[i]==a:
      aNum=i
      break
    i+=1
    
while j<7:
    if charactors[j]==b:
      bNum=j
      break
    j+=1
    
if aNum>bNum:
  print(">")
elif aNum==bNum:
  print("=")
else:
  print("<")

Measured memory_bytes: 3064
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int input;
    int b;
    cin >> input>>b;
    int s=input*b;
    int L=2*(input+b);
    cout << s<<" "<<L<<endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



Measured memory_bytes: 3076
package main

import (
	"fmt"
)

func main() {
	var a, b int
	if _, err := fmt.Scan(&a, &b); err != nil {
		panic(err)
	}

	area := a * b
	circumferential := 2*a + 2*b
	fmt.Printf("%d %d\n", area, circumferential)
}



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

int main() {
	int N;
	cin >> N;
	vector<int> ans(N);
	for (int i = 0; i < N - 1; i++) {
		int tmp;
		cin >> tmp;
		ans.at(tmp - 1)++;
	}
	for (auto x : ans) {
		cout << x << endl;
	}
}

Measured memory_bytes: 3996
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] h=new int[n];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    int max=0,count=0;
    for(int i=0;i<n;i++){
      if(h[i]>=max){
        count++;
        max=h[i];
      }
    }
    System.out.print(count);
  }
}

Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0)break;
			else calc(n, m);
			
		}
	}
	public void calc(int n, int m){
		int[] h = new int[n+1];
		int[] w = new int[m+1];
		int maxH = 0;
		int maxW = 0;
		for(int i = 1; i < n+1; i++){
			h[i] = sc.nextInt();
			maxH += h[i];
		}
		for(int i = 1; i < m+1; i++){
			w[i] = sc.nextInt();
			maxW += w[i];
		}
		int[] habaNumH = new int[maxH + 1];
		int[] habaNumW = new int[maxW + 1];
		for(int i = 1; i < n+1; i++){
			int t = 0;
			for(int j = i; j < n+1; j++){
				t = t + h[j];
				habaNumH[t] += 1;
			}
		}
		for(int i = 1; i < m+1; i++){
			int t = 0;
			for(int j = i; j < m+1; j++){
				t = t + w[j];
				habaNumW[t] += 1;
			}
		}
		int haba;
		if(maxH < maxW) haba = maxH;
		else haba = maxW;
		int sum = 0;
		for(int i = 1; i < haba + 1; i++){
			sum += habaNumH[i] * habaNumW[i];
		}
		System.out.println(sum);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 62844
/*input
4
5 5 5 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
int die[maxn];
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    multiset<int> s;
    REP(i,n) cin>>arr[i],s.insert(arr[i]);
    int ans=0;
    REP(i,n){
        int x=arr[i];
        s.erase(s.find(x));
        bool wk=1;
        for(int i=1;i<=sqrt(x);i++){
            if(x%i==0){
                if(s.find(i)!=s.end() or s.find(x/i)!=s.end()){
                    wk=0;
                    break;
                }
            }
        }
        s.insert(x);
        ans+=wk;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 13776
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
#define otz  500000004ll
using namespace std;
ll dp[3005][3005],f[3005][3005];
int n,q,a[3005];
int main(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)if(a[i]>a[j])dp[i][j]=1;
    }
    for(int i=1;i<=q;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        f[x][y]=f[y][x]=dp[x][y]+dp[y][x];
        for(int k=1;k<=n;++k){
            if(k==x||k==y) continue;
            f[x][k]=dp[x][k]+dp[y][k];
            f[k][x]=dp[k][x]+dp[k][y];
            f[y][k]=dp[y][k]+dp[x][k];
            f[k][y]=dp[k][y]+dp[k][x];
        }
        for(int j=1;j<=n;++j){
            dp[x][j]=f[x][j]*otz%orz;
            dp[y][j]=f[y][j]*otz%orz;
            dp[j][x]=f[j][x]*otz%orz;
            dp[j][y]=f[j][y]*otz%orz;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j)ans+=dp[i][j];
    }
    ans%=orz;
    for(int i=1;i<=q;++i)ans=ans*2ll%orz;
    printf("%lld\n",ans);
	//system("pause");
	return 0;
}


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

using namespace std;
const int N=1e5+5;
int n,k,f[N],h[N];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>h[i];
    f[1]=0;
    for(int i=2;i<=n;i++)
    {
        f[i]=f[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=k;j++)
            if (i>j)
                f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
    }
    cout<<f[n];
    //for(int i=1;i<=n;i++) cout<<' '<<f[i];
    return 0;
}


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

signed main() {
  int k;
  cin>>k;
  int t = 7%k;
  for (int i=1; i<=2*k; i++) {
    if (t==0) {
      cout<<i;
      return 0;
    }
    t = (t*10+7)%k;
  }
  cout<<-1;
}

Measured memory_bytes: 3632
import collections
n = int(input())
a = collections.Counter(list(map(int, input().split()))).most_common()
a = sorted(a, reverse=True)
t = 0
for i, v in a:
    if v >= 4:
        if t == 0:
            print(i * i)
            exit()
        else:
            print(t * i)
            exit()
    elif v >= 2:
        if t == 0:
            t = i
        else:
            print(t * i)
            exit()
print(0)


Measured memory_bytes: 21412
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int dp[101][101];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    int a,b;
    cin >> a >> b;

    string s;
    cin >> s;




    if(s.size() != a + b + 1)
    {
      cout << "No";
      return 0;
    }

    bool ok = true;
    for(int i = 0; i < s.size(); i++)
    {
      if(i == a)
      {
        if(s[i] != '-')
        {
          ok = false;
          break;
        }
      }
      else
      { 
        if(!(s[i] >='0' and s[i] <= '9'))
        {
          ok = false;
          break;
        }
      }
    }

    if(ok)cout << "Yes";
    else cout << "No";

    return 0;   
}


Measured memory_bytes: 3664
#include <cstdio>
int main(void)
{
  while(1){
    int n;
    scanf("%d",&n);
    if(!n) break;
    int ap=0,bp=0;
    for(int i=0;i<n;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      if(a > b) ap+=a+b;
      else if(a < b) bp+=a+b;
      else { 
	ap += a;
	bp += b;
      }
    }
    printf("%d %d\n",ap,bp);
  }
}

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

using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
ll d[N];
ll res[N];
ll pos[N];
bool ans[N];


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n, D;
    cin >> n >> D;
    for (int i = 0; i < n; i++)
        cin >> d[i];
    res[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (res[i + 1] < d[i] / 2)
            res[i] = res[i + 1];
        else
            res[i] = res[i + 1] + d[i];
    }

    pos[0] = D;
    for (int i = 0; i < n; i++) {
        pos[i + 1] = pos[i] - d[i];
        if (pos[i + 1] < 0)
            pos[i + 1] = -pos[i + 1];
        if (pos[i + 1] > pos[i])
            pos[i + 1] = pos[i];
    }
    for (int i = 0; i < n; i++) {
        if (pos[i] > res[i + 1])
            ans[i] = true;
        else
            ans[i] = false;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        ll a;
        cin >> a;
        a--;
        if (ans[a])
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}



Measured memory_bytes: 14208
using System;
using System.Collections.Generic;

namespace ITP1_3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>();
            int input;
            while ((input = int.Parse(Console.ReadLine())) != 0)
            {
                list.Add(input);
            }
            for(int i = 0; i < list.Count; i++)
            {
                Console.WriteLine("Case " + (i + 1) + ": " + list[i]);
            }
        }
    }
}

Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int n;
Graph G;

void dfs(int v, vi& d) {
    for (auto nxt : G[v]) {
        if (d[nxt] == inf) {
            d[nxt] = d[v] + 1;
            dfs(nxt, d);
        }
    }
}

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

    cin >> n;
    G.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    vi df(n, inf), ds(n, inf);
    df[0] = 0;
    dfs(0, df);
    ds[n - 1] = 0;
    dfs(n - 1, ds);

    int f = 0, s = 0;
    rep(i, n) {
        if (df[i] <= ds[i]) f++;
        else s++;
    }

    // printV(df);
    // printV(ds);
    // output(s, f);

    cout << (f > s ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
int n,m,k,a[10][10],vis[10][10],ans;
int check(){
 int sum=0;
 for(int i=1;i<=n;++i)
  for(int j=1;j<=m;++j)
   if(a[i][j]==1&&vis[i][j]==0)
     sum++;
 return sum;
}
//void print(){
// for(int i=1;i<=n;++i,cout<<endl)
//  for(int j=1;j<=m;++j)
//   cout<<vis[i][j]<<" ";
//}
void dfs(int x,int g){
 if(check()<k)
  return;
 if(x==n+m+1&&g==1){
  if(check()==k)
   ans++;//,print();
   return;
 }
 if(x==n+m+1&&g==0){
  return;
 }
 if(g==0){
  dfs(x+1,0),dfs(x+1,1);
  return;
 }
 int t=x;
 if(g==1)
 if(x>n){
  t=x-n;
  for(int i=1;i<=n;++i)
   vis[i][t]++;
  dfs(x+1,0);
  dfs(x+1,1);
  for(int i=1;i<=n;++i)
   vis[i][t]--;
 }
 else{
  for(int i=1;i<=m;++i)
   vis[x][i]++;
  dfs(x+1,0);
  dfs(x+1,1);
  for(int i=1;i<=m;++i)
   vis[x][i]--;
 }
}
int main(){
 char ch;
 cin>>n>>m>>k;
 for(int i=1;i<=n;++i)
  for(int j=1;j<=m;++j)
   cin>>ch,a[i][j]=(ch=='#'?1:0);
 dfs(1,0);
 dfs(1,1);
 cout<<ans;
 return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
const int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
const int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

const ll MOD = ll(1e9) + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll i, ll mod){
    return modpow(i, mod-2, mod);
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0, sum2 = 0;
    rep(i,n) sum = (sum + a[i]) % MOD;
    rep(i,n) {
        sum2 = (sum2 + (a[i] * a[i]) % MOD) % MOD;
    }
    ll ans = ((sum * sum % MOD) - sum2) * modinv(2, MOD);
    ans = ans % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int h, w;
vector<vector<int> > G;
vector<P> ans;
int main(){
    sc(h) sc(w)
    G.resize(h);
    for (int i = 0; i < h; i++) G[i].resize(w);
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) sc(G[i][j])
    for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) if (G[i-1][j-1]%2){
        if (j != w) ans.push_back(P(i, j)), ans.push_back(P(i, j+1)), G[i-1][j]++;
        else if (i != h) ans.push_back(P(i, j)), ans.push_back(P(i+1, j)), G[i][j-1]++;
    }
    cout << ans.size() / 2 << endl;
    for (int i = 0; i < ans.size(); i++){
        if (i % 2 == 0) cout << ans[i].first << " " << ans[i].second << " ";
        else cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int MAXN = 200;
//ll a[MAXN], ST[MAXN * 4], LZ[MAXN*4];

/*bool perfectSquare(ll x){
    ll s = sqrt(x);
    if(s *s == x) return true;
    else return false;
}*/
typedef long double ld;

int main() { 
    string s;
    cin >> s;
    int ans = 100000;
    for(int i = 0; i < s.length(); ++i){
        string t = s.substr(i,3);
        int n = stoi(t);
        int k = abs(n - 753);
        ans = min(ans,k);
    }
    cout << ans << endl;
  
    return 0; 
} 


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

int main() {
	string str;
	cin >> str;
	int ans=0;
	rep(i,4) {
		if (str.at(i)=='+') ans++;
		else ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*ITP1_6_A:Reversing Numbers*/
#include <iostream>
using namespace std;

int main() {

    int n,i;
    cin >> n;
    int a[n];

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

    for (i=n-1;0<i;i--) {
        cout << a[i] << " ";
    }   

    cout << a[0] << endl;

    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
set<int> S;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a;
		if(i % 2 == 0) S.insert(a);
		A[i] = a;
	}
	sort(A, A + N);
	int res = 0;
	rep(i, 0, N) {
		if(i % 2 == 0) {
			if(S.count(A[i])) {
				res++;
			}
		}
	}
	cout << (N + 1) / 2 - res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

vector<int> vis, deg;
vector<vector<int>> g;
vector<pair<int, int>> p;

void dfs(int u, int par) {
  vis[u] = 1;
  for (auto to : g[u]) {
    int v = (p[to].first == u) ? p[to].second : p[to].first;
    if (vis[v]) {
      if (p[to].first == u) deg[u] ^= 1;
      continue;
    }
    p[to].first = u, p[to].second = v;
    deg[u] ^= 1;
    dfs(v, to);
  }
  if (deg[u]&1) {
    swap(p[par].first, p[par].second);
    deg[p[par].first] ^= 1;
    deg[p[par].second] ^= 1;
  }
}

void adjust(int u, int par) {
  vis[u] = 1;
  for (auto to : g[u]) {
    int v = p[to].second;
    if (vis[v]) continue;
    adjust(v, to);
  }
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;

  g.resize(n);
  deg.assign(n, 0);

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    --u; --v;
    g[u].push_back((int)p.size());
    g[v].push_back((int)p.size());
    p.emplace_back(u, v);
  }

  if (m&1) {
    cout << -1 << '\n';
    return 0;
  }

  vis.assign(n, 0);
  dfs(0, -1);
  // for (int i = 0; i < m; ++i) {
  //   deg[p[i].first] ^= 1;
  // }
  // vis.assign(n, 0);
  // adjust(0, -1);

  for (int i = 0; i < m; ++i) {
    cout << p[i].first + 1 << " " << p[i].second + 1 << '\n';
  }
}

Measured memory_bytes: 13172
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int num = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    class Inner{
      boolean inner(int x){
        if(x == 2){
          return true;
        }else if(x < 2 || x%2 == 0){
          return false;
        }else{
        	int i = 3;
        	while(i <= Math.sqrt(x)){
          		if(x%i == 0){
            		return false;
          		}
          		i = i + 2;
        	}
        	return true;
        }
      }
    }
    Inner in = new Inner();
    for(int aa : a){
      if(in.inner(aa)){
        num++;
      }
    }
    System.out.println(num);
  }
}



Measured memory_bytes: 43572
#include <bits/stdc++.h>
 
#define FILE
#define fr first
#define se second
 
using namespace std;
 
const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
 
int n;
int k;
int res;
string s;
string t;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
 
    cin >> s >> k;
    n = (int)s.size();
    t = string(n, '0');
    if(k == 1){
        for(int i = 0; i < n; i ++){
            for(int ni = 1; ni <= 9; ni ++){
                t[i] = (ni + '0');
                res += (t <= s);
                t[i] = '0';
            }
        }
    }
    else if(k == 2){
        for(int i = 0; i < n; i ++){
            for(int j = i + 1; j < n; j ++){
                for(int ni = 1; ni <= 9; ni ++){
                    for(int nj = 1; nj <= 9; nj ++){
                        t[i] = (ni + '0');
                        t[j] = (nj + '0');
                        res += (t <= s);
                        t[i] = t[j] = '0';
                    }
                }
            }
        }
    }
    else if(k == 3){
        for(int i = 0; i < n; i ++){
            for(int j = i + 1; j < n; j ++){
                for(int k = j + 1; k < n; k ++){
                    for(int ni = 1; ni <= 9; ni ++){
                        for(int nj = 1; nj <= 9; nj ++){
                            for(int nk = 1; nk <= 9; nk ++){
                                t[i] = (ni + '0');
                                t[j] = (nj + '0');
                                t[k] = (nk + '0');
                                res += (t <= s);
                                t[i] = t[j] = t[k] = '0';
                            }
                        }
                    }
                }
            }
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256