akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7; 
long long a[N], dp[N];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = mod;
        if(i == 1)dp[i] = 0;
        for(int j = i - 1; j >= max(1, i - k); j--){
            dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i,0,n+1) {cin >> a[i];}
    rep(i,0,n) {cin >> b[i];}
    ll count =0;
    rep(i,0,n) {
        if (a[i] <= b[i]) {
            count += a[i];
            b[i] = b[i] -a[i];
            a[i] =0;
            if (b[i] > 0) {
                if (a[i+1] <= b[i]) {
                    count += a[i+1];
                    b[i] = b[i] -a[i+1];
                    a[i+1] = 0;
                } else {
                    count += b[i];
                    a[i+1] -=  b[i];
                }
            }
        } else {
            count += b[i];
            a[i] = a[i] - b[i];
            b[i] = 0;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

char arr[26];

void solve(){
    
    ll n; cin >> n;
    arr[0] = 'z';
    vector<char> a;
    for(int i = 1; i < 26; i++)
        arr[i] = char(i + 'a' - 1);
    while(n > 0){
        ll rem = n % 26;
        a.pb(arr[rem]);
        n /= 26;
        if(rem == 0)
            n--;
    }
    reverse(all(a));
    for(char c : a) cout << c;
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3600
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = print =<< solve <$> getInput

getInput :: IO (Int, Int, Int, Int)
getInput = (,,,) <$> readLn <*> readLn <*> readLn <*> readLn

solve :: (Int, Int, Int, Int) -> Int
solve (a, b, c, x) =
  length [ (a', b', c')
         | a' <- [0 .. a]
         , b' <- [0 .. b]
         , c' <- [0 .. c]
         , 500 * a' + 100 * b' + 50 * c' == x
         ]


Measured memory_bytes: 508
from collections import deque
n = int(input())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
q_li = deque(lis)
a = 0
b = 0
for l in range(n):
    if l % 2 == 0:
        a += q_li.popleft()
    else:
        b += q_li.popleft()
print(a-b)


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

int main(){
  double r;
  double g;
  double res;
  
  cin >> r >> g;
  res = g * 2 - r;
  
  cout << res;
  
  //G == (x + R) / 2
  //x = G*2 - R
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A,B = inputMap()
    P = inputList()
    
    rinko = []
    manaka = []
    nene = []
    for i in P:
        if i <= A:
            rinko.append(i)
        elif i >= B+1:
            nene.append(i)
        else:
            manaka.append(i)
            
    print(min(len(rinko), len(nene), len(manaka)))
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {
    static int r;
    static int d;
    static int x;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        r = scanner.nextInt();
        d = scanner.nextInt();
        x = scanner.nextInt();
        scanner.close();
    }


    public static void main(String args[]) {
        init();

        int s = r * x - d;
        int[] ans = new int[10];
        ans[0] = s;
        for(int i = 1; i < 10; i++) {
            s = r * s - d;
            ans[i] = s;
        }

        for(int i = 0; i < 10; i++) {
            System.out.println(ans[i]);
        }

    }
}

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

int main() {
  int n;
  scanf("%d", &n);
  for (int k=0; k<n; k++) {
    int h, m;
    scanf("%d:%d", &h, &m);
    double t = (double)(h*60+m)/(12*60) * 360;
    double c = (double)m/60 * 360;
    if (t > c) swap(t, c);
    double sa = c - t;
    if (sa > 180) sa = 360 - sa;
    if (sa < 30) cout << "alert" << endl;
    else if (sa >= 90) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
}

Measured memory_bytes: 1188
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;
    ll times = N / B;
    if (times == 0) {
        ll l = A * N / B;
        ll r = A * (N / B);
        cout << l - r << endl;
    }
    else {
        ll x = B * times - 1;
        ll l = A * x / B;
        ll r = A * (x / B);
        cout << l - r << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int n = sc.nextInt();
      int[][] ab = new int[n][2];
      for(int i = 0; i < n; i++) {
        ab[i][0] = sc.nextInt();
        ab[i][1] = sc.nextInt();
      }
      long[] dp = new long[h+1];
      Arrays.fill(dp, Long.MAX_VALUE);
      dp[0] = 0;
      for(int i = 0; i < n; i++) {
        for(int j = 1; j <= h; j++) {
          if(ab[i][0] >= j)
            dp[j] = Math.min(dp[j], ab[i][1]);
          else {
            int idx = j - ab[i][0];
            dp[j] = Math.min(dp[j], dp[idx] + ab[i][1]);
          }            
        }
      }
      System.out.println(dp[h]);
  }
}

Measured memory_bytes: 27616
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>
#include <numeric>

int main()
{
	int a, b, c, d, e, k;

	std::cin >> a >> b >> c >> d >> e >> k;

	if (e - a > k) {
		std::cout << ":(\n";
	} else {
		std::cout << "Yay!\n";
	}
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pn(n) cout << (n) << endl;

int main() {
	string s,t;
	cin >> s >> t;
	int res = 0;
	FOR(i, 0, 2) {
		if (s[i] == t[i]) {
			res++;
		}
	}
	pn(res)
}

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

int main(){
  int n;
  cin >> n;
  cout << (n%2==0 ? n/2 : n/2+1) << endl;
  return 0;
}

Measured memory_bytes: 256
//ll _(){
//    ll n;
//    cin >> n;
//    vl a(n),b(n),c(n);
//    cin >> a >> b >> c;
//    sort(all(a));
//    sort(all(b));
//    sort(all(c));
//    ll w = 0;
//    ll l = 0;
//    vl wb(n);
//    rep(i,0,n-1){
//        while(l < n && a[l] < b[i]){
//            w++;
//            ++l;
//        }
//        wb[i] = w;
//    }
//    l = 0;
//    w = 0;
//    ll ans = 0;
//    rep(i,0,n-1){
//        while(l < n && b[l] < c[i]){
//            w += wb[l];
//            ++l;
//        }
//        ans += w;
//    }
//    return ans;
//}
//
//
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    ll n;
    cin >> n;
    vl a(n),b(n),c(n);
    cin >> a >> b >> c;
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll w = 0;
    ll l = 0;
    vl wb(n);
    rep(i,0,n-1){
        while(l < n && a[l] < b[i]){
            w++;
            ++l;
        }
        wb[i] = w;
    }
    l = 0;
    w = 0;
    ll ans = 0;
    rep(i,0,n-1){
        while(l < n && b[l] < c[i]){
            w += wb[l];
            ++l;
        }
        ans += w;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 3456
N,K,C = (int(i) for i in input().split())
S = str(input())

L = [-1] * K
R = [-1] * K
S_index = 0
count = 0
while count < K:
  if S[S_index] == "o":
    L[count] = S_index
    count += 1
    S_index += C+1
  else:
    S_index += 1

S_index = N-1
count = 0
while count < K:
  if S[S_index] == "o":
    R[count] = S_index
    count += 1
    S_index -= C+1
  else:
    S_index -= 1

R.reverse()
for l,r in zip(L,R):
  if l == r:
    print(l+1)


Measured memory_bytes: 20620
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
bool check(ll score, vector<ll> &a, vector<ll> &f, ll &k){
    ll need = 0;
    for(int i = 0; i < a.size(); i++){
        need += max(0LL, a[i] - (score / f[i]));
    }
    if(need <= k){
        return true;
    } else {
        return false;
    }
}


int main(void){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    vector<ll> f(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> f[i];

    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());

    ll ng = -1;
    ll ok = INF; 

    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if (check(mid, a, f, k)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

}

Measured memory_bytes: 3328
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, D; cin >> n >> D;
    vector<int> d(n);
    rep(i, n) {
        cin >> d[i];
    }
    int q; cin >> q;
    vector<int> l(n + 1, D);
    rep(i, n) {
        l[i + 1] = min(l[i], abs(l[i] - d[i]));
    }
    if(l[n] != 0) {
        rep(i, q) {
            int x; cin >> x;
            cout << "YES" << endl;
        }
        return;
    }
    vector<int> ng(n + 1);
    ng[n] = 1;
    for(int i = n - 1; i >= 0; -- i) {
        if(d[i] >= 2 * ng[i + 1]) {
            ng[i] = ng[i + 1];
        } else {
            ng[i] = ng[i + 1] + d[i];
        }
    }
    rep(i, q) {
        int x; cin >> x;
        if(l[x - 1] == 0 || ng[x] > l[x - 1]) {
            cout << "NO" << endl;
        } else {
            cout << "YES" << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 8988
def maxDivisor(divisor, divided):
    '''最大公約数を返す関数'''
    while(True):
        rest = divided % divisor
        if rest == 0:
            return divisor
        else:
            divided = divisor
            divisor = rest


N = int(input())
A = list(map(int, input().split()))

inf = 1 * 10**9
ans = inf
for i in range(len(A)):
    if i == len(A) - 1:
        break
    else:
        ans = min(ans, maxDivisor(A[i], A[i+1]))

print(ans)


Measured memory_bytes: 14252
#include <stdio.h>
#include <stdlib.h>

 int main(void){
   int A,B;
   int d;
   
      rewind(stdin);
      scanf("%d %d",&A,&B);
      
      if(A,B<0 || A,B>23){
       printf("０時〜２３時の間で入力してください\n");
       exit(0);
       }
       
      d = A + B;
      
      if(d>=24){
        d = d - 24;
        }
        
      printf("%d\n",d);
      
    }

Measured memory_bytes: 128
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

int main(){
	migmig;
	ll r,d,x;
	cin>>r>>d>>x;
	ll xx=x;
	for(int i=0;i<10;i++){
		cout<<r*xx-d<<endl;
		xx=r*xx-d;
	}
	return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc167/tasks/abc167_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M, X;
  cin >> N >> M >> X;

  struct Book {
    ll cost;
    VL as;
  };

  V<Book> bs(N);

  rep(i, N) {
    cin >> bs[i].cost;
    bs[i].as.resize(M);
    rep(j, M) cin >> bs[i].as[j];
  }

  ll res = INF;

  rep(bit, 1 << N) {
    ll sum_cost = 0;
    VL got_as(M);

    rep(i, N) {
      unless(bit & (1 << i)) continue;

      sum_cost += bs[i].cost;
      rep(j, M) got_as[j] += bs[i].as[j];
    }

    if (all_of(all(got_as), [&](ll v) { return v >= X; })) {
      chmin(res, sum_cost);
    }
  }

  if (res == INF) drop(-1);

  cout << res << "\n";
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

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

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint k,s,count=0;
	cin>>k>>s;
	rep(i,k+1)rep(j,k+1)if(s-(i+j)<=k&&0<=s-(i+j))count++;
	cout<<count<<endl;
}

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


using namespace std;
using ll= long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const int mod = 1e9 + 7;

string f(vector<int> v, bool& valid, string s){
    //cout << v.size() << endl;
    int n = v.size(), last, next;
    for (int i=0; i<n; i++){
        last = (i -1 + n)%n, next = (i + 1 + n)%n;
        if ((s[i] == 'o' and v[i] == 2) || (s[i] == 'x' and v[i] == 1)){
            if (v[last] + v[next] == 3){
                valid = false;
                return "-";
            }
            v[last] = v[next] = max(v[last], v[next]);
        }
        else {
            if (v[last] == v[next]) return "-";
            if (v[last] == 0) v[last] = 3 - v[next];
            else v[next] = 3 - v[last];
        }
    }
    string ans;
    for (int i=0; i<n; i++){
        if (v[i] == 1) ans += 'W';
        else ans+= 'S';
    }
    valid = true;
    return ans;
}

int main (){
    bool valid = false;
    int n;
    string s, ans;
    cin >> n >> s;

    vector<int> v(n, 0);
    v[0] = v[1] = 1;
    ans = f(v, valid, s);
    if (valid){
        cout << ans << endl;
        return 0;
    }

    // v.clear();
    v[0] = v[1] = 2;
    ans = f(v, valid, s);
    if (valid){
        cout << ans << endl;
        return 0;
    }

    // v.clear();
    v[0] = 1,  v[1] = 2;
    ans = f(v, valid, s);
    if (valid){
        cout << ans << endl;
        return 0;
    }

    // v.clear();
    v[0] = 2, v[1] = 1;
    ans = f(v, valid, s);
    if (valid){
        cout << ans << endl;
        return 0;
    }

    cout << "-1" << endl;
    
    
    return 0;
}

Measured memory_bytes: 1528
#include<stdio.h>
int main()
{
    int a;
    int b;
    scanf("%d",&a);
    scanf("%d",&b);
    if((a==1 && b==2) || (a==2 && b==1))
    {
          printf("3");
    }
     else if((a==2 && b==3) || (a==3 && b==2) )
    {
          printf("1");
    }
     else
    {
          printf("2");
    }

    printf("\n");
    return 0;


}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

for i in range(3):
	if S[i] == S[i+1]:
		print("Bad")
		break

else:
	print("Good")

Measured memory_bytes: 5396
#include <iostream>
#include <string>
#include <map> //map<string, int> cnt; key とvalue
#include <set>//  set<int> s;
#include <cstdlib>  // abs() for integer
#include <vector>
#define rep(i,n) for(int i = 0 ; i < (n); ++i)
using namespace std;
using ll = long long;
// g++ -std=c++11
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i = a; i <= b; i++) if(i%k == 0){
    cout << "OK" << endl;
    return 0;
  }
  cout << "NG" << endl;
  return 0;
}

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

int main() {
	int h, w, n;
	cin >> h >> w;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	vector<vector<int>>ans(h, vector<int>(w,0));
	vector<int>b;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < a.at(i); j++)b.push_back(i + 1);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)ans.at(i).at(j) = b.at(i * w + j);
	}
	bool flip = false;
	for (int i = 0; i < h; i++) {
		if (flip) {
			reverse(ans.at(i).begin(), ans.at(i).end());
			flip = false;
		}
		else flip = true;
	}
	for (int i = 0; i < h; i++) {
		cout << ans.at(i).at(0);
		for (int j = 1; j < w; j++) cout << " " << ans.at(i).at(j);
		cout << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100001
#define INF 10000000000001
typedef long long ll;
ll N, K, x[MAX_N];
int main(void){
	cin >> N >> K;
	for(ll i=0; i<N; i++){
		cin >> x[i];
	}
	ll ret = INF;
	for(ll i=0; i<N-K+1; i++){
		ret = min(ret, min(abs(x[i]), abs(x[i+K-1])) + x[i+K-1] - x[i]);
	}
	cout << ret << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

struct Rank {
	int num;
	int AC_cnt;
	int t;
	bool operator < (const Rank& r) const {
		if (AC_cnt < r.AC_cnt) return true;
		if (AC_cnt == r.AC_cnt) {
			if (t > r.t) return true;
			if (t == r.t) {
				if (num < r.num) return true;
			}
		}
		return false;
	}
};

signed main(void)
{
	int i, j, k;
	while (1) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int k[100];
		rep(i, n) {
			cin >> k[i];
		}
		string s;
		cin >> s;
		rep(i, s.size()) {
			int num = tolower(s[i])-'a';
			if (isupper(s[i])) num += 26;
			num -= k[i%n];
			if (num < 0) num += 52;
			s[i] = 'a' + num % 26;
			if (num >= 26) s[i] = toupper(s[i]);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] a = new String[N+1];
		String[] b = new String[M+1];
		String ans = "No";

		for (int i = 0; i <= N; i++) {
			a[i] = sc.nextLine();
		}

		for (int i = 0; i < M; i++) {
			b[i] = sc.nextLine();
		}

		// 行毎に
		loop1:
		for (int i = 1; i <= N - M + 1; i++) {
			// 左から一文字ずつ
			for (int j = 0; j <= N - M; j++) {
				if (a[i].substring(j).startsWith(b[0])) {
					ans = "Yes";
					// 一致したら下の行も確認
					for (int k = 1; k < M; k++) {
						if (!a[i + k].substring(j).startsWith(b[k])) {
							ans = "No";
						}
					}
					if (ans.equals("Yes")) {
						break loop1;
					}
				}
			}
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >>B >>C;
    A[0] = A[0] - 0x20;
    B[0] = B[0] - 0x20;
    C[0] = C[0] - 0x20;
    cout << A[0] << B[0] << C[0] << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1000000007;
const int MAX_N = 101, MAX_K = 1e5 + 1;
ll dp[MAX_N][MAX_K];

int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (a[i] >= j) {
        if (j - 1 >= 0)
          dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
        else
          dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] =
            (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - a[i] - 1] + MOD) % MOD;
      }
    }
  }
  ll ans = dp[N][K];
  cout << ans << endl;
  return 0;
}

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

int n ;

int main(){
	#define NAME "abc103a"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ;

	cin >> n ;

	int ans = 0 ;

	for (int i = 1; i <= n; ++ i){
		int x ; cin >> x ;
		ans += x - 1 ;
	}

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;

	int A[20], B[20], C[19];

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N-1; i++) {
		cin >> C[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		ans += B[A[i]-1];
		if (i+1 == N) {
			break;
		}
		if (A[i + 1] - A[i] == 1) {
			ans += C[A[i]-1];
		}
	}

	cout << ans;

	return 0;
}


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

int main(){
	int a, b, n;
	double tmp;
	int sum;
	while (cin >> a >> b >> n) {
		sum = 0;
		a %= b;
		for (int i = 0; i < n; i++) {
			sum += (a * 10) / b;
			a = (a * 10) % b;
		}
		cout << sum << endl;
	} 
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;
void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil)
    return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList(){
  Node *cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 33920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3000+10][3000+10];
char a[3010],b[3010];
char link[3010];

int main()
{
    cin>>a>>b;
    ll x,y,i,j,k;
    x=strlen(a);
    y=strlen(b);
    for(i=0;i<=x;i++){
        for(j=0;j<=y;j++){
            if(i==0 || j==0)
                dp[i][j]=0;
        }
    }
    ll ans=0;
    for(i=1;i<=x;i++){
        for(j=1;j<=y;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
                if(ans<dp[i][j]){
                    ans=dp[i][j];
                    //link[i-1]=a[i-1];
                }
            }
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll l=dp[x][y];
    i=x,j=y;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            link[l-1]=a[i-1];
            i--;
            j--;
            l--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    cout<<link<<endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

void solve(){
  int n; cin>>n; 
  map<int,int> m;
  int sum=0;
  for(int i=0,a ; i<n ; i++) cin>>a,m[a]++,sum+=a;
  int q; cin>>q;
  while(q--)
  {
    int b,c; cin>>b>>c;
    sum+=m[b]*(c-b);
    m[c]+=m[b];
    m[b]=0;
    cout<<sum;LOL
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}

Measured memory_bytes: 9576
// ABC162 B

#include <iostream>
#include <string>

using namespace std;

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	vl v(1e7);
	for(ll i=1;i<=100;i++){
		for(ll j=1;j<=100;j++){
			for(ll k=1;k<=100;k++){
				ll h=(i+j+k);
				h*=h;
				h-=(i*j)+(j*k)+(i*k);
				if(h<=n)v[h]++;
			}
		}
	}
	rep(i,1,n+1){
		cout<<v[i]<<endl;
	}
				
	
	return 0;
}

Measured memory_bytes: 81396
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b,a%b);
}
int main(){
	ll a, b;
	cin>>a>>b;
	cout<<(a*b)/gcd(a,b)<<"\n";
	return 0;
}

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

int main() {
    lli a,b,c,k;
    cin>>a>>b>>c>>k;
    
    int ans=0;
    ans+=min(k,a);
    k-=min(k,a);
    k-=min(k,b);
    ans-=min(k,c);
    cout<<ans<<endl;
    
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
char a[100];
int check(char ch)
{
 if (ch=='A'||ch=='C'||ch=='G'||ch=='T')
   return 1;
  else
   return 0;


}
int main()
{
 int j=0,ans=0;
  cin>>a;
  int len=strlen(a);
   for(int i=0;i<len;i++)
  {
   if (check(a[i])) j++;
    else
    {
     ans=max(ans,j);
      j=0;

    }
  }
 cout<<max(ans,j)<<endl;

 return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

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

	int dx=0,dy=0;
	if(s.find('N')!=string::npos) dy++;
	if(s.find('S')!=string::npos) dy--;
	if(s.find('E')!=string::npos) dx++;
	if(s.find('W')!=string::npos) dx--;
	
	if(dx==0 && dy==0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a != b && b == c)
    cout << a << endl;
  if (a != b && a == c)
    cout << b << endl;
  if (a == b && b != c)
    cout << c << endl;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x;
    cin >> x;
    print(x >= 30 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3588
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()

if S.count("x") < 8:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 5200
N, T = map(int, input().split())

ct_list = [tuple(map(int, input().split())) for i in range(N)]

# print(ct_list)

min_cost = 10000
flag = False

for ct in ct_list:
  c = ct[0]
  t = ct[1]
  # print(c, t)
  
  if t <= T:
    if c <= min_cost:
      min_cost = c
      flag = True
    
      
if flag:     
  print(min_cost)
else:
  print("TLE")
  

Measured memory_bytes: 3060
// ConsoleApplication1.cpp: 定义控制台应用程序的入口点。
//
#include<stdio.h>
int gen(int m, int n)
{
	if (m > n)
		return m - n;
	else
		return n - m;
}
int main()
{
	int  a[100001];
	int n;
	int i;
	int flag=0;

	scanf("%d",&n);

	scanf("%d", &a[0]);
	for (i = 1; i < n; i++)
	{
		scanf("%d",&a[i]);
		flag = flag + gen(a[i], a[i -1]);
	}
	flag=flag+gen(0,a[0])+gen(0,a[n-1]);

	printf("%d\n",flag-gen(0,a[0])-gen(a[0],a[1])+gen(0,a[1]));

	for (i = 1; i < n-1; i++)
	{
		printf("%d\n", flag - gen(a[i], a[i-1]) - gen(a[i], a[i+1]) + gen(a[i-1], a[i+1]));
	}
	printf("%d\n", flag - gen(0, a[n-1]) - gen(a[n-2], a[n-1]) + gen(a[n-2], 0));

    return 0;
}



Measured memory_bytes: 1536
get = ->{ Array.new(8) {$<.gets.chomp.split} }

left = 3.times.flat_map do
  given = get.().sort_by {|a| a.last.to_f}
  puts given.shift.join(" ")
  puts given.shift.join(" ")
  given
end.sort_by(&:last)
puts left.shift.join(" ")
puts left.shift.join(" ")


Measured memory_bytes: 6868
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String op = "";

        int a, b;
        while(true){
            a = scanner.nextInt();
            op = scanner.next();
            b = scanner.nextInt();
            if (op.equals("?"))break;
            if(op.equals("+"))System.out.println(a+b);
            else if(op.equals("-"))System.out.println(a-b);
            else if(op.equals("*"))System.out.println(a*b);
            else if(op.equals("/"))System.out.println(a/b);
        }
    }
}



Measured memory_bytes: 26300
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[300]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int m=114514;
    for(int i=0;i<n;i++){
        int z=0;
        while(1){
            if(a[i]%2==0){
                a[i]/=2;
                z++;
            }else{
                break;
            }
        }
        if(m>z){
            m=z;
        }
    }
    cout<<m<<endl;
}



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

int main()
{
  int64_t N,K;
  int count=0;
  int i=0; 
  cin >> N >> K;
  while(1)
  {
    if(N<pow(K,i))
    {
      count=i;
      break;
    }
    i++;
  }
  cout << count << endl;
}

Measured memory_bytes: 384
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
su = sum(A)
flag = True
for i in range(M):
  if A[i] < su/(4*M):
    flag = False
if flag == False:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3060
from operator import add, sub, mul


def getopr(opr_str):
    if opr_str == '+':
        return add
    elif opr_str == '-':
        return sub
    elif opr_str == '*':
        return mul
    else:
        return None


def evaluate(expr: str):
    stack = []
    for item in expr.split():
        if getopr(item):
            right = stack.pop()
            left = stack.pop()
            stack.append(getopr(item)(left, right))
        else:
            stack.append(int(item))
    return stack.pop()


if __name__ == '__main__':
    exp = input()
    result = evaluate(exp)
    print(result)



Measured memory_bytes: 5684
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int


puts (N % 1000 == 0) ? 0 : 1000 - N % 1000


Measured memory_bytes: 14404
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	long long int q, s, d, h, n;
	cin >> q >>h >> s >> d >> n;
	long long int a[4], b[4];
	long long int mina = 1000000000, minb = 1000000000;
	a[0] = q * 8;
	a[1] = h * 4;
	a[2] = s * 2;
	a[3] = d;
	b[0] = q * 4;
	b[1] = h * 2;
	b[2] = s;
	for (int i = 0; i < 4; i++) {
		if (a[i] < mina) {
			mina = a[i];
		}
	}
	for (int i = 0; i < 3; i++) {
		if (b[i] < minb) {
			minb = b[i];
		}
	}
	long long int c;
	c = n / 2;
	if (n % 2 == 0) {
		cout << c*mina << endl;
	}
	else {
		cout << c*mina + minb << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N = 1e3 + 5;
const int M = 1e9 + 7;
int a[N];

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string a, b;
    cin >> a >> b;
    int i;
    for( i = 0; i < a.size() && i < b.size(); i++) {
        cout << a[i] << b[i];
    }
    if(i < a.size())
        cout << a[i];
    if(i < b.size())
        cout << b[i];
}


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

int main() {
    int h, w;
    cin >>h >>w;
    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    for (int j = -1; j < w; j++) {cout << "#";}
    cout << "#" << endl;
    for (int i = 0; i < h; i++) {
        cout << "#";
        for (int j = 0; j < w; j++) {
            cout << a[i][j];
        }
        cout << "#" << endl;
    }
    for (int j = -1; j < w; j++) {cout << "#";}
    cout << "#" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0)
	{
		cout<<"Zero";
	}
	if(a>=0&&b<=0)
	{
		cout<<"Zero";
	}
	if(a>0&&b>0)
	{
		cout<<"Positive";
	}
	if(a<0&&b<0)
	{
		if((a-b)%2==0)
		{
			cout<<"Negative";
		}
		else
		{
			cout<<"Positive";
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());

        int[] h = new int[n];
        for(int i =0; i < n; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }

        int count = 0;
        int max = 0;
        for(int i = 0; i < n -1; i++) {
            if(h[i] >= h[i+1]) {
                count +=  1;
            } else {
                max = Math.max(max, count);
                count = 0;
            }
        }

        max = Math.max(max, count);
        System.out.println(max);
    }
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S;
    ll K;

    cin >> S;
    cin >> K;

    ll L = S.length();
    ll cnt1 = 0;
    ll cnt2 = 0;
    char tmp = S[0];

    if(L > 1){
        REP(i,1,L){
            if(S[i] == tmp){
                ++cnt1;
                tmp = '_';
            }
            else{
                tmp = S[i];
            }
        }
        if(tmp == S[0]){
            tmp = '_';
            ++cnt2;
            REP(i,1,L){
                if(S[i] == tmp){
                    ++cnt2;
                    tmp = '_';
                }
                else{
                    tmp = S[i];
                }
            }
            if(tmp == '_'){
                cnt1 *= (K+1)/2;
                cnt2 *= K/2;
            }
            else cnt2 *= (K-1);
        }
        else{
            cnt1 *= K;
        }
    }
    else{
        cnt1 = K / 2;
    }
    
    _PR(cnt1 + cnt2);

    return 0;
}

/*

iii * 3
iiiiiiiii
i_i_i_i_i

iii * 4
iiiiiiiiiiii
i_i_i_i_i_i_


*/

Measured memory_bytes: 256