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

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

int main() {
  int a, b, c, x;
  int cnt = 0;
  cin >> a >> b >> c >> x;
  range(i, 0, a+1) {
    range(j, 0, b+1) {
      range(k, 0, c+1) {
        if (500*i + 100*j + 50*k == x) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
}


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

int main() {
  int A = 0,W = 0,T =0,R = 0,N;
  cin >> N;
  vector<string>s(N);
  for(int i = 0;i < N;i++)cin >> s[i];
  for(int i = 0;i < N;i++){
    if(s[i] == "AC")A++;
    else if(s[i] == "WA")W++;
    else if(s[i] == "TLE")T++;
    else R++;
  }
  cout << "AC x " << A <<endl;
  cout << "WA x " << W <<endl;
  cout << "TLE x " << T <<endl;
  cout << "RE x " << R <<endl;
}

Measured memory_bytes: 6344
a,b,m = (int(x) for x in input().split())

a_list = [int(x) for x in input().split()]
b_list = [int(x) for x in input().split()]

x_list = []
y_list = []
c_list = []

for s in range(m):
  x,y,c = (int(value) for value in input().split())
  x_list.append(x)
  y_list.append(y)
  c_list.append(c)

min_value = min(a_list) + min(b_list)

for i in range(len(x_list)):
  value = a_list[x_list[i]-1] + b_list[y_list[i]-1] - c_list[i]
  if value < min_value:
    min_value = value
print(min_value)




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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K, X;

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

  std::cin >> K >> X;

  for(int i=X-(K-1);i<=X+(K-1);++i){
      std::cout << i << " \n"[i == X + (K - 1)];
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
   int h,w;
   cin >> h >> w;
   vector<vector<string>> s(h,vector<string>(w));
   rep(i,h){
       rep(j,w){
           cin >> s.at(i).at(j);
       }
   }
   bool a=false;
   rep(i,h){
       rep(j,w){
           if( s.at(i).at(j)=="snuke"){
               char x=char('A'+j);
               cout << x << i+1 << endl;
               a=true;
               break;
           }
       }
       if(a)break;
   }
} 

    

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

int main() {
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long p=a*c;
	long long q=a*d;
	long long r=b*c;
	long long s=b*d;
	cout<<max(p,max(q,max(r,s)));
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M;
    cin >> M;
    cout << 24 - M + 24 << endl;
    return 0;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

///////////////////////////////////////////////////////

const int N = 100;

int n;
int arr[N + 5];

int f(int x){
	int ret = 0;
	FOR(i,n){
		ret += (arr[i]-x) * (arr[i]-x);
	}
	return ret;
}

int solve(){
	int ret = INF;
	REP(i,-N,N){
		ret = min(ret, f(i));
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i,n) cin >> arr[i];
	cout << solve() << endl;
	return 0;
} 

Measured memory_bytes: 256
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static List<int> DrawCount;
     static void Main(string[] args) {
     //入力を受け取る
     var N = int.Parse(Console.ReadLine());
     DrawCount = new List<int>();
     //DrawStep(N,0);
     
     var res = N;
     for(int i = 0;i <= N;i++){
         var tmp = 0;
         var pay6 = i;
         var pay9 = N-i;
         
         //6で払う部分のステップ
         while(pay6 >0){
             tmp += pay6%6;
             pay6 /= 6;
         }
         
         //9で払う部分のステップ
         while(pay9 >0){
             tmp += pay9%9;
             pay9 /= 9;
         }
         
         if(res > tmp){
             res = tmp;
         }
     }
     
     Console.WriteLine(res);
     }
     
     
     static void DrawStep(int N,int count){
         if(N <= 0){
             Console.WriteLine(count);
             DrawCount.Add(count);
         }else{
             var over6 =
             (int)Math.Pow(6,Over(N,6));
             var cou6  = N/over6;   
             Console.Write("6^"+Over(N,6)+"*"+cou6+" ");           
             DrawStep(N-over6*cou6,count+cou6);
             var over9 =
             (int)Math.Pow(9,Over(N,9));
             var cou9  = N/over9;
             Console.Write("9^"+Over(N,9)+"*"+cou9+" ");
             DrawStep(N-over9*cou9,count+cou9);
         }
     }
     
     static int Over(int N,int M){
         var count = 0;
         while(N/M !=0){
             N /= M;
             count++;
         }
         return count;
     }
}

//進数計算用クラス（マイナスにも対応！！）
static class Base{
          //10進数のMをN進数に変換する
        public static string MConvertToBaseN(long N,long M){
          //0の場合は空文字を返してしまうので0を返すように対応
          if(BaseN(N,M) == ""){
            return "0";
          }else{
            return BaseN(N,M);
          }
        }
  
        static string BaseN(long N,long M){
          //0進数の場合はエラーを返す
          if(N == 0){
            return "0進数にはできません";
          }
          if(M == 0){
            return "";
          }else{
            return BaseN(N,NonMinusDivision(M,N))+(NonMinusRest(M,N)).ToString();
          }
        }
        
        //非負剰余の商　a = b*c + r ( abs(b)>r>= 0 )
        //非負剰余で定義したときの商
  　　　 static long NonMinusDivision(double a , double b){
        	if(a > 0 && b > 0){
              return (long) (Math.Floor(a/b));
            }
            else{
              return (long) (Math.Ceiling(a/b));
            }
        }
        
  　　　//非負剰余の余
        static long NonMinusRest(long m, long n){
          return m-NonMinusDivision(m,n)*n;
        }
}

     
     
     
     
     


Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

ll x[55];
ll dp[55][55][2555];

int main(){
	ll n, a;
	cin >> n >> a;
	ll sum = 0;
	FORI(0, n) {
		cin >> x[i];
		sum += x[i];
	}
	dp[0][0][0] = 1;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 2555; k++) {
				dp[i+1][j][k] += dp[i][j][k];
				dp[i+1][j+1][k+x[i]] += dp[i][j][k];
			}
		}

	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ans += dp[n][i][i*a];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 56448
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long double db;
typedef long long ll;
int n,m;
int l[10],p[10],used[10];
ll ans;
ll f[310][40];
void dfs(int x)
{
	if(x==n)
	{
		int i,j,S,msk=(1<<(n-1))-1;
		memset(f,0,sizeof(f));
		f[l[0]*n][0]=1;
		for(i=0;i<m*n;i++)
		{
			x=p[i%n];
			if(!x)	continue;
			for(j=i;j<=m*n;j++)
			{
				for(S=0;S<msk;S++)	if(!((S>>(x-1))&1))
				{
					f[max(j,min(l[x]*n+i,m*n))][S|(1<<(x-1))]+=f[j][S];
				}
			}
		}
		ans+=f[m*n][msk];
		return ;
	}
	for(int i=1;i<n;i++)	if(!used[i])	used[i]=1,p[x]=i,dfs(x+1),used[i]=0;
}
int main()
{
	scanf("%d%d",&n,&m);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d",&l[i]);
		if(l[i]>l[0])	swap(l[i],l[0]);
	}
	dfs(1);
	ll tmp=1;
	for(i=1;i<=n-1;i++)	tmp*=i*m;
	printf("%.16Lf",(db)ans/tmp);
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,K,mod;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
void solve1()
{
	int dp[151][151];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=(n+1)/2;++i)
	{
		for(int j=0;j<=K/2;++j)add(dp[i][0],dp[i-1][j]);
		for(int j=0;j<K/2;++j)add(dp[i][j+1],dp[i-1][j]);
	}
	int res1=0,res2=0;
	for(int i=0;i<=K/2;++i)add(res1,dp[n/2][i]);
	for(int i=0;i<=K/2;++i)add(res2,dp[(n+1)/2][i]);
	printf("%d",1ll*res1*res2%mod);
}
void solve2()
{
	int dp[310][80][160];
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	int lim=(K+1+n)/2;
	for(int i=0;i<lim;++i)
	{
		if(i+1<=(K+1)/2)
		{
			for(int j=0;j<=(n+1)/2;++j)
				if(dp[i][j][0])
				{
					add(dp[i+1][j+1][0],dp[i][j][0]);
					add(dp[i+1][0][0],dp[i][j][0]);
				}
		}
		else if(i+1<=(n+1)/2)
		{
			for(int j=0;j<=(n+1)/2;++j)
				for(int k=0;k<=K+1;++k)
					if(dp[i][j][k])
					{
						add(dp[i+1][0][0],dp[i][j][k]);
						add(dp[i+1][0][k?k+1:0],dp[i][j][k]);
						add(dp[i+1][j+1][0],dp[i][j][k]);
						add(dp[i+1][j+1][max(k?k+1:0,j+2)],dp[i][j][k]);
					}
		}
		else
		{
			int nowlim=i==(n+1)/2?(n+1)/2:0;
			for(int j=0;j<=nowlim;++j)
				for(int k=0;k<=K+1;++k)
					if(dp[i][j][k])
					{
						add(dp[i+1][0][0],dp[i][j][k]);
						add(dp[i+1][0][k?k+1:0],dp[i][j][k]);
					}
		}
	}
	int ans=0;
	for(int j=0;j<=(n+1)/2;++j)
		for(int k=0;k<=K+1;++k)
			add(ans,dp[lim][j][k]);
	printf("%d",ans);
}
int main()
{
	scanf("%d %d %d",&n,&K,&mod);
	if(!(K&1))solve1();
	else solve2();
	return 0;
}


Measured memory_bytes: 15616
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
      a:i64, 
      v:i64,
      b:i64,
      w:i64,
      t:i64
  }

  if (b - a).abs() <= (v - w) * t {
      println!("{}", "YES");
  }else{
      println!("{}", "NO");
  }


}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e5 + 5;

const int inf = (signed) (~0u >> 2);

typedef class Segment {
	public:
		int l, r;

		Segment() {	}
		Segment(int l, int r) : l(l), r(r) {	}

		Segment operator & (Segment b) const {
			return Segment(max(l, b.l), min(r, b.r));
		}
		int length() {
			return max(r - l + 1, 0);
		}
		boolean operator < (Segment b) const {
			return r < b.r;
		}
} Segment;

int n;
Segment s[N], sl[N], sr[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &s[i].l, &s[i].r);
	}
	sort(s + 1, s + n + 1);
	int ans = 0;
	sl[0] = Segment(0, inf);
	for (int i = 1; i <= n; i++)
		sl[i] = sl[i - 1] & s[i];
	sr[n + 1] = Segment(0, inf);
	for (int i = n; i; i--)
		sr[i] = sr[i + 1] & s[i];
	for (int i = 1; i < n; i++)
		ans = max(ans, sl[i].length() + sr[i + 1].length());
	for (int i = 1; i <= n; i++)
		ans = max(ans, s[i].length() + (sl[i - 1] & sr[i + 1]).length());
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc148/tasks/abc148_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<int> st;
    REP(i, 2) {
        int t;
        cin >> t;
        st.insert(t);
    }
    FOR(i, 1, 4) {
        if (st.count(i) == 0) {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h> 

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

	if (100 * N % 108 == 0)
	{
		int X = 100 * N / 108;
		std::cout << X;
	}
	else
	{
		double X = N / 1.08;
		if (floor(X) * 108 / 100 < (double)(N + 1) && floor(X) * 108 / 100 >= (double)(N))
		{
			std::cout << (int)(floor(X));
		}
		else if ((floor(X) + 1) * 1.08 < (double)(N + 1) && (floor(X) + 1) * 1.08 >= (double)(N))
			std::cout << (int)(floor(X) + 1);
		else
		{
			std::cout << ":(";
		}
	}

	return 0;
}

Measured memory_bytes: 256
<?php
$card_count = trim(fgets(STDIN));
$card_kind = array('S','H','C','D');
$card_set = array();
foreach ($card_kind as $kind) {
    for( $i = 1 ; $i <= 13 ; ++ $i ){
        array_push($card_set,$kind.' '.$i);
    }
}
$find_card_set = array();
while($input = trim(fgets(STDIN))){
    array_push($find_card_set,$input);
}
$missing_card_set = array_diff($card_set,$find_card_set);
if (count($missing_card_set)>0) echo join($missing_card_set,PHP_EOL),PHP_EOL;

Measured memory_bytes: 15320
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main(){
	string str;
	string  JOI="JOI",IOI="IOI";
	while(cin>>str){
		int answer1=0;
		int answer2=0;
		for(int i=0;i<str.size()-2;++i){
			if(str.substr(i,3)==JOI)++answer1;
			if(str.substr(i,3)==IOI)++answer2;
		}
		cout<<answer1<<endl<<answer2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long  llong;
int n, k;
llong T[MAX];

//最大積載量
int check(llong P)
{
	int i = 0;
	for (int j = 0; j < k; ++j)
	{
		llong s = 0;
		while (s + T[i] <= P)
		{
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

int solve()
{
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1)
	{
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3880
N=int(input())
count=0
def saiki(word):
    nums=['3','5','7']
    global count
    ans=0
    if(N==word):
        saiki(nums[0])
        saiki(nums[1])
        saiki(nums[2])
    elif(int(word)>N):
        return
    else:
        if '3' in word and '5' in word and '7' in word:
            count+=1
        saiki(word+nums[0])
        saiki(word+nums[1])
        saiki(word+nums[2])
        return
saiki(N)
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

int parent[300000], ronk[300000]; //parent, rank (but ronk)

void initset(int n) {
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        ronk[i] = 0;
    }
}

int findset(int x) {
    if(parent[x] == x) return x; //Parent of node is the node itself, this means the node is itself
    parent[x] = findset(parent[x]); //path compression
    return parent[x];
}

bool sameset(int x, int y){
    return findset(x) == findset(y);
}

void mergeset(int x, int y) {
    x = findset(x); // find representatives
    y = findset(y);
    if(ronk[x] > ronk[y]) {
        parent[y] = x;
    } else {
        parent[x] = y;
        if(ronk[x] == ronk[y]) {
            ronk[y]++;
        }
    }
}

int n, m, k, l;

vector<int> v[300000];


int main(){

    cin >> n >> m;

    initset(n+m+100000);

    for(int i = 0; i < n; i++){
        cin >> k;
        for(int j = 1; j < k+1; j++){
            cin >> l;
            mergeset(i+1, n+l);
        }
    }

    for(int i = 1; i <= n; i++){
        if(!sameset(i, 1)){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 9600
n = int(input())
bt, bx, by = 0, 0, 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    if ((t % 2 == 0 and (x + y) % 2 == 0) or (t % 2 == 1 and (x + y) % 2 == 1)) and (abs(x - bx) + abs(y - by) <= t - bt):
        bt, bx, by = t, x, y
        continue
    else:
        ans = 'No'
        break
print(ans)


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

using namespace std;

int main(){
  string s;
  long long int a=0,b=0;
  cin >> s;
  for(long long int i=0;i!=s.size();i++){
    if(s[i]=='W'){
      a++;
      b=b+i+1;
    }
  }
  cout << b-(a+1)*a/2 << endl;
}


Measured memory_bytes: 640
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y'))

def main():
    n = int(input())
    reds = []
    blues = []

    for _ in range(n):
        x, y = map(int, input().split())
        reds.append(Point(x, y))

    for _ in range(n):
        x, y = map(int, input().split())
        blues.append(Point(x, y))
    
    print(solve(reds, blues))

def solve(reds, blues):
    cnt = 0
    r = reds.copy()

    for b in sorted(blues):
        i = find_pair(r, b.x, b.y)
        if i is not None:
            del r[i]
            cnt += 1
        pass
    
    return cnt

def find_pair(reds, x, y):
    t = None
    for i, p in enumerate(reds):
        if p.x < x and p.y < y:
            if t is None:
                t = i
            elif p.y > reds[t].y:
                t = i
    return t

main()


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = s.size();
  int left = 0, right = N-1;
  int ans = 0;
  while(1){
    if(s[left] == 'x' && s[right] == 'x'){
      left++; right--;
    }else if(s[left] == 'x'){
      left++;
      ans++;
    }else if(s[right] == 'x'){
      right--;
      ans++;
    }else{
      if(s[left] != s[right]){
        cout << -1 << endl;
        return 0;
      }else{
        left++;
        right--;
      }
    }
    if(right < left) break;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    string s;
    cin >> s;
    vector<vector<int>> a(26);
    int m = s.size();
    rep(i,m){
        a[s[i]-'a'].emplace_back(i);
    }
    int ans = INF;
    rep(i,26){
        if(a[i].size()==0) continue;
        int x = a[i][0];
        rep(j,a[i].size()-1){
            chmax(x,a[i][j+1]-a[i][j]-1);
        }
        chmax(x,(m-a[i][a[i].size()-1]-1));
        chmin(ans,x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	LL x;
	cin >> x;

	LL div;
	if (x % 11 == 0) {
		div = x / 11;
	}
	else {
		div = x / 11 + 1;
	}
	LL ans = div * 2;

	if (div * 11 - x > 4) {
		ans--;
	}
	cout << ans;


	return 0;
}



Measured memory_bytes: 508
#!/usr/bin/env python3
import sys
import math
input = sys.stdin.readline
MOD = 10**9 + 7

def single_mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    if r > n - r:
        r = n - r
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD
    return ret

x, y = [int(item) for item in input().split()]
if (x + y) % 3 != 0:
    print(0)
    exit()
step = (x + y) // 3
x -= step; y -= step
if x < 0 or y < 0:
    print(0)
    exit()

print(single_mod_nCr(x+y, x))

Measured memory_bytes: 41196
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    double x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    double di=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    printf("%lf\n",di);
    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    string s;
    cin>>s;
    if (sz(s)!=6){
    	cout<<"No"<<endl;
    	return;
    }
    if (s[2]==s[3] && s[4]==s[5]){
    	cout<<"Yes"<<endl;
    	return;
    }
    cout<<"No"<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

int main()
{
    double x1, y1, x2, y2, Z;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    Z = pow(x1 -x2, 2) + pow(y1 - y2, 2);

    printf("%lf\n", sqrt(Z));

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int sumBit(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
int main() {
  int n,a,b;
  long long total = 0;
  
  cin >> n >> a >> b;
  
  int tmpSum = 0;
  for(int i = 1; i <= n; i++){
    tmpSum = sumBit(i);
    if(a <= tmpSum && tmpSum <= b){
      total += i;
    }
  }
  
  cout << total;
  return 0;
}

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

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))
    
for k in range (n):
    ans = 0
    for j in range(m):
        ans += A[k][j]*b[j]
    print(ans)



Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    string S;
    cin >> N >> K >> S;
    if(S[K-1]=='A')S.replace(K-1,1,"a");
    else if(S[K-1]=='B')S.replace(K-1,1,"b");
    else if(S[K-1]=='C')S.replace(K-1,1,"c");
    cout << S << endl;
    
}

Measured memory_bytes: 3564
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];

	vector<VI> a(60, VI(N));
	VI used(200010, -1);
	
	//doubling
	REP(k, 2) {
		REP(i, N) {
			if (used[A[i]] != -1) {
				a[0][used[A[i]] % N] = k * N + i - used[A[i]] + 1;
			}
			used[A[i]] = k * N + i;
		}
	}

	FOR(k, 1, 60) {
		REP(i, N) {
			a[k][i] = a[k - 1][i] + a[k - 1][(a[k - 1][i] + i) % N];
		}
	}

	int sum = 0, now = 0;
	const int C = N * K;

	while (1) {
		int ind = 0;
		REP(k, 60) {
			if (a[k][now] + sum >= C) {
				ind = k - 1;
				break;
			}
		}
		if (ind == -1)break;
		sum += a[ind][now];
		now = sum % N;
	}
	//シュミレーションと出力
	stack<int> st;
	bool F[200010] = { false };
	FOR(i, now, N) {
		if (F[A[i]]) {
			if (!st.empty()) {
				//while (st.top() != A[i])st.pop();
				while (1) {
					if (st.top() != A[i]) {
						F[st.top()] = false;
						st.pop();
					}
					else break;
				}
				st.pop();
			}
			
			F[A[i]] = false;
		}
		else {
			st.push(A[i]);
			F[A[i]] = true;
		}
	}

	VI ans;
	while (!st.empty()) {
		ans.push_back(st.top());
		st.pop();
	}
	reverse(ans.begin(), ans.end());
	REP(i, ans.size())cout << ans[i] << " ";
	cout << endl;


	return 0;
}



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

typedef long long ll;

typedef pair<int, pair<int, int> > p;

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

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

    vector<int> l(N);

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

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;

    for(int i = 0; i < K; i++) ans += l[i];

    cout << ans << endl;
}

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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << char(s1[0] - 'a' + 'A') << char(s2[0] - 'a' + 'A') << char(s3[0] - 'a' + 'A') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
// #define rep(i, n) for(int i = 0; i < n; i++)
// #define rrep(i, n) for(int i = n; i >= 0; i--)
// #define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,ans;
vll a,b;

bool is_even(int l, string s){return s.substr(0,l/2) == s.substr(l/2);}

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

    string s;
    cin >> s;
    n=s.size()-2;
    s = s.substr(0,n);
    // cout <<s.substr(0,n) << ":" << s.substr(n)<< endl;
    while(n>2) {
        if(is_even(n,s)) break;
        n -= 2;
        s = s.substr(0,n);
    }
    if(n==2 && !is_even(n,s)) n = 1;
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	char x;
	bool flag=false;
	rep(i, 0, 3)
	{
		cin >> x;
		if (x == '7')flag = true;
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

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; int k; cin >> s >> k;
  int n = s.size();

  rep(i,n){
    int cnt = 'z' - s[i];
    cnt = (cnt + 1)%26;
    if(k >= cnt){
      k -= cnt;
      s[i] = 'a';
    }
  }
  k %= 26;
  int tmp = s[n-1] - 'a';
  tmp = (tmp + k)%26;
  s[n-1] = char('a' + tmp);

  cout << s << endl;
}


Measured memory_bytes: 512
n = int(input())
DP = [[0] * 3 for _ in range(n+1)]
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
for i in range(1, n+1):
    for j in range(0, 3):
        for k in range(0, 3):
            if j != k:
                DP[i][j] = max(DP[i][j], DP[i-1][k] + A[i-1][j])
print(max(DP[-1]))

Measured memory_bytes: 72556
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define X real()
#define Y imag()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
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) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

//多角形
typedef vector<P> G;

bool isconvex(const G &P) {
  for (int i = 0; i < P.size(); ++i){
    //cout <<prev(P, i) <<", " <<curr(P, i) <<", " <<next(P, i) <<endl;
    //cout <<ccw(prev(P, i), curr(P, i), next(P, i)) <<endl;
    if (ccw(prev(P, i), curr(P, i), next(P, i)) == 1) return false;
  }
  return true;
}

int N;

int main() {
  cin >>N;
  G g(N);
  REP(i, N){
    int x, y; cin >>x >>y;
    g[i] = P(x, y);
  }
  REVERSE(g);
  cout <<isconvex(g) <<endl;
  return 0;
}

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

int D, G, p[10009], r[10009], minx = 1000000;

int main() {
	cin >> D >> G;
	for (int i = 0; i < D; i++) cin >> p[i] >> r[i];
	for (int i = 0; i < (1 << D); i++) {
		int score = G, pr = 0;
		for (int j = 0; j < D; j++) { if ((i / (1 << j)) % 2 == 1) { score -= r[j]; pr += p[j]; score -= 100 * (j + 1)*p[j]; } }
		vector<int>vec;
		for (int j = 0; j < D; j++) {
			if ((i / (1 << j)) % 2 == 1) continue;
			for (int k = 0; k < p[j]; k++) vec.push_back(100 * (j + 1));
		}
		reverse(vec.begin(), vec.end());
		for (int j = 0; j < vec.size(); j++) {
			if (score > 0) { score -= vec[j]; pr++; }
		}
		minx = min(minx, pr);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
typedef vector<int> vi;
typedef vector<vector<int>> vi2;
int main(void)
{
    string s;
    cin >> s;
    bool f = true;
    if (s[0] != 'A' || s[1] == 'C')
    {
        f = false;
    }
    int count = 0;
    int countL = 0;
    for (int i = 1; i < s.length(); i++)
    {
        if (s[i] == 'C' && i > 1 && i < s.length() - 1)
        {
            count++;
        }
        if (65 <= s[i] && s[i] <= 90)
        {
            countL++;
        }
    }
    if (f == true && count == 1 && countL == 1)
    {
        cout << "AC" << endl;
    }
    else
    {
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
lst = []

for i in range(102):
    if i not in p:
        lst.append(abs(x- i))
d = min(lst)
l = x-d
u = x+d
if l not in p:
    print(l)
else:
    print(u)

Measured memory_bytes: 9140
/*
 * ID: ITP2_1_B
 * Problem: Deque
 * Tty: 2nd
 */

#include <stdio.h>
#define QUE_LENGTH 400000

int main(void)
{
    int a[QUE_LENGTH * 2];
    int n_query;
    int start = QUE_LENGTH;
    int last = QUE_LENGTH;
    int i;

    scanf("%d", &n_query);
    for (i = 0; i < n_query; i++) {
        int query, index, value;
        scanf("%d %d", &query, &index);
        switch (query) {
            case 0: // push(index, value)
                scanf("%d", &value);
                if (index == 0)
                    a[--start] = value;
                else
                    a[last++] = value;
                break;
            case 1: // randomAccess(index)
                printf("%d\n", a[start + index]);
                break;
            case 2: // pop(index)
                if (index == 0)
                    start++;
                else
                    last--;
                break;
        }
    }

    return 0;
}



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



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;




template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}


int main(){
  double xs,ys,xt,yt;
  int n;
  cin>>xs>>ys>>xt>>yt;
  cin>>n;
  WG<double> es(n+2);

  vector<double> a,b,c;
  a.PB(xs);
  b.PB(ys);
  c.PB(0.0);
  rep(i,n){
    int x,y,r;
    cin>>x>>y>>r;
    a.PB(x);
    b.PB(y);
    c.PB(r);
  }
  a.PB(xt);
  b.PB(yt);
  c.PB(0.0);

  rep(i,n+2){
    FOR(j,i+1,n+2){
      double w=max(0.0,sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]))-(c[i]+c[j]));
      es[i].EB(edge<double>(j,w));
      es[j].EB(edge<double>(i,w));
    }
  }

  vector<double> v=dijkstra(es,0);

  printf("%.15lf\n",v[n+1]);
}


Measured memory_bytes: 22640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int n, a;
    cin >> n;
    int count4 = 0, count2 = 0;

    for(int i = 0; i < n; ++i){
        cin >> a;
        if(a%4 == 0){
            count4++;
        }else if(a%2 == 0){
            count2++;
        }
    }
    if(n <= 2*count4 + 1 || n <= 2*count4 + count2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll get(string arr[], ll n)
{
    ll m = arr[0].length();
    ll cnt = 0;
    rep(n)
        repi(j,m)
            if(arr[i][j] == '#')
                cnt++;
    return cnt;            
}

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   sort(arr,arr+n,greater<ll>());
   ll ans = arr[0];
   for(ll i=2;i<n;i++)
   {
        ans+=(arr[i/2]);
   }
   cout<<ans;
   
   
   
   return 0;        
}  
  
          
   

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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;

Long x, y, g, ans;

int main() {
	cin >> x >> y;

	cout << ((x % y == 0) ? -1 : x);
	return 0;
}


Measured memory_bytes: 256