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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int digits(int x) {
  int ret = 0;
  while (x) {
    ++ret;
    x /= 10;
  }
  return ret;
}

int main() {
  in(int, n);
  int ans = 0;
  rep(i, n) if (digits(i + 1) % 2 == 1) ++ans;
  out(ans);
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n;
	cin >> n;
	cout << (n - 1) / 2 << endl;
	return 0;
}

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
   a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
   a = max(a, b); 
}

void test_case() {
   int n;
   cin >> n;
   vector<ll> a(n);
   for(int i = 0; i < n; i++) {
      cin >> a[i];
   }
   string s;
   cin >> s;
   vector<ll> basis;
   for(int i = n-1; i >= 0; --i) {
      ll x = a[i];
      
      for(ll y : basis) {
         x = min(x, x^y);
      }
      if(x == 0) {
         continue;
      }
      if(s[i] == '0') {
         basis.push_back(x);
      } else {
         cout << "1\n";
         return;
      }
   }
   cout << "0\n";
}

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   int tc;
   cin >> tc;
   while(tc--) {
      test_case();
   }
}















// Author: blondie


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

bool in[100005];
int cnt[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    in[1] = true;
    rep(i,m){
        int x, y;
        cin >> x >> y;
        in[y] |= in[x];
        if(--cnt[x] < 0) in[x] = false;
        ++cnt[y];
    }
    int ans = 0;
    rep(i,n+1){
        if(in[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4076
/*

* author:mel0n
* le epic style 
*
*

*/

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define lli long long int
#define pi pair<int,int>
#define all(x) (x).begin(),(x).end()

using namespace std;



int main()
{
lli n;
cin>>n;
lli a=0,w=0,t=0,r=0;
while(n--)
{
string s;
cin>>s;
if(s=="AC")
	a++;
else if(s=="TLE")
	t++;
else if(s=="WA")
	w++;

else if(s=="RE")
	r++;

}


cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
cout<<"RE"<<" "<<"x"<<" "<<r<<endl;

}



Measured memory_bytes: 3628
N = int(input())

W = []

for i in range(N):
    W.append(input())

cnt = set()
last = W[0][-1]
for i, w in enumerate(W):
    if i == 0:
        cnt.add(w)
        continue
    if w[0] != last:
        print('No')
        exit()
    last = w[-1]
    cnt.add(w)
    if i+1 != len(cnt):
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 9172
//
// Created by yamunaku on 2020/04/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    vi idx(n);
    iota(all(idx), 0);
    sort(all(idx), [&](int &l, int &r){
        return a[l] > a[r];
    });
    vl dp(n + 1, 0);
    rep(i, n){
        vl ndp(n, 0);
        rep(j, i + 1){
            if(j + 1 < n) ndp[j + 1] = max(ndp[j + 1], dp[j] + a[idx[i]] * abs(j - idx[i]));
            ndp[j] = max(ndp[j], dp[j] + a[idx[i]] * abs(n - 1 - (i - j) - idx[i]));
        }
        dp = ndp;
    }
    ll ans = 0;
    rep(i, n + 1){
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
END { load __FILE__ unless $stdin.eof? }

n = gets.to_i
a = gets.split.map!(&:to_i)

ranges = Array.new(n + 1)
prev_range = [0, 0]

a.each_with_index.reverse_each do |leaves, depth|
  prev_range = ranges[depth] = [(prev_range[0] + 1) / 2 + leaves, prev_range[1] + leaves]
end

if ranges[0][0] > 1
  puts -1
  exit
end

prev_nodes = nil
ranges.zip(a, 0..n) do |range, leaves, depth|
  next (range[1] = 1; prev_nodes = range[1] - leaves) if depth == 0
  range[1] = [range[1], prev_nodes * 2].min; prev_nodes = range[1] - leaves
end

p ranges.sum(&:last)


Measured memory_bytes: 26640
import collections

def count_defaultdict(it):
    counter = collections.defaultdict(int)
    for x in it:
        counter[x] += 1
    return dict(counter)

_ = int(input())
l = list(map(int, input().split()))
all_sum = 0
count = count_defaultdict(l)
for _, v in count.items():
    all_sum += v * (v - 1) // 2
for i in range(len(l)):
    if count[l[i]] > 1:
        v = count[l[i]]
        print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)
    else:
        print(all_sum)

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



using Matrix = vector<vector<number>>;

void warshall_floyd(int V, Matrix &g) {
    rep(k, V) {
        rep(i, V) {
            rep(j, V) {
                if (g[i][k] == INF || g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}



int main() {
    int N, M, R; cin >> N >> M >> R;
    vi r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }

    Matrix G(N, vll(N, INF));
    rep(i, N) G[i][i] = 0;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        G[a][b] = c;
        G[b][a] = c;
    }

    warshall_floyd(N, G);

    ll ans = INF;

    vi v(R);
    iota(all(v), 0);
    do {
        ll tmp = 0;
        rep(i, R - 1) tmp += G[r[v[i]]][r[v[i + 1]]];
        chmin(ans, tmp);
    } while (next_permutation(all(v)));    // 次の順列を生成

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}

int main(){
  ll n=read(),a=read(),b=read(),ans=1e9;
  vector<ll> h(n);rep(i,n)h[i]=read();
  ll left=1,right=1e9,mid,cnt=0;
  while (right!=left+1) {
    mid =(right+left)/2;
    cnt=0;
    rep(i,n){
      ll temp=h[i]-b*mid;
      if(temp>0){
        cnt+=(temp+a-b-1)/(a-b);
      }
    }
    if(cnt<mid){
      right=mid;
    }else left=mid;
  }
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*right;
    if(temp>0){
      cnt+=(temp+a-b-1)/(a-b);
    }
  }
  ans=min(ans,max(cnt,right));
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*left;
    if(temp>0){
      cnt+=(temp+a-b-1)/(a-b);
    }
  }
  ans=min(ans,max(cnt,left));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y, z, k; cin >> x >> y >> z >> k;
  vector<ll> A(x), B(y), C(z);
  rep(i, x) cin >> A[i];
  rep(i, y) cin >> B[i];
  rep(i, z) cin >> C[i];
  vector<ll> AB;
  rep(i, x) rep(j, y) {
    AB.push_back(A[i]+B[j]);
  }
  sort(all(AB));
  int w = x*y;
  sort(all(C));
  auto bsearch = [&]() {
    auto test = [&](ll t) {
      ll cnt = 0;
      rep(i, w) {
        cnt += end(C) - lower_bound(all(C), t-AB[i]);
      }
      return cnt <= k;
    };
    ll ok = longinf, ng = 0;
    while(ok-ng>1) {
      ll mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  ll res = bsearch();
  vector<ll> ans;
  rep(i, w) {
    for(auto itr=lower_bound(all(C), res-AB[i]); itr!=end(C); itr++) {
      ans.push_back(*itr+AB[i]);
    }
  }
  sort(all(ans), greater<ll>());
  rep(i, k) {
    if(i < ans.size()) cout << ans[i] << endk;
    else cout << res-1 << endk;
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k;
  cin>>n>>k;
  vll p(n);
  REP(i,n)cin>>p[i];
  sort(ALL(p));

  ll ans=0;
  REP(i,k)ans+=p[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 3664
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    for(int i = N; i <= 999; i++) {
        if (i % 111 == 0) {
            print(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    int ans = 0;
    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (0 <= z && z <= K) {
          ans++;
        }
      }
    }
      
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
def sim(i):
    for t, d in qs:
        if S[i] == t:
            div = 1 if d == "R" else -1
            i += div
            if i == 0:
                return 0
            elif i == N+1:
                return N+1
    return i

def bin_search_left():
    ok = 0
    ng = N+1

    while abs(ok-ng)>1:
        mid = (ok+ng) //2
        res = sim(mid)
        #print(ok,ng,mid,res)
        if res == 0:
            ok = mid
        if res >0:
            ng = mid
    return ok


def bin_search_right():
    ng = 0
    ok = N+1

    while abs(ok-ng)>1:
        mid = (ok+ng) //2
        res = sim(mid)
        #print(ok,ng,mid,res)
        if res < N+1:
            ng = mid
        if res >= N+1:
            ok = mid
    return ok


N, Q = map(int,input().split())
S = "0"+input()+"0"
qs = []
for _ in range(Q):
    t, d = input().split()
    qs.append((t,d))

L = bin_search_left()
R = bin_search_right()
print(N-L-(N+1-R))

Measured memory_bytes: 89820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	static int n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// n = Integer.parseInt(br.readLine());
		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0] + str[1]);

		for (int i = 1; i < a / 2; i++) {
			if (i * i == a) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21204
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int a = nextInt();
    int b = nextInt();

    String ab = "";
    String ba = "";

    //ab
    for(int i=1;i<=b;i++){
      ab += String.valueOf(a);
    }

    for(int i=1;i<=a;i++){
      ba += String.valueOf(b);
    }

    String[] c = {ab,ba};

    Arrays.sort(c);


    System.out.println(c[0]);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

int main() {
	int n, a[100];
	cin >> n;
	
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	for (int i=n-1; i>=0; i--) {
		if (i > 0)
			cout << a[i] << " ";
		else
			cout << a[i];
	}
	cout << endl;

	return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a') {
    cout << "vowel" << endl;
  } 
    
  else if(c == 'e') {
    cout << "vowel" << endl;
  } 
  
  else if(c == 'i') {
    cout << "vowel" << endl;
  } 
  
  else if(c == 'o') {
    cout << "vowel" << endl;
  } 
  
  else if(c == 'u') {
    cout << "vowel" << endl;
  } 
  
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using namespace std;

int main()
{
  long long int N,K;
  cin >> N >> K;

  vector<pair<long long int, long long int> >M(N);
  for(int i=0; i < N; i++){
    long long int a,b;
    cin >> a >> b;
    M[i] = MP(a,b);
  }
  sort(M.begin(), M.end());
  long long int ans;
  long long int acc=0;
  for(int i=0; i < N; i++){
    acc += M[i].second;
    if(acc >= K){
      ans = M[i].first;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

string s;

bool judge(int bit){
    int sum=s[0]-48;
    REP(i,s.size()-1){
        if(bit&(1<<i)){
            sum+=s[i+1]-'0';
        }else{
            sum-=s[i+1]-'0';
        }
    }

    return sum==7 ? true : false;
}

int main(){
    cin>>s;

    for(int bit=0; bit<(1<<s.size()-1); bit++){
        if(judge(bit)){
            cout<<s[0];
            REP(i,s.size()-1){
                if(bit&(1<<i)){
                    cout<<'+'<<s[i+1];
                }else{
                    cout<<'-'<<s[i+1];
                }
            }
            cout<<"=7"<<endl;
            break;
        }
    }
}

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

int W,H;
int nx[4],ny[4];
string M[128];

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

bool good_cell(int x,int y) {
  return min(x,y) >= 0 && x<W && y<H;
}

bool safe_cell(int x, int y) {
  return good_cell(x,y) && M[y][x] == '.';
}

void neighbor4(int x, int y) {
  for (int d=0; d<4; ++d) {
    nx[d] = x + dx[d], ny[d] = y + dy[d];
  }
}

void walk1() {
  for (int y=0; y<H; ++y) {
    for(int x=0; x<W; ++x) {
      if (M[y][x] == '@') {
	neighbor4(x, y);
	for (int i=0; i<4; ++i) {
	  if (good_cell(nx[i],ny[i]) == 1)
	  if (M[ny[i]][nx[i]] == '.') M[ny[i]][nx[i]] = '@';
	}
      }
    }
  }
}

void print_map() {
  for (int y=0; y<H; ++y) cout << M[y] << endl;
}

int main() {
  while (cin >> W >> H && W > 0) {
    int c=0;
    for (int i=0; i<H; ++i)
      cin >> M[i];
  


for (int y=0; y<H; ++y) {
  for (int x=0; x<W; ++x) {
    if (M[y][x] == '@') {
    }
  }
 }
 for (int i=0; i<W*H; ++i) walk1();
 //print_map();
 for (int y=0; y<H; ++y) {
   for(int x=0; x<W; ++x) {
     if(M[y][x] =='@') {
       c++;
     }
   }
 }
 cout << c << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
  int n,idx=0;
  int data[100];
  while(1)
  {
    scanf("%d",&n);
    if(idx==0 && n==0) break;

    else if(n==0)
    {
      idx-=1;
      printf("%d\n",data[idx]);

    }

    else
    {
      data[idx]=n;
      idx+=1;
    }
  }
}

Measured memory_bytes: 1736
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()



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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll w[101],val[101],dp[101][100001],N,W;
ll trump(ll n,ll m){
	if(m<1||n>N)return 0;
	if(dp[n][m]!=-1)return dp[n][m];
	ll a=0,b=0;
	if(m>=w[n])
	a=val[n]+trump(n+1,m-w[n]);
	b=trump(n+1,m);
	return dp[n][m]=max(a,b);
}
int main(){
	ios::sync_with_stdio(false);
	cin>>N>>W;
    memset(dp,-1,sizeof(dp));
	for(int i=1;i<=N;i++){
		cin>>w[i]>>val[i];
	}
	cout<<trump(1,W)<<endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n > m + 1 || m > n + 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  for (int i = 1; i <= m; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  if (n == m) {
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, m, i, j, k;
int main(){
	scanf("%d", &n);
	n %= 10;
	if(n == 3) printf("bon\n");
	else if(n==0 || n==1 || n==6 || n==8){
		printf("pon\n");
	}
	else printf("hon\n");
	return 0;
}

Measured memory_bytes: 1660
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int L, R, d;
  int ans = 0;

  cin >> L >> R >> d;

  for (int i = L; i <= R; i++) {
    ans += i % d == 0;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;


bool tansaku(vector<int> list,int index,int b,int c)
{
	if (index<10)
	{
		if (b < list[index])
		{
			if (tansaku(list, index + 1, list[index], c))
				return true;
		}
		if (c < list[index])
		{
			if (tansaku(list, index + 1, b, list[index]))
				return true;
		}
	}
	else
	{
		return true;
	}
	return false;
}
int main()
{
	vector<int> s(10);
	int b;

	cin >> b;
	for (int i = 0; i < b; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> s[j];
		}
		if (tansaku(s, 0, 0, 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
void print(ll a, ll digit=30){
    string s = "";
    while(a){
        s += (a & 1 ? '1' : '0');
        a = a >> 1;
    }
    while(s.size() < digit) s += '0';
    reverse(s.begin(), s.end());
    cout << s << endl;
}
int main(){
    ll N, K;
    cin >> N >> K;
    pair<ll, ll> po[N];
    for(ll i = 0; i < N; i++) cin >> po[i].first >> po[i].second;
    vector<ll> v;
    ll digit = 1;
    while((1 << (digit + 1)) <= K) digit++;
    ll now = 1;
    v.push_back(K);
    if(K) v.push_back((1 << digit) - 1);
    for(ll i = digit - 1; i >= 0; i--){
        now = now << 1;
        ll tmp = now;
        if((K >> i) & 1){
            now++;
            for(ll j = i; j > 0; j--) tmp = (tmp << 1) + 1;
            if(tmp <= K) v.push_back(tmp);
        }
    }
    ll ans = 0;
    /*
    for(ll u : v) print(u);
    return 0;
    */
    for(ll u : v){
        ll tmp = 0;
        for(ll i = 0; i < N; i++){
            bool add = 1;
            for(ll d = 0; po[i].first >= (1 << d); d++) if(!(u & (1 << d)) && (po[i].first & (1 << d))) add = 0;
            if(add) tmp += po[i].second;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
  	int a, b, ans;
  	cin >> a >> b;
  	b *= 10;
  	for (int i = b; i < b + 10; i++) {
      	if ((i * 8) / 100 == a) {
          	cout << i << endl;
          	return 0;
        }
    }
    cout << "-1" << endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  string s;
  cin >> s;
  s+="a";
  deque<int>right;
  deque<int>left;
  int r=1;
  int l=0;
  rep(i,s.size()){
    if(s[i]==s[i+1] && s[i]=='R')r++;
    if(s[i]==s[i+1] && s[i]=='L')l++;
    if(s[i]!=s[i+1] && s[i]=='R'){
      right.push_back(r);
      r=0;
      l=1;
    }
    if(s[i]!=s[i+1] && s[i]=='L'){
      left.push_back(l);
      r=1;
      l=0;
    }
  }
  rep(i,s.size()-1){
    if(i!=0){
      cout << " ";
    }
    if(s[i]!=s[i+1] && s[i]=='R'){
      cout << left.front()/2+(right.front()+1)/2;
    }
    else if((s[i-1]!=s[i] && s[i]=='L') ||(s[i-1]!=s[i] && s[i]=='a')){
      cout << right.front()/2+(left.front()+1)/2;;
      right.pop_front();
      left.pop_front();
    }
    else cout << 0;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 3, Mod = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll maxi=a*c;
	maxi=max(maxi,a*d);
	maxi=max(maxi,b*d);
	maxi=max(maxi,b*c);
	cout<<maxi<<endl;
}


Measured memory_bytes: 3644
M = 10**9+7

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

sum_A = list()

sum_val = 0

for idx in range(len(A)-1, -1, -1):
    sum_val += A[idx]
    sum_A.append(sum_val)

sum_A.reverse()

ret = 0

for idx in range(0, len(A)):
    ret += A[idx]*(sum_A[idx] - A[idx])
    ret %= M

print('{}'.format(ret))


Measured memory_bytes: 31424
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=55;
int n,lim,d;
int p[N],sz[N],que[N]; 
ll y[N],dp[N*N*N]; 
inline void insert(int a,ll b){
	for(int i=n*n*n;i>=a;--i) dp[i]=min(dp[i],dp[i-a]+b); 
}
int main(){
	scanf("%d%d%d%lld",&n,&lim,&d,&y[1]); ++sz[1];
	for(int i=2;i<=n;++i) scanf("%lld%d",&y[i],&p[i]); 
	for(int i=n;i>=2;--i) ++sz[i],sz[p[i]]+=sz[i],y[p[i]]+=y[i];
	memset(dp,0x3f,sizeof(dp));//得到i收益最少用多少代价
	int cnt=min(d,n); d-=cnt; dp[0]=0; int ans=0;
	for(int i=1;i<=n;++i){
		int e=cnt;
		for(int j=0;j<=5;++j) if(1<<j<=e) insert(sz[i]<<j,y[i]<<j),e-=1<<j;
		if(e) insert(sz[i]*e,y[i]*e);
	}
	for(int i=1;i<=n;++i) que[i]=i;
	sort(que+1,que+n+1,[](int a,int b){return sz[a]*y[b]>sz[b]*y[a];});
	for(int i=0;i<=n*n*n;++i){
		if(dp[i]>lim) continue;
		int lst=lim-dp[i],add=0;
		for(int j=1;j<=n;++j){
			int x=que[j],e=min(0ll+(x==1?lst:d),lst/y[x]);
			lst-=y[x]*e; add+=sz[x]*e;
		}
		ans=max(ans,i+add);
	}
	return printf("%d\n",ans),0;
}
 

Measured memory_bytes: 5096
/*
	Author: Luis Manuel D�az Bar�n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 3e3 + 2;

string s, t;

int dp[lim][lim];
bool mark[lim][lim];

pii stat[lim][lim];

int DynamicProgramming(int ls, int rs)
{
    if(ls == 0 || rs == 0)
        return 0;

    if(mark[ls][rs])
        return dp[ls][rs];
    
    mark[ls][rs] = true;

    int idxs = ls - 1;
    int idxr = rs - 1;

    int s1 = DynamicProgramming(ls, rs - 1);
    int s2 = DynamicProgramming(ls - 1, rs);

    int s3 = 0;
    if(s[ls-1] == t[rs-1])
        s3 = 1 + DynamicProgramming(ls - 1, rs - 1);

    int mx = max(max(s1, s2), s3);

    if(s1 >= s2 && s1 >= s3)
        stat[ls][rs] = mkp(ls, rs - 1);
    if(s2 >= s1 && s2 >= s3)
        stat[ls][rs] = mkp(ls - 1, rs);
    if(s3 >= s1 && s3 >= s2)
        stat[ls][rs] = mkp(ls - 1, rs - 1);
    

    dp[ls][rs] = mx;
    return mx;
}

void solve()
{
    cin >> s >> t;

    int cnt = DynamicProgramming(s.size(), t.size());

    string answ = "";

    int l = s.size();
    int r = t.size();
    
    while(l > 0 && r > 0)
    {
        
        if(s[l-1] == t[r-1])
        {
            
            answ = s[l-1] + answ;
        }
        int xl = stat[l][r].first;
        int xr = stat[l][r].second;
        l = xl;
        r = xr;
    }
    // print answer
    cout << answ << endl;    
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 115200
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct info{
    int name, diffi, time;
};

void swap(struct info *a, struct info *b){
    struct info *temp = a;
    a = b;
    b = temp;
}

void sort(struct info info[1005], int n){
    rep(i,n - 1){
        rep(j,n - 1){
            struct info temp;
            if(info[j].time > info[j + 1].time){
                swap(info[j], info[j + 1]);
            }else if(info[j].time == info[j + 1].time && info[j].diffi > info[j + 1].diffi){
                swap(info[j], info[j + 1]);
            }
        }
    }
}

    int main(){
    int n, m;
    while(cin >> n >> m, n||m){
        struct info info[1005];
        rep(i,n){
            int inp, maxTime;
            cin >> inp;
            for(maxTime = inp; maxTime <= m; maxTime+=inp);
            maxTime-=inp;
            info[i].name = i + 1;
            info[i].diffi = inp;
            info[i].time = maxTime;
        }
        sort(info, n);
        if(info[0].time == info[1].time && info[0].diffi == info[1].diffi){
            cout << n << endl;
        }else{
            cout << info[0].name << endl;
        }

    }
}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

template<typename T>
constexpr T binaryPow_mod(T radix, T index, T mod) noexcept {
	radix %= mod;
	T rtv = 1;
	while (index > 0) {
		if (index & 1) {
			rtv *= radix;
			rtv %= mod;
		}

		radix *= radix;
		radix %= mod;

		index = index >> 1;
	}

	return rtv;
}

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

	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	ll* v = new ll[k+1];
	llRREP(i, 1, k) {
		v[i] = binaryPow_mod(k / i, n, _MOD);

		ll sum = 0;
		for (ll j = 2; j*i <= k; ++j) {
			sum += v[j*i];
			sum %= _MOD;
		}

		v[i] -= sum;
		v[i] += _MOD;
		v[i] %= _MOD;

		ans += i * v[i];
		ans %= _MOD;
	}

	cout << ans << "\n";

	return 0;
}


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

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> sc(m);
  rep(i,m){
    int s,c;
    cin >> s >> c;
    sc.at(i) = make_pair(s,c);
  }
  rep(i,1000){
    vector<int> c(1,i%10);
    int ni = i/10;
    int keta = 1;
    while(ni){
      keta++;
      c.push_back(ni%10);
      ni /= 10;
    }
    if(n!=keta) continue;
    int flag = 0;
    reverse(c.begin(),c.end());
    rep(i,m){
      if(c.at(sc.at(i).first-1)!=sc.at(i).second){
        flag = 1;
        break;
      }
    }
    if(flag)continue;
    else{
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<a-b+1;
}

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

int main() {
   int A, B;
   string op;
   cin >> A >> op >> B;
  if(op == "+"){
   cout << A + B <<endl;
  }else if(op == "-"){
   cout << A - B <<endl;
  }
  return 0;
}

Measured memory_bytes: 3596
n, m = map(int, input().split())

x = [None for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    c = map(int, input().split())
    t = sum(map(lambda x: 2 ** (x - 1), c))
    x[i] = (a, t)

INF = 10 ** 9
dp = [INF for _ in range(2 ** n)]
dp[0] = 0

for ai, ti in x:
    for j in range(2 ** n):
        dp[ti | j] = min(dp[ti | j], dp[j] + ai)

if dp[-1] >= INF:
    ans = -1
else:
    ans = dp[-1]
print(ans)


Measured memory_bytes: 3272
let cross (x0,y0) (x1,y1) = x0*.y1-.x1*.y0;;

let () =
  let n = Scanf.scanf " %d\n" (fun x -> x) in
  let a = Array.init n (fun x -> Scanf.scanf " %f %f\n" (fun y z -> (y, z))) in
  let f i =
    let p0x, p0y = a.(i mod n) and
        p1x, p1y = a.((i+1) mod n) and
        p2x, p2y = a.((i+2) mod n) in
    let v0 = (p1x-.p0x, p1y-.p0y) and
        v1 = (p2x-.p1x, p2y-.p1y) in
    if cross v0 v1 >= 0. then 1
    else 0
  in
  let rec loop = function
      i when Array.length a = i -> Printf.printf "%d\n" 1
    | i -> if f i = 0 then Printf.printf "%d\n" 0
           else loop (i+1)
  in loop 0
;;

Measured memory_bytes: 2448
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
  ll n;
cin>>n;
  string res;
  while(1){
  res+=(char)('a'+((n-1)%26));
  n=(n-1)/26;//nを26で割った商を代入する
  if(n==0) break;//割った商が0ならbreak
  
  //n=n-1;//'','a','b'...となるので、最初の''は除く
  }
  reverse(res.begin(),res.end());
  cout<<res<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
    int a, b , n;
    cin >> n >> a >> b;
    cout << min(a * n, b ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	vector<string> s(n);
  	rep(i, n) cin >> s[i];
  	map<string, int> ans;
  	
	rep(i, n){
      	string key = s[i];
      	ans[key] = 1;
    }
  	
  	cout << ans.size() << endl;
}

Measured memory_bytes: 25128
using System;
using System.Collections.Generic;
using System.Linq;

class Program{

  static int n = 0;
  static int ans = 0;

  static int Main() {

    n = int.Parse(Console.ReadLine());

    string[] nyu = Console.ReadLine().Split(' ');
    int t = int.Parse(nyu[0]);
    int a = int.Parse(nyu[1]);

    int[] h = new int[n];
    string[] nya = Console.ReadLine().Split(' ');
    for (int i = 0; i < n; i++) {
      h[i] = int.Parse(nya[i]);
    }
    // ここまで入力

    double[] tempSa = new double[n];
    for (int i = 0; i < n; i++) {
      tempSa[i] = System.Math.Abs(t - h[i] * 0.006 - a);
    }

    ans = Array.IndexOf(tempSa, tempSa.Min()) + 1;

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


Measured memory_bytes: 11292
/*
    Author : DemonStar
*/

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int rec(vi &dp, vector<vi> &v, int i)
{
    int &ans = dp[i];
    if (ans != -1)
        return ans;
    ans = 0;
    for (auto x : v[i])
    {
        ans = max(ans, 1 + rec(dp, v, x));
    }
    return ans;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vi v(n);
    cin >> v;
    vector<bool> dp(k + 1, 0);
    loop(i, k + 1)
    {
        for (auto x : v)
        {
            if (i - x >= 0 and !dp[i - x])
                dp[i] = 1;
        }
    }
    if (dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;

#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = ["".join(sorted(input())) for _ in range(n)]
ans = 0
d = {}
for i in range(n):
  if l[i] not in d:
    d[l[i]] = 1
  else:
    ans += d[l[i]]
    d[l[i]] += 1
print(ans)

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

int main(){
	string s;
	int n;
	cin >> s >> n;
	while(n--){
		string q;
		cin >> q;
		if(q == "replace"){
			int a, b;
			string t;
			cin >> a >> b >> t;
			for(int i = a; i <= b; i++) s[i] = t[i - a];
		}else{
			int a, b;
			cin >> a >> b;
			if(q == "reverse") reverse(s.begin() + a, s.begin() + b + 1);
			else{
				for(int i = a; i <= b; i++) cout << s[i];
				cout << endl;
			}
		}
	}
}

Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c,d,l;

ll gcd(ll x, ll y){
	return ((y)?(gcd(y,x%y)):x);
}

ll solve(ll x){
	return (x-(x/c)-(x/d)+(x/l));
}

int main(void){
	ll a,b;
	cin >> a >> b >> c >> d;
	l = c*d/gcd(c,d); --a;
	cout << solve(b)-solve(a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a[3];
    for(int i=0; i<3; i++) cin >> a[i];
    sort(a,  a+3);
  int ans = a[0];
    if(a[0]==a[1]) ans = a[2];
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  int ans=0;
  if(n+1==m) ans++;
  rep(i,s.size()){
    if(s[i]==t[i]) ans++;
  }
  if(ans==t.size()) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

#define MAX 100005
#define NIL -1

void print (int);     //表示
void rec(int u,int p); //再帰的に深さを求める

typedef struct{
  int p;              //parent
  int l;              //left
  int r;              //right
} NODE;

NODE T[MAX];
int n,D[MAX];

int main()
{
  int d,v,c,l,r;                
  int i,j;
  
  scanf("%d",&n);

  //構造体の初期化
  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
      }

  for (i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r = i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}

void print(int u)
{
  int i, c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
   printf("]\n");
}

void rec(int u,int p)
{
  D[u] = p;
  if( T[u].r != NIL) rec(T[u].r,p);
  if( T[u].l != NIL) rec(T[u].l,p+1);
}

  
  



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b, v, w, t;
	cin >>a >>v >>b >>w >>t;
	if(w >= v) {puts("NO"); return 0;}
	if(abs(b-a) <= t*(v-w) ) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	int minVal = 10000;
	int maxVal = 0;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		minVal = min(minVal, a[i]);
		maxVal = max(maxVal, a[i]);
	}
	cout << maxVal - minVal << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256