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

int main(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d||abs(c-b)<=d&&abs(b-a)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;






    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	vector<string> v1;
	int n, counter = 1;
	cin >> n;
	for(int i = 0; i < n; i++){
		string a;
		cin >> a;
		v1.pb(a);
	}
	sort(all(v1));

	for(int i = 1; i < n; i++){
		if(v1[i] != v1[i - 1]){
			counter++;
		}
	}

	cout << counter;

} 

Measured memory_bytes: 11596
#include<bits/stdc++.h>
#define int long long
using namespace std;
int h,w,m,aa,ab,p[300010],q[300010],ans=0;
map <long long,int> mp;
signed main()
{
	cin>>h>>w>>m;
	for (int i=h;i>=1;i--) p[i]=i;
	for (int j=w;j>=1;j--) q[j]=j;
	for (int i=1;i<=m;i++)
	{
		scanf("%lld%lld",&aa,&ab);
		mp[aa*300001+ab]++;
		p[aa]+=300001;
		q[ab]+=300001;
	}
	sort(p+1,p+h+1);
	sort(q+1,q+w+1);
	for (int i=h;i>=1;i--) 
	{
		for (int j=w;j>=1;j--) 
		{
			if (mp[(p[i]%300001)*300001+q[j]%300001]==0) {cout<<p[i]/300001+q[j]/300001<<endl;return 0;}
			else ans=p[i]/300001+q[j]/300001-1;
			if (q[j]/300001>q[j-1]/300001) break;
		}
		if (p[i]/300001>p[i-1]/300001) break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 27176
/*
Vim shortcuts:
  :pc -> close scratch window
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;

int N,x;
int a[110];
int main(int argc, char **argv, char **envp) {
  cin >> N >> x;
  REP(i,N) {
    cin >> a[i];
  }
  sort(a,a+N);
  int ans=0;
  REP(i,N) {
    x-=a[i];
    ans++;
    if (x<=0) {
      break;
    }
  }
  if (x!=0) ans--;
  cout << ans<<endl;
  return 0;
}


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


const int maxn = 1e5 + 5;
long long sq[maxn];
int main(){
    int t;
    std::cin >> t;
    long long ret = 0;
    for(int i =1 ;i <= t ;++ i) std::cin >> sq[i];
    long long mn = sq[1] > 0 ? sq[1]: -sq[1];
    auto min = [](long long x, long long y) -> long long{return x < y ? x :y;};
    auto abs = [](long long x) -> long long {return x > 0 ? x : -x;};
    for(int i = 1 ; i<= t ; ++ i) {
        mn = min(abs(sq[i]),mn);
        ret += abs(sq[i]);
    }
    for(int i = 1; i <= t- 1; ++ i) {
        if (sq[i] < 0) {
            sq[i] = -sq[i];
            sq[i + 1] = -sq[i + 1];
        }
    }
    if(sq[t] < 0) ret = ret - mn - mn;
    return !(std::cout << ret << std::endl);
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
int a,b;
while(true){
cin >> a >> b;
if(a==0&&b==0)break;
if(a<b){
cout << a << " " << b <<endl;
}else{
cout << b << " " << a <<endl;
}
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int A, B;
	cin >> A >> B;
	int ans = -pow(10, 9);
	ans = max(ans, A + B);
	ans = max(ans, A - B);
	ans = max(ans, A * B);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int dim(int a,int b){
	return (a > b) ? 0 : (b-a);
}

int check(int *data,int *num,int p){
	int i,n;

	n = 0;
	for(i = 0;i < 8;i++){
		n += dim(data[(i+p)%8],num[i]);
	}

	return n;
}

int main(){
	int i,j,min,n,num,tmp,ans;
	int p[8],c[8];

	while(scanf("%d",&p[0]) != EOF){
		min = p[0];
		c[0] = 1;
		num = 2121414;
		for(i = 1;i < 8;i++){
			scanf("%d",&p[i]);
			min += p[i];
			c[i] = num%10;
			num /= 10;
		}

		for(i = 0;i < 8;i++){
			n = check(c,p,i);
			tmp = 0;
			for(j = 0;j < 8;j++){
				tmp *= 10;
				tmp += c[(i+j)%8];
			}

			if(min > n){
				min = n;
				num = tmp;
				ans = i;
			}else if(min == n){
				if(num > tmp){
					num = tmp;
					ans = i;
				}
			}
		}

		for(j = 0;j < 8;j++){
			printf("%d%c",c[(ans+j)%8],(j == 7) ? '\n' : ' ');
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n;
int ans = 0;

void dfs(int val, int three, int five, int seven){
    if(val > n) return;
    if(three >= 1 && five >= 1 && seven >= 1) ans++;


    dfs(val * 10 + 3, three + 1, five, seven);
    dfs(val * 10 + 5, three, five + 1, seven);
    dfs(val * 10 + 7, three, five, seven + 1);
}

signed main() {
    cin >> n;

    dfs(0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
x=list(map(int, input().split()))
if x[1]==0:
  print(x[0])
else:
  p=list(map(int, input().split()))
  i=0
  while True:
    if p.count(x[0]-i)==0:
      print(x[0]-i)
      break
    elif p.count(x[0]+i)==0:
      print(x[0]+i)
      break
    else:
      i+=1

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

int main()
{
    int A, B;
    int j=0;
    cin >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10)
        {
            j++;
        }
    }
    cout << j << endl;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector < vector<int>> C(H, vector<int>(W));
	int index = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w <W; ++w) {
			if (h & 1) {
				C[h][W-w-1] = index + 1;
			}
			else {
				C[h][w] = index + 1;
			}
			A[index]--;
			if (A[index] == 0) {
				index++;
			}
		}
	}
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (w)cout << " ";
			cout << C[h][w];
		}
		cout << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

typedef long long LL;
void rec(LL n, LL mx);
int sichigosan();
vector<LL>v;

int main() {
  LL n;
  cin >> n;
  rec(0, n);
  
  cout << sichigosan() << endl;
  return 0;
}

void rec(LL n, LL mx) {
  if(n > mx) {
    return;
  }
  v.push_back(n);
  rec(n * 10 + 3, mx);
  rec(n * 10 + 5, mx);
  rec(n * 10 + 7, mx);
  
  return;
}

int sichigosan() {
  int cnt = 0;
  
  for(int i = 0; i < v.size(); ++i) {
    int n, g, s;
    LL tmp = v[i];
    n = g = s = 0;
    while(tmp > 0) {
      LL t = tmp % 10;
      if(t == 7) ++n;
      if(t == 5) ++g;
      if(t == 3) ++s;
      tmp /= 10;
    }
    if(n && g && s) ++cnt;
  }

  return cnt;
}



Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e6+5;
int ch[N][3],n,m,t,cnt,ans[N];
bool tg[N];
char s[N];

void build(int x,int v,int fl,int pw){
	if(fl==n) return ;
	for(int i=0;i<3;i++) ch[x][i]=fl+1<n?++cnt:v+i*pw,build(fl+1<n?cnt:v+i*pw,v+i*pw,fl+1,pw*3);
}

void dfs(int x,int v,int fl,int pw){
	if(fl==n){
		ans[x]=v;
		return ;
	}
	if(tg[x]) swap(ch[x][1],ch[x][2]);
	for(int i=0;i<3;i++) tg[ch[x][i]]^=tg[x]; tg[x]=0;
	for(int i=0;i<3;i++) dfs(ch[x][i],v+i*pw,fl+1,pw*3);
}

void upr(int x,int fl){
	if(fl==n) return ;
	if(tg[x]) swap(ch[x][1],ch[x][2]);
	for(int i=0;i<3;i++) tg[ch[x][i]]^=tg[x]; tg[x]=0;
	swap(ch[x][1],ch[x][2]);
	swap(ch[x][0],ch[x][1]);
	upr(ch[x][0],fl+1);
}

void ups(){
	tg[m]^=1;
}

signed main(){
	read(n);
	scanf("%s",s+1);
	t=strlen(s+1);
	m=1; for(int i=1;i<=n;i++) m*=3;
	build(cnt=m,0,0,1);
	for(int i=1;i<=t;i++) if(s[i]=='R') upr(m,0); else ups();
	dfs(m,0,0,1);
	for(int i=0;i<m;i++) write(ans[i]),putchar(' ');
}

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

LL x, ans = 0;

int main(){
	scanf("%lld", &x);
	ans = x/11*2;
	x %= 11;
	if (x >= 7) ans += 2;
	else if (x >= 1) ans++;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {
  private static class Tuple {
    public final int a;
    public final long b;
    public Tuple(int a, long b) {
      this.a = a;
      this.b = b;
    }
  }
  public static void main(String[] args) throws Throwable {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    long K = scanner.nextLong();
    Tuple[] ab = new Tuple[N];
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      ab[i] = new Tuple(a, b);
    }
    Arrays.sort(ab, (x, y) -> Integer.compare(x.a, y.a));

    Integer lastA = null;
    long k = 0;
    for (int i = 0; k < K && i < N; i++) {
      k += ab[i].b;
      lastA = ab[i].a;
    }

    System.out.println(lastA);
  }
}

Measured memory_bytes: 96916
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
ll ans=0;
int n,m,q,a[100][4];
vector<int> v;
inline void recurse(int len)
{
	if(len==n)
	{
		ll res=0;
		for(int i=0;i<q;i++)
		{
			if(v[a[i][1]]-v[a[i][0]]==a[i][2])
			{
				res+=a[i][3];
			}
		}
		ans=max(ans,res);
		return;
	}
	int prev=1;
	if(!v.empty())
	{
		prev=v.back();
	}
	for(int i=prev;i<=m;i++)
	{
		v.push_back(i);
		recurse(len+1);
		v.pop_back();
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	for(int i=0;i<q;i++)
	{
		for(int j=0;j<4;j++)
		{
			cin>>a[i][j];
			if(j<2)
			{
				a[i][j]--;
			}
		}
	}
	recurse(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3656
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();

    println!("{}",( s.iter().filter(|x| **x == '+').count()*2) as i32 - s.len() as i32);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
using namespace std;

const int MAX_N = 2e5+ 6;

int _[MAX_N],__[MAX_N];

int main () {
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=1;m>=i;i++) {
		int a,b;
		scanf("%d %d",&a,&b);
		if (a==1) _[b]=1;
		if (b==n) __[a]=1;
	}
	string ans="IMPOSSIBLE";
	for (int i=2;n>i;i++) {
		if (_[i] && __[i]) ans="POSSIBLE";
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   vector <ll> arr(5);
   for (int z=0;z<5;z++){
      cin >> arr[z];
      if (arr[z] == 0) cout << z+1 << endl;
   }
} 

Measured memory_bytes: 3644
n = int(input())
h = [int(i) for i in input().split()]
c = 0
for i in range(n):
    d = 0
    for j in range(0,i + 1):
        if h[i] >= h[j]:
            d += 1
    if d == i + 1:
        c += 1
print(c)            


Measured memory_bytes: 3060
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int a[] = { 1,3,5,7,8,10,12 };

bool flag1 = false, flag2 = false;

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

	for (int i = 0; i < 7; i++) {
		if (a[i] == x)
			flag1 = true;
		if (a[i] == y)
			flag2 = true;
	}

	if (flag1 == flag2 && x != 2 && y != 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  bool check=true;
  for(int i=0;i<n;i++){
    if(a[i]>i){
      check=false;
    }
    if(i<n-1&&a[i+1]-a[i]>1){
      check=false;
    }
  }
  if(!check){
    cout << -1 << endl;
  }
  else{
    ll ans=a[n-1];
    for(int i=n-2;i>=0;i--){
      if(a[i]>=a[i+1]){
        ans+=a[i];
      }
    }
    cout << ans << endl;
  }
}
      

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int d[6];

void N()
{
  int tmp=d[0];
  d[0]=d[1];
  d[1]=d[5];
  d[5]=d[4];
  d[4]=tmp;
}
void E()
{
  int tmp=d[0];
  d[0]=d[3];
  d[3]=d[5];
  d[5]=d[2];
  d[2]=tmp;
}
void S()
{
  int tmp=d[0];
  d[0]=d[4];
  d[4]=d[5];
  d[5]=d[1];
  d[1]=tmp;
}
void W()
{
  int tmp=d[0];
  d[0]=d[2];
  d[2]=d[5];
  d[5]=d[3];
  d[3]=tmp;
}
void T()
{
  int tmp=d[1];
  d[1]=d[2];
  d[2]=d[4];
  d[4]=d[3];
  d[3]=tmp;
}
int main(){
  for (int i = 0; i < 6; ++i) cin>>d[i];
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    int a,b;
    cin>>a>>b;
    if(a==d[1]) N();
    else if(a==d[4]) S();
    while(a!=d[0]) E();
    while(b!=d[1]) T();
    cout<<d[2]<<endl;
  }
}


Measured memory_bytes: 3096
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	if (n % 100 > 0 && n % 100 < 13 && n / 100 > 0 && n / 100 < 13)printf("AMBIGUOUS\n");
	else if (n % 100 > 0 && n % 100 < 13)printf("YYMM\n");
	else if (n / 100 > 0 && n / 100 < 13)printf("MMYY\n");
	else printf("NA\n");

	Please AC;
}


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

int main(){
    int n,k,now;
    double ans = 0.0;
    double one_n,temp;
    cin >> n >> k;
    one_n = 1.0 / n;

    for (int i = 1; i <= n; i++) {
        now = i;
        temp = one_n;
        while ( now < k ) {
            now *= 2.0;
            temp /= 2.0;
        }
        ans += temp;
    }

    cout << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
ABCD = list(input())

plus_minus = ["+", "-"]
for op1 in plus_minus:
    for op2 in plus_minus:
        for op3 in plus_minus:
            formula = ABCD[0] + op1 + ABCD[1] + op2 + ABCD[2] + op3 + ABCD[3]
            if eval(formula) == 7:
                print(formula + "=7")
                exit()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI acos(-1.0)
#define test() int t; cin>>t; while(t--)
#define ll long long int
int mod = 1e9 + 7;
int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a;
	long double b;
	cin >> a >> b;
	ll ans = round(b * 100);
	ans = (a * ans) / 100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var n = p[0].ToInt();
		var m = p[1].ToInt();
		var k = p[2].ToLong();
		var a = new long[n];
		var b = new long[m];
		var aw = new long[n+1];
		var bw = new long[m+1];
		p = Input();
		long max = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = p[i].ToLong();
			aw[i+1] = aw[i] + a[i];
		}
		p = Input();
		for(int i = 0; i < m; i++)
		{
			b[i] = p[i].ToLong();
			bw[i+1] = bw[i] + b[i];
		}
		
		for(int i = 0; i <= n; i++)
		{
			var pt = k - aw[i];
			if(pt < 0)
				continue;
			var q = UpperBound(bw, pt);
			//Console.WriteLine("{0} {1} {2} {3}", pt, q, i+q, bw[q-1]);
			max = Math.Max(i + q-1, max);
		}
		
		for(int i = 0; i <= m; i++)
		{
			var pt = k - bw[i];
			if(pt < 0)
			
				continue;
			
			var q = UpperBound(aw, pt);
			max = Math.Max(i + q-1, max);
		}
		
		Console.WriteLine(max);
		
	}
	
	public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
	{
	    int low = start;
	    int high = end;
	    int mid;
	    while (low < high)
	    {
	        mid = ((high - low) >> 1) + low;
	        if (comparer.Compare(arr[mid], value) <= 0)
	            low = mid + 1;
	        else
	            high = mid;
	    }
	    return low;
	}

	//引数省略のオーバーロード
	public static int UpperBound<T>(T[] arr, T value)
	{
	    return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 64732
#include<iostream>
#include<string>
#include<cmath>
#include<map>
#include<vector>

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

int main(){
int N; cin >> N; ll ans = 1;
  
  vector<ll> mp(N + 10,0);
  
  vector<ll> prime;
  
  for(ll i = 2; i <= N; i++){ //N以下の素数を列挙する
    bool flag = true; ll c = (ll) sqrt((double) i);
    for(ll j = 2; j <= c; j++){
      if( i % j == 0){ flag = false;}}
    //iが√iまでのいずれかの数字で割り切れたら、iは素数ではない
    if(flag){ prime.push_back(i);}
  }
  
  int s = prime.size() ;
  for(ll i = 1; i <= N; i++){ //N以下の数を全て素因数分解
    for(int j = 0; j < s; j++){
      ll Quote = prime[j]; //iがQuoteで何回割れるのか調べる(Quoteは列挙した全ての素数を動く)
      ll k = i;
      while( k % Quote == 0){ k /= Quote; mp[Quote]++;}
    } //i の素因数分解終了
  }
  
  
  

  
  for(int k = 0; k <= N; k++){
    ans *= ( mp[k] + 1 );  ans %= MOD;}
  
  cout << ans << endl; return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d %d %d",&a,&b,&c);
	printf("%d %d %d\n",c,a,b);
	return 0;
} 

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<int> al(n);
	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		al[i] = a;
		int pre = 0;
		if (i - 1 >= 0) {
			pre = al[i - 1];
		}
		sum += abs(a - pre);
	}
	sum += abs(al[n - 1]);
	rep(i, n) {
		int tmp = sum;
		int pre = 0;
		int next = 0;
		if (i - 1 >= 0) {
			pre = al[i - 1];
		}
		if (i + 1 < n) {
			next = al[i + 1];
		}
		tmp -= abs(pre - al[i]);
		tmp -= abs(al[i] - next);
		tmp += abs(pre - next);
		cout << tmp << endl;
	}
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



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

S = [input() for _ in range(N)]
PS = sorted(["".join([c + str(s.count(c)) for c in sorted(list(set(s)))]) for s in S])

t = 0
i = 0
while i < len(PS):
    j = i + 1
    while j < len(PS) and PS[j] == PS[i]:
        j += 1
    n = j - i

    t += n * (n - 1) // 2

    i = j

print(t)

Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 764
import java.util.Scanner;
import java.util.HashMap;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String,Integer> map=new HashMap<>();
		int ans=0;
		for(int i = 0; i<n; i++){
			String a=sc.next();
			if(map.containsKey(a)){
				map.put(a,map.get(a)+1);
			}else{
				map.put(a,1);
			}
		}
		int m = sc.nextInt();
		for(int i = 0; i<m; i++){
			String b=sc.next();
			if(map.containsKey(b)){
				map.put(b,map.get(b)-1);
			}else{
				map.put(b,-1);
			}
		}
		for(String i:map.keySet()){
			if(ans<map.get(i)){
				ans=map.get(i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar Yasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt();
            int mask = 0;
            boolean ok = false;
            int num = 0;
            while (n-- > 0) {
                int rating = sc.nextInt();
                if (rating >= 1 && rating <= 399) {
                    mask |= 1;
                } else if (rating >= 400 && rating <= 799) {
                    mask |= 2;
                } else if (rating >= 800 && rating <= 1199) {
                    mask |= 4;
                } else if (rating >= 1200 && rating <= 1599) {
                    mask |= 8;
                } else if (rating >= 1600 && rating <= 1999) {
                    mask |= 16;
                } else if (rating >= 2000 && rating <= 2399) {
                    mask |= 32;
                } else if (rating >= 2400 && rating <= 2799) {
                    mask |= 64;
                } else if (rating >= 2800 && rating <= 3199) {
                    mask |= 128;
                } else {
                    num++;
                    ok = true;
                }
            }
            int res = 0;
            for (int i = 0; i <= 7; i++)
                if ((mask & (1 << i)) != 0) res++;
            out.print(ok ? Math.max(1, res) : res);
            out.println(" " + (res + num));
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let mut ans = 0_usize;
    let a = input_vector::<usize>();
    for i in 0..n {
        if i == a[a[i] - 1] - 1 {
            ans += 1;
        }
    }
    println!("{}", ans / 2);
}


Measured memory_bytes: 6396
import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Scanner;
     
    public class Main {
        public static void main(String[] args) {
            TestCase testCase = readFromInput();
     
            int number = findNumber(testCase);
     
            output(number);
        }
     
        private static TestCase readFromInput() {
            Scanner sc = new Scanner(System.in);
            final int N = sc.nextInt();
            final int M = sc.nextInt();
     
            List<List<Integer>> A = new ArrayList<>();
            for (int i = 0; i < N; ++i) {
                int K = sc.nextInt();
                List<Integer> AN = new ArrayList<>();
                for (int j = 0; j < K; ++j) {
                    AN.add(sc.nextInt());
                }
                A.add(AN);
            }
     
            sc.close();
     
            return new TestCase(N, M, A);
        }
     
        public static int findNumber(TestCase testCase) {
            int[] counts = new int[testCase.M];
            Arrays.fill(counts, testCase.N);
     
            testCase.A.forEach(AN -> AN.forEach(A -> counts[A - 1]--));
     
            return countNumberAllLiked(counts);
        }
     
        private static int countNumberAllLiked(int[] counts) {
            int number = 0;
            for (int i : counts) {
                if (i == 0) {
                    number++;
                }
            }
            return number;
        }
     
        private static void output(int i) {
            System.out.println(i);
        }
     
        public static class TestCase {
            final int N, M;
            final List<List<Integer>> A;
     
            public TestCase(int N, int M, List<List<Integer>> A) {
                this.N = N;
                this.M = M;
                this.A = A;
            }
        }
     
    }

Measured memory_bytes: 28620
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($a, $b) = split / /, <STDIN>);
if ($a>0) {
  say 'Positive';
} elsif ($a<=0 && 0<=$b) {
  say 'Zero';
} elsif (($b-$a)%2==0) {
  say 'Negative';
} else {
  say 'Positive';
}

Measured memory_bytes: 768
n=int(input())
a=int(n//100)
b=int(n%10)
c=int((n-100*a-b)//10)
#print(c)
ans=0
if a==7:
  ans+=1
if b==7:
  ans+=1
if c==7:
  ans+=1
if ans==0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC080B solver = new ABC080B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC080B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            out.println(N % f(N) == 0 ? "Yes" : "No");

        }

        private int f(int n) {
            int sum = 0;
            while (n > 0) {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};


//BIT [1,n]
const int MAX_N = 202020;
int bit[MAX_N + 1], n = 202020;

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x) {
  while (i <= n) {
    bit[i] += x;
    i += i & -i;
  }
}


int N, M;
vint lis[101010];

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> N >> M;
  REP(i,N) {
    int l, r;
    cin >> l >> r;
    r++;
    lis[r-l].pb(l);
  }

  int latte = N;
  for (int d=1; d<=M; d++) {
    for (auto l : lis[d]) {
      int r = l + d;
      add(r, -1);
      add(l, 1);
    }
    latte -= lis[d].size();
    int ans = latte;
    for (int x=d; x<=M; x+=d) ans += sum(x);
    cout << ans << endl;
  }
}

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a % b << " " << setprecision(6) << fixed << double(a) / b << endl;
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define Cerr(x) cerr << (x) << endl
#define fi first
#define se second

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl, check[10];
struct edge
{
    int to, cost;
};
string dp[ohara];
ll need[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n >> m;
    rep(i, m) cin >> a[i], check[a[i]] = true;

    dp[0] = "";
    rep(i, n)
    {
        rep(j, 10)
        {
            if (check[j] == false || (i != 0 && dp[i].size() == 0))continue;

            string s = dp[i + need[j - 1]];
            string com = (dp[i] + char('0' + j));

            int s_big;
            if (Size(s) > Size(com))s_big = 1;
            else if (Size(s) < Size(com))s_big = 0;
            else
            {
                if (s > com)s_big = 1;
                else s_big = 0;
            }

            if (s_big == 0)
            {
                dp[i + need[j - 1]] = dp[i] + char('0' + j);
            }
        }
    }
    Cout(dp[n]);
    return 0;
}


Measured memory_bytes: 55808
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String a=sc.next();
    String b=sc.next();
    String c=sc.next();
    System.out.println((a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0))?"YES":"NO");
  }
}

Measured memory_bytes: 21844
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define sz(x) (int)x.size()

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e9+7;
const ll N = 1e5+1;
const ll mod = 1e9+7;
const ll P = 31;

int main() {
    IOS
    ll a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    while(d--){
        if(a > 0) {
            a--;
            ans++;
        }
        else if(b > 0){
            b--;
        }
        else if(c> 0) {
            c--;
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const firstLine = input[0].split(" ").map((v) => parseInt(v, 10));
const N = firstLine[0];
const M = firstLine[1];

const P = input[M + 1].split(" ").map((v) => parseInt(v, 10));

const lines = [];

for (let i = 1; i <= M; i++) {
  lines.push(input[i].split(" ").map((v) => parseInt(v, 10)));
}

function search(switches) {
  if (switches.length === N) {
    for (let i = 0; i < M; i++) {
      const line = lines[i];
      let on = 0;

      for (let j = 1; j <= line[0]; j++) {
        if (switches[line[j] - 1]) { on++; }
      }

      if (on % 2 !== P[i]) { return 0; }
    }

    return 1;
  }

  return search([...switches, 0]) + search([...switches, 1]);
}

console.log(search([]));


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll start[n];
    ll endd[n];
    REP(i,n){
        cin>>start[i]>>endd[i];
    }
    sort(start,start+n);
    sort(endd,endd+n);
    if(n & 1){
        ll med1=start[n/2];
        ll med2=endd[n/2];
        cout<<med2-med1+1<<endl;

    }
    else{
        ll med1=start[n/2-1]+start[n/2];
        ll med2=endd[n/2-1]+endd[n/2];
        cout<<med2-med1+1<<endl;
    }
}


Measured memory_bytes: 6736
import java.math.BigInteger;
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		boolean longerThanHeight = w > h;
		int ans = 0;
		
		if(longerThanHeight) {
			
			ans = n / w + 1;
			ans  = n % w == 0 ? ans -1: ans;
		} else {
			ans = n / h + 1;
			ans  = n % h == 0 ? ans -1: ans;
		}


		
		
		System.out.println(ans);
		
		
		
		

		
		
	}

}

 

Measured memory_bytes: 21716
#include<cstdio>

using namespace std;

int main(){
    char s[3][4];
    for(int i = 0; i < 3; i++){
        scanf("%s", s[i]);
        
    }
    for(int i = 0; i < 3; i++){
        printf("%c", s[i][i]);
    }
    
    
    puts("");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int flag = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    string color;
    cin >> color;
     if(color == "Y"){
       flag = 1;
     }
  }
  
  if(flag == 1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
function main(input) {
  var str = input.split("\n");
  switch (str[0]) {
    case "A":
      console.log("T")
      break;
    case "C":
      console.log("G")
      break;
    case "G":
      console.log("C")
      break;
    case "T":
      console.log("A")
      break;
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef pair<int, int> P;

int const MAX_N  = 10000;
int N, M;
P piles[MAX_N];

double distance(int x0, int y0, int x1, int y1) {
    return hypot(x1-x0, y1-y0);
}

// O(E*log(V))
struct Edge {
    Edge(int a, int b, double c) {
        u = a; v = b; cost = c;
    }
    int u, v;
    double cost;
};

bool comp(const Edge& e1, const Edge& e2) {
    return e1.cost < e2.cost;
}

struct UF{
    vector<int> par;
    UF(int m) : par(m){
        for(int i = 0; i < m; i++){
            par[i] = i;
        }
    }
    int find(int x){
        return x != par[x] ? par[x] = find(par[x]) : x;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    void unite(int x, int y){
        // y is above
        if(!same(x, y)) par[find(x)] = find(y);
    }
};

double kruskal(int V, vector<Edge>& es) {
    sort(es.begin(), es.end(), comp);
    UF uf(V);
    double res = 0;
    for(int i = es.size()-1; i >= 0; i--) {
        Edge e = es[i];
        if(!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
        } else {
            res += e.cost;
        }
    }
    return res;
}

vector<Edge> es;

int main() {
    cin >> N >> M;
    int x, y;
    for(int i = 0; i < N; i++) {
        cin >> x >> y;
        piles[i] = P(x, y);
    }
    int j, k;
    double s = 0;
    for(int i = 0; i < M; i++) {
        cin >> j >> k;
        j--; k--;
        P p1 = piles[j], p2 = piles[k];
        double d = distance(p1.first, p1.second, p2.first, p2.second);
        s += d;
        es.push_back(Edge(j, k, d));
    }
    printf("%.5f\n", kruskal(N, es));
    return 0;
}

Measured memory_bytes: 1872
N = int(input())
s = input()
num_R = 0
num_B = 0
for i in range(len(s)):
    if s[i] == "R":
        num_R += 1
    else:
        num_B += 1

if num_R > num_B:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
# encoding:utf-8
from collections import Counter

def main():
	n = int(input())
	vs = list(map(int, input().split()))

	v1 = [vs[i] for i in range(n) if i % 2 == 0]
	v2 = [vs[i] for i in range(n) if i % 2 == 1]

	v1c = Counter(v1)
	v2c = Counter(v2)

	mc1 = v1c.most_common(2)
	mc2 = v2c.most_common(2)
	
	if len(mc1) == 1:
		mc1.append((0, 0))

	if len(mc2) == 1:
		mc2.append((0, 0))

	if mc1[0][0] == mc2[0][0]:
		if mc1[0][1] - mc1[1][1] >= mc2[0][1] - mc2[1][1]:
			print(n - mc1[0][1] - mc2[1][1])
		else:
			print(n - mc1[1][1] - mc2[0][1])
	else:
		print(n - mc1[0][1] - mc2[0][1])


if __name__ == '__main__':
	main()


Measured memory_bytes: 19032
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		while (true){

		double x =sc.nextInt();
		double h = sc.nextInt();

		if(x==0 && h==0){
			break;
		}

		double s4 = x*x;
		double s3  = Math.sqrt(h*h+x*x/4)*2*x;

		System.out.println(s4+s3);
		}
	}

}

Measured memory_bytes: 26140