akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

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

	    String s=gs();

        System.out.println((s.length() - s.replace("o","").length())*100+700);
//        if (a<=x && a+b>=x) {
//        	System.out.print("YES");
//        }else {
//        	System.out.print("NO");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            swap(a,b);
            u-=t*v;
            swap(u,v);
        }
        return ModInt(u);
    }
    friend ostream &operator<<(ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend istream &operator>>(istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};

const int mod=1e9+7;
using mint=ModInt<mod>;
vvi G;
vector<mint> dp1,dp2;//黒 白
mint dfs(int now,int parent=-1){
    cerr<<now<<endl;
    REP(i,G[now].size()){
        if(G[now][i]!=parent){
            dfs(G[now][i],now);
            dp1[now]*=dp1[G[now][i]]+dp2[G[now][i]];
            dp2[now]*=dp1[G[now][i]];
        }
    }
    return dp1[now]+dp2[now];
}
int main(){
    int n;
    cin>>n;
    G.resize(n);
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dp1.resize(n,1);
    dp2.resize(n,1);
    cout<<dfs(0)<<endl;
    return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n = 5;
  int ans = 0, r = 10;

  vi v(n);
  REP(i, n) {
    int x;
    cin >> x;
    if(x % 10 > 0) r = min(r, x % 10);
    ans += ((x - 1) / 10 + 1) * 10;
  }

  cout << (r == 10 ? ans : ans + r - 10) << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
(function main(){
  let lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  let n = Number(lines.shift());
  let arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  let n = arr.length;
  let maxHeapify = (i) => {
    let left = 2 * i + 1, right = 2 * i + 2;
    let largest = i;
    if (left < n && arr[left] > arr[largest]) largest = left;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 140160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

  vi p(n);
  rep(i, n) {
    cin >> p[i];
  }

  // 期待値計算
  vector<int> kitai(n);
  rep(i, n) {
    kitai[i] = p[i] + 1;
  }

  // 初期値
  int ans = 0;
  rep(i, k) {
    ans += kitai[i];
  }

  int tmp = ans;
  rep_s(i, 1, n-k+1) {
    tmp -= kitai[i - 1];
    tmp += kitai[i + k - 1];
    ans = max(tmp, ans);
  }

  double res = ans;
  res /= 2;

  printf("%.10f\n", res);
}


Measured memory_bytes: 1792
#include<iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>

using namespace std;

int main(){
  while(1){
    int n=0,m=0,a=0;
    vector<int> h(1000,0),p(1000,0),q(1000,0);
    int curH,curX;
    int maxH;
    
    cin>>n>>m>>a;
    if(n==0&&m==0&a==0){
      break;
    }
    for(int i=0;i<m;i++){
      cin>>h[i]>>p[i]>>q[i];
    }
    
    maxH=*std::max_element(h.begin(),h.end());
    curH=maxH;
    curX=a;
    
    for(int i=maxH;i>0;i--){
    for(int j=0;j<m;j++){
      int id=j;
      if(curH==h[j]&&curX==p[j]){
	curX=q[id];
      }else if(curH==h[j]&&curX==q[j]){
	curX=p[id];
      }
    }
    curH--;
    }
    cout<<curX<<endl;
  }
}



Measured memory_bytes: 3096
import java.util.*;


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

		int a[]=new int[3];
		for(int i=0;i<3;i++){
			a[i]=sc.nextInt();
		}
		int max=a[0];
		for(int i=1;i<3;i++){
			max=Math.max(a[i],max);
		}
		System.out.println(a[0]*a[1]*a[2]/max/2);








	}
}


Measured memory_bytes: 22868
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "aising2020_e.cpp"

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

  int t;
  cin >> t;
  REP(num, t) {
    int n;
    cin >> n;
    vi k(n);
    vector<pair<ll, int>> l(n), r(n);
    REP(i, n) {
      ll tl, tr;
      cin >> k[i] >> tl >> tr;
      l[i] = {tl, k[i]};
      r[i] = {tr, n - k[i]};
    }

    ll ans = 0;
    REP(i, n) {
      ll tmp = min(l[i].first, r[i].first);
      ans += tmp;
      l[i].first -= tmp;
      r[i].first -= tmp;
    }

    sort(ALL(l), [](const auto &lhs, const auto &rhs) -> bool { return lhs.second < rhs.second; });
    sort(ALL(r), [](const auto &lhs, const auto &rhs) -> bool { return lhs.second < rhs.second; });

    priority_queue<ll, vl, greater<ll>> q;

    int itr = 0;
    FOR(i, 1, n + 1) {
      while (itr < n && l[itr].second == i) {
        q.push(l[itr].first);
        itr++;
      }
      while (q.size() > i) {
        q.pop();
      }
    }

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

    itr = 0;
    while (itr < n && r[itr].second == 0)
      itr++;
    FOR(i, 1, n + 1) {
      while (itr < n && r[itr].second == i) {
        q.push(r[itr].first);
        itr++;
      }
      while (q.size() > i) {
        q.pop();
      }
    }
    while (!q.empty()) {
      ans += q.top();
      q.pop();
    }

    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 12304
def comb(n,r):
    r=min(r,n-r)
    c=1
    for i in range(r):
        c=c*(n-i)/(r-i)
    return int(c)

N,M,Q=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(Q)]

npat=comb(N+M,M)
A=[1 for _ in range(N)]
ans=0

for i in range(npat):
    temp=0
    for j in range(Q):
        if A[a[j][1]-1]-A[a[j][0]-1]==a[j][2]:
            temp+=a[j][3]
    ans=max(ans,temp)
#    print(A)
#    print(temp)
    A[-1]+=1
    if A[-1]>M and i<npat-1:
        k=1
        while max(A)>M and k<N:
            A[N-k-1]+=1
            A[N-k]=A[N-k-1]
            k+=1
            for l in range(1,k):
                A[N-l]=A[N-k]
    if min(A)>M:
        break
print(ans)

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli m,k;
	cin>>m>>k;

	if(m==1){
		if(k>=1)cout<<-1<<endl;
		else cout<<"0 0 1 1"<<endl;
		return 0;
	}

	lli n=1;
	REP(i,0,m)n*=2;

	if(k==0){
		REP(i,0,2*n)cout<<i/2<<" ";
		cout<<endl;
		return 0;
	}
	lli left = n-1;
	lli right = left-k;
	if(right<0){
		cout<<-1<<endl;
		return 0;
	}

	cout<<left<<" ";
	lli now = n-1;
	REP(i,0,n-2){
		while(now==left || now==right)now--;
		cout<<now<<" ";
		now--;
	}
	cout<<left<<" ";
	cout<<right<<" ";
	now = 0;
	REP(i,0,n-2){
		while(now==left || now==right)now++;
		cout<<now<<" ";
		now++;
	}
	cout<<right<<endl;
	return 0;
}

Measured memory_bytes: 1792
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
import math
def calcCordinate(cordiOne, cordiTwo):
  res = 0
  for i in range(len(cordiOne)):
    res += (cordiOne[i] - cordiTwo[i])**2
  return math.sqrt(res)
    
    

n,d = map(int, input().split())
cordinate = [[int(i) for i in input().split()] for j in range(n)]
res = 0
for i in range(n-1):
  for j in range(i+1,n):
    if calcCordinate(cordinate[i],cordinate[j]).is_integer():
      res += 1
      
print(res)
      
    
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K; cin >> K;
  cout << a[K-1] << endl; 
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	tree := make([][]int, n)

	for i := 0; i < n; i++ {
		tree[i] = make([]int, 0)
	}

	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		tree[a] = append(tree[a], b)
		tree[b] = append(tree[b], a)
	}

	cc := make([]int, n)
	dd := make([]int, n)
	for i := 0; i < n; i++ {
		cc[i] = getNextInt(scanner)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(cc)))

	sum := 0
	ci := 1
	dd[0] = cc[0]
	dfs(0, 0, &ci, &sum, tree, cc, dd)

	fmt.Fprintln(writer, sum)
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, dd[i])
	}

	writer.Flush()
}

func dfs(i, p int, ci, sum *int, tree [][]int, cc, dd []int) {
	for _, to := range tree[i] {
		if to == p {
			continue
		}
		dd[to] = cc[*ci]
		*sum += cc[*ci]
		*ci++
		dfs(to, i, ci, sum, tree, cc, dd)
	}
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll S;
	cin>>S;
	
	ll x1=1e9;
	ll y2=(S+x1-1)/x1;
	ll x2=1;
	ll y1=x1*y2-S;
	assert(abs(x1*y2-x2*y1)==S);	
	cout<<0<<" "<<0<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 301;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int n; 
double mem[N][N][N];
 
//dp[i][j][k] is expected value for i num of 1 sushi, 
// j num of 2 sushi, k num of 3 sushi
double dp(int i, int j, int k) {
   if (i == 0 && j == 0 && k == 0) return 0.0;
   if (mem[i][j][k] != -1) return mem[i][j][k];

	double res = n;
	if (i > 0) { 
		res += i*dp(i-1, j, k);
	}
	if (j > 0) {
		res += j*dp(i+1, j-1, k);
	}
	if (k > 0) { 
		res += k*dp(i, j+1, k-1);
	}
	res /= (double)(i+j+k);
	return mem[i][j][k] = res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	vint a(4);
	int x;
	fori(n) {
		cin >> x; a[x]++;
	}
	fori(N) 
		forj(N)
			fork(N)
				mem[i][j][k] = -1;
	mem[0][0][0] = 0.0;

	cout << setprecision(15) << dp(a[1], a[2], a[3]) << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 213376
n = int(input())
a = list(map(int,input().split()))
B = []

for i in range(n):
  B.append(a[i] - (i+1))
  
B = [0]+sorted(B)
b = B[int(n/2)]
b1 = B[int(n/2)+1]

tmp = 0
tmp1 = 0
for i in range(1,n+1):
  tmp += abs(B[i] - b)
  tmp1 +=abs(B[i] - b1)
  
print(min(tmp,tmp1))


Measured memory_bytes: 26836
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var AB = ReadLine().Split();
            var A = long.Parse(AB[0]);
            var Bx100 = long.Parse(AB[1].Where(c => c != '.').ToArray());
            WriteLine(A * Bx100 / 100);
        }
    }
}

Measured memory_bytes: 28316
n, m = map(int, input().split())
edges = []
forward_edges = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a, b, -c))
    forward_edges[a].append(b)

stack = [0]
can_reach = [0]*n
while stack:
    v = stack.pop()
    if can_reach[v]:
        continue
    can_reach[v] = 1
    for v2 in forward_edges[v]:
        if can_reach[v2]:
            continue
        stack.append(v2)

INF = 10**18
dist = [INF]*n
dist[0] = 0
for i in range(n-1):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        dist[v2] = dist[v]+c

negative = [0]*n
for i in range(n):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        if not can_reach[v2]:
            continue
        dist[v2] = -INF
        negative[v2] = 1


if negative[-1]:
    print('inf')
else:
    print(-dist[-1])

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  ll res = 0;
  rep(i,n){
    if(v[i] > i || (i-1 >= 0 && v[i] > v[i-1]+1)){
      cout << -1 << endl;
      return 0;
    }else{
      if(i-1 >= 0 && v[i] == v[i-1]+1){
        res++;
      }else{
        res += v[i];
      }
    }
  }
  cout << res << endl;









  return 0;
}

Measured memory_bytes: 1152
import itertools
n,k = (int(x) for x in input().split())
a = []
l = []

for i in range(k):
    d = int(input())
    a.append(list(map(int, input().split())))
b = list(itertools.chain.from_iterable(a))

for i in range(1,n+1):
    l.append(i)

ans = set(b)^set(l)
print(len(set(ans)))

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

using namespace std;

int main() {

	string str;
	stack<int> st;
	string buf;
	int t1,t2;
	string line;
	getline(cin, line);
	istringstream stream(line);
	while (getline(stream, buf, ' ')) {
		if (buf[0] >= '0' && buf[0] <= '9') {
			st.push(stoi(buf));
		}
		else if (buf[0] == '+') {
			t2 = st.top();
			st.pop();
			t1 = st.top();
			st.pop();
			st.push(t1 + t2);
		}
		else if (buf[0] == '-') {
			t2 = st.top();
			st.pop();
			t1 = st.top();
			st.pop();
			st.push(t1 - t2);
		}
		else if (buf[0] == '*') {
			t2 = st.top();
			st.pop();
			t1 = st.top();
			st.pop();
			st.push(t1 * t2);
		}

	}
	cout << st.top() << endl;

}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
char a[1000][1000],b[1000][1000],y[1000][1000];
int main(){
int n,m;
cin>>n>>m;
string x,s;
bool ok=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
    cin>>a[i][j];
  }
}
int c=0;
for(int i=0;i<n;i++){
    ok=0;
   for(int j=0;j<m;j++){
        if(a[i][j]=='#'){
            ok=1;break;
        }
    }
    if(ok==1){
     for(int k=0;k<m;k++)b[c][k]=a[i][k];
     c++;
    }
}int h=0;
for(int i=0;i<m;i++){
    ok=0;
    for(int j=0;j<c;j++){
   if(b[j][i]=='#'){
       ok=1;break;
   }
    }
 if(ok==1){
     for(int k=0;k<m;k++)y[k][h]=b[k][i];
     h++;
    }
}
for(int i=0;i<c;i++){
    for(int j=0;j<h;j++){
    cout<<y[i][j];
}
cout<<"\n";
}
		return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#define M 100010
using namespace std;
int n,k,ans,f[M],dp[M];
vector<int>S[M];
void dfs(int x) {
	dp[x]=1;
	for(int i=0;i<S[x].size();i++)
		dfs(S[x][i]),dp[x]=max(dp[x],dp[S[x][i]]+1);
	if(dp[x]==k&&x!=1&&f[x]!=1) ans++,dp[x]=0;
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&f[i]);
	if(f[1]!=1) ans++;
	for(int i=2;i<=n;i++) S[f[i]].push_back(i);
	dfs(1);printf("%d\n",ans);return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, L;
	bool ans=true;
	int a[100005];
	vector<int> fst;
	bool ok[100005]={};

	cin >> N >> L;
	rep(i,N) cin >> a[i];
	rep(i,N-1) if( a[i] + a[i+1] >= L ){
		fst.push_back( i );
		ok[i] = true;
	}
	rep(i,N-2) if( ok[i] == true && ok[i+1] == false ){
		fst.push_back( i+1 );
		ok[i+1] = true;
	}
	for(int i=N-2; i>=0; i--) if( ok[i+1] && ok[i] == false ){
		fst.push_back( i );
		ok[i] = true;
	}
	reverse( all(fst) );
	
	if( fst.size() == N-1 ){
		cout << "Possible" << endl;
		for(auto t: fst) cout << (t+1) << endl;
	}else{
		cout << "Impossible" << endl;
	}

	return 0;
}


Measured memory_bytes: 1784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int first[n] = { };
	int second[n] = { };
	REP(i, m){
		int a, b;
		cin >> a >> b;
		if(a == 1) first[b-1] = 1;
		if(b == n) second[a-1] = 1;
	}
	int ans = 0;
	REP(i, n){
		if(first[i] == 1 && second[i] == 1) ans = 1;
	}
	if(ans) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 1792
var=input()
var=var.split()
W=int(var[0])
H=int(var[1])
x=int(var[2])
y=int(var[3])
r=int(var[4])
if(-100<=x<=100 and -100<=y<=100):
    if(0<W<=100 and 0<H<=100 and 0<r<=100):
        if((x+r)<=W and (x-r)>=0):
            if((y+r)<=H and (y-r)>=0):
                print("Yes")
            else:
                print("No")
        else:
            print("No")


Measured memory_bytes: 5596
def Min_Max_Sum(n,list):
    max_num = list[0]
    min_num = list[0]
    sum = list[0]
    for i in range(1,len(list)):
        if list[i] > max_num:
            max_num = list[i]
        elif list[i] < min_num:
            min_num = list[i]
        sum += list[i]
    return min_num,max_num,sum


def main():
    n = int(input())
    num_list = list(map(int, input().split()))
    print("%d %d %d"%(Min_Max_Sum(n,num_list)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 6604
//Never stop chasing!-MD.SOURAV.

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
 #define sex(a,b,n)   ( n>=a && n<=b)
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

     int x;
     cin>>x;
     if(sex(400,599,x))
	 {
	 	cout << "8";
	 }
	 else if(sex(600,799,x))
	 {
	 	cout << "7";
	 }
	 else if(sex(800,999,x))
	 {
	 	cout << "6";
	 }
	 else if(sex(1000,1199,x))
	 {
	 	cout << "5";
	 }
	 else if(sex(1200,1399,x))
	 {
	 	cout << "4";
	 }
	 else if(sex(1400,1599,x))
	 {
	 	cout << "3";
	 }
	 else if(sex(1600,1799,x))
	 {
	 	cout << "2";
	 }
	 else if(sex(1800,1999,x))
	 {
	 	cout << "1";
	 }


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3656
const main = input => {
  // 26進数
  let out = input % 26;
  if (out === 0) {
    out = 26;
  }
  if (input - out <= 0) {
    return array[out];
  } else {
    return main((input - out) / 26) + array[out];
  }
}

array = '0 a b c d e f g h i j k l m n o p q r s t u v w x y z'.split(' ');
console.log(main(parseInt(require("fs").readFileSync("/dev/stdin", "utf8"))));


Measured memory_bytes: 29556
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string ans;
    cin >> ans;
    int q;
    cin >> q;
    int tp = 0;
    string h,t;
    while (q--) {
        int op;
        cin >> op;
        if (op == 1) {
            tp ^= 1;
        } else {
            int x;
            string w;
            cin >> x >> w;
            if (x == 1) {
                if (tp == 0) {
                    h += w;
                } else {
                    t += w;
                }
            } else {
                if (tp == 0) {
                    t += w;
                } else {
                    h += w;
                }
            }
        }
    }
    if (h.length() != 0) {
        reverse(h.begin(), h.end());
    }
    ans = h + ans + t;
    if (tp == 1) {
        reverse(ans.begin(), ans.end());
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1348
using System;
using System.Text.RegularExpressions;
 
namespace Key
{
    class Program
    {
        static void Main()
        {
            var rs = new string[] {"[qwertasdfgzxcvb]", "[yuiophjklnm]" };
            string n;
            while ((n = Console.ReadLine()) != "#")
            {
                for(int i = 0; i < 2; i++)
                    n = new Regex(rs[i] + '+').Replace(n, "0");
                Console.WriteLine("{0}", n.Length - 1);
            }
        }
    }
}

Measured memory_bytes: 11112
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int ds[205][205];
int hs[205][205];


int getrd[4][4]={
	{0,0,0,0},
	{0,0,3,5},
	{0,4,0,1},
	{0,2,6,0}
};

int getr(int t,int f){
	int c=0;
	if(t>=4){
		c=1-c; t=7-t;
	}
	if(f>=4){
		c=1-c; f=7-f;
	}
	int res=getrd[t][f];
	if((t+1)%3==f%3)res=6-t-f;
	else res=t+f+1;
	if(c==1)res=7-res;
	return res;
}

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		memset(hs,0,sizeof(hs));
		memset(ds,0,sizeof(ds));
		
		rep(qqq,n){
			int t,f;
			scanf("%d%d",&t,&f);
			int y=100,x=100;
			for(;;){
				bool rd=false;
				ireg(i,4,6){
					if(i==t || i==7-t)continue;
					int dy,dx,tt,tf;
					if(i==f || i==7-f){
						dx=0;
						if(i==f){
							dy=1; tt=7-f; tf=t;
						}
						else{
							dy=-1; tt=f; tf=7-t;
						}
					}
					else{
						dy=0;
						int r=getr(t,f);
						if(i==r){
							dx=1; tt=7-r; tf=f;
						}
						else{
							dx=-1; tt=r; tf=f;
						}
					}
					
					int ty=y+dy,tx=x+dx;
					if(hs[ty][tx]<hs[y][x]){
						y = ty; x = tx;
						t = tt; f = tf;
						rd=true;
						break;
					}
				}
				if(!rd){
					hs[y][x]++;
					ds[y][x]=t;
					break;
				}
			}
		}
		int anss[7];
		rep(i,7)anss[i]=0;
		rep(i,205)rep(j,205){
			anss[ds[i][j]]++;
		}
		reg(i,1,6)printf("%d%c",anss[i],i==6?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	int ret = 1e18;
	for(int i = 1;i*i <= n;i++){
		if(n%i == 0){
			ret = min(ret,i+(n/i)-2);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3536
def main():
    A, B, C, D = map(int, input().split())

    c = C - A
    d = D - B
    mod = 998244353
    dp = [[0]*(d+1) for i in range(c+1)]
    dp[0][0] = 1

    for i in range(c+1):

        for j in range(d+1):
            ret = 0
            if i == 0 and j == 0:
                continue
            if i > 0 and j > 0:
                if i == j == 1:
                    ret -= (A+i-1) * (B+j-1)
                else:
                    ret -= dp[i-1][j-1]
                    ret *= (A+i-1)*(B+j-1)
            ret += dp[i-1][j]*(B+j) + dp[i][j-1]*(A+i)

            ret %= mod
            dp[i][j] = ret
    print(dp[c][d])


main()



Measured memory_bytes: 138592
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    double t, a;
    cin >> n >> t >> a;
    double diff = N;
    int ans = 0;
    for(int i = 0; i < n; i++){
        double x;
        cin >> x;
        double tmp = t - x * 0.006;
        if(abs(a - tmp) < diff){
            ans = i + 1;
            diff = abs(a - tmp);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
def q1():
    while 1:
        count=0
        n=int(input())
        if(n==0):
            break
        data=input().split()
        f=False
        ft=[False,False]
        for order in data:
            if order[0]=='l':
                x=0
            else:
                x=1
            if order[1]=='u':
                y=True
            else:
                y=False
            ft[x]=y
            if ft[0]==ft[1]==True and f==False:
                f=True
                count+=1
            elif ft[0]==ft[1]==False and f==True:
                f=False
                count+=1
        print(count)
                
question = [q1]

question[0]()


Measured memory_bytes: 5624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

void ok(vector<int> &A){
    string s = "";
    rep(i, A.size()){
        if(A[i] == 0) s += 'S';
        else s += 'W';
    }
    output(s);
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    
    rep(a, 2) rep(b, 2){
        vector<int> A(N, -1); // 0: S, 1: W
        A[0] = a, A[1] = b;
        rep(i, 1, N - 1){
            if(A[i] == 0 && s[i] == 'o'){
                A[i + 1] = A[i - 1];
            }
            else if(A[i] == 0 && s[i] == 'x'){
                A[i + 1] = A[i - 1] ^ 1;
            }
            else if(A[i] == 1 && s[i] == 'o'){
                A[i + 1] = A[i - 1] ^ 1;
            }
            else{
                A[i + 1] = A[i - 1];
            }
        }
        bool yes = true;
        if(A[N - 1] == 0 && s[N - 1] == 'o' && A[N - 2] != A[0]){
            yes = false;
        }
        else if(A[N - 1] == 0 && s[N - 1] == 'x' && A[N - 2] == A[0]){
            yes = false;
        }
        else if(A[N - 1] == 1 && s[N - 1] == 'o' && A[N - 2] == A[0]){
            yes = false;
        }
        else if(A[N - 1] == 1 && s[N - 1] == 'x' && A[N - 2] != A[0]){
            yes = false;
        }
        if(A[0] == 0 && s[0] == 'o' && A[N - 1] != A[1]){
            yes = false;
        }
        else if(A[0] == 0 && s[0] == 'x' && A[N - 1] == A[1]){
            yes = false;
        }
        else if(A[0] == 1 && s[0] == 'o' && A[N - 1] == A[1]){
            yes = false;
        }
        else if(A[0] == 1 && s[0] == 'x' && A[N - 1] != A[1]){
            yes = false;
        }
        if(yes) ok(A);
        
    }
    output(-1);
    
    
    return 0;
}

Measured memory_bytes: 1096
import sys
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
for i in range(n):
    h[i] = abs(a-(t - h[i]*0.006))
minh = min(h)
for i in range(n):
    if h[i] == minh:
        print(i+1)
        sys.exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
int gcd(int a,int b){
    if(a<=0||b<=0){
        return 0;
    }
    if(a<b)swap(a,b);
    int r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}


signed main(){
    int N,X;
    int x[114514];
    cin >> N >> X;
    REP(i,N){cin >> x[i];}
    int Ans=abs(X-x[0]);
    REP(i,N){
        Ans=gcd(Ans,abs(X-x[i]));
    }
    cout << Ans << endl;
    return 0;
}   

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

int main() {
  
  int N;
  int A;
  int B;
  
  cin >> N >> A >> B;
  
  if ( A*N >= B )
    
    cout << B << endl;
  
  if ( A*N < B )
    
    cout << A*N << endl;
  
} 

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

int main(void){
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    if(N == 1){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i, N - 1){
        if(H[i] > H[i + 1]){
            H[i + 1]++;
        }

        if(H[i] > H[i + 1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cctype>
#include<algorithm>

typedef long long LL;

int read(){
    int w=0;char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    for(;isdigit(ch);ch=getchar())w=w*10+(ch^48);
    return w;
}
int min(int x,int y){return x<y?x:y;}

const int N=1e5+5;

int n;
int type[N],cnt;
int alla,allb;
LL ans;

struct Node{
    int val,pos,type;
    Node(){}
    Node(int val,int pos,int type):val(val),pos(pos),type(type){}
    bool operator<(const Node &a)const{
        return val<a.val;
    }
}nd[N*2];

int main(){
    n=read();
    for(int i=0;i<n;++i){
        nd[i<<1]=Node(read(),i,1);
        nd[i<<1|1]=Node(read(),i,2);
    }
    std::sort(nd,nd+n*2);
    alla=allb=1;
    for(int i=0;i<n;++i){
        ans+=nd[i].val;
        type[nd[i].pos]|=nd[i].type;
        if(type[nd[i].pos]==3)++cnt;
        if(nd[i].type==1)allb=0;
        if(nd[i].type==2)alla=0;
    }
    if(!cnt&&!alla&&!allb){
        if(nd[n-1].pos!=nd[n].pos){
            ans+=(nd[n].val-nd[n-1].val);
        }else{
            ans+=min(nd[n].val-nd[n-2].val,nd[n+1].val-nd[n-1].val);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

 ll a,b,c;
 int solve(){
     int ret=0;
     if(a%2==0 && a==b && b==c)return -1;
     while(a%2==0 && b%2==0 && c%2==0){
         if(a==b && b==c)return -1;
         ll ta,tb,tc;
         ta=(b+c)/2;
         tb=(a+c)/2;
         tc=(a+b)/2;
         a=ta;
         b=tb;
         c=tc;
         ret++;
     }
     return ret;
 }
 int main(void)
 {
     cin>>a>>b>>c;
     cout<<solve()<<endl;
     return 0;
 }

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cctype>
#include<vector>
const int N=200007;
int read(){int x=0,c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))x=x*10+c-48,c=getchar();return x;}
std::vector<int>e[N];std::queue<int>q;
int n,m,ans,vis[N],deg[N][2];char col[N];
int main()
{
    n=read(),m=read(),scanf("%s",col+1);
    for(int i=1,u,v;i<=m;++i) u=read(),v=read(),e[u].push_back(v),e[v].push_back(u),++deg[u][col[v]=='B'],++deg[v][col[u]=='B'];
    for(int i=1;i<=n;++i) if(!deg[i][0]||!deg[i][1]) ++ans,q.push(i),vis[i]=1;
    for(int u;!q.empty();)
    {
    u=q.front(),q.pop();
    for(int v:e[u]) if(!vis[v]&&!--deg[v][col[u]=='B']) ++ans,q.push(v),vis[v]=1;
    }
    puts(ans==n? "No":"Yes");
}

Measured memory_bytes: 13184
#include<stdio.h>

int main(){
  int i,sum,k,loop,kari;

  while(1){
    sum = 0;
    scanf("%d",&k);

    if(k == 0) break;

    loop = k * (k - 1)/2;

    for(i = 0; i < loop; i++){
      scanf("%d",&kari);
      sum += kari;
    }

    sum /= (k-1);

    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int N;
vector<int> a, b;

long long calc(int shift)
{
	// T
	long long t = (1 << shift);
	//cout << n << endl;
	vector<int> aa(N), bb(N);
	for(int i=0; i<N; i++){
		aa[i] = a[i] % (t*2);
		bb[i] = b[i] % (t*2);
	}

	sort(bb.begin(), bb.end());
	//cout << "aa : ";
	//for(int i=0; i<N; i++)
	//	cout << aa[i] << " ";
	//cout << endl;
	//cout << "bb : ";
	//for(int i=0; i<N; i++)
	//	cout << bb[i] << " ";
	//cout << endl;

	long long cnt = 0;
	for(int i=0; i<N; i++){
		for(int j=1; j<=2; j++){
			int c = 2 * j -1;
			int lt = c * t;
			int rt = lt + t;
			auto left = lower_bound(bb.begin(), bb.end(), lt-aa[i]);
			auto right = lower_bound(bb.begin(), bb.end(), rt-aa[i]);
			cnt += right - left;
			//cout << aa[i] << " : [" << lt << ", " << rt << ") : " << lt-aa[i] << " " << rt-aa[i] << " : " << right - left << endl;
		}
	}

	return (cnt%2 == 1 ? t : 0);
}

int main(void)
{
	cin >> N;

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

	b = vector<int>(N);
	for(int i=0; i<N; i++)
		cin >> b[i];

	long long ret = 0;
	for(int i=0; i<29; i++){
		ret += calc(i);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3432