akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B), x(M), y(M), c(M);
    rep(i, 0, A) cin >> a.at(i);
    rep(i, 0, B) cin >> b.at(i);
    rep(i, 0, M) cin >> x.at(i) >> y.at(i) >> c.at(i);
    int fin = INF;
    rep(i, 0, M){
        int sum = a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i);
        fin = min(fin, sum);
    }
    sort(all(a));
    sort(all(b));
    fin = min(fin, a.at(0) + b.at(0));
    cout << fin << endl;
}


Measured memory_bytes: 2176
import math
a,b=map(int,input().split())
a1=math.ceil(a/0.08)
a2=math.floor((a+1)/0.08)
A=set([i for i in range(a1,a2)])
b1=math.ceil(b/0.1)
b2=math.floor((b+1)/0.1)
B=set([i for  i in range(b1,b2)])

if A&B==set(): 
    print(-1)
    exit()

print(min(A & B))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  while(k--){
    int a, b;
    cin >> a >> b;
    cout << (min(min(n - a + 1,n - b + 1),min( a, b)) + 2) % 3 + 1 << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool even = false;
    for (int i = n - 2; i > 0; i = i - 2)
    {
        bool same = true;
        for (int j = 0; j < i / 2; j++)
        {
            if (s[j] != s[j + i / 2])
            {
                same = false;
                break;
            }
        }
        if (same == true)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 3592
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,gyo0=0,gyo1=0,re0=0,re1=0,count;
    string s,h;
    cin>>s>>h;
    if(s=="H"){
        if(h=="H"){
            cout<<h;
        }
        else{
            cout<<"D";
        }
    }
    else{
        if(h=="H"){
            cout<<"D";
        }
        else{
            cout<<"H";
        }
    }
    return(0);
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !
A , B , C , D , E , F = map(int ,input().split())
def solve():
    ans = (100*A , 0)
    for a in range(0,F,100*A):
        for b in range(0,F,100*B):
            water = a + b
            for c in range(0,F,C):
                for d in range(0,F,D):
                    sugar = c + d
                    if water + sugar > F or 100*sugar > E*water or water ==0:
                        break
                    elif 100*sugar == E*water:
                        return (water,sugar)
                    elif sugar*ans[0] > ans[1]*water:
                        ans = (water , sugar)
    return ans
ans = solve()
print(sum(ans),ans[1])

Measured memory_bytes: 3064
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(n:usize);
    let mut eratos:Vec<usize> = vec![];
    eratos.resize(n + 2, 0);
    for i in 1..eratos.len() {
        for j in (i..eratos.len()).step_by(i) {
            eratos[j] += 1;
        }
    }
    let mut ans = 0;
    for i in 1..n+1 {
        ans += i * eratos[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 80140
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;

	writeln(N[0] == N[2] ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
object Main extends App {


  val n = scala.io.StdIn.readLine.toInt
  val ab = (1 to n).map { _ =>
    val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    (a, b)
  }.sortBy(_._2)

  //  println(ab)
  var now = 0L
  ab.foreach { aabb =>
    now += aabb._1
    if (now > aabb._2) {
      println("No")
      sys.exit
    }
  }

  println("Yes")
}


Measured memory_bytes: 117616
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,k,a[200005]={},b[200005]={},x[200005]={};
  cin >> n >> m >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<m; i++) {
    cin >> b[i];
  }
  for(int i=1; i<=m; i++) {
    x[i]+=x[i-1]+b[i-1];
  }
  ll cnt=0,ans=0,y;
  y=upper_bound(x,x+m+1,k)-x-1;
  ans=y;
  for(int i=0; i<n; i++) {
    cnt+=a[i];
    if(cnt>k) {
      break;
    }
    y=upper_bound(x,x+m+1,k-cnt)-x;
    ans=max(ans,i+y);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 8344
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> h(n);
  vector<int> move(n);
  for(int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  move[n - 1] = 0;
  for(int i = n - 2; i > -1; i--)
  {
    if(h[i] >= h[i + 1])
    {
      move[i] = move[i + 1] + 1;
    }
    else
    {
      move[i] = 0;
    }
  }
  cout << *max_element(move.begin(), move.end());

  return 0;
}


Measured memory_bytes: 1024
#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;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


int main(){
  ll i,j;
  ll h,w,k;
  cin>>h>>w>>k;

  ll c[w+1];
  c[0]=1;
  c[1]=1;
  for(i=2;i<=w;i++){
    c[i]=c[i-2]+c[i-1];
  }

  VVI dp(h+1,VI(w+2,0));
  dp[0][1]=1;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      dp[i][j]+=dp[i-1][j-1]*c[max(0ll,j-2)]*c[max(0ll,w-j)];
      dp[i][j]%=Mod;
      dp[i][j]+=dp[i-1][j]*c[max(0ll,j-1)]*c[max(0ll,w-j)];
      dp[i][j]%=Mod;
      dp[i][j]+=dp[i-1][j+1]*c[max(0ll,j-1)]*c[max(0ll,w-j-1)];
      dp[i][j]%=Mod;
    }
  }

  cout<<dp[h][k]<<endl;


  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i;
    cin>>a>>b>>c;
    for(i=1;i<=b;i++)
    {
        if((a*i)%b==c){cout<<"YES"<<endl;return 0;}
    }
   cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


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

	int x;
	cin >> x;

	if (x >= 30)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ORDER 500000

struct NODE{
  int key,nil;
  struct NODE *left,*right,*parent;
};

typedef struct NODE Node;

Node *head;

void insert(Node*);
void print1(Node*);
void print2(Node*);
int find(Node*,int);
void delete(Node*);
Node* successor(Node*);
Node* minimum(Node*);
Node* search(Node*,int);

int main(){
  int i,num;
  Node *n;
  char order[ORDER][10];
  Node tmp;

  scanf("%d",&num);

  n = (Node *)malloc(sizeof(Node) * num);

for(i=0; i<num; i++){
    scanf("%s",order[i]);
    if(strcmp(order[i],"print")!=0)scanf("%d",&n[i].key);
  }

  for(i=0; i<num; i++){
    if(strcmp(order[i],"insert")==0) insert(&n[i]);
    if(strcmp(order[i],"print")==0){
      print1(head);
      printf("\n");
      print2(head);
      printf("\n");
    }
    if(strcmp(order[i],"find")==0){
      if(find(head,n[i].key)==1) printf("yes\n");
      else printf("no\n");
    }
    if(strcmp(order[i],"delete")==0)
 delete(search(head,n[i].key));
  }

  return 0;
}






void insert(Node *z){
  Node *y,*x;

 z->left = NULL;
  z->right = NULL;
  y = NULL;
  x = head;

  while(x != NULL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL) head = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}



void print1(Node *node){
  if(node == NULL){
    return;
  }

  print1(node->left);
  printf(" %d",node->key);
  print1(node->right);
  return ;
}



void print2(Node *node){
  if(node == NULL){
    return;
  }
  printf(" %d",node->key);
  print2(node->left);
  print2(node->right);
  return;
}



int find(Node *node,int num){
  int found=0;
  if(node == NULL){
    return 0;
  }
  if(node->key == num) found=1;
  if(node->key > num) found = find(node->left,num);
  if(node->key < num) found = find(node->right,num);

  return found;
}



void delete(Node *node){
  Node *x,*y;
  if(node->left == NULL || node->right == NULL) y = node;
  else y = successor(node);

  if(y->left != NULL) x = y->left;
  else x = y->right;

  if(x != NULL) x->parent = y->parent;

  if(y->parent == NULL) head = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;

  if(y != node) node->key = y->key;
}



Node* successor(Node *node){
  Node *y,*x;
  if(node->right != NULL) return minimum(node->right);
  x = node;
  y = x->parent;
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}


Node* minimum(Node *node){
  while(node->left != NULL){
    node = node->left;
  }
  return node;
}


Node* search(Node *node,int num){
  Node *found;
  if(node == NULL){
    return 0;
  }
  if(node->key == num){
    found = node;
  }
  if(node->key > num) found = search(node->left,num);
  if(node->key < num) found = search(node->right,num);

  return found;
}

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

int siguma (int n){
  int sum = 0 ;
  while(n>0){
    sum += n%10 ;
    n /=10 ;
  }
  return sum;
}

int main(){
  int N , A , B ;
  cin >> N >> A >> B ;
  int total = 0 ;
  for(int i = 1 ; i<=N ; i++){
    int sum = siguma(i) ;
    if(sum>=A&&sum<=B){
      total += i ;
    }
  }
  
  cout << total << endl;
  
}
    


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <math.h>


int main(){
	int X;
	int Y;
	int N,D;
	int counts = 0;
	
	if(scanf("%d %d", &N, &D))
	{
		for(int i=0; i<N; i++){
			if(scanf("%d %d", &X, &Y)){
			}
			double dis = sqrt((double)X*X + (double)Y * Y);
			
			if(dis <= D) counts++;
		}
		printf("%d\n", counts);
	}
	return 0;
}




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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n; cin >> n;
  unordered_map<int, int> D;
  rep(i, n) {
    int d; cin >> d;
    D[d]++;
  }
  int m; cin >> m;
  rep(i, m) {
    int t; cin >> t;
    if (D[t] == 0) no();
    D[t]--;
  }
  yes();
}


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

typedef long long ll;
const ll InF = 1e15;
ll mod = 1000000007;
#define SIZE 500000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll modpow(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = modpow(a, b / 2);
	z = z*z%mod;
	if (b % 2 == 1)z = z*a%mod;
	return z;
}

int main() {
  invinit();
  int N,A,B,C;
  cin>>N>>A>>B>>C;
  ll a = A * inv[A + B] % mod;
  ll b = B * inv[A + B] % mod;
  ll ans = 0;
  for (int i = 0; i <= N - 1; i++) {
    ll sa = com(N - 1 + i, N - 1) * a % mod * modpow(a, N - 1) % mod * modpow(b,i) % mod;
    ll sb = com(N - 1 + i, N - 1) * b % mod * modpow(b, N - 1) % mod * modpow(a,i) % mod;
    ans = (ans + (sa + sb) % mod * (N + i)) % mod;
  }
  ans = ans * 100 % mod * inv[A + B] % mod;
  cout<<ans<<endl;
  return 0;
}

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

void fnInput(int &a_riElementCnt, vector<int> &a_rviElement, 
             int &a_riTargetCnt , vector<int> &a_rviTarget )
{
  cin >> a_riElementCnt;

  a_rviElement.resize(a_riElementCnt);
  for (int i = 0; i < a_riElementCnt; i++)
    cin >> a_rviElement[i];

  cin >> a_riTargetCnt;

  a_rviTarget.resize(a_riTargetCnt);
  for (int i = 0; i < a_riTargetCnt; i++)
    cin >> a_rviTarget[i];
}

int fnRcsSearch(int a_iPos, const vector<int> &a_cnrviElement, int a_iTarget,
                vector<vector<int>> &a_rvviOK)
{
  if (a_iPos == a_cnrviElement.size())  return 0;
  if (!a_iTarget)    return 1;
  if (a_iTarget < 0) return 0;
  if (a_rvviOK[a_iPos][a_iTarget] != -1)
  {
    return a_rvviOK[a_iPos][a_iTarget];
  }

  a_iPos++; 
  int iRtn0 = fnRcsSearch(a_iPos, a_cnrviElement, a_iTarget, a_rvviOK);
  a_rvviOK[a_iPos][a_iTarget] = iRtn0;
  if (iRtn0)  return iRtn0;

  int iSmallTarget = a_iTarget - a_cnrviElement[a_iPos];
  int iRtn1 = fnRcsSearch(a_iPos, a_cnrviElement, iSmallTarget, a_rvviOK);
  if (iSmallTarget >= 0)
  {
    a_rvviOK[a_iPos][iSmallTarget] = iRtn1;
    return iRtn1;
  }
}

void fnExhSearch(const vector<int> &a_cnrviElement, const vector<int> &a_cnrviTarget)
{
  vector<vector<int>> vviOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < a_cnrviTarget.size(); i++)
  {
    int iTarget = a_cnrviTarget[i];
    int iRtn0, iRtn1;

    if (fnRcsSearch(0, a_cnrviElement, iTarget, vviOK))
    {
      cout << "yes" << endl;
      vviOK[0][iTarget] = fnRcsSearch(0, a_cnrviElement, iTarget, vviOK);
      continue;
    }

    int iSmallTarget = iTarget - a_cnrviElement[0];
    if (fnRcsSearch(0, a_cnrviElement, iSmallTarget, vviOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    if (iSmallTarget >= 0)
    {
      vviOK[0][iSmallTarget] = fnRcsSearch(0, a_cnrviElement, iSmallTarget, vviOK);
    }
  }
}

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

  int iElementCnt, iTargetCnt;
  vector<int> viElement, viTarget;

  fnInput(iElementCnt, viElement, iTargetCnt, viTarget);
  fnExhSearch(viElement, viTarget);

  return 0;
}

Measured memory_bytes: 1340
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
vvl G(200005);
vl sum(200005,0);
bool visit[200005];
vl v(200005,0);

void bfs(ll s, ll n){
    queue<ll> q;
    q.push(s);
    sum[s] += v[s];
    while(!q.empty()){
        ll t = q.front(); q.pop();
        for(auto i : G[t]){
            sum[i] = sum[t] + v[i]; 
            q.push(i);
        }
    }
}
 
int main(){
    ll a; string s; cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else puts("red");
}

Measured memory_bytes: 8064
from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])

A.sort()

check = list(accumulate(A))

for key in range(N-1, 0, -1):
    if check[key-1] * 2 < check[key] - check[key-1]:
        print(N - key)
        exit()

print(N)


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

const int MAX = 100100100;

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

  int x,n,min=0,num[102],minimum=100100;
  rep(i,102) num[i] = i;
  cin>>x>>n;
  int p[n];
  rep(i,n){
    cin >> p[i];
    num[p[i]] = MAX;
  }
  rep(i,102){
    if(x - num[i] >= 0 && x - num[i] < minimum){
      min = num[i];
      minimum = x - num[i];
    }else if(num[i] - x >= 0 && num[i] - x < minimum){
      min = num[i];
      minimum = num[i] - x;
    }
  }
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        if(n % 2 == 0) System.out.println(n);
        else System.out.println(2 * n);
    }  
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {

  int A,B,C;

  scanf("%d%d%d", &A, &B, &C);

  int ans;

  if( A == C)
    printf("%d\n", B);
  else if( A == B)
    printf("%d\n", C);
  else
    printf("%d\n", A);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll max=0;
  ll max_index;
  rep(i,n){
    cin>>a[i];
    if(abs(a[i])>=abs(max)){
      max=a[i];
      max_index=i;
    }
  }

  if(max==0){
    cout<<0<<endl;
    return 0;
  }

  cout<<2*n-2<<endl;
  rep(i,n){
    if(i!=max_index){
      cout<<max_index+1<<" "<<i+1<<endl;
    }
  }
  if(max>0){
    rep(i,n-1){
      cout<<i+1<<" "<<i+2<<endl;
    }
  }else{
    rep(i,n-1){
      cout<<n-i<<" "<<n-1-i<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

int main() 
{
	int t;
	cin >> t;
	for(int i=0;i<t;i++)
	{
		
		int n,k;
		cin >> n >> k;
		
		int x[n];
		for(int j=0;j<n;j++){	cin >> x[j];	}
		
		int a[n];
		for(int j=0;j<n-1;j++){	a[j] = (x[j+1] - x[j]);	}
		
		sort(a,a+n-1);
		
		int ans = 0;
		for(int j=0;j<(n-k);j++)
				ans +=a[j];
				
		cout << ans << endl;
	}	
	return 0 ;
}

Measured memory_bytes: 1960
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a = 0;
        for (int i = 0; i < N; i++) {
            a |= sc.nextInt();
        }
        int ans = Integer.numberOfTrailingZeros(a);
        System.out.println(ans);
    }
}

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

int main() {
  string n;
  cin >> n;
  if (n[n.length()-1] == '2' || n[n.length()-1] == '4' || n[n.length()-1] == '5' || n[n.length()-1] == '7' || n[n.length()-1] == '9') {
    cout << "hon" << endl;
  } else if (n[n.length()-1] == '3') {
    cout << "bon" << endl;
  } else {
    cout << "pon" << endl;

  }
  return 0;
}

Measured memory_bytes: 3628
n = int(input())
AB = []
for i in range(n):
    a,b = map(int,input().split())
    AB.append([a,b])
AB.sort(key=lambda x: x[1])
sum = 0
for a,b in AB:
    sum += a
    if sum > b:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 40516
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, N;
    cin >> H >> N;

    rep(i, N) {
        int A;
        cin >> A;
        H -= A;
    }

    if (H > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	string a,b,c;
	cin>>a>>b;
	for(int i=0;i<n;i++){
	    cout<<a[i]<<b[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
int main(void) {
	int N;
	std::cin >> N;
	std::vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	int FLUG=1;
	int NumberChange = 0;
	while (FLUG) {
		FLUG = 0;
		for (int i = N - 1; i > 0; --i) {
			if (A[i] < A[i - 1]) {
				std::swap(A[i], A[i - 1]);
				++NumberChange;
				FLUG = 1;
			}
		}
	}
	for (int i = 0; i < N-1; ++i) {
		std::cout<< A[i]<<" ";
	}
	std::cout << A[N - 1] << std::endl << NumberChange << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int x,n,y;
		cin>>n>>x>>y;
		vector<int>a[n];
		for(int i=0;i<n-1;i++){
			a[i].pb(i+1);
			a[i+1].pb(i);
		}
		a[x-1].pb(y-1);
		a[y-1].pb(x-1);
		int ans[n]={0};
		//int done[n]={0};
		for(int i=0;i<n-1;i++){
			//done[i]=1;
			queue<int>q;
			q.push(i);
			int vis[n]={0};
			int lev[n]={0};
			while(!q.empty()){
				int p=q.front();
				q.pop();
				for(auto x:a[p]){
					if(!vis[x]){
						vis[x]=1;
						q.push(x);
						lev[x]=lev[p]+1;
						if(x>i)
							ans[lev[x]]++;
					}
				}
			}
		}
		for(int i=1;i<n;i++)
			cout<<ans[i]<<" "<<endl;
	}
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll


signed main(){
  int n,m;
  cin>>n>>m;
  vector<pair<P,int> > v;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    v.PB(make_pair(P(a,b),i));
  }

  sort(all(v));

  vector<P>w(m);
  int t=1;
  rep(i,m){
    if(i!=0&&v[i].F.F!=v[i-1].F.F)
      t=1;
    w[v[i].S] = P(v[i].F.F,t);
    t++;
  }

  
  rep(i,m){
    printf("%06lld%06lld\n",w[i].F,w[i].S);
  }

}

Measured memory_bytes: 6000
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a, b, t;
		while(true) {
			a = sc.nextInt(); b = sc.nextInt();
			if(a == 0 && b == 0) break;
			if(a > b) { t = a; a = b; b = t; }
			System.out.println(a + " " + b);
		}
	}
}

Measured memory_bytes: 36412
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n; scanf("%lld", &n);

	if(n & 1) {
		printf("0\n");
		return 0;
	}
	n >>= 1;

	i64 ans = 0;
	while(n) {
		ans += n / 5;
		n /= 5;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
let iota n =
    let rec _iota n a =
        if n < 0 then a else _iota (n - 1) (n :: a) in
    _iota (n - 1) [];;


let max_route x l =
    let rec _max_route x y is_odd prev_route prev_y a =
        match x with
          [] -> a
        | (h::xs) ->
                match y with
                  [] -> 0
        | (now::ys) ->
                match is_odd with
                        | true ->
                                let route = prev_route + l - prev_y * 2 + h * 2 in
                                _max_route xs ys false route prev_y (max a route)
                        | _ ->
                                let route = prev_route + l - prev_y - now + h * 2 in
                                _max_route xs y true route now (max a route) in
    match x with
      [] -> 0
                        | (h::xs) ->
                                _max_route xs x true h h h;;




let () =
    let (l, n) = Scanf.scanf " %d %d" (fun l n -> (l, n)) in
    let x = List.rev_map (fun i -> Scanf.scanf " %d" (fun x -> x)) (iota n) in
    let x_rev = List.rev_map (fun y -> l - y) x in
    print_int (max (max_route x l) (max_route x_rev l));
    print_newline();;


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


int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  int minimum=100,maximum=-100;
  int input;
  for(int i=0;i<N;i++){
    cin >> input;
    vec.at(i) = input;
    minimum = min(minimum,input);
    maximum = max(maximum,input);
  }
  int res = 2000000;
  int sum;
  for(int i=minimum;i<=maximum;i++){
    sum = 0;
    for(int x: vec){
      sum += (i-x)*(i-x);
    }
    res = min(res,sum);
  }
  cout << res << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<int> B(M);
    for (int i = 0; i < M; ++i) cin >> B[i];
    ll tot = 0;
    for (int i = 0; i < M; ++i) tot += B[i];

    int j = M;
    int ans = 0;

    for (int i = 0; i < N+1; ++i) {
        while (j > 0 && tot > K) {
            --j;
            tot -= B[j];
        }
        if (tot > K) break;
        ans = max(ans, i+j);
        if (i == N) break;
        tot += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
<?php
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d %d %d", $a1, $a2,$b1,$b2);

while(true){
        $b1 = $b1 - $a2;
        if($b1 <= 0 ) die("Yes");
        $a1 = $a1 - $b2;
        if($a1 <= 0 ) die("No");
}

Measured memory_bytes: 16036
/*
 * アルゴリズムとしてはチケットの枚数分のネットワークをレイヤ構造で持ち
 * 各々のレイヤから上位レイヤへはチケットを使った場合に遷移するようにする
 * 上位レイヤから下位レイヤには遷移することができないようにし，
 * 最下位レイヤの始点から終点と同じ点を表すすべてのレイヤの点までの最短経路を求める．
 *
 * (イメージ)
 *      T`T`T`  
 *      |/|/|   S=始点, o=点, T`=終点 |=辺 /=レイヤ下位から上位への有効辺
 *      o o o   
 *      |/|/|   S->T`までの距離で最短のものを求め出力する
 *      S o o   
 *Layer 0 1 2   
 *
 **/

#include <iostream>
#include <map>
#include <limits.h>

#define rep(i,s,t) for(int i=s;i<t;i++)

using namespace std;

//c層目のid値を返す関数
int id2cid(int c,int id){
	return c*1000+id;
}

//dijkstraアルゴリズム
//特に無加工，距離を持った隣接を表すgraphと各点までの距離を保持するdis,始点ssを入力
//計算結果はdisに保持し，返り値は無し
void dijkstra(map<int,map<int,int> > &graph,map<int,int>  &dis,int ss){
	//未確定点を保持する集合multimap，距離をkey,点idをvalueとする
	multimap<int, int> T;
	//注目する点pのid値
	int pid;
	//始点をまず入力する
	T.insert(make_pair(0,ss));
	//未確定点がなくなるまで
	while(!T.empty()){
		//未確定の中で一番距離が小さい要素(mapの先頭)を取得し注目点pを得る
		pid=(*(T.begin())).second;
		//点pを未確定点集合から削除する
		T.erase(T.begin());

		//pに隣接する点について
		for(map<int,int>::iterator it=graph[pid].begin();it!=graph[pid].end();it++){
			//隣接点のid値cidとその点までの距離distを取得
			int cid=(*it).first;
			int dist=(*it).second;
			//隣接点が未確定点集合に含まれない，もしくは暫定の距離より小さい場合
			//未確定点集合の隣接点の距離を始点から注目点までの距離＋注目点からの距離に更新する
			if((dis.find(cid)!=dis.end() &&  dis[cid]>dis[pid]+dist) ||
				dis.find(cid)==dis.end()){
					T.insert(make_pair(dis[pid]+dist,cid));			
					dis[cid]=dis[pid]+dist;
			}
		}
	}
}

int main(void){
	int c,n,m,s,d;
	//グラフ構造用意
	map<int,map<int,int> > graph;
	//各点の最短距離を保持するmap
	map<int,int>  dis;
	while(cin >> c >> n >> m >> s >> d){
		if(c==0) break;

		//グラフ構造を初期化
		graph.clear();
		//mapを用いて辺i,jのコストcで隣接関係を表現

		//m路線に対して
		rep(i,0,m){
			int a,b,f;
			cin >> a >> b >> f;

			//グラフをc+1個の層構造とする
			rep(j,0,c+1){
				//j層目のグラフでは通常料金の移動コストで辺を張る
				//id2cid(j,id)でj層目の点idを示すid値に変換する
				//点は最大でも500点しかないため，1000桁目以上がn層目とする.
				//ex(0層目の点125は id=125,8層目の点125は8125)となる．
				graph[id2cid(j,a)][id2cid(j,b)]=f;
				graph[id2cid(j,b)][id2cid(j,a)]=f;
				//j層目からj+1層目へは割引料金を用いた移動コストの辺を張る
				//j層目からj-1層目への辺がないため階層が上がるに連れて下がることはできない
				//j層目はすなわちj回チケットを利用した枚数に相当する．
				if(j<c){
					graph[id2cid(j,a)][id2cid(j+1,b)]=f/2;
					graph[id2cid(j,b)][id2cid(j+1,a)]=f/2;
				}
			}
		}
		rep(j,0,c+1){
			//各レイヤからダミー終点INT_MAXまで辺をはる
			graph[id2cid(j,d)][INT_MAX]=0;
		}
		//各点への最短距離を保持するmapの初期化
		dis.clear();
		//通常のダイクストラで始点sからの各点への最短距離を求め，計算結果を変数disに保持する
		dijkstra(graph,dis,id2cid(0,s));

		//結果出力
		cout << dis[INT_MAX] << endl;
	}

	return 0;
}

Measured memory_bytes: 2040
#include <stdio.h>
int main(void)
{
  int n;
  scanf("%d", &n);
  int i, x[n];
  i = 0;
  while (i < n)
  {
    scanf("%d", &x[i]);
    i++;
  }
  
  int ans, sigma, k;
  ans = 2147483647;
  i = 0;
  while (i <= 100)
  {
    k = 0;
    sigma = 0;
    while (k < n)
    {
      sigma += (x[k] - i) * (x[k] - i);
      k++;
    }
    if (ans >= sigma)
    {
      ans = sigma;
    }
    i++;
  }
  printf("%d", ans);
  return 0;
}

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

typedef long long ll; 
#define inf 1000*1000*1000+9
#define infl (ll)inf*inf
#define sz(x) ((int) x.size())
#define all(a) a.begin(),a.end()
const int mod=1e9+7; 

const int nax=1e6+6; 
vector<ll> tr[nax<<2]; 
ll sum[nax<<2]; 
vector<ll> ss[nax<<2]; 
ll a[nax]; 

void build(int p, int l, int r){
	if(l==r){
		tr[p].push_back(a[l]); 
		sum[p]=a[l]; 
		ss[p].push_back(a[l]); 
	}	
	else {
		int m=(l+r)>>1, c1=p<<1, c2=p<<1|1 ; 	
		build(c1,l,m); 
		build(c2,m+1,r); 
		int i=0, j=0; 
		ll cur=0; 
		while(i< sz(tr[c1]) && j<sz(tr[c2])){
			if(tr[c1][i]<tr[c2][j]){
				tr[p].push_back(tr[c1][i]); i++; 
				ss[p].push_back(cur+tr[p].back()); 
				cur=ss[p].back(); 
			}	
			else {
				tr[p].push_back(tr[c2][j]); j++; 
				ss[p].push_back(cur+tr[p].back()); 
				cur=ss[p].back(); 
			}
		}
		while(i<sz(tr[c1])){
			tr[p].push_back(tr[c1][i]); i++; 
			ss[p].push_back(cur+tr[p].back()); 
			cur=ss[p].back(); 
		}
		while(j<sz(tr[c2])){
			tr[p].push_back(tr[c2][j]); j++; 
			ss[p].push_back(cur+tr[p].back()); 
			cur=ss[p].back(); 
		}
		for(int i:tr[p]){
			sum[p]+=i; 
		}
	}
}
ll agg=0; 
int mm; 
void query(int p, int l, int r, int i, int j, ll y){
	//if(agg>=y) return; 
	// cout<<p<<" " <<l<<" " <<r<<" " <<i<<" " <<j<<endl; 
	if(r<i || l>j) return; 
	if(i<=l && r<=j){
		int pos=upper_bound(all(tr[p]),mm)-tr[p].begin(); 	
		// for(int j:tr[p]) cout<<j<<" " ;  cout<<endl; 
		pos--; 
		if(pos>=0){
			agg+=ss[p][pos]; 	
		}
		return; 
	}
	int m=(l+r)>>1, c1=p<<1, c2=p<<1|1; 	
	query(c1,l,m,i,j,y); 
	query(c2,m+1,r,i,j,y); 
}

void solve(){
	int n; cin>>n; 
	for(int i=0;i<n;i++) cin>>a[i]; 
	build(1,0,n-1); 
	// int p=0; 
	// int j=1; 
	// while(p<4){
	// 	for(int i=0;i<(1<<p);i++){
	// 		cout<<sum[j+i]<<" " ; 
	// 	}
	// 	cout<<endl; 
	// 	j+=(1<<p); 
	// 	p++; 
	// }	
	int q; cin>>q; 
	while(q--){
		ll l,r,y;  
		cin>>l>>r>>y; 
		agg=0; 
		l--; r--; 
		int lo=0, hi=mod; 
		while((hi-lo)>1){
			mm=(lo+hi)>>1; 	
			agg=0; 
			query(1,0,n-1,l,r,y); 
			// cout<<mm<<" " <<agg<<endl; 
			// break; 
			if(agg>=y){
				hi=mm; 
			}
			else {
				lo=mm; 
			}
		}
		agg=0; 
		mm=hi; 
		query(1,0,n-1,l,r,y); 
		if(agg<y){
			cout<<-1<<endl; 
		}
		else {
			cout<<agg<<endl; 
		}
	}	
}

struct S
{
	int x,y; 	
};

ll sq(ll a){
	return a*a; 
}
double dist(vector<S> p){
	double ret=0; 
	for(int i=0;i<sz(p)-1;i++){
		ret+=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y)); 
	}
	return ret; 
}

#define vi vector<int> 
void pre(){
	int n; cin>>n; 	
	vector<S> p(n); 
	for(int i=0;i<n;i++){
		cin>>p[i].x>>p[i].y; 
	}
	double sum=0; 
	ll cnt=0; 
	vi id(n); 
	for(int i=0;i<n;i++) id[i]=i; 
	do {
		vector<S> v(n); 
		for(int i=0;i<n;i++){
			v[i]=p[id[i]]; 
		}
		double d=dist(v); 
		sum+=d; 
		cnt++; 
	}
	while(next_permutation(all(id))); 
	cout<<sum/cnt<<endl; 
}

int main(){
	cout<<fixed<<setprecision(10); 
	pre(); 
}

Measured memory_bytes: 192128
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int



#if 1
const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int n, i, j;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);


    cin >> n;
    vector <int> fr(n + 1);
    for(i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if(i == 1 && x != 0) {
            cout << 0;
            return 0;
        }
        fr[x]++;
    }

    int ans = (fr[0] == 1);
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= fr[i]; j++) {
            mul(ans, fr[i - 1]);
        }
    }

    cout << ans;

    return 0;
}


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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
  string n;
  cin >> n;
  ll sum = 0;
  ll len = n.size();
  for (int i = 0; i < len; i++){
    int num = ctoi(n[i]);
    sum += num;
  }
  sum %= 9;
  if (sum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3696
import java.util.Scanner

object Main {
  def main(args : Array[String]) = {
    val scanner = new Scanner(System.in)
    var list = List.empty[Int]

    for(i <- 1 to 10){
      list = scanner.nextLine().toInt :: list
    }

    list
      .sorted
      .reverse
      .take(3)
      .foreach(println(_))
  }
}

Measured memory_bytes: 44996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	while(cin >> s){
		int cnt = 0 ;
		for(auto i:s){
			cnt += (i=='x');
		}
		if(cnt>=8){
			cout<<"NO"<<endl;
		}
		else{
			cout<<"YES"<<endl;
		}
	}
	
}

Measured memory_bytes: 256
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=2e5+10;
const ll mod=1e9+7;

ll a[maxn];

int main(){
    ll n;cin>>n;
    REP(i,n){
	cin>>a[i];
	a[i]-=i+1;
    }
    sort(a,a+n);
    ll ans=0;
    REP(i,n){
	ans+=abs(a[i]-a[n/2]);
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#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 SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const int MOD = 1000000007;

int mpow (ll b, int ep) {
    int ret = 1;
    while (ep) {
        if (ep & 1) {
            ret = ret * b % MOD;
        }
        b = b * b % MOD;
        ep >>= 1;
    }
    return ret;
}

int n, a[MAXN], fac[MAXN], inv[MAXN];
int c(int x, int y) {
    assert(x >= y);
    return ll(fac[x]) * inv[y] % MOD * inv[x-y] % MOD;
}

void sub (int &x, int y) {
    x -= y;
    if (x < 0) {
        x += MOD;
    }
}

void add (int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int lst[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    fac[0] = inv[0] = 1;
    REP1 (i, MAXN-1) {
        fac[i] = ll(fac[i-1]) * i % MOD;
        inv[i] = mpow(fac[i], MOD - 2);
    }
    debug(mpow(3, 4));

    cin >> n;

    memset(lst, -1, sizeof(lst));
    int l, r;
    REP (i, n+1) {
        cin >> a[i];
        if (lst[a[i]] != -1) {
            l = lst[a[i]];
            r = i;
        }
        lst[a[i]] = i;
    }

    debug(l, r);

    REP1 (i, n+1) {
        int cur = c(n+1, i);
        if (n + 1 - (r-l+1) >= i-1) {
            debug(n+1, i);
            assert(c(n+1, i) >= 0);
            assert(c(n + 1 - (r-l+1), i-1) < MOD);
            sub(cur, c(n + 1 - (r-l+1), i-1));
        }
        cout << cur << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
import Control.Monad

solve :: Int -> [Integer] -> Integer -> Integer -> Integer
solve 0 as hd cnt = cnt
solve _ [] _ _ = 10^19 
solve k (a:as) hd cnt
  | hd < a = solve (k-1) as a cnt
  | otherwise = solve k as hd cnt `min` solve (k-1) as (hd+1) (cnt+hd+1-a)


main = do
  [n,k] <- map read . words <$> getLine
  a <-  map read . words <$> getLine :: IO [Integer]

  let ans = solve (k-1) (tail a) (head a) 0
  print ans

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,u,v,z;
  cin>>n>>m;
  vvi g(n);
  for(int i=0;i<m;i++){
    cin>>u>>v>>z;
    u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vi c(n);
  function<void(int,int)>dfs=[&](int u,int k){
    c[u]=k;
    for(int v:g[u])
      if(!c[v])
        dfs(v,k);
  };
  int k=1;
  for(int i=0;i<n;i++)
    if(!c[i])
      dfs(i,k++);
  cout<<k-1<<"\n";
}


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

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

  vector<long long> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }

  long long ans = T.at(0);
  for (int i = 1; i < N; i++) {
    ans = ans / __gcd(ans, T.at(i)) * T.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

bool used[100];
int main(){
    int n; cin >> n;
    P red[n], blue[n];
    REP(i,n){
        int a,b; cin >> a >> b;
        red[i] = make_pair(a,b);
    }
    REP(i,n){
        int c,d; cin >> c >> d;
        blue[i] = make_pair(c,d);
    }
    sort(red, red+n);
    sort(blue,blue+n);
    int ans = 0;
    REP(i,n){
        int c = blue[i].first;
        int d = blue[i].second;
        int maxy = -1;
        int num = -1;
        REP(j,n){
            if(red[j].first >= c) break;
            if(red[j].second >= d || used[j]) continue;
            else{
                if(maxy < red[j].second){
                    num = j;
                    maxy = red[j].second;
                }
            }
        }
        if(num!=-1){
            used[num] = true;
            ans++;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  ll N, K;
  cin >> N >> K;
  ll ans = 1;
  while(N--) {
    ans = min(ans * 2, ans + K);
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int x, y, z, k; cin >> x >> y >> z >> k;
    long long a[x], b[y], c[z];
    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];
    vector<long long> tmp, tmp2;
    for (int i = 0; i < x; i++) 
        for (int j = 0; j < y; j++)
            tmp.push_back(a[i] + b[j]);
    sort(tmp.begin(), tmp.end(), greater<long long>());
    for (int i = 0; i < k && i < tmp.size(); i++)
        for (int j = 0; j < z; j++)
            tmp2.push_back(tmp[i] + c[j]);
    sort(tmp2.begin(), tmp2.end(), greater<long long>());
    for (int i = 0; i < k; i++) cout << tmp2[i] << endl;
}


Measured memory_bytes: 43108
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def ox(s, i):
	return s[i]=="o"


def main():
	n,k=nextIntList()
# 	aa=[]
	s=set()
	for ki in range(k):
		d=nextIntList()[0]
		ai=nextIntList()
# 		aa.append(ai)
		s.update(ai)
	c=0
	for ni in range(1,n+1):
		if ni not in s:
			c+=1
	print(c)
	
	
if __name__=="__main__":
	main()


Measured memory_bytes: 9144
n=int(input())
l=[[] for i in range(n+1)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  l[a].append([b,c])
  l[b].append([a,c])
q,k=map(int,input().split())
from heapq import heappush,heappop
inf=10**20
def dijkstra(s):
  q=[(0,s)]
  dist=[inf]*(n+1)
  dist[s]=0
  while q:
    c,v=heappop(q)#cは始点からvまでのコスト vは頂点
    if dist[v]<c:
      continue
    for i in l[v]:
      t=i[0]
      cost=i[1]
      if dist[v]+cost<dist[t]:
        dist[t]=dist[v]+cost
        heappush(q,[dist[t],t])
  return dist
d=dijkstra(k)
for i in range(q):
  x,y=map(int,input().split())
  print(d[x]+d[y])

Measured memory_bytes: 56472
import sys

if sys.platform =='ios':
    sys.stdin=open('input133d.txt')

#+++++

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

sum = 0
for s in a:
    sum += s

asum = 0
for i in range(n):
    if i % 2 == 1:
        asum += a[i]

x1 = sum - 2 * asum

ret = []
ret.append(x1)

for i in range(1, n):
   xi = 2 * a[i - 1] - ret[i - 1] 
   ret.append(xi)

for i in ret:
    print(i, end =" ")


Measured memory_bytes: 14616