akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
#define pii pair<int,int>
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 500;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int p[mxN*mxN+3];
int dis[mxN+3][mxN+3];
int a[mxN+3][mxN+3];
queue<pii> que1,que2;
int n; llong ans;

pii getpos(int id) {return mkpr((id-1)/n+1,id%n==0?n:id%n);}
int getid(int x,int y) {return (x-1)*n+y;}

void bfs(pii s)
{
	que1.push(s);
	while(!que1.empty()||!que2.empty())
	{
		pii u;
		if(que2.empty()||(!que1.empty()&&dis[que1.front().x][que1.front().y]<dis[que2.front().x][que2.front().y])) {u = que1.front(); que1.pop();}
		else {u = que2.front(); que2.pop();}
		for(int i=0; i<4; i++)
		{
			pii v = mkpr(u.x+dx[i],u.y+dy[i]);
			if(v.x>=1&&v.x<=n&&v.y>=1&&v.y<=n&&dis[v.x][v.y]>dis[u.x][u.y]+a[v.x][v.y])
			{
				dis[v.x][v.y] = dis[u.x][u.y]+a[v.x][v.y];
				if(a[v.x][v.y]==1) {que2.push(v);} else {que1.push(v);}
			}
		}
	}
}

int main()
{
	n = read();
	for(int i=1; i<=n*n; i++) p[i] = read();
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) {a[i][j] = 1; dis[i][j] = min(min(i,j),min(n-i+1,n-j+1));}
	for(int t=1; t<=n*n; t++)
	{
		pii u = getpos(p[t]);
		a[u.x][u.y] = 0; dis[u.x][u.y]--; ans += dis[u.x][u.y];
		bfs(u);
	}
	printf("%lld\n",ans);
	return 0;
}

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

const int maxn = 1e4+10;

vector<int> g[maxn], a;
int n, ans[maxn], sum;

void add2(int u, int v) {
	g[u].push_back(v);
	g[v].push_back(u);
}

void dfs(int u, int fa) {
	ans[u] = a.back(); a.pop_back();
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v != fa) dfs(v, u);
	}
}

int main() {
	scanf("%d", &n);
	int u, v;
	for (int i = 0; i < n-1; ++i) {
		scanf("%d%d", &u, &v);
		add2(u, v);
	}
	for (int i = 0; i < n; ++i) {
		scanf("%d", &u);
		a.push_back(u);
		sum += u;
	}
	sort(a.begin(), a.end());
	sum -= a.back();
	dfs(1,0);
	printf("%d\n", sum);
	for (int i = 1; i <= n; ++i) {
		printf("%d ", ans[i]);
	}
}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int n,flag=0;
	scanf("%d",&n);
	if(n%4==0||n%7==0)flag=1;
	while(n-=7)
	{
		if(n<0)break;
		if(n%4==0){flag=1;break;}
	}
	printf("%s\n",flag?"Yes":"No"); 
	return 0;
} 



Measured memory_bytes: 128
def main():
    N  = int(input())
    Ds = [list(map(int,input().split())) for _ in range(N)]
    count = 0
    for D in Ds:
        if D[0]==D[1]:
            count += 1
        else:
            count = 0
        if count == 3:
            print("Yes")
            return
    print("No")
    
main()

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define     bolt     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     text     freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define     F        first
#define     S        second
#define     pb       push_back
#define     lb       lower_bound
#define     ub       upper_bound
#define     endl     "\n"
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7 ;
const ld pi=3.1415926535897932384626433;
const ll inf = 1e18;
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}

int main ()
{
   bolt;
   ll a,b;
   cin>>a>>b;
   if (!(a-b))
      cout<<"Yes";
   else
      cout<<"No";
   

}


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

using namespace std;

vector<int64_t> D;
vector<vector<array<int64_t, 2>>> E;

void dfs(int v, int parent, int64_t d){
  	D[v] = d;
    for (const auto &e: E[v]){
        if (e[0] != parent)
            dfs(e[0], v, d + e[1]);
    }
}

int main(){
    int n;
    cin >> n;
    E.resize(n);
    D.resize(n);
    for (int i = 0; i < n - 1; i++){
        int64_t a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        E[a].push_back({b, c});
        E[b].push_back({a, c});
    }

    int Q, k;
    cin >> Q >> k;
    k--;
    dfs(k, -1, 0);

    for (int q = 0; q < Q; q++){
        int x, y;
        cin >> x >> y;
        cout << D[--x] + D[--y] << endl;
    }
}

Measured memory_bytes: 14336
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;

enum N = 1_000_000_007;

void main() {
    const tmp = readln.split.to!(int[]);
    const H = tmp[0], W = tmp[1], K = tmp[2];

    ulong _countCase(int x) {
        if (x <= 0) return 1;
        return memoize!_countCase(x-1) + memoize!_countCase(x-2);
    }
    alias countCase = memoize!_countCase;

    ulong func(int current, int cnt) {
        if (cnt == H) return current == K ? 1 : 0;
        ulong res = 0;
        res += memoize!func(current, cnt+1) * countCase(current-2) * countCase(W-current-1);
        if (1 < current) res += memoize!func(current-1, cnt+1) * countCase(current-3) * countCase(W-current-1);
        if (current < W) res += memoize!func(current+1, cnt+1) * countCase(current-2) * countCase(W-current-2);
        return res % N;
    }

    writeln(func(1, 0));
}



Measured memory_bytes: 380
// this code is not mine, I am just testing something
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;
 
using ll=int64_t;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))
 
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}
 
ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}
 
void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}
 
template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}
 
template<class T>
T Sq(const T& t){
	return t*t;
}
 
#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}
 
const ll infLL=LLONG_MAX/3;
 
#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif
 
const int S=5010;
int a[S],dp1[S][S],dp2[S];
vi tr[S];
 
int dfs(int v,int p){
	int s=1;
	if(a[v]>0)
		dp2[v]=0;
	dp1[v][0]=a[v];
	for(auto ch:tr[v])
		if(ch!=p){
			int t=dfs(ch,v);
			{
				int w=dp2[ch];
				REP(i,t)
					if(dp1[ch][i]<0)
						chmin(w,i+1);
				dp2[v]+=w;
				chmin(dp2[v],inf);
			}
			REP(i,t)if(dp1[ch][i]<0)
				chmin(dp1[ch][i+1],0);
			if(dp2[ch]<t)
				chmin(dp1[ch][dp2[ch]+1],0);
			for(int i=s;i>=0;i--){
				int w=dp1[v][i];
				dp1[v][i]=inf;
				REP(j,t+1){
					chmin(dp1[v][i+j],w+dp1[ch][j]);
				}
			}
			s+=t;
		}
	return s;
}
 
 
signed main(){
	int n=read();
	REP(i,n+1){
		REP(j,n+1)
			dp1[i][j]=inf;
		dp2[i]=inf;
	}
	REP(i,n)
		a[i]=read();
	REP(_,n-1){
		int u=read()-1,v=read()-1;
		tr[u].PB(v);
		tr[v].PB(u);
	}
	dfs(0,-1);
	int ans=dp2[0];
	REP(i,n)if(dp1[0][i]<0)
		chmin(ans,i);
	print(ans);
}

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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[5];
string mark = "MARCH";

int main() {
  // 入力
  int N;
  cin >> N;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    string::size_type pos = mark.find(s[0]);
    if (pos == string::npos) continue;
    cnt[pos]++;
  }

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

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut pairs = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        pairs.push((v[0] - 1, v[1]));
    }
    let r_min = pairs.iter().map(|&x| x.1).min().unwrap();
    let l_max = pairs.iter().map(|&x| x.0).max().unwrap();

    let length_max = pairs.iter().map(|&x| x.1 - x.0).max().unwrap();
    let mut ans = length_max + max(0, r_min - l_max);

    pairs.sort_by_key(|x| (x.0, -x.1));

    let mut fl = vec![0; n + 1];
    for i in 0..n {
        fl[i + 1] = max(fl[i], pairs[i].0);
    }
    let mut br = vec![1000_000_000; n + 1];
    for i in 0..n {
        let j = n - 1 - i;
        br[j] = min(br[j + 1], pairs[j].1);
    }
    for i in 1..n {
        let temp = max(0, br[i] - l_max) + max(0, r_min - fl[i]);
        ans = max(ans, temp);
    }
    println!("{}", ans);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int LIS(int N, vector<int>& A){
    int LIS[100100];
    fill(LIS, LIS+N, 1e9);
    int len = 1;
    LIS[0] = A[0];

    for(int i=1;i<N;i++){
        if(LIS[len-1] < A[i]) LIS[len++] = A[i];
        else *lower_bound(LIS, LIS+len, A[i]) = A[i];
    }

    return len;
}

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

    cout << LIS(N,A) << endl;
}



Measured memory_bytes: 4336
N = int(input())
import itertools
TF = [0,1]
All = list(itertools.product(TF, repeat=N))
lis_A = [0]
lis_x = []
lis_y = []
ans = 0
for i in range(N):
  A = int(input())
  lis_A.append(A)
  for j in range(A):
    x,y = map(int,input().split())
    lis_x.append(x-1)
    lis_y.append(y)
for p in range(1,N+1):
  lis_A[p] = lis_A[p-1]+lis_A[p]
for k in range(len(All)):
  L = All[k]
  jud = True
  for g in range(N):
    if L[g] == 1:
      for q in range(lis_A[g],lis_A[g+1]):
        if L[lis_x[q]] != lis_y[q]:
          jud = False
          break
  if jud:
    ans = max(sum(L),ans)
print(ans)


Measured memory_bytes: 10916
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  int cnt1 = 0;
  int cnt2 = 0;
  int cnt4 = 0;
  rep(i, N){
    int a;
    cin >> a;
    if(a % 2 == 0){
      ((a % 4 == 0) ? cnt4 : cnt2)++;
    }else{
      cnt1++;
    }
  }
  bool ans;
  if(cnt2 == 0){
    ans = (cnt1 <= cnt4 + 1);
  }else{
    ans = (cnt1 <= cnt4);
  }
  puts(ans ? "Yes" : "No");
  return 0;
}


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

int main() {
	string S;
	cin>>S;
	if(S.compare("Sunny")==0){
		cout<<"Cloudy";
	}
	else if(S.compare("Cloudy")==0){
		cout<<"Rainy";	
	}
	else{
		cout<<"Sunny";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 200005
#define MAXM 200005

int n, c[MAXN] = {0};

int main()
{
    cin >> n;
    REP(i, 0, n){
        int a;
        cin >> a;
        if(a / 400 >= 8){
            c[8]++;
        }
        else{
            c[a / 400] = 1;
        }
    }
    int ans = 0;
    REP(i, 0, 8){
        ans += c[i];
    }
    if(ans == 0)cout << 1 << " " << c[8] << endl;
    else cout << ans << " " << ans + c[8] << endl;



    return 0;
}
/*
*/





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

int main(){
	int N, K, Q, A, i;
	scanf("%d%d%d", &N, &K, &Q);
	vector<int> V(N, K - Q);
	for(i = 0; i < Q; i++){
		scanf("%d", &A);
		V[A - 1]++;
	}
	for(i = 0; i < N; i++){
		if(V[i] > 0){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    if a<10 and b< 10:
        print(a*b)
    else:
        print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5312
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
    long long x,k=100,count=0;
    cin>>x;
    while(k<x)
    {
      k+=k/100;
      count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3576
W, H, x, y, r = list(map(int, input().split()))

if x <= 0 or y <= 0 or x >= W or y >= H:
    print('No')
    exit()

if x + r > W or y + r > H or x - r < 0 or y - r < 0:
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 5596
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
using namespace std;
//# Functions for Vector/Matrix
template <typename T>
vector<T> zeros(int length){
    vector<T> vec(length, 0);
    return vec;
}
template <typename T>
vector<vector<T>> zeros(tuple<int, int> dim){
    vector<vector<T>> mat(get<0>(dim), vector<T>(get<1>(dim), 0));
    return mat;
}
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define VARNAME(VariableName) # VariableName
template <typename T>
void show(vector<T> &vec){
    cerr << VARNAME(vec) << ": " << endl;
    for (auto value : vec) {
        cerr << value << " ";
    }
    cerr << endl;
}
template <typename T>
void show(vector<vector<T>> &mat){
    for (auto vec : mat) {
        show(vec);
    }
}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
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; }
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }
int dist(int x, int y) { return abs(x - y);}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(){
	// cin.tie(0);
   	// ios::sync_with_stdio(false);
    int A, B, K; cin >> A >> B >> K;
    dump(A); dump(B); dump(K);
    int gcd_AB = gcd(A, B);
    dump(gcd_AB);
    // // gcd_ABを素因数分解して小さい方因数をk個取り除いたものが
    // // 求める数
    // VI x(gcd_AB + 1);
    // int num = gcd_AB;
    // for (int i = 2; i <= gcd_AB; i++) {
	// 	while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
	// 		x.at(i)++; //割った個数を配列に足す
	// 		num /= i;
	// 	}
	// }
    int div = 1; // gcd_ABをK番目に大きな数にするために割る
    for(int i=gcd_AB; i >= 1; i--){
        div = i;
        if(gcd_AB % i == 0) K--;
        if(K == 0) break;
    }
    cout << div;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
S = input()
alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans = ''
for s in S:
  index = alphabet.index(s)
  new_index = index + N if index + N < 26 else index + N - 26
  ans += alphabet[new_index]
print(ans)

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    _, _, X, Y = map(int, input().split())
    max_x = max(map(int, input().split() + [X]))
    min_y = min(map(int, input().split() + [Y]))

    if max_x < min_y:
        print('No War')
    else:
        print('War')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
z = []

if X < Y:
    for i in range(X+1, Y+1):
        z.append(i)
    for Z in z:
        if x[N-1] < Z <= y[0]:
            print('No War')
            exit()
    print('War')
else:
    print('War')


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

 int main(){
   
   int a,b,N;
   cin >> a >> b;
   
   N = a * b;
   
   if ( N % 2 == 0 ){
     cout << "Even" << endl;
   }
   
   else {
     cout << "Odd" << endl;
   }
 }

Measured memory_bytes: 3624
$n = <>;
$s = 0;
@array = ();
for ($i=0; $i<$n; $i++) {
    $x = <>;
    $s += $x;
    if ($x %10 != 0) {
        push @array, $x;
    }
}
@array = sort {$a <=> $b} @array;

if ($s %10 !=0) {
    print $s;
} else {
    if (@array) {
        print ($s-$array[0]);
    } else {
        print 0;
    }
}

Measured memory_bytes: 4720
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let s:Vec<char> = get_input().chars().collect();
    let u:i64 = s[0..2].to_vec().into_iter().collect::<String>().parse().unwrap();
    let d:i64 = s[2..].to_vec().into_iter().collect::<String>().parse().unwrap();

    let mut yymm = false;
    let mut mmyy = false;

    if u >= 0 && 1 <= d && d <= 12 {
        yymm = true;
    }

    if 1 <= u && u <= 12 && d >= 0  {
        mmyy = true;
    }

    let ans = if yymm && mmyy {
        "AMBIGUOUS"
    } else if yymm {
        "YYMM"
    } else if mmyy {
        "MMYY"
    } else {
        "NA"
    };

    println!("{}", ans);
}


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

struct point{
	int x;
	int y;
	int d;
}q[2505];

int n,m,a[55][55],s,t,w,mo[4][2]={1,0,0,1,-1,0,0,-1};
bool v[55][55];

int main(){
	char ch;
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		for (j=1;j<=m;j++){
			cin>>ch;
			if (ch=='.'){
				a[i][j]=0;
				s++;
			}
			else{
				a[i][j]=1;
			}
		}
	}
	t=1;
	w=1;
	q[1].x=1;
	q[1].y=1;
	q[1].d=1;
	v[1][1]=true;
	while (t<=w){
		int xx,yy;
		for (i=0;i<4;i++){
			xx=q[t].x+mo[i][0];
			yy=q[t].y+mo[i][1];
			if (xx>=1 && xx<=n && yy>=1 && yy<=m){
				if (!v[xx][yy] && a[xx][yy]==0){
					w++;
					q[w].x=xx;
					q[w].y=yy;
					v[xx][yy]=true;
					q[w].d=q[t].d+1;
					if (xx==n && yy==m){
						printf("%d",s-q[w].d);
						return 0;
					}
				}
			}
		}
		t++;
	}
	printf("-1");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979

//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N), R(N);
    rep(i, 0, N) cin >> P.at(i);
    rep(i, 0, N) cin >> Q.at(i);
    R = P;
    sort(all(R));
    int a, b;
    int count = 0;
    do{
        count++;
        if (P == R){
            a = count;
        }
        if (Q == R){
            b = count;
        }
    }while(next_permutation(all(R)));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int h,m,s;
    scanf("%d", &s);
    h = s/3600;
    m = (s-(h*3600))/60;
    s = s-(m*60)-(h*3600);
    printf("%d:%d:%d\n", h, m, s );
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
priority_queue<int>q;
int a[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        q.push(a[i]);
    }
    for(int i=0; i<n; i++)
        if(a[i]!=q.top())
            cout<<q.top()<<endl;
    else
    {
        int k=q.top();
        q.pop();
        cout<<q.top()<<endl;
        q.push(k);
    }
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  unordered_map<int, int> mp{};
  REP(i, N) {
    cin >> a[i];
    mp[a[i]]++;
  }
  ll ans = 0;
  for (auto s : mp) {
    if(s.first<=s.second){
      ans += s.second - s.first;
    }else{
      ans += s.second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7552
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define ll long long
#define vpll vector<pair<ll,ll> >
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,b) memset(a , b , sizeof a );
#define M 1000000007
#define bs(a,b,x) binary_search(a,b,x)
template<typename T>
T fact(T n)
{
    // to find factorial
    return (n==1 || n==0) ? 1: n * fact(n - 1);
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
      int a[5];
      for(int i=0;i<5;i++)
      {
          cin>>a[i];
          if(a[i]==0) 
          {
              cout<<i+1<<endl;
              break;
          }
      }
    
    return 0;
}



Measured memory_bytes: 3536
s = input()
head = int(s[0])*10 + int(s[1])
back = int(s[2])*10 + int(s[3])
if(1 <= head and head <= 12 and 1 <= back and back <= 12):
    print('AMBIGUOUS')
elif(0 <= head and 1 <= back and back <= 12):
    print('YYMM')
elif 0 <= back and 1 <= head and head <= 12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a, _, _, _, e, k := nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	if e - a <= k {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

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

  u64 sum = 0;
  for (auto c : n) {
    sum += c - '0';
    sum %= 9;
  }

  if (sum == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
using ii = pair<i64, i64>;
 
vector<ii> hoge;
 
int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int ma_x = x, mi_y = y;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ma_x = max(ma_x, a);
    }
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        mi_y = min(mi_y, a);
    }
    
    cout << (ma_x < mi_y ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 
 
int main()
{
    fastio();
    float n,k; cin>>n; k=n; n/=1.08; 
    if(floor(ceil(n)*1.08)!=k && floor(floor(n)*1.08)!=k) cout<<":(";
    else
    {
        float zk=(floor(ceil(n)*1.08)==k)?ceil(n):floor(n); cout<<zk<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n + 1];
	FOR (i, n)
		cin >> a[i + 1];
	int cnt = 0;
	ffor (i, 1, n + 1)
		if (a[i] < i)
			cnt += a[a[i]] == i;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int N, S;
int i[9];

int saiki(int n);

int main(void) {
	scanf("%d %d", &N, &S);
	while (N != 0 || S != 0) {
		printf("%d\n", saiki(0));
		scanf("%d %d", &N, &S);
	}
	return 0;
}

int saiki(int n) {
	int count = 0;
	int j;
	int x;
	if( n == 0)
		i[n] = 0;
	else
		i[n] = i[n-1] + 1;
		
	for (; i[n] < 10; i[n]++) {
		x = 0;
		if( n == N - 1) {
			for (j = 0; j < N; j++)
				x += i[j];
			if( x == S)
				count++;
		}
		else
			count += saiki(n + 1);
	}
	return count;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
    string S; cin >> S; int N = S.size()-1;
    if(S[N]=='3') cout << "bon" << endl;
    else if(S[N]=='0' || S[N]=='1' || S[N]=='6' || S[N]=='8' ){
        cout << "pon" << endl;
    }
    else cout << "hon" << endl;
}

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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,x;
	cin>>a>>b>>x;
	if (a<=x&&a+b>=x){
		cout<<"YES";
	}
	else {
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int main()
    {
    	int R,G;
    	ios::sync_with_stdio(false);
    	cin>>R>>G;
    	int ans=G+(G-R);
    	cout<<ans<<endl;
    	return 0;
    }

Measured memory_bytes: 256
// ABC155_A
#include <algorithm>
#include <bitset>  // static_cast<std::bitset<8>>
#include <cctype>  // std::isdigit()
#include <climits>  // INT_MIN
#include <cmath>
#include <cstring>  // std::memset
#include <functional>  // std::greater<T>()
#include <iomanip>
#include <iostream>
#include <iterator>
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <sstream>  // std::stringstream
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>  // std::swap()
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll num;
    set<ll> st;
    rep(i, 3) {
        cin >> num;
        st.insert(num);
    }
    
    // calculation
    if (st.size() == 3 || st.size() == 1) {
        cout << "No" << "\n";
    } else {
        cout << "Yes" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool pal(int x)
{
	int sum=0;
	int xx;
	xx=x;
	while(x!=0)
	{
		sum=sum*10+x%10;
		x/=10;
	}
	if(xx==sum)
	return true;
	else
	return false;
}
int main()
{
	int n;
	cin>>n;
	if(pal(n))
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 768
n = int(input())
s = input()

ans = s.count("R") * s.count("G") * s.count("B")
for i in range(n):
    for j in range(i + 1, n):
        d = j - i
        if j + d < n and s[i] != s[j] and s[j] != s[j + d] and s[j + d] != s[i]:
            ans -= 1
print(ans)


Measured memory_bytes: 73184
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader br = null;
        PrintWriter writer = null;
        
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            writer = new PrintWriter(System.out);
            
            String[] inputCoinNum = br.readLine().split(" ");
            int A = Integer.parseInt(inputCoinNum[0]),
                B = Integer.parseInt(inputCoinNum[1]),
                C = Integer.parseInt(inputCoinNum[2]);
            
            writer.println(A + B >= C ? "Yes" : "No");
        }finally{
            if(br != null){
                br.close();
            }
            if(writer != null){
                writer.close();
            }
        }

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using ldouble = long double;

void fnInput(int& rnWide, int& rnHigh, int& rnx, int& rny)
{
  cin >> rnWide >> rnHigh >> rnx >> rny;
}

void fnRectCutArea(int nWide, int nHigh, int nx, int ny)
{
  llong nRectArea = (llong)nWide * nHigh;
  ldouble nRectCutArea = nRectArea / 2.0L;
  cout << nRectCutArea << " ";

  double nCenterx = nWide / 2.0;
  double nCentery = nHigh / 2.0;
  if (nCenterx == nx && nCentery == ny)
    cout << "1" << endl;
  else
    cout << "0" << endl;
}
  
int main()
{
  int nWide, nHigh, nx, ny;

  fnInput(nWide, nHigh, nx, ny);
  fnRectCutArea(nWide, nHigh, nx, ny);

  return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <utility>
#include <queue>
#include <stdio.h>
#include <string>
#include <map>
#include <stack>
#include <complex>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000007
using namespace std;
typedef long long int ll;
typedef complex<double> xy;

int main(){
    vector<xy> inp(21);
    double x,y;
    int n=0;
    string S;
    while (~scanf("%lf,%lf", &x, &y)) {
        inp[n++]=xy(x,y);
    }
    double ans=0.0;
    for (int i=1; i<n-1; i++) {
        xy a = inp[i], b = inp[i+1];
        xy hoge=a-inp[0],piyo=b-inp[0];
        ans += abs((conj(hoge)*piyo).imag())/2.0;
    }
    printf("%.6f\n", ans);
}

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

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

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

  string ans = "None";

  for (int i = 1; i < S.size(); i++) {
    if (S.at(i) - S.at(i - 1) != 1) {
      ans = S.at(i - 1) + 0x01;
      break;
    }
  }

  if (S.size() == 25 && S.at(S.size() - 1) == 'y') ans = "z";

  cout << ((S.at(0) != 'a') ? "a" : ans) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int i,a,b,c,d,e,X=0;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	for(i=0;i<a;i++){
		if(b<=0&&c<=0){
			X++;
		}
		else{
			b-=d;
			c-=e;
		}
	}
	printf("%d\n",X);
	return 0;
}

Measured memory_bytes: 1024
N = str(input())
N_list = [int(x) for x in list(N)]
counter = 0
mae = N_list[0]
for i in range(len(N_list)-1):
    if N_list[i+1]==mae:
        counter +=1
        if mae == 0:
            N_list[i+1]=1
        else:
            N_list[i+1]=0

    mae=N_list[i+1]

print(counter)

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

void solve(){	
	int n, W, V=0;
	cin>>n>>W;
	pair<int, int> arr[n];
	FOR(i, 0, n){
		int w, v;
		cin>>w>>v;
		arr[i] = {w, v};
		V+=v;
	}
	vector<int> dp(V + 1, inf);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j = V;j>=arr[i].S;j--){
			dp[j] = min(dp[j], dp[j-arr[i].S]+arr[i].F);
		}
	}
	int res=0;
    for(int i = 0; i <= V; ++i){
      if(dp[i] <= W){
        res = max(res, i);
      }
    }	
	cout<<res<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 1024
#A - Wanna go back home
S =input()
n = 0
w = 0
s = 0
e = 0
for i in range(len(S)):
    if S[i] == "N":
        n += 1
    elif S[i] == "W":
        w += 1
    elif S[i] == "S":
        s += 1
    else:
        e += 1

#print(n,w,s,e)

if (n > 0 and s == 0) or (s > 0 and n == 0):
    print("No")
elif(w > 0 and e == 0) or (e > 0 and w == 0):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 38384
#include "bits/stdc++.h"

using namespace std;

int eulerPhi(int n)
{
    int ret = n;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            ret -= ret / i;
        while (n % i == 0)
            n /= i;
    }
    if (n > 1)
        ret -= ret / n;
    return ret;
}

int main()
{
    int n;
    cin >> n;
    cout << eulerPhi(n) << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <assert.h>
#include <unordered_map>

using namespace std;

const int maxN = 1e5 + 10;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)
#define PINT pair < int, int >
#define MP make_pair

int n, m, a[maxN], p[maxN], res;

int get_root(int u) {
    return (u == p[u]) ? u : (p[u] = get_root(p[u]));
}

int main() {
    cin >> n >> m;
    FORU(i, 1, n) p[i] = i, cin >> a[i];
    FORU(i, 1, m) {
        int u, v; cin >> u >> v;
        int ru = get_root(u);
        int rv = get_root(v);
        if (ru != rv) p[ru] = rv;
    }
    FORU(i, 1, n)
        if (get_root(i) == get_root(a[i])) ++res;
    cout << res;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  for(int i=0;i<1000;i++){
    if(i%2==0){
      if(b>=c){
        cout << "Yes";
        return 0;
      }
      c-= b;
    }
    else{
      if(d>=a){
        cout << "No";
        return 0;
      }
      a -= d;
    }
  }
  
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int n; cin>>n;
    double ans1=0,ans2=0;
    while(n--){
        double x; cin>>x;
        string s; cin>>s;
        if(s=="JPY") ans1+=x;
        else ans2+=x;
    }

    cout << fixed << setprecision(10) << ans1+ans2*380000 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
bool compare(int a,int b)
{
return a>b;
}
int main(){
	long double  a,b,c,e,f,g;
	cin>>a>>b>>c;
	int n=0;
	while(n<100000){
		n++;
		e=a;g=b;f=c;
		if((int)a%2!=0||(int)b%2!=0||(int)c%2!=0){
			cout<<--n<<endl;
			break;
		}
			
		a=(g+f)/2.0;
		b=(e+f)/2.0;
		c=(e+g)/2.0;
		if(a>(int)a||b>(int)b||c>(int)c){
			n--;
			cout<<n<<endl;
			break;
		}
			
	}
	if(n==100000)
		printf("-1\n");
	return 0;
}

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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int A, B, Q;
vector<ll> s, t, x;

ll solve(ll x){
  auto ite1 = lower_bound(s.begin(), s.end(), x);
  auto ite2 = lower_bound(t.begin(), t.end(), x);
  // cerr << "------------------------------" << endl;
  // cerr << "x: " << x << " ite1:" << *ite1 << " ite2:" << *ite2 << " " << *(t.begin()) << endl;
  // if(t.begin() == ite2){
  //   cout << "t.begin() == ite2" << endl;
  // }
  // if(s.begin() == ite1){
  //   cout << "s.begin() == ite1" << endl;
  // }
  ll ans = (ll)1 << 62;
  if(ite1 != s.end() && ite2 != t.end()){
    ans = max(*ite1 - x, *ite2 - x);
    // cerr << ans << " ";
  }
  if(ite1 != s.begin() && ite2 != t.begin()){
    ll d = max(x - *(ite1-1), x - *(ite2-1));
    ans = min(ans, d);
    // cerr << d << " ";
  }
  if(ite1 != s.begin() && ite2 != t.end()){
    ll d= min(x-*(ite1-1), *ite2-x) * 2 + max(x-*(ite1-1), *ite2-x);
    ans = min(ans, d);
    // cerr << d << " ";
  }
  if(ite1 != s.end() && ite2 != t.begin()){
    ll d = min(*ite1 - x, x - *(ite2-1)) * 2 + max(*ite1 - x, x - *(ite2-1));
    ans = min(ans, d);
    // cerr << d << endl;
  }
  return ans;
}

int main(){
  cin >> A >> B >> Q;
  s.resize(A), t.resize(B), x.resize(Q);
  REP(i, A){
    cin >> s[i];
  }
  REP(i, B){
    cin >> t[i];
  }
  REP(i, Q){
    cin >> x[i];
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  REP(i, Q){
    cout << solve(x[i]) << endl;
  }


  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
const int MOD(1e9 + 7);
int n, v[200005], s, res;
int powlog(int baza, int exp)
{
    int rez = 1;
    while (exp)
    {
        if(exp % 2 == 1)
            rez = rez * baza % MOD;
        baza = baza * baza % MOD;
        exp /= 2;
    }
    return rez;
}
main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        s += v[i];
    }
    for (int i = 1; i <= n; ++i)
        (res += ((s - v[i]) % MOD * v[i])) %= MOD;
    (res *= powlog(2, MOD - 2)) %= MOD;
    cout << res;
    PLEC
}


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

int main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k - 1; i++) {
		cout << i << " ";
	}
	cout << x + k - 1;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, m, p;
    cin >> n >> m >> p;
    if(n == 0) break;
    m--;
    int s = 0;
    int mx = 0;
    for(int i = 0; i < n; i++) {
      int x;
      cin >> x;
      s += x;
      if(i == m) {
        mx = x;
      }
    }
    s *= (100-p);
    cout << (mx == 0 ? 0 : (s/mx)) << endl;
  }
  return 0;
}



Measured memory_bytes: 2996
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
	string S;
	cin >> S;
	int N =S.size();

	ll ans = 0;
	ll cnt = 0;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='B'){
			ans+= N-1-i-cnt;
			cnt++;
		}
	}

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



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

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

using namespace std;

int main(){
  ll n,m;cin>>n>>m;
  map<ll, ll> c;
  ll ac=0,wc=0;
  rep(i,n)c[i+1]=0;
  rep(i,m){
    ll p;cin>>p;
    string r;cin>>r;
    if(r=="AC"){
      if(c[p]!=-1){
        ac++;
        wc+=c[p];
      }
      c[p]=-1;
    }else{
      if(c[p]!=-1)c[p]++;
    }
  }

  cout<<ac<<' '<<wc;

  return 0;
}

Measured memory_bytes: 6528
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    a: [usize; 3]
    }
    let ans = if a.iter().sum::<usize>() >= 22 {"bust"} else {"win"};
    println!("{}", ans);
}


Measured memory_bytes: 2168
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int k = sc.nextInt();
		int[] x=new int[n*m];
		int l = 0;
		for(int t=1;t<=k;t++){
			int u=sc.nextInt();
			for(int i=0;i<u;i++){
				x[l] = t;
				l++;
			}
		}
		l = 0;
		int[][] y=new int[n][m];
		for(int i=0;i<n;i++){
			if(i%2==0){
				for(int j=0;j<m;j++){
					y[i][j] = x[l];
					l++;
				}
			}
			else{
				for(int j=m-1;j>=0;j--){
					y[i][j] = x[l];
					l++;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				System.out.print(y[i][j]+" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 31768
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
s = 0 
def main():
    n, k = map(int, readline().split())
    a = [int(i)-1 for i in readline().split()]
    done = [0 for _ in range(n)] 
    cycle = []
    def dfs(x):
        global s
        if done[x] == 1:
            s = x
            return
        nx = a[x]
        done[x] = 1
        cycle.append(x)
        dfs(nx)

    dfs(0)
    start_idx = cycle.index(s)
    ln = len(cycle)
    if k < ln: 
        print(cycle[k]+1)
    else:
        k -= start_idx
        idx = start_idx+(k%(ln-start_idx))
        print(cycle[idx]+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 236464
import copy

n, m = map(int, input().split())
ks_ls = []
count = 0
while count < m:
    ks_ls.append(list(map(int, input().split())))
    count = count + 1
p_ls = list(map(int, input().split()))

all_pattern = []
hoge = [0]
hoge2 = [1]
all_pattern.append(hoge)
all_pattern.append(hoge2)
count2 = 0
while count2 < n-1:
    temp = []
    for s in all_pattern:
        hoge3 = s
        hoge4 = copy.deepcopy(s)
        hoge3.append(0)
        hoge4.append(1)
        temp.append(hoge3)
        temp.append(hoge4)
    count2 = count2 + 1
    all_pattern = temp
result = []
for i in all_pattern:
    ok_flg = True
    for index2, j in enumerate(ks_ls):
        sum = 0
        for index, k in enumerate(j):
            if index == 0:
              continue
            sum = sum + i[k-1]
        if sum%2 != p_ls[index2]:
            ok_flg = False
    if ok_flg :
        result.append(i)
print(len(result))


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    LL l;cin >> l;
    vector<LL> a(n);
    inc(i, 0, n) cin >> a[i];
    vector<int> ans;
    inc(i, 0, n-1){
        if(a[i]+a[i+1] >= l){
            ans.push_back(i);
            for(int j=i-1;j>=0;j--) ans.push_back(j);
            for(int j=i+1;j<n-1;j++) ans.push_back(j);
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    if(ans.size()){
        cout << "Possible" << endl;
        for(auto a : ans){
            cout << a+1 << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#include<vector>
#define elif else if
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
int N;

int main(){
    int K;
    cin>>N>>K;
    int idx_one = 0;
    int A[TENFIVE];
    rep(i,N){
        cin>>A[i];
        if(A[i]==1)idx_one = i;

    }
    int ans = 1;
    N = N-K;
    ans += N/(K-1);        
    if(N % (K-1) !=0 )ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640