akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1000000;
int main(){
    int x;
    cin >> x;

    auto dp = vector<int>(x+1,-1);
    auto v = vector<int>({100,101,102,103,104,105});
    
    dp[0] = 0;
    for(int i=0;i<6;i++){
        for(int j=0;j<=x;j++){
            if(dp[j]>=0){
                dp[j]= INF;
            }else if(j<v[i]||dp[j-v[i]]<=0){
                dp[j] = -1;
            }else{
                dp[j] = dp[j-v[i]]-1;
            }
        }
    }
    if(dp[x]>=0) cout << 1;
    else cout << 0;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  if (a > b) swap(a, b);
  cout << (a < c and c < b ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;

    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll find(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return siz[find(x)];
    }
};


int main(){
    ll N,M; cin >> N >> M;
    vl p(N); rdv(p);
    UnionFind uf(N);
    rep(i,M){
        ll a,b; cin >> a >> b;
        uf.merge(--a,--b);
    }
    ll ans = 0;
    rep(i,N) if(uf.issame(i,--p[i])) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
N, M, X, Y = map(int, raw_input().split())
xlst = map(int, raw_input().split())
ylst = map(int, raw_input().split())
xlst.sort()
ylst.sort()
ans = 'War'
if xlst[N-1] < Y and X < ylst[0] and xlst[N-1] < ylst[0]:
	ans = 'No ' + ans

print ans

Measured memory_bytes: 2568
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll s;

void solve(){
    cin >> s;
    ll left=0,right=mod;
    while(left+1<right){
        //cout << left << " " << right << endl;
        ll mid=(left+right)/2;
        if(mid*mid>=s)right=mid;
        else left=mid;
        //cout << mid << endl;
    }
    cout << 0 << " " << 0 << " " << right << " " << right*right-s << " " << 1 << " " << right << endl; 
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (n, A, B, C) = readLine()!!.split(" ").map(String::toInt)
    var l : MutableList<Int> = mutableListOf()
    for (i in 0..(n-1)) {
        l.add(readLine()!!.toInt())
    }

    println(dfs(0, 0, 0, 0, n, A, B, C, l))
}

fun dfs(cur : Int, a : Int, b : Int, c : Int, n : Int, A : Int, B : Int, C : Int, l : List<Int>) : Int{
    val INF = 1000000000
    if(cur == n) return if(Math.min(a, Math.min(b, c)) > 0) Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30 else INF
    val ret0 = dfs(cur + 1, a, b, c, n, A, B, C, l)
    val ret1 = dfs(cur + 1, a + l[cur], b, c, n, A, B, C, l) + 10
    val ret2 = dfs(cur + 1, a, b + l[cur], c, n, A, B, C, l) + 10
    val ret3 = dfs(cur + 1, a, b, c + l[cur], n, A, B, C, l) + 10
    return Math.min(ret0, Math.min(ret1, Math.min(ret2, ret3)))
}

Measured memory_bytes: 39116
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt()+1;
		int X = sc.nextInt();
		int[] L = new int[N];
		int count=1;		
		L[0]=0;
		
		for(int i=1;i<N;i++) {
			L[i]=sc.nextInt()+L[i-1];
			if(L[i]<=X) {
				count++;
			}
		}
		
		System.out.println(count);
		sc.close();
	}
}


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

int main(){
  string S;
  cin >> S;
  int cnt = 0;
  int ans = 0;
  for(int i=0; i < S.length(); i++){

    if(S.at(i) == 'A') cnt++;
    else if(S.at(i) == 'T') cnt++;
    else if(S.at(i) == 'G') cnt++;
    else if(S.at(i) == 'C') cnt++;
    else{
      if(cnt>=ans) ans = cnt;
      cnt = 0;
    }
  }
  if(cnt>=ans) ans = cnt;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    vector<int> v(n);
    for(i=0;i<n;i++) cin>>v[i];
    double ans;
    sort(v.begin(),v.end());
    ans=v[0];
    for(i=1;i<n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  s = new Array();
  var mas =0;
  for(i=0;i<n;i++){
    s[i]=parseInt(input[i+1]);
    mas+=s[i];
  }
  if(mas%10==0){
    s.sort(function(a,b){
            if( a > b ) return -1;
            if( a < b ) return 1;
            return 0;
    });
    for(i=n-1;i>=0;i--){
      if(s[i]%10!=0){
        mas-=s[i];
        break;
      }
    }
  }
  if(mas%10==0){
    mas=0;
  }
  var ans =mas;
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
  int n, a, b;
  long long k;
  scanf("%d %d %d %lld", &n, &a, &b, &k);
  const int md = 998244353;
  auto inv = [&](int a) {
    int b = md, s = 1, t = 0;
    while (b) {
      int q = a / b;
      swap(s -= q * t, t);
      swap(a -= q * b, b);
    }
    return s < 0 ? s + md : s;
  };
  auto add = [&](int a, int b) {
    return (a += b - md) < 0 ? a + md : a;
  };
  auto mul = [&](int a, int b) {
    return (long long)(a) * b % md;
  };
  vector<int> c(n + 1);
  c[0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i] = mul(c[i - 1], mul(inv(i), n - i + 1));
  }
  long long rm = k;
  int ans = 0;
  for (int x = 0; x <= n; x++) {
    if (rm % b == 0) {
      int y = rm / b;
      if (y >= 0 && y <= n) {
        ans = add(ans, mul(c[x], c[y]));
      }
    }
    rm -= a;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
    int D;
    cin >> D;
    string ans;
    if(D == 25) ans = "Christmas";
    else if(D == 24) ans = "Christmas Eve";
    else if(D == 23) ans = "Christmas Eve Eve";
    else if(D == 22) ans = "Christmas Eve Eve Eve";
    else ans = " ";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect


n = int(input())
l = list(map(int, input().split()))
ans = 0
l = sorted(l)
for i in range(n):
    for j in range(i + 1, n):
        sum_ = l[i] + l[j]
        diff = l[j] - l[i]
        right = bisect.bisect_left(l, sum_)
        left = bisect.bisect_right(l, diff)
        if left <= i < right:
            ans -= 1
        if left <= j < right:
            ans -= 1
        ans += right - left
print(ans // 3)

Measured memory_bytes: 46812
#include<iostream>
#include<string>
#include<queue>
#include<sstream>
#include<cstring>
#include<algorithm>
#include <cstdio>
#include<set>
#include <stdlib.h>
#include <vector>
#include<cmath>
#include<stack>
using namespace std;
const int N=1000;
int arr[N],arr1[N];

int main() {
string str1,str2;
cin>>str1>>str2;

if(str1==str2)cout<<"NO";
else if(str2.size()>str1.size())
{
    str2.pop_back();
    if(str1==str2)cout<<"Yes";
    else cout<<"No";
}
else if(str2.size()<str1.size())
{
    str1.pop_back();
    if(str1==str2)cout<<"Yes";
    else cout<<"No";
}



return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//繰り返し二乗法
//x^n mod
ll mod_pow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) { //奇数
        return mod_pow(x, n - 1) * x % MOD; //偶数の再帰にできるように変形
    } else { //偶数
        ll t = mod_pow(x, n / 2); //半分のものを求めて、2乗する
        return t * t % MOD;
    }
}

int main() {

    int n, k; cin >> n >> k;

    vector<ll> cnt(k + 10, 0);
    for (int i = k; i >= 1; --i) {
        cnt[i] = mod_pow((ll)(k / i), (ll)n);

        ll t = 2 * i;
        while (t <= k) {
            cnt[i] -= cnt[t];
            t += i;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= k; ++i) {
        ans += cnt[i] * i;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  vector<long long> a(N);
  vector<long long> score(N);
  for (int i = 0; i < N; ++i ) {
    long long tmp;
    cin >> tmp;
    a[i] = tmp;
    score[i] = i - tmp;
  }

  vector<long long> s = score;
  sort(s.begin(), s.end());

  long long ret = 0;
  for (int i = 0; i < N; ++i) {
    long long cur = i + a[i];
    vector<long long>::iterator j = lower_bound(s.begin(), s.end(), i + a[i]);
    vector<long long>::iterator k = upper_bound(s.begin(), s.end(), i + a[i]);
    if (j == s.end() || *j > cur)
      continue;
    if (k == s.end())
      ret += distance(j, s.end());
    else
      ret += distance(j, k);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll ans = max({a*c, a*d, b*c, b*d});
        cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector <ll> a(n),b(n);
    ll aa=0,bb=0;
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        //cin >> a[i] >> b[i];
        if(b[i]>=a[i]){
            bb+=b[i]-a[i];
        }
        else if(a[i]>b[i]){
            if((a[i]-b[i])%2==0){
                aa+=(a[i]-b[i])/2;
            }
            else{
                aa+=(a[i]-b[i])/2+1;
                ++bb;
            }
        }
    }

    if(aa>=bb){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    
    

    return 0;
}

Measured memory_bytes: 3776
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N,M=map(int,input().split())
S=input()
T=input()

nagasa=lcm(N, M)

aidaS=nagasa//N
aidaT=nagasa//M
#print(aidaS,aidaT)

aidaOnajiCheck=lcm(aidaS, aidaT)

jyoken=True

#print(nagasa//aidaOnajiCheck)

for i in range((nagasa//aidaOnajiCheck)):
  #print((aidaOnajiCheck//aidaS)*i)
  if(not (S[(aidaOnajiCheck//aidaS)*i]==T[(aidaOnajiCheck//aidaT)*i])):
    jyoken=False

if(jyoken):
  print(nagasa)
else:
  print(-1)
  

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int x;
    cin>>x;
    int16_t ans;
    if(x){
        ans=0;
    }
    else{
        ans=1;
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3580
#include<cstdio>
#include<vector>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;

int main(void){
	
	int n;
	while(scanf("%d", &n),n){
		int h[128];
		int ans = -1;
		n++;
		rep(i,n)
			scanf("%d", &h[i]);
		
		rep(i,n){
			vector<int> x;
			bool flag = true;
			rep(j,n){
				if(j != i){
					x.push_back(h[j]);
				}
			}
			
			int dh = x[1] - x[0];
			reps(j, 1, x.size()){
				if(x[j] - x[j-1] != dh){
					flag = false;
					break;
				}
			}
			
			if(flag)ans = h[i];
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S, T;
  cin>>S>>T;
  int cnt=0;
  REP(i,0,3){
    if(S[i]==T[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a[3][3], b[10], n, c[3][3] = {}, flag = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b[i] == a[j][k]) {
          c[j][k] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    if (c[i][0] && c[i][1] && c[i][2]) {
      flag = 1;
    }
    if (c[0][i] && c[1][i] && c[2][i]) {
      flag = 1;
    }
  }
  if (c[0][0] && c[1][1] && c[2][2]) {
    flag = 1;
  }
  if (c[0][2] && c[1][1] && c[2][0]) {
    flag = 1;
  }
  if (flag) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P,char> PP;
const double EPS = 1e-8;
namespace std {bool operator < (const P& a, const P& b) {return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);}}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}

int ccw(P a, P b, P c) {
  b-=a;c-=a;
  if(cross(b,c)>EPS)return +1;
  if(cross(b,c)<-EPS)return -1;
  if(dot(b,c)<-EPS)return +2;
  if(norm(b)<norm(c))return -2;
  return 0;
}

vector<P> convex_hull(vector<P> p) {
  int n=p.size(),k=0;
  if(n==1) return p;
  sort(p.begin(),p.end());
  vector<P> q(2*n);
  for(int i=0;i<n;q[k++]=p[i++])while(k>=2&&ccw(q[k-2],q[k-1],p[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;q[k++]=p[i--])while(k>=t&&ccw(q[k-2],q[k-1],p[i])<=0)--k;
  q.resize(k-1);
  return q;
}

int contains(vector<P> v, P p){ 
  bool in=false; 
  for(int i=0;i<v.size();i++){ 
    P a=v[i]-p; 
    P b=v[(i+1)%v.size()]-p; 
    if(imag(a)>imag(b)) swap(a,b); 
    if((imag(a)<=0||fabs(imag(a))<=EPS)&&EPS<imag(b)) 
      if(cross(a,b)<-EPS) in=!in; 
    if(fabs(cross(a,b))<=EPS&&dot(a,b)<EPS) return 1; 
  } 
  return in?2:0; 
}

bool intersect_1pt(P a,P b,P c,P d,P &r) {
  double D=cross(b-a,d-c);
  if(fabs(D)<EPS) return false;
  double t=cross(c-a,d-c)/D;
  double s=-1*cross(a-c,b-a)/D;
  r=a+t*(b-a);
  return((t > 0||fabs(t)<EPS)&&(t<1||fabs(t-1)<EPS)&&(s>0||fabs(s)<EPS)&&(s<1||fabs(s-1)<EPS));
}

vector<P> convex_intersect(vector<P> v1,vector<P> v2) {
  int n=v1.size(),m=v2.size();
  int a=0,b=0,aa=0,ba=0,in=2;
  vector<P> v3;
  do {
    int a1=(a+n-1)%n,b1=(b+m-1)%m;
    double A=cross(v1[a1]-v2[b],v1[a]-v2[b]);
    double B=cross(v2[b1]-v1[a],v2[b]-v1[a]);
    double C=cross(v1[a]-v1[a1],v2[b]-v2[b1]);
    P r;
    if(intersect_1pt(v1[a1],v1[a],v2[b1],v2[b],r)){
      if(in==2) aa=ba=0;
      v3.push_back(r);
      in=B>0?0:A>0?1:in;
    }
    if(C==0&&B==0&&A==0){
      if(in==0){b=(b+1)%m;ba++;}
      else {a=(a+1)%n;aa++;}
    } else if(C>=0){
      if(A>0){
        if(in==0) v3.push_back(v1[a]);
        a=(a+1)%n;
        aa++;
      } else {
        if(in==1) v3.push_back(v2[b]);
        b=(b+1)%m;
        ba++;
      }
    } else {
      if(B>0){
        if(in==1) v3.push_back(v2[b]);
        b=(b+1)%m;
        ba++;
      } else {
        if(in==0) v3.push_back(v1[a]);
        a=(a+1)%n;
        aa++;
      }
    }
  } while((aa<n||ba<m)&&aa<2*n&&ba<2*m);
  if(in==2){
    if(contains(v2,v1[0])) return v1;
    if(contains(v1,v2[0])) return v2;
  }
  return v3;
}

int main() {
  int n,m;
  while(cin >> n >> m && n) {
    vector<P> v[2];
    for(int i=0; i<n; i++) {
      double x,y;
      cin >> x >> y;
      v[0].push_back(P(x,y));
    }
    for(int i=0; i<m; i++) {
      double x,y;
      cin >> x >> y;
      v[1].push_back(P(x,y));
    }
    for(int i=0; i<2; i++) v[i]=convex_hull(v[i]);
    if(!v[0].size()||!v[1].size()||v[0].size()==1&&v[1].size()==1) {
      cout << "YES" << endl;
      continue;
    }
    vector<P> ans=convex_intersect(v[0],v[1]);
    if(ans.size()) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 3212
import itertools

n, m = map(int, input().split())
AB = []
for i in range(m):
    AB.append(list(map(int, input().split())))
ct = 0
N_lis = [(i + 2) for i in range(n - 1)]
Pat = itertools.permutations(N_lis)
for one_case in Pat:
    tmp = 1
    all_flag = True
    for j in one_case:
        flag = False
        for k in range(m):
            if AB[k][0] == tmp:
                if AB[k][1] == j:
                    tmp = j
                    flag = True
                    break
            elif AB[k][1] == tmp:
                if AB[k][0] == j:
                    tmp = j
                    flag = True
                    break
        if not flag:
            all_flag = False
            break
    if all_flag:
        ct += 1
print(ct)

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

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


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

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

  vvi S(2 * N, vi(2 * N));
  for (ll i = 0; i < N; i++) {
    string s; cin >> s;
    for (ll j = 0; j < N; j++) {
      S[i][j] = s[j];
    }
  }

  for (ll i = 0; i < 2 * N; i++) {
    for (ll j = 0; j < 2 * N; j++) {
      S[i][j] = S[i % N][j % N];
    }
  }

  vvi v(N, vi(N));

  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (i == 0 || j == 0) {
        // 左上が (i, j)
        for (ll k = 0; k < N; k++) {
          for (ll l = k; l < N; l++) {
            if (S[i + k][j + l] != S[i + l][j + k]) {
              v[i][j] += 1;
            }
          }
        }

        for (ll k = 1; k < N - i - j; k++) {
          // 左上が (i + k, j + k) 右下が (i + k + N - 1, j + k + N - 1)
          // (i + k - 1, j + k - 1) ... (i + k - 1, j + k - 1 + N - 1)
          // (i + k + N - 1, j + k) ... (i + k + N - 1, j + k + N - 1)
          v[i + k][j + k] = v[i + k - 1][j + k - 1];

          for (ll l = 0; l < N; l++) {
            if (S[i + k - 1 + l][j + k - 1] != S[i + k - 1][j + k - 1 + l]) {
              v[i + k][j + k] -= 1;
            }
          }

          for (ll l = 0; l < N; l++) {
            if (S[i + k + N - 1 - l][j + k + N - 1] != S[i + k + N - 1][j + k + N - 1 - l]) {
              v[i + k][j + k] += 1;
            }
          }
        }
      }
    }
  }

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      if (v[i][j] == 0) {
        ans += 1;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string S, T, U;
	int A, B;
	cin>>S>>T>>A>>B>>U;
	if(S==U){
		cout<<A-1<<' '<<B;
	}else if(T==U){
		cout<<A<<' '<<B-1;
	}
}

Measured memory_bytes: 3620
c = [list(map(int, input().split())) for _ in range(3)]

for j in range(1, 3):
    flag = True
    for i in range(1, 3):
        if c[0][j]-c[0][(j+1) % 3] != c[i][j]-c[i][(j+1) % 3]:
            flag = False
            break
    if not flag:
        print('No')
        exit()
for i in range(1, 3):
    flag = True
    for j in range(1, 3):
        if c[i % 3][0]-c[(i+1) % 3][0] != c[i][j]-c[(i+1) % 3][j]:
            flag = False
            break
    if not flag:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

int INF=1000000000;
int x,y;
int sx,sy;
int gx,gy;
string str[1001];
int cnt[5];
int cx[5][1001],cy[5][1001];
int dp[5][5][1001];
int res,resn;

int main(void){
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		//初期化
		res=INF;
		for(int i=0;i<5;i++){
			cnt[i]=0;
			for(int j=0;j<5;j++){
				for(int k=0;k<=1000;k++){
					dp[i][j][k]=INF;
				}
			}
		}
		for(int i=0;i<y;i++){
			cin >> str[i];
			for(int j=0;j<x;j++){
				if(str[i][j]>='1' && str[i][j]<='5'){
					int ic=str[i][j]-'0'-1;
					cx[ic][cnt[ic]]=j;
					cy[ic][cnt[ic]]=i;
					cnt[ic]++;
				}
				if(str[i][j]=='S')sx=j,sy=i;
				if(str[i][j]=='G')gx=j,gy=i;
			}
		}
		for(int i=0;i<5;i++){
			for(int j=0;j<cnt[(i+1)%5];j++){
				dp[i][(i+1)%5][j]=abs(cx[(i+1)%5][j]-sx)+abs(cy[(i+1)%5][j]-sy);
			}
			for(int j=2;j<5;j++){
				for(int k=0;k<cnt[(j+i)%5];k++){
					for(int l=0;l<cnt[(j+i+4)%5];l++){
						int np=dp[i][(j+i+4)%5][l]+abs(cx[(j+i)%5][k]-cx[(j+i+4)%5][l])+abs(cy[(j+i)%5][k]-cy[(j+i+4)%5][l]);
						dp[i][(j+i)%5][k]=min(dp[i][(j+i)%5][k],np);
					}
				}
			}
			int re=res;
			for(int j=0;j<cnt[(i+4)%5];j++){
				int gp=dp[i][(i+4)%5][j]+abs(cx[(i+4)%5][j]-gx)+abs(cy[(i+4)%5][j]-gy);
				res=min(res,gp);
			}
			if(re!=res)resn=i+1;;
		}
		if(res>=INF)printf("NA\n");
		else printf("%d %d\n",resn,res);
	}
	return 0;
}

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

typedef long long ll;
ll q, h, s, d, n;

int main() {
    cin >> q >> h >> s >> d >> n;
    cout << n / 2 * min({d, s * 2, h * 4, q * 8}) + n % 2 * min({s, h * 2, q * 4}) << endl;
    return 0;
}

Measured memory_bytes: 256
import math

X = int(input())

for i in range(X, 10**6):
    if i == 1:
        continue
    elif i == 2 or i == 3:
        print(i)
        break
    elif i % 2 == 0 or i % 3 == 0:
        continue
    for j in range(5, math.floor(math.sqrt(i)) + 1, 6):
        if i % j == 0 or i % (j+2) == 0:
            break
    else:
        print(i)
        break

Measured memory_bytes: 9080
#include <cstdio>
#include <algorithm>
int readint() {
	char ch = getchar();
	int res = 0; bool f = false;
	if (ch == '-') {
		f = true;
		ch = getchar();
	}
	while ('0' <= ch && ch <= '9') {
		res = res * 10 + ch - '0';
		ch = getchar();
	}
	if (f) res = -res;
	return res;
}
int A[50176];
int main() {
	// step #1. read input
	int N = readint();
	int H = (N >> 1);
	for (int i = 0; i < H; ++i) A[i] = readint();
	if (N & 1) readint();
	for (int i = H - 1; i >= 0; --i) A[i] += readint();
	// step #2. calculate the answer
	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		long long sum = 0;
		int pos = i;
		while (pos < H) {
			sum += A[pos];
			ans = std::max(ans, sum);
			pos += i;
		}
		if ((N - 1) % i != 0) {
			pos = (N - 1) - pos;
			while (pos >= i) {
				sum += A[pos];
				ans = std::max(ans, sum);
				pos -= i;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1768
#include <iostream>
#include <string>

using namespace std;

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

    int n = S.size();

    long long ans = 0;
    for(int i = 0; i < (1 << (n-1)); i++){
        long long tmp = 0;
        for(int j = 0; j < n; j++){
            tmp = tmp * 10 + S[j] - '0';
            if(i & (1 << j)){
                ans += tmp;
                tmp = 0;
            }
        }
        ans += tmp;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
// $input１ = fgets(STDIN);
// $input２ = fgets(STDIN);
// $n=trim(fgets(STDIN));
$inputs = (explode(' ', fgets(STDIN)));
echo ((int)$inputs[0] * (int)$inputs[1] % 2 ==0) ? 'Even' : 'Odd';
?>


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int a, b; cin >> a >> b;
    int ans = a + b;
    Max(ans, a - b);
    Max(ans, a * b);
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
-- import Data.List
import Control.Monad
import Text.Printf

type Order = [Int] -- [b,f,r,v]

main = do
  n <- readLn
  ss <- replicateM n getLine
  let orders = map (map read) $ map words ss
  printRooms 1 1 1 orders 

newline :: IO ()
newline = putStrLn ""

isThisroom :: (Int,Int,Int) -> Order -> Bool
isThisroom (b',f',r') (b:f:r:_) = b' == b && f' == f && r' == r

printRooms :: Int -> Int -> Int -> [Order]-> IO ()
printRooms b f r orders = do
  let v = sum . map getPopulation . filter (\o -> isThisroom (b,f,r) o) $ orders
  printf " %d" v
  case (b,f,r) of
    (4,3,10) -> do {newline; return ()}
    (_,3,10) -> do {newline; putStrLn line;
                    printRooms (b + 1) 1 1 orders }
    (_,_,10) -> do {newline;
                    printRooms b (f + 1) 1 orders}
    _        ->     printRooms b f (r + 1) orders
    where line = "####################"
         
getPopulation :: Order -> Int
getPopulation (_:_:_:[v]) = v

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

void chmin (long long &a, long long b) {
    if (a > b) a = b;
}

template<typename T>
struct Edge {
    int to; T cost;
    Edge (int to, T cost = 1) : to(to), cost(cost) { }
    bool operator< (const Edge &r) const { return (cost < r.cost); }
};

template<typename T> using Graph = vector<vector<Edge<T>>>;

template <typename T>
vector<T> dijkstra(const Graph<T> &g, int s) {
    using P = pair<T, int>;
    vector<T> ret(g.size(), -1);
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(ret[s], s); ret[s] = 0;
    while (not que.empty()) {
        int v; T c; tie(c, v) = que.top(); que.pop();
        if (ret[v] < c) continue;
        for (const auto &e : g[v]) {
            if (ret[e.to] > ret[v] + e.cost or ret[e.to] == -1) {
                ret[e.to] = ret[v] + e.cost;
                que.emplace(ret[e.to], e.to);
            }
        }
    }
    return ret;
}

int main() {
    constexpr long long SIZE = 2550;
    constexpr long long MAX = 2525;
    long long n, m, s;
    cin >> n >> m >> s;
    s = min(s, MAX);
    
    Graph<long long> g(n * SIZE);
    
    auto idx = [&] (long long v, long long x) {
        // 頂点 v で x 枚の銀貨を持っている
        assert(v + x * n < g.size());
        return v + x * n;
    };

    for (int i = 0; i < m; i++) {
        long long v, u, a, b;
        cin >> v >> u >> a >> b; v--; u--;
        for (long long x = 0; x <= MAX; x++) if (x - a >= 0) {
            g[idx(v, x)].emplace_back(idx(u, x - a), b);
            g[idx(u, x)].emplace_back(idx(v, x - a), b);
        }
    }
    
    for (long long i = 0; i < n; i++) {
        long long c, d;
        cin >> c >> d;
        for (long long x = 0; x <= MAX; x++) {
            long long to = min(MAX, x + c);
            g[idx(i, x)].emplace_back(idx(i, to), d);
        }
    }
    
    vector<long long> dist = dijkstra(g, idx(0, s));
    
    vector<long long> ans(n, numeric_limits<long long>::max());
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j <= MAX; j++) {
            if (dist[idx(i, j)] != -1) {
                chmin(ans[i], dist[idx(i, j)]);
            }
        }
    }
    
    for (int i = 1; i < n; i++) {
        cout << ans[i] << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 23992
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    string s;
    int k;
    cin>>s>>k;
    if(s.length()==1){
        cout<<k/2<<endl;
        return 0;
    }
    ll cnt=1,ans=0;
    bool judge=true;
    rep(i,s.length()){
        if(s[i]==s[i+1])cnt++;
        else{
            ans+=cnt/2;
            cnt=1;
            if(i<s.length()-1)judge=false;
        }
    }

    ans=ans*k;

    if(s[0]==s[s.length()-1]){
        ll a=0,b=0;
        for(;;a++)if(s[a]!=s[a+1])break;
        for(int i=s.length()-1;;i--)if(s[i-1]!=s[i])break;else b++;
        a++;b++;
        //cout<<a<<" "<<b <<endl;
        if(a==s.length())ans=(ll)(a*k)/2;
        else ans-=(a/2+b/2-(a+b)/2)*(k-1);
    }
    cout<<ans<<endl;

    return 0; 
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
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;
typedef pair<int, int> P;


int main() {
    int a, b, c; cin >> a >> b >> c;
    REP(i,1,b+1) {
        if ((i*a-c)%b == 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
} 

Measured memory_bytes: 3588
s = input()
if s == 'SUN':
    print(7)
if s == 'MON':
    print(6)
if s == 'TUE':
    print(5)
if s == 'WED':
    print(4)
if s == 'THU':
    print(3)
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)

Measured memory_bytes: 3064
import java.util.*;

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

        int[] a = new int[n];
        int rCount = 0;
        int gCount = 0;
        int bCount = 0;
        for (int i = 0; i < n; i++) {
            if(s.charAt(i) == 'R') {
                a[i] = 0;
                rCount++;
            }
            if(s.charAt(i) == 'G') {
                a[i] = 1;
                gCount++;
            }
            if(s.charAt(i) == 'B') {
                a[i] = 2;
                bCount++;
            }
        }

        Long res = (long) rCount * gCount * bCount;

        for (int i = 0; i < n; i++) {
            for(int j = i +1; j < n; j++) {
                int k = j + (j - i);

                if (k < n) {
                    if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) {
                        continue;
                    }

                    res--;
                }
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 52464
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
const int mod = 1e9 + 7;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    vvi dp(h + 1,vi(w + 1));
    vector<vector<char>> a(h,vector<char>(w));
    ffor(i,h)
    {
        ffor(j,w)
        {
            cin >> a[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i = 1; i <= h; ++i)
    {
        for(int j = 1; j <= w; ++j)
        {
            if(i == 1 && j == 1)continue;
            if(a[i - 1][j - 1] != '#')
            {
                (dp[i][j] = dp[i - 1][j] + dp[i][j - 1])%=mod;
            }
        }
    }
    cout << dp[h][w];
}

Measured memory_bytes: 9088
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int d[13] = {};
    for(int i=0;i<n;++i)
    {
        int tmp;
        cin >> tmp;
        d[tmp] += 1;
    }

    int ret = -1;
    for(int i=0;i<(1<<13);++i)
    {
        vector<int> times;
        times.push_back(0);
        times.push_back(24);
        for(int j=0;j<13;++j)
        {
            if(d[j] == 1)
            {
                if((i & (1 << j)) == 0)
                {
                    // do not reverse
                    times.push_back(j);
                }
                else
                {
                    times.push_back(24 - j);
                }
            }
            else if(d[j] == 2)
            {
                times.push_back(j);
                times.push_back(24 - j);
            }
            else if(d[j] > 2)
            {
                times.push_back(j);
                times.push_back(j);
                times.push_back(24 - j);
            }
            
        }
        std::sort(times.begin(), times.end());
        
        int mini = 25;
        for(int j=1;j<times.size();++j)
        {
            //cerr << times[j] << " ";
            mini = min(mini, times[j] - times[j-1]);
        }
        //cerr << endl;

        ret = max(ret, mini);
    }

    cout << ret << endl;
}

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

int main(){

  int N, count, friends[100000];
  cin >> N;
  for(int i = 1; i < N+1; i++){
    cin >> friends[i];
  }

  for(int i = 1; i < N+1; i++){
    if(friends[friends[i]] == i) count++;
  }

  cout << count / 2 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N,M,Q;
    cin >> N >> M >> Q;
    vector<vector<ll>> A(N+1,vector<ll>(N+1)), S(N+1,vector<ll>(N+1));
    ll L,R;
    rep(i,M){
        cin >> L >> R;
        L--;R--;
        A[L][R]++;
        //PR(A,N+1);
    }
    ll p, q;
    //PR(A,N+1);
    rep(i,N){
        rep(j,N){
            S[i+1][j+1] = S[i+1][j] + A[i][j];
        }
    }
    //PR(A,N+1);
    vector<ll> ans;
    rep(i,Q){
        cin >> p >> q;
        ll sum = 0;
        REP(j,p,q+1){
            sum += S[j][q] - S[j][p-1];
            //cmin(m,A[j]);
        }
        cout << sum <<endl;
        //ans.push_back(sum);
    }
    //PR(ans,Q);
    //cout << "aaaaa" << endl;
}

Measured memory_bytes: 4864
using System;

public class Sample18{
    public static void Main(){
        while (true){
            string[] line = Console.ReadLine().Trim().Split(' ');
            if ((line[0] == "0") && (line[1]=="0")){
                break;
            }
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var s1 = "";
            var s2 = "";
            for (int i = 0; i < w; i++) s1 += "#";
            for (int i = 0; i < w-2; i++) s2 += ".";
            s2 = "#" + s2 + "#";
            Console.WriteLine(s1);
            for (int i = 0; i < h - 2;  i++)
                Console.WriteLine(s2);
            Console.WriteLine(s1);
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13856
#include<stdio.h>
int main(){
int a,b,d;
char c;
int card[4][14];
scanf("%d\n",&a);
for(b=0;b<a;b++){
scanf("%c %d\n",&c,&d);
if(c=='S'){
card[0][d]=d;
}
else if(c=='H'){
card[1][d]=d;
}
else if(c=='C'){
card[2][d]=d;
}
else if(c=='D'){
card[3][d]=d;
}
}
b=1;
while(b<=13){
if(card[0][b]==b){
b++;
}
else{
printf("S %d\n",b);
b++;
}
}
b=1;
while(b<=13){
if(card[1][b]==b){
b++;
}
else{
printf("H %d\n",b);
b++;
}
}
b=1;
while(b<=13){
if(card[2][b]==b){
b++;
}
else{
printf("C %d\n",b);
b++;
}
}
b=1;
while(b<=13){
if(card[3][b]==b){
b++;
}
else{
printf("D %d\n",b);
b++;
}
}
return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

long long int N, A[112345];
long long int sum, tmp;
bool ans_flag = true;

int main(void)
{
	scanf("%lld", &N);
	for (long long int i = 0; i < N; ++i)
	{
		scanf("%lld", &A[i]);
		sum += A[i];
	}

	A[N] = A[0];
	for (long long int i = 0; i < N; ++i)
	{
		A[i] = A[i + 1] - A[i];
	}
	tmp = N*(N + 1) / 2;
	if (sum % tmp == 0)
	{
		tmp = sum / tmp;
		for (long long int i = 0; i < N; ++i)
		{
			A[i] -= tmp, A[i] = -A[i];
			if (A[i] < 0 || A[i] % N != 0)
			{
				ans_flag = false;
				break;
			}
		}
	}
	else
	{
		ans_flag = false;
	}

	if (ans_flag == true)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  rep(i, n) cin >> a[i];

  ll c1(0), c2(0), c3(0);
  ll tmp = 1;

  V<ll> sub;
  rep(i, n) {
    if (c1 == c2 && c2 == c3) {
      sub.push_back(tmp);
      tmp = 1;
    }

    int p1(0), p2(0), p3(0);
    if (a[i] == c1) p1++;
    if (a[i] == c2) p2++;
    if (a[i] == c3) p3++;

    ll p = p1 + p2 + p3;
    tmp = tmp * p % mod;
    if (p1)
      c1++;
    else if (p2)
      c2++;
    else if (p3)
      c3++;
  }
  ll ans = tmp;
  for (auto e : sub) ans = ans * e % mod;
  cout << ans << endl;
}


Measured memory_bytes: 4928
import itertools as it
T,F = True,False

while 1:
    s = raw_input()
    if s == "#": break
    while "--" in s: s = s.replace("--","")
    for b,a in zip(["=","->","-","*","+"],[") == ("," != 1 or "," not "," and "," or "]):
        s = s.replace(b,a)
    s = "("+s+")"
    for v in xrange(2**11):
        a,b,c,d,e,f,g,h,i,j,k = map(int,list(format(v,"b").zfill(11)))
        if not eval(s):
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 4448
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""
###煩雑 => 列挙して最小値を出力
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2  ##
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2 ##
else:
    ans = X * A + Y * B 
print(ans)
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    ans1 = max(X,Y) * C * 2  #条件分岐が減る
    if X > Y :
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) #print()が分岐する
else:   
    ans1 = X * A + Y * B 
    print(ans1)

Measured memory_bytes: 3064
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int n;
	int ans = 0;
	int now = 0;
	char str[101];

	cin >> n;
	cin >> str;

	for (int i = 0; i < n; i++) {
		int x;
		if (str[i] != 'D') {
			x = 1;
		}
		else {
			x = -1;
		}
		now += x;
		ans = max(ans, now);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;

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

    int x_max = max(X, *max_element(x, x + n));
    int y_min = min(Y, *min_element(y, y + m));

    if (x_max < y_min){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256