akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll vis[2345678];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	ll n, m, a, b; cin >> n >> m;
	vector<vector<ll>> G(n + 2);
	rep(i, m) {
		cin >> a >> b;
		G[a].push_back(b); G[b].push_back(a);
	}
	vector<ll> start, goal;
	vis[a] = 1; vis[b] = 1;
	ll x = a, y = b;
	while (true) {
		bool ng = false;
		rep(i, G[x].size()) {
			if (vis[G[x][i]] == 0) {
				x = G[x][i]; vis[x] = 1; start.push_back(x); ng = true; break;
			}
		}
		if (!ng) { break; }
	}
	while (true) {
		bool ng = false;
		rep(i, G[y].size()) {
			if (vis[G[y][i]] == 0) {
				y = G[y][i]; vis[y] = 1; goal.push_back(y); ng = true; break;
			}
		}
		if (!ng) { break; }
	}
	reverse(all(start));

	cout << start.size() + goal.size() + 2 << endl;

	rep(i, start.size()) {
		cout << start[i] << ' ';
	}
	cout << a << ' ' << b;
	rep(i, goal.size()) {
		cout << ' ' << goal[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 10552
K = int(input())

def gcd(x,y):
	while y:
		x,y = y, x % y
	return x

ret = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			ret = ret + gcd(i,gcd(j,k))

print(ret)

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int X; cin >> X;
	if(X < 600) cout << 8 << endl;
	else if(X < 800) cout << 7 << endl;
	else if(X < 1000) cout << 6 << endl;
	else if(X < 1200) cout << 5 << endl;
	else if(X < 1400) cout << 4 << endl;
	else if(X < 1600) cout << 3 << endl;
	else if(X < 1800) cout << 2 << endl;
	else if(X < 2000) cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main()
{
    int L;
    cin >> L;
    typedef pair<int, int> edge;
    vector<pair<edge, int>> g;
    int N = 20;
    for (int i = 2; i < N; i++)
    {
        g.push_back({edge(i, i + 1), 0});
        g.push_back({edge(i, i + 1), 1 << (N - i - 1)});
    }

    int st = 0;
    for (int i = 2; i <= N; i++)
    {
        while (L - st >= (1 << (N - i)))
        {
            g.push_back({edge(1, i), st});
            st += 1 << (N - i);
        }
    }
    cout << 20 << " " << g.size() << endl;
    for (int i = 0; i < g.size(); i++)
    {
        cout << g[i].first.first << " " << g[i].first.second << " " << g[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
signed main() {
	int z;
	cin >> z;
	for (int i = -2000; i <= 2000; i++) {
		for (int j = -2000; j <= 2000; j++) {
			if (mypow(i, 5, INF) - mypow(j, 5, INF) == z) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


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

int main() {
  ll n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
  } else {
    cout << min({n, abs(n - k), n - k * (n / k), abs((n - k * (n / k)) - k)})
         << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for x in s:
    if x in dic.keys():
        dic[x] += 1
    else:
        dic[x] = 1

max_v = max(dic.values())
a = []
for k, v in dic.items():
    if v == max_v:
        a.append(k)

ans = sorted(a)
for a in ans:
    print(a)


Measured memory_bytes: 35220
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
input = x.split(/ /);
w = parseInt(input[0]);
h = parseInt(input[1]);
x = parseInt(input[2]);
y = parseInt(input[3]);
r = parseInt(input[4]);
if ((x >= r) && ((w - x) >= r) && (y >= r) && ((h - y) >= r))
  console.log("Yes");
else console.log("No");



Measured memory_bytes: 15376
tle,ac,wa,re = 0,0,0,0
for _ in range (int(input())):
    n = input()
    if n == 'TLE':
        tle+=1
    elif n=='AC':
        ac+=1
    elif n=='RE':
        re+=1
    else:
        wa+=1
print("AC x ",ac)
print("WA x ",wa)
print("TLE x ",tle)
print("RE x ",re)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
  ull a; string b;
  cin >> a >> b;
  string b_ = "";
  for(char x : b){
    if(x != '.'){
      b_ += x;
    }
  }
  ull bnum = stoull(b_);
  cout << a * bnum / 100 << endl;
  return 0;
}

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

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

  if(s[0] == s[1]) {
    if(s[1] == s[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if(s[1] == s[2]) {
    if(s[2] == s[3]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve [_, b, c]
  | (b * 10 + c) `mod` 4 == 0 = "YES"
  | otherwise = "NO"


Measured memory_bytes: 508
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
        if i < len_x:
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
        if i == len_x:
                return sum([int(k) for k in x.split("+")])

        else:
                return 0
s = input()
dfs(s,len(s)-1)
print(ans+int(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

int main()
{
  INT(N);
  vector<string> A(N);
  REP(i, N) cin >> A[i];
  REP(i,N){
    A[i]=A[i]+A[i];
  }
  REP(i,N){
    A.push_back(A[i]);
  }

  ll cnt = 0;
  REP(i,N){
    int y = 0;
    int x = i;
    int flag= 0;
    REP(j,N){
      REP(k,N){
        int ny = y+j;
        int nx = x+k;
        if(A[ny][nx]!=A[nx-x][ny+x]){
          flag = 1;
        }
      }
    }
    if(flag==0){
      cnt+=N-i;
    }
  }

  FOR(i,1,N){
    int y = i;
    int x = 0;
    int flag= 0;
    REP(j,N){
      REP(k,N){
        int ny = y+j;
        int nx = x+k;
        if(A[ny][nx]!=A[nx+y][ny-y]){
          flag = 1;
        }
      }
    }
    if(flag==0){
      cnt+=N-i;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a = 0, b = 0;
    drep(i,n){
        if(s[i]==')') a++;
        else a = max(0, a - 1);
    }
    rep(i,n){
        if(s[i]=='(') b++;
        else b = max(0, b - 1);
    }
    rep(i,a) cout << '(';
    rep(i,n) cout << s[i];
    rep(i,b) cout << ')';
    cout << endl;

    return 0;
}




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

int N, mn = 1e9, mx;
int c[100005];

int main() {
    scanf("%d", &N);
    for (int i = 0, n; i < N; i++) {
        scanf("%d", &n);
        mn = min(mn,n);
        mx = max(mx,n);
        c[n]++;
    }
    if (mx-mn>1) {
        printf("No\n");
        return 0;
    }
    if (mx-mn == 1) {
        int g = mx - c[mn];
        printf("%s\n", g > 0 && c[mx]/g > 1 ? "Yes":"No");
        return 0;
    }

    if (mn == N-1) printf("Yes\n");
    else printf("%s\n", N/mn > 1 ? "Yes":"No");
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  
  public static void main (String [] args){
    
    Scanner scanner = new Scanner(System.in);     
    
    int num = scanner.nextInt(); 
    
    int N = num*num*num;
      
      System.out.println(N);
    
    scanner.close();
    
  }
  
}
   

Measured memory_bytes: 21844
A, B = map(int,input().split())
A -= 1
B -= 1

grid = [list("#"*100) for _ in range(50)] + [list("."*100) for _ in range(50)]

def fill_white(A):
    for i in range(1,50,2):
        for j in range(0,100,2):
            if A > 0:
                grid[i][j] = "."
                A -= 1
            else:
                return

def fill_black(B):
    for i in range(51,100,2):
        for j in range(0,100,2):
            if B > 0:
                grid[i][j] = "#"
                B -= 1
            else:
                return

fill_white(A)
fill_black(B)

print(100,100)

for line in grid:
    print("".join(line))

Measured memory_bytes: 3188
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,ans;
int main(){
	scanf("%d",&n);
	while(n--){
		int l,r;
		scanf("%d%d",&l,&r);
		ans=ans+(r-l+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
int main()
{
    int x , y ;
    cin >> x >> y;
    if(y & 1) {
        cout << "No" << endl;
        return 0;
    }
    if(x * 2 > y || x * 4 < y){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
int S[2020];
int T[2020];
int dp[2020][2020];

signed main() {
    cin >> N >> M;
    rep(i, N) {
        cin >> S[i];
    }
    rep(i, M) {
        cin >> T[i];
    }
    rep(i, N + 1) {
        dp[i][0] = 1;
    }
    rep(i, M + 1) {
        dp[0][i] = 1;
    }
    rep(s, N) {
        rep(t, M) {
            if (S[s] == T[t]) {
                dp[s + 1][t + 1] = (dp[s + 1][t] - dp[s][t]) + (dp[s][t + 1] - dp[s][t]) + 2 * dp[s][t];
            } else {
                dp[s + 1][t + 1] = (dp[s + 1][t] - dp[s][t]) + (dp[s][t + 1] - dp[s][t]) + dp[s][t];
            }
            dp[s + 1][t + 1] %= 1000000007;
        }
    }
    dp[N][M] += 1000000007;
    dp[N][M] %= 1000000007;
    cout << dp[N][M] << endl;
    return 0;
}


Measured memory_bytes: 31872
#include <iostream>
#include <vector>

using lint = long long;

constexpr int N = 200000;
std::vector<lint> vs(N, 0);

void input() { std::cin >> vs[0] >> vs[1]; }

int cnt = 0;
void query(char c, int i, int j, int k) {
    std::cout << c << " " << i << " " << j << " " << k << "\n";
    ++cnt;

    if (c == '+') {
        vs[k] = vs[i] + vs[j];
    } else if (c == '<') {
        vs[k] = (vs[i] < vs[j]);
    }
}

/* ----- several constants, functions ----- */

constexpr int A = 0, B = 1, S = 2;
constexpr int ZERO = 100, ONE = 101;
constexpr int K = 30, KB = 200;

void reset(int i) { query('+', ZERO, ZERO, i); }
void copy(int i, int j) { query('+', ZERO, i, j); }

void negate(int i) { query('<', i, ONE, i); }
void pow(int i, int k) {
    while (k--) query('+', i, i, i);
}

/* ----- main routine ----- */

void init() {
    query('+', A, B, 2);
    query('<', ZERO, 2, ONE);  // v[ZERO] = 0, v[ONE] = 1
    reset(2);

    query('+', ZERO, ONE, KB);
    for (int k = 1; k <= K; ++k) {
        query('+', KB + k - 1, KB + k - 1, KB + k);
        // v[KB + k] = 2^k
    }
}

void tobin(int xi, int l) {
    const int SB = l + K + 1;

    for (int k = K; k >= 0; --k) {
        query('+', SB, KB + k, SB + 1);
        query('<', xi, SB + 1, l + k);
        negate(l + k);  // v[l+k] = (sum + 2^k <= x)

        copy(l + k, SB + 1);
        pow(SB + 1, k);
        query('+', SB, SB + 1, SB);  // sum += (v[l+k] * 2^k)
    }
}

void multiply(int xi, int yi, int zi, int l) {
    for (int xk = 0; xk <= K; ++xk) {
        for (int yk = 0; yk <= K; ++yk) {
            query('+', xi + xk, yi + yk, l + 1);
            query('<', ONE, l + 1, l + 1);
            query('+', zi + xk + yk, l + 1, zi + xk + yk);
            // v[zi+xk+yk] += x[xk] & y[yk]
        }
    }

    for (int k = 0; k <= K * 2; ++k) {
        pow(zi + k, k);
        query('+', l, zi + k, l);
    }
}

void solve() {
    init();

    constexpr int AB = 300, BB = 400, FB = 500;
    tobin(A, AB);
    tobin(B, BB);
    multiply(AB, BB, FB, S);
}

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

    std::cout << 6048 << "\n";
    // input();
    solve();
    // std::cerr << "result: " << vs[2] << "\n";
    // std::cerr << "counter: " << cnt << "\n";

    return 0;
}


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

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

  int S, W;
  cin >> S >> W;
  
  if (S > W)
  {
    cout << "safe" << "\n";
  }else
  {
    cout << "unsafe" << "\n";
  }
  
}




Measured memory_bytes: 3608
#include<iostream>
#include<string>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  REP(i,s.size()-8){
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
// 考察 2:33-2:42 ぐらい
// 一見状態が4^N個あり間に合わないが、皿は並べ替えても同じ状態とみなせるから実は間に合う

// 状態は寿司がi個ある皿の枚数(i=0,1,2), O(N^3)個
// dp配列にその状態での答えを保持
// 遷移は O(1)

#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#define IFD(...)
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/hana/functional/fix.hpp>
using boost::hana::fix;
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, b, a) for (int i = (b); i >= (a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector sara(4, 0);
    rep(i, n)
    {
        int a;
        cin >> a;
        ++sara[a];
    }
    rep(j, 3)
    {
        sara[j + 1] += sara[j];
    }

    vector dp(n + 1, vector(n + 1, vector<double>(n + 1, 0.)));
    FORD(i, n, 0)
    {
        FORD(j, n, i)
        {
            FORD(k, n, j)
            {
                double p0 = (double)i / n;
                double a1 = i == j ? 0. : ((1. / (1. - p0) + dp[i + 1][j][k]) / (1. - p0)) * (j - i) / n;
                double a2 = j == k ? 0. : ((1. / (1. - p0) + dp[i][j + 1][k]) / (1. - p0)) * (k - j) / n;
                double a3 = k == n ? 0. : ((1. / (1. - p0) + dp[i][j][k + 1]) / (1. - p0)) * (n - k) / n;
                dp[i][j][k] = a1 + a2 + a3;
            }
        }
    }
    cout << dp[sara[0]][sara[1]][sara[2]] << '\n';

    return 0;
}


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

long long int sa(long long int*a,int c,int d){
	long long int res=0;
	for(int i=c;i<=d;i++){
		res += a[i];
	}
	return res;
}


int main(void)
{
	int n = 0;
	cin>>n;
	long long int a[n]={0};
	long long int b[n+1]={0};
	long long int sac = 0;
	long long int pre = 0;long long int las = 0;long long int re = 0;
	for(int k=0;k<n;k++){
		long long int h =0;
		cin>>h;
		a[k]=h;
		b[k+1]=b[k]+h;
	}
	sac = sa(a,0,n-1);
	long long int res = 0;
	long long int min = 9223372036854775807;
	for(int i=0;i<n-1;i++)
	{
		res = abs(sac- 2*b[i+1]);
		if (res < min) min=res;
	}
	cout <<min;
	return 0;
}





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

int main() {
    int n;cin>>n;
    int c=0;
    for (int i=0;i<n;i++) {
        int a;cin>>a;
        if (a==c+1)
            c++;
    }
    if (c==0)
        cout<<-1<<endl;
    else
        cout<<n-c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

vector<pair<int,int>> P, D;

int solve(int x, int y)
{
	int ret=P.size();
	for(int i=0;i<P.size();i++) {
		for(int j=0;j<P.size();j++) {
			int dx=P[i].first-P[j].first, dy=P[i].second-P[j].second;
			if(x==dx && y==dy) {
				ret--;
				break;
			}
		}
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans;
	cin>>N; ans=N;
	P.resize(N);
	for(int i=0;i<N;i++) {
		cin>>P[i].first>>P[i].second;
		for(int j=0;j<i;j++) {
			int x=P[j].first-P[i].first, y=P[j].second-P[i].second;
			D.emplace_back(x,y); D.emplace_back(-x,-y);
		}
	}
	for(auto p: D) ans=min(ans,solve(p.first,p.second));
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int ini = sc.nextInt();

		int ans[] = new int[11];
		ans[0] = ini;

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

Measured memory_bytes: 23764
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	ll xa = a;
	ll xb = b;
	if (xa < xb) {
		xa = a + v * t;
		xb = b + w * t;
		if (xb <= xa) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	else {
		xa = a - v * t;
		xb = b - w * t;
		if (xa <= xb) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    map<char,int> mp;
    REP(i,n){
        mp[s[i]]++;
    }
    ll ans=1;
    for(auto x:mp){
        ans *= (x.second+1);
        ans %= MOD;
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
int n,c[2005][2005],f[2005][2005],a[2005],b[2005];
ll ans;
char s[100005];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	c[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++) 
		{
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			if(c[i][j]>=mod) c[i][j]-=mod;
		}
	}
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1],b[i]=b[i-1];
		if(s[i]=='0') a[i]+=2;
		else if(s[i]=='1') a[i]++,b[i]++;
		else b[i]+=2;
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=min(i,a[i]);j++)
		{
			if(i-j>b[i]) continue;
			f[i][j]=f[i-1][j];
			if(j>0) f[i][j]+=f[i-1][j-1];
			if(f[i][j]>=mod) f[i][j]-=mod;
			//printf("f(%d,%d)=%d\n",i,j,f[i][j]);
		}
	}
	for(int i=0;i<=n;i++)
		if(f[n][i]) ans=(ans+1ll*f[n][i]*c[n][a[n]-i])%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 30848
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tri;

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

int r,w,h,x,y;
int g[555][555];
bool vis[555][555];

int main(){
  while(scanf("%d",&r), r){
    vector<pii> num[2];

    for(int id=0;id<2;id++){
      scanf("%d%d%d%d",&w,&h,&x,&y);
      x--; y--;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)scanf("%d",&g[i][j]);
      }

      memset(vis,0,sizeof(vis));
      vis[y][x] = true;
      priority_queue<tri> q;
      q.push(tri(-g[y][x],y,x));

      int cnt = 0, val = 0;
      while(q.size()){
	num[id].push_back(pii(cnt,val));
	
	do{
	  cnt++;
	  y = get<1>(q.top()); x = get<2>(q.top());
	  val = min(val, get<0>(q.top()) );
	  q.pop();
	  
	  for(int i=0;i<4;i++){
	    int ny = y+dy[i], nx = x+dx[i];
	    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
	    if(vis[ny][nx])continue;
	    vis[ny][nx] = true;
	    q.push(tri(-g[ny][nx],ny,nx));
	  }
	}while(q.size() && get<0>(q.top()) >= val);
      }
      num[id].push_back(pii(cnt,val));
    }
    
    int ans = 1e9, rev_ite = num[1].size() - 1;
    for(int i=0;i<(int)num[0].size();i++){
      while(rev_ite>=0 && num[0][i].first + num[1][rev_ite].first >= r)rev_ite--;
      rev_ite++;
      if(num[0][i].first + num[1][rev_ite].first >= r){
	ans = min(ans, - num[0][i].second - num[1][rev_ite].second);
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 5288
from itertools import chain,repeat
K,N = map(int,input().split())

def solve():

  if K % 2 == 0:
    return ' '.join(map(str, chain((K//2,),repeat(K,N-1))))
  else:
    seq = [K//2+1]*N
    d = N//2
    for _ in range(d):
      if seq[-1] == 1:
        seq.pop()
      else:
        seq[-1] -= 1
        seq.extend(repeat(K,N-len(seq)))
    return ' '.join(map(str, seq))

def naive():
  from itertools import product
  s = sorted(chain.from_iterable(product(range(1,K+1),repeat=i) for i in range(1,N+1)))
  return ' '.join(map(str, s[(len(s)-1)//2]))

print(solve())
# print(naive())

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll n,k,h[MAXN],dp[MAXN];
int main()
{
    fast_io;
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>h[i];
    }
    dp[1]=0;
    for(ll i=2;i<=n;i++){
        dp[i]=INF;
        for(ll j=1;j<=k && i-j>0;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int[] arr = {in.nextInt(), in.nextInt(), in.nextInt()};
        Arrays.sort(arr);

        System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
        System.exit(0);
    }
}



Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

VVI dp(30,VI(10,0));

void solve(int i,int j,int k){
  cout<<j;
  if(i<=1) return;
  for(int l=-1;l<=1;l++){
    if(j+l>=0&&j+l<10){
      if(k>dp[i-1][j+l]) k-=dp[i-1][j+l];
      else {
        solve(i-1,j+l,k);
        return;
      }
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j,l;
  int k;
  cin>>k;
  int cnt=0;
  for(i=0;i<10;i++) {
    dp[1][i]=1;
  }
  for(i=2;i<30;i++){
    for(j=0;j<10;j++){
      for(l=-1;l<=1;l++){
        if(j+l>=0&&j+l<10){
          dp[i][j]+=dp[i-1][j+l];
        }
      }
    }
  }
  for(i=1;i<30;i++){
    for(j=1;j<10;j++){
      if(k-dp[i][j]>0) k-=dp[i][j];
      else {
        solve(i,j,k);
        cout<<endl;
        return 0;
      }
    }
  }
  


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}



Measured memory_bytes: 26344
#include<stdio.h>

int main(){

    long int ans = 1;

    int N, M;
    scanf("%d%d", &N, &M);

    int a[M+2];

    a[0] = -1;
    a[M + 1] = N+1;

    for (int i = 1; i < M+1; i++){

        scanf("%d", &a[i]);

        if(a[i] == a[i-1] + 1){
            ans = 0;
        }
    }

    if(ans == 1){

        long int pattern[N+1];

        pattern[0] = 1;
        pattern[1] = 1;
        pattern[2] = 2;

        for (int i = 3; i < N+1; i++){
            pattern[i] = (pattern[i - 1] + pattern[i - 2]) % 1000000007;

            //printf("pattern[%d] = %ld\n", i, pattern[i]);
        }

        for (int i = 1; i < M+2; i++){

            ans = (ans * pattern[a[i] - a[i - 1] - 2]) % 1000000007;
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1152
H, W = tuple(int(i) for i in input().split())
a = [ [int(i) for i in input().split()] for i in range(H)]

move = []
for i in range(H-1):
    for j in range(W):
        if a[i][j] % 2 != 0:
            if j == W-1:
                move.append(((i, j), (i+1, j)))
                a[i+1][j] += 1
            elif a[i][j+1] % 2 != 0:
                move.append(((i, j), (i, j+1)))
                a[i][j+1] += 1
            else:
                move.append(((i, j), (i+1, j)))
                a[i+1][j] += 1

for j in range(W-1):
    if a[H-1][j] % 2 != 0:
        move.append(((H-1, j), (H-1, j+1)))
        a[H-1][j+1] += 1

print(len(move))
for (y1, x1), (y2, x2) in move:
    print("%d %d %d %d" % (y1+1, x1+1, y2+1, x2+1))


Measured memory_bytes: 35856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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



	int N, K;
	cin >> N >> K;

	int x[50], y[50];
	vector<int> XZ, YZ;

	rep(i, N) {
		cin >> x[i] >> y[i];
		XZ.push_back(x[i]);
		YZ.push_back(y[i]);
	}

	ll saishou = 4e18;
	for (int itrx : XZ) {
		for (int itry : YZ) {
			for (int itrx2 : XZ) {
				for (int itry2 : YZ) {
					int kosuu = 0;
					rep(i, N) if (itrx <= x[i] && x[i] <= itrx2 && itry <= y[i] && y[i] <= itry2) kosuu++;
					ll menseki = 1ll * (itrx2 - itrx) * (itry2 - itry);	
					if (kosuu >= K && saishou > menseki) {
						saishou = menseki;
					}
				}
			}
		}
	}

	co(saishou);
	Would you please return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    S.append(str(input()))
print('AC x {}'.format(S.count('AC')))
print('WA x {}'.format(S.count('WA')))
print('TLE x {}'.format(S.count('TLE')))
print('RE x {}'.format(S.count('RE')))

Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n;
    cin >> n;
    ll cnt = 0;
    for (ll i = 1; i < n; i++) cnt += (n - 1) / i;
    cout << cnt << endl;
}

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

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

  double res = 0.0;
  if (2 * x <= a * a * b) {
    res = atan(a * b * b / (2 * x));
  } else {
    res = atan(((2 * a * a * b) - (2 * x)) / (a * a * a));
  }
  
  cout << fixed << setprecision(10);
  cout << res * 180 / M_PI << endl;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int a = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      a++;
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int sum[N];
int dp[N][2];
int c[N];

int32_t main(){
  fast;

  int n;
  cin >> n;
  FOR(i,1,n)cin >> c[i];
  vector<int>C;
  int prev = -1;
  FOR(i,1,n){
    if(c[i] != prev){
      C.pb(c[i]);
      prev = c[i];
    }
  }
  dp[0][0] = 1;
  dp[0][1] = 0;
  sum[C[0]] = 1;

  FOR(i,1,sz(C) - 1){
    dp[i][0] = add(dp[i-1][0],dp[i-1][1]);
    dp[i][1] = sum[C[i]];
    sum[C[i]] = add(add(sum[C[i]],dp[i-1][0]),dp[i-1][1]);
  } 

  // FOR(i,0,sz(C) - 1)cout << dp[i][0] << " " << dp[i][1] << "\n";

  cout << add(dp[sz(C) - 1][0] , dp[sz(C) -1][1]);

  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  double R;
  cin >> R;

  cout << setprecision(16) << 2 * 3.1415926535 * R << endl;

  return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>

double round(double x);

int main(void) {
    int temp;
    double a,b,c,d,e,f,x,y;
    while (scanf("%lf %lf %lf %lf %lf %lf\n",&a,&b,&c,&d,&e,&f)!=EOF) {
        x = 1.0*(c*e-b*f)/(a*e-b*d);
        y = 1.0*(a*f-c*d)/(a*e-b*d);
        printf("%.3lf %.3lf\n",round(x),round(y));
    }
    return 0;
}

double round(double x) {
    int temp;
    if (x>=0) {
        temp = x*1000+0.5;
        return 1.0*temp/1000;
    } else {
        temp = x*1000-0.5;
        return 1.0*temp/1000;
    }
}

Measured memory_bytes: 656
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int n;  cin >> n;
    string s;	cin >> s;
    int x = 0;
    int ans = 0;
    rep(i, n){
	switch(s[i]){
	    case 'I':
		++x;
		break;
	    case 'D':
		--x;
		break;
	}
	ans = max(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int A,B;
  scanf("%d %d",&A,&B);
  int s;
  if(A>B){
    s=s+A;
    A=A-1;
  }
  else{
    s=s+B;
    B=B-1;
  }
  if(A>B){
    s=s+A;
  }
  else{
    s=s+B;
  }
  printf("%d\n",s);
  return 0;
}
  

Measured memory_bytes: 1732
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, A, B;
    scan(N, A, B);
    if (N == 1)
    {
        writeln(A == B ? 1 : 0);
        return;
    }
    if (B < A)
    {
        writeln(0);
        return;
    }
    writeln((B * (N - 1) + A) - (A * (N - 1) + B) + 1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
//__gcd(a,b)
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int a,b,c;
	cin>>a>>b>>c;
	if( c-a-b>0 && 1LL*4*a*b<1LL*(c-a-b)*(c-a-b))
	{
	    cout<<"Yes"<<endl;
	}
	else 
	{
	    cout<<"No"<<endl;
	}
}

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

int main(){
    int n,tmp;
    vector<long long int> bo;
    vector<long long int> ans;
    int count = 0;
    cin >> n;
    for(int i=0; i < n; i++){
        cin >> tmp;
        bo.push_back(tmp);
    }
    sort(bo.rbegin(), bo.rend());
    for(int i=0; i < n; i++){
        if(bo[i] == bo[i+1]){
            ans.push_back(bo[i]);
            count++;
            i++;
        }
    }
    if(count >= 2){
        sort(ans.rbegin(), ans.rend());
        cout << ans[0] * ans[1] << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 1908
#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))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  ll s[200200];
  for(int i =0; i < n; i++) {
    int x; cin >> x;
    s[i+1] = s[i] + x;
  }
  map<ll, int> occ;
  ll res = 0;
  for(int i = 0; i <=n; i++) {
    res += occ[s[i]];
    occ[s[i]]++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 14336
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    if (a < b) puts("1");
    else puts("0");
}



Measured memory_bytes: 3108
n = int(input())

n_divisors = []

for i in range(1, int(n ** 0.5) + 1) :
    if n % i == 0 :
        n_divisors.append(i)
        if n // i != i :
            n_divisors.append(n // i)
        else :
            n_divisors.append(i)

len_nd = len(n_divisors)

print(n_divisors[len_nd - 1] + n_divisors[len_nd - 2] - 2)

Measured memory_bytes: 3268
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main() {

    int n;                  // XとYの次元数n
    int x[100];             // ベクトル
    int y[100];             // ベクトル

    double S[4] = {0};
    double D[4];  // ミンコフスキー距離

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

    for (double p = 0; p < 3; p++) {

        for (int i = 0; i < n; i++) {
            S[(int)p] += pow(abs(x[i] - y[i]), p + 1);
        }

        D[(int)p] = pow(S[(int)p], 1 / (p + 1));

    }

    D[3] = x[0] - y[0];

    for (int i = 0; i < n; i++) {
        if (abs(x[i] - y[i]) > D[3]) {
            D[3] = abs(x[i] - y [i]);
        }
    }

    cout << fixed;

    for (int i = 0; i < 4; i++) {
        cout << setprecision(10) << D[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3424
import bisect
n = int(input())
A = [int(input()) for _ in range(n)]
L = [-1]*n
count = 0
for i in A:
  t = bisect.bisect_left(L, i) - 1
  if L[t] == -1:
    count += 1
  L[t] = i
print(count)

Measured memory_bytes: 7840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a.length()==3){
		reverse(a.begin() ,a.end());
		cout<<a<<endl;
	}
	else{
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

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

	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	binwitdh := 60

	kstr := strconv.FormatInt(int64(K), 2)
	kchars := strings.Split(kstr, "")
	kbin := make([]int, binwitdh)
	for j := 0; j < len(kchars); j++ {
		kbin[binwitdh-len(kchars)+j], _ = strconv.Atoi(kchars[j])
	}

	bins := make([][]int, N)
	for i, a := range as {
		str := strconv.FormatInt(int64(a), 2)
		chars := strings.Split(str, "")
		bs := make([]int, binwitdh)
		for j := 0; j < len(chars); j++ {
			bs[binwitdh-len(chars)+j], _ = strconv.Atoi(chars[j])
		}
		bins[i] = bs
	}
	/*
		for _, b := range bins {
			fmt.Println(b)
		}
	*/

	flag := false
	for i := 0; i < binwitdh; i++ {
		if kbin[i] == 1 {
			zcnt := 0
			ocnt := 0
			for _, b := range bins {
				if b[i] == 0 {
					zcnt++
				} else {
					ocnt++
				}
			}
			if zcnt > ocnt {
				for _, b := range bins {
					if b[i] == 0 {
						b[i] = 1
					} else {
						b[i] = 0
					}
				}
			} else {
				flag = true
			}
		} else if flag {
			zcnt := 0
			ocnt := 0
			for _, b := range bins {
				if b[i] == 0 {
					zcnt++
				} else {
					ocnt++
				}
			}
			if zcnt > ocnt {
				for _, b := range bins {
					if b[i] == 0 {
						b[i] = 1
					} else {
						b[i] = 0
					}
				}
			}
		}
	}

	ans := 0
	//fmt.Println("---")
	for _, b := range bins {
		ans = ans + bin2Dec(b)
	}
	fmt.Println(ans)
}

func bin2Dec(digits []int) int {
	ret := 0
	for i := 0; i < len(digits); i++ {
		ret = ret*2 + digits[i]
	}
	return ret
}


Measured memory_bytes: 66176
#include<bits/stdc++.h>
using namespace std;
int main()
{
   // ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long long N,K,A[200009];
    cin>>N>>K;
    for(long i=0;i<N;i++)
        cin>>A[i];
    A[N]=A[N-1]+(K+2);
    long long i=1,X=A[0],P=X,S=0;
    while(i<N)
    {
        P=X;
        while(A[i]-X<=K){
            X=A[i];
            i++;
        }
        S+=(X-P+K);
        X=A[i];
    }
    if(N==1)
        cout<<K;
    else
        cout<<S;
}

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

int main(){
    int n,q,count=0;
    
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    cin>>q;
    int b[q];
    for(int i=0;i<q;i++)cin>>b[i];
    for(int i=0;i<q;i++){
        int j=0;
        int m=n-1;
        if(b[i]== a[j] || b[i]==a[m]){ 
            count++;
        }
        else{
        while(true){
            if(b[i] == a[(j+m)/2]){
            count++;
            break;
            }
            else if(j+1 == m) break;
            else if(b[i]>a[(j+m)/2]) j=(j+m)/2;
            else m=(j+m)/2;
        }
        } 
    }
    cout<<count<<endl;
    return 0;
}




Measured memory_bytes: 3588
import java.util.Scanner;
class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int num1 = scan.nextInt();
    	int num2 = scan.nextInt();
    	int x;
    	int y;
    	
    	if(num1 > num2){
    		x = num1;
    		y = num2;
    	}else{
    		x = num2;
    		y = num1;
    	}
    	
    	int tmp;
    	for( ;(tmp = x % y) != 0; ){
    		x = y;
    		y = tmp;
    	}
    	
    	System.out.println(y);
     }
}

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

string s;
int m;
int h;

int main(){
  while(1){
    cin >> s;
    if(s == "-") break;
    cin >> m;
    for(int i = 0; i < m; i++){
      cin >> h;
      s += s.substr(0, h);
      s.erase(s.begin(), s.begin()+h);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 3160