akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli mod = 1e9 + 7;
lli n; string s[2];
int main() {
  cin >> n >> s[0] >> s[1];
  lli st, pos=0, ans = 1;
  if (s[0][0] == s[1][0]) { st=0; ++pos; ans = 3; }
  else { st=1; pos+=2; ans = 6; }
  while (pos < n) {
    if (s[0][pos] == s[1][pos]) {
      if (st==0) ans = ans * 2 % mod;
      st=0;
      ++pos;
    } else {
      if (st==0) ans = ans * 2 % mod;
      else ans = ans * 3 % mod;
      st=1;
      pos+=2;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        boolean answer = b - a == c - b;
        System.out.println(answer ? "YES" : "NO");
    }
}


Measured memory_bytes: 24020
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, N;
  cin>>H>>W>>N;
  if(H<W) swap(H, W);
  if(N%H==0) cout<<N/H<<endl;
  else cout<<N/H+1<<endl;
}



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

bool primeFlg[1000000];

void makePrime(){
  memset(primeFlg, true, sizeof(primeFlg));
  primeFlg[0] = primeFlg[1] = false;

  for(int i = 2; i * i <= 1000000; i++){
    if(primeFlg[i]){
      for(int j = i + i; j < 1000000; j += i){
        primeFlg[j] = false;
      }
    }
  }
}

int main(){
  int n;

  makePrime();

  while(cin >> n){
    for(int i = n - 1; ; i--){
      if(primeFlg[i]){
        cout << i << " ";
        break;
      }
    }

    for(int i = n + 1; ; i++){
      if(primeFlg[i]){
        cout << i << endl;
        break;
      }
    }
  }
}

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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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

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

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

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


int main(){
  int n, a, b;
  int counter[3] = {};

  scanf("%d%d%d", &n, &a, &b);

  for(int i=0;i<n;i++){
    int x;
    scanf("%d", &x);
    counter[0] += x <= a;
    counter[1] += a < x && x <= b;
    counter[2] += b < x;
  }

  cout << min({counter[0], counter[1], counter[2]}) << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    int o=n/2+n%2;
    printf("%0.6lf\n",(o*1.0/n));
}
int main()
{
    solve();
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] inputArray(int size){
		int arr[] = new int[size];
		for(int i=0;i<size;i++)arr[i]=sc.nextInt();
		return arr;
	}
	public static void main(String[] args){
		int[] arr = inputArray(sc.nextInt());
		int[] dp = new int[arr.length];
		dp[0]=0;
		dp[1]=(int)Math.abs(arr[1]-arr[0]);
		for(int i=2;i<dp.length;i++){
			dp[i]=Math.min(dp[i-1]+(int)Math.abs(arr[i-1]-arr[i]),dp[i-2]+(int)Math.abs(arr[i-2]-arr[i]));
		}
		//System.out.println(Arrays.toString(dp));
		System.out.println(dp[arr.length-1]);
	}
}

Measured memory_bytes: 59588
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int K = io.nextInt();
		int g = io.nextInt();
		int max = g;
		
		for (int i = 2; i <= N; i++){
			int num = io.nextInt();
			max = Math.max(max,num);
			g = gcd(g,num);
		}
		
		System.out.println((K%g==0 && K<=max)? "POSSIBLE":"IMPOSSIBLE");
		
	}
	
	private int gcd(int a,int b){
		if(a%b==0) return b;
		return gcd(b,a%b);
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 46472
#include <vector>
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;

int main() {
    int n,h ;
    cin >> n >> h ;
    int a[n],b[n] ;
    int amax = -1 ;

    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] ;
        amax = max(a[i],amax) ;        
    }

    int ans = 2147483647 ;
    sort(b,b+n) ;
    reverse(b,b+n) ;

    for(int i= 0 ; i<=n;i++){
        int cnt = 0 ;
        if(i>0) h-= b[i-1] ;
        if(h>0) cnt = (h+amax-1)/amax ;
        ans = min(cnt+i,ans) ;
    }

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


Measured memory_bytes: 4408
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
cnt=0
ans_min=999
for i in h:
    cnt = cnt+1
    mean=t-i*0.006
    ans = abs(a-mean)
    #print(ans)
    if ans<=ans_min:
        ans_min=ans
        cnt_ans=cnt
print(cnt_ans)


Measured memory_bytes: 3060
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d);	
   	return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $k);

if ($k <= $a) {
    echo $k;
} else if ($k <= $a + $b) {
    echo $a;
} else {
    $tmp = $k - ($a + $b);
    echo $a - $tmp;
}


Measured memory_bytes: 16152
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a;
	cin >> a;
	cout << a + (a*a) + (a*a*a) << '\n';
	
	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>
#include <vector>
#include <bitset>

struct edge
{
  int from;
  int to;
  int cost;
};

long long dist[2500];
std::bitset<2500> nloop;

int main()
{
  int n, m, p;
  scanf("%d%d%d", &n, &m, &p);
  std::vector<edge> edges;
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    edges.emplace_back(edge{a - 1, b - 1, p - c});
  }
  constexpr long long INF = 1e18;
  std::fill(dist + 1, dist + n, INF);
  for (int i = 0; i < n - 1; ++i)
  {
    for (auto &e : edges)
    {
      if (dist[e.from] == INF) continue;
      long long c = dist[e.from] + e.cost;
      if (c < dist[e.to]) dist[e.to] = c;
    }
  }
  for (int i = 0; i < n; ++i)
  {
    for (auto &e: edges)
    {
      if (dist[e.from] == INF) continue;
      nloop[e.to] = nloop[e.to] | nloop[e.from];
      long long c = dist[e.from] + e.cost;
      if (c < dist[e.to])
      {
        dist[e.to] = c;
        nloop[e.to] = true;
      }
    }
  }
  if (nloop[n - 1]) puts("-1");
  else printf("%lld\n", std::max(0LL, -dist[n - 1]));
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	int H[100010]; H[0] = 0;
	cin >> N;
	int max = 0;
	int now = 0;
	for (int i = 1; i <= N; i++) {
		cin >> H[i];
	}
	for (int i = 1; i <= N-1; i++) {
		if (H[i] >= H[i + 1])now++;
		else if (now > max) { max = now; now = 0; }
		else now = 0;
	}
	if (now > max) { max = now; now = 0; }
	cout << max;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int N;
  cin >> N;
  vi X(N);
  rep(i, 0, N) {
    cin >> X[i];
  }

  sort(All(X));

  int mi = X[0], ma = X[N-1];

  int ans = 1e9+7;
  rep(p, mi, ma+1) {
    int tmp = 0;
    for (int x: X) {
      tmp += (x - p) * (x - p);
    }
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
char ch[5] = {'M','A','R','C','H'};
P cnt[5];

ll Howmany(P a[5]){
  ll res = 0;
  do{
    res += a[0].second*a[1].second*a[2].second;
    //cout << a[0] << a[1] << a[2] << a[3] << a[4] <<endl;
  }while(next_permutation(a,a+5));

  res /= 12;
  return res;
}

int main(){
  int N;
  cin >> N;
  string S[N];

  for(int j=0;j<5;j++) cnt[j] = make_pair(j,0);

  for(int i=0;i<N;i++){
    cin >> S[i];
    for(int j=0;j<5;j++){
      if(S[i][0]==ch[j]){
        cnt[j].second++;
      }
    }
  }
  ll ans = Howmany(cnt);
  cout << ans <<endl;

  return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,Q;
    cin>>N>>Q;
    rep(i,Q){
        int a,b; cin>>a>>b;
        nums[a]++;
        nums[b]++;
    }
    
    rep1(i,N){
        if(nums[i]%2){
            cout1("NO");
            return 0;
        }
    }
    cout1("YES");
}

Measured memory_bytes: 640
s = input()
n = len(s)
for i in range(2**(n-1)):
    op = ["-"] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            op[n - 2 -j] = "+"
    #print(op)
    chk = ""
    for p_n, p_o in zip(s, op + [""]):
        chk += (p_n + p_o)
    if eval(chk) == 7:
        print(chk + "=7")
        exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
/****************************** START ******************************/

signed main(){
  int N,K;
  cin >> N >> K;
  Vi L(K),R(K);
  map<int,int> S,a,f;
  rep(i,0,K){
    cin >> L.at(i) >> R.at(i);
  }
  int mod = 998244353;
  
  f[1] = 1;
  f[2] = -1;
  repeq(i,1,N){
    f[i] = (f[i] % mod + mod) % mod;
    f[i+1] += f[i];
    rep(j,0,K){
      if (i+L.at(j) <= N){
        f[i+L.at(j)] += f[i];
      }
      if (i+R.at(j)+1 <= N){
        f[i+R.at(j)+1] -= f[i];
      }
    }
  }
  
  cout << f[N];
}


Measured memory_bytes: 16052
#include<stdio.h>
#define MAX 100000
int a[MAX];
int partition(int p,int r){
  int x,i,j,t;
  x = a[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(a[j] <= x){
      i++;
      t = a[i];
      a[i] = a[j];
      a[j] = t;
    }
  }
    t = a[i+1];
    a[i+1] = a[r];
    a[r] = t;
    return i+1;
  
}
int main(){
  int i,q,datanum;
  scanf("%d",&datanum);
  for(i=0;i<datanum;i++){
    scanf("%d",&a[i]);
  }
  q = partition(0,datanum-1);
  for(i=0;i<datanum;i++){
    if(i)printf(" ");
    if(i == q)printf("[");
    printf("%d",a[i]);
    if(i == q)printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back
#define PS string qqwwee;cin>>qqwwee;
typedef pair<int,int> pii;

int a[105];
int main() {
    int n;
    cin>>n;
    ii cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;++i) {
        for(int j=i+1;j<=n;++j) {
            for(int k=j+1;k<=n;++k) {
                vi v{a[i],a[j],a[k]};
                sort(all(v));
                if(v[0]!=v[1] && v[1]!=v[2] && v[0]+v[1]>v[2]) ++ans;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
    
    double x1,x2,x3,y1,y2,y3,xp,yp,A,B,C;
    
    while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        A=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        B=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
        C=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
        
        
        if((A>0 && B>0 && C>0) || (A<0 && B<0 && C<0))
            printf("YES\n");
        else
            printf("NO\n");
        
    }
    return 0;
    
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
string s[N];
int ok = 1;
vector<char> ans;
inline void op(int &a,int &b,char ans1,char ans2,bool jug) {
	if(a == 0 && b == 0) {ok = 0;return;}
	if(a == 1 && b == 1) {
		if(jug == 1) --a,++b,ans.push_back(ans2);
		else ++a,--b,ans.push_back(ans1);
	}
	else if(a < b) --b,++a,ans.push_back(ans1);
	else --a,++b,ans.push_back(ans2);
}
int main() {
	ios::sync_with_stdio(0);
	int n,a,b,c;
	cin >> n >> a >> b >> c;
	for(int i = 1;i <= n;++i)
		cin >> s[i];
	s[n+1] = "DD";
	for(int i = 1;i <= n;++i) {
		if(s[i][0] == 'A' && s[i][1] == 'B') op(a,b,'A','B',c == 0 && s[i+1] == "BC");
		if(s[i][0] == 'A' && s[i][1] == 'C') op(a,c,'A','C',b == 0 && s[i+1] == "BC");
		if(s[i][0] == 'B' && s[i][1] == 'C') op(b,c,'B','C',a == 0 && s[i+1] == "AC");
		if(ok == 0) break;
	}
	if(!ok) cout << "No" << endl;
	else {
		cout <<"Yes" << endl;
		for(int i = 0;i < n;++i)
			cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 6928
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int n, c[500], s[500], f[500];
    cin >> n;
    for (int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i < n; i++) {
        int t = 0;
        for(int j=i;j<n-1;j++){
            if (t < s[j])t = s[j];
            else if (t%f[j] == 0);
            else t = t + f[j] - t%f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    return 0;
}


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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char SMAX(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char SMIN(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 7;
int n = 4, x, y, deg[N], jcnt;

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	for (int i = 1; i < n; ++i) read(x), read(y), ++deg[x], ++deg[y];
	for (int i = 1; i <= n; ++i) if(deg[i] & 1) ++jcnt;
	if (jcnt == 0 ||jcnt == 2) puts("YES");
	else puts("NO");
}

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

int main() {
  int n, count = 0;
  bool P = 0, W = 0, G = 0, Y = 0;
  string s;
  cin >> n;
  rep(i, n) {
    cin >> s;
//    cout << "s is " << s << " count is " << count << endl;
    if (s == "P" && !P) {
      count++;
      P = 1;
    } else if (s == "W" && !W) {
      count++;
      W = 1;
    } else if (s == "G" && !G) {
      count++;
      G = 1;
    } else if (s == "Y" && !Y) {
      count++;
      Y = 1;
    }
  }
  if (count == 3)
    cout << "Three" << endl;
  else if (count == 4)
    cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
char A[110], B[110], C[110];

int main()
{
	scanf("%d%s%s%s", &N, A, B, C);

	int ret = 0;
	for (int i = 0; i < N; ++i) {
		char a = A[i], b = B[i], c = C[i];
		if (a == b && b == c) ret += 0;
		else if (a == b || b == c || c == a) ret += 1;
		else ret += 2;
	}
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    long long A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    
    long long sum=0;
    long long x,y;
    int q=max(X,Y);
    long long ans=INFL;
    for(int i=0;i<2*q+1;i+=2){
        x=max(0LL,X-i/2);
        y=max(0LL,Y-i/2);
        ans=min(ans,i*C+x*A+y*B);
    }
    cout << ans << endl;



}

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

struct Answer {
    double maxArea;
    int multiple;
    Answer(double a = 0.0, int b = 0) {
        maxArea = a;
        multiple = b;
    }
};

Answer func(double w, double h, double x, double y) {
    Answer A;
    if (x * 2 == w && y * 2 == h) {
        A.multiple = 1;
    }
    A.maxArea = w * h / 2.0;
    return A;
}

int main() {
    double W, H, x, y;
    cin>>W>>H>>x>>y;
    auto Answer = func(W, H, x, y);
    cout<<Answer.maxArea<<" "<<Answer.multiple<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000


int L[MAX/2+2], R[MAX/2+2];
int cnt;


void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid-left;
	int n2 = right-mid;
	for(int i=0;i<n1;i++) L[i] = A[left+i];
	for(int i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = SENTINEL;
	int i=0, j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}


void mergeSort(int A[], int n, int left, int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main(){
	int A[MAX], n, i;
	cnt = 0;
	
	cin >> n;
	for(i=0;i<n;i++) cin >> A[i];
	
	mergeSort(A, n, 0, n);
	
	for(i=0;i<n;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	cout << cnt << endl;
	
	
	return 0;
}

Measured memory_bytes: 6980
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	v<ld> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	v<v<ld>> dp(n+1,v<ld>(n+1));
	for(int i=0;i<n+1;i++){
		for(int j=0;j<n+1;j++){
			if(i==0 && j==0){
				dp[i][j]=1;
			}
			else if(j>i){
				dp[i][j]=0;
			}
			else if(j==0){
				dp[i][j]=dp[i-1][0]*(1-p[i-1]);
			}
			else{
				dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
			}
		}
	}
	ld ans=0;
	int h=n/2+1;
	for(int i=h;i<=n;i++){
		ans+=dp[n][i];
	}
	cout<<ans<<"\n";
}	

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> tako(N);
  rep(i,N){
    cin >> tako.at(i);
  }
  
  int sum = 0;
  rep(i,N-1){
    for(int j = i+1; j<N; j++){
      if(i == j) continue;
      sum += tako.at(i)*tako.at(j);
    }
  }
  
  cout << sum << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N;
    string S;
    cin >>N>>S;
    if(N%2==1){
        cout << "No"<<endl;
    }else{
        rep(i,N/2){
            if(S[i] != S[i+N/2]){
                cout << "No"<<endl;
                break;
            }
            if(i == N/2-1){
                cout << "Yes"<<endl;
            }
        }
    }
    //cin >>N;
    
    
    

}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        string ans = "NO";

        if(inpt[0]<=inpt[2]&&inpt[2]<=inpt[0]+inpt[1]) {
            ans = "YES";
        }
        Console.WriteLine(ans);
    
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



3 5 4



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <cstdio>

int face[6];
int times,a,b;


int main(){
	
	for(int i=0; i<6; ++i){
		scanf("%d", &face[i]);
	}
	
	int check[6][4] = {
		{face[1],face[2],face[4],face[3]},
		{face[5],face[2],face[0],face[3]},
		{face[5],face[4],face[0],face[1]},
		{face[5],face[1],face[0],face[4]},
		{face[5],face[3],face[0],face[2]},
		{face[4],face[2],face[1],face[3]}
	};
	
	scanf("%d", &times);
	
	for(int i=0; i<times; ++i){
		scanf("%d %d", &a, &b);
		for(int j=0; j<6; ++j){
			if(a == face[j]){
				for(int k=0; k<4; ++k){
					if(b == check[j][k] && k!=3){
						printf("%d\n", check[j][k+1]);
					}else if(k == 3 && b == check[j][3]){
						printf("%d\n", check[j][0]);
					}
				}
			}
		}
	}	
}


Measured memory_bytes: 2600
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long geko[300000];
int main() {
#define int long long
	long long n;
	cin >> n;
	string x;
	cin >> x;
	long long tmp = 1;
	long long ans = 1;
	for (int i = x.size() - 1; i >= 0; --i) {
		ans += tmp * (long long)(x[i] - '0');
		ans %= MOD;
		tmp *= 2;
		tmp %= MOD;
	}
	ans *= 2LL * n;
	ans %= MOD;
	long long Stick = 1;
	long long Go = 0;
	for (long long i = 0; i < x.size(); ++i) {
		Go *= 2LL;
		if (x[i] == '1') {
			Go += 1LL;
		}
		Go %= MOD;
		if (n % (i + 1LL) == 0) {
			if ((n / (i + 1LL)) % 2 == 1) {
				//For no requirements
				//For requirements
				int ok = 1;
				for (int q = i + 1; q < x.size(); ++q) {
					if ((q / (i + 1LL)) % 2LL == 0) {
						if (x[q] != x[q % (i + 1LL)]) {
							if (x[q] < x[q % (i + 1LL)]) {
								ok = 0;
							}
							break;
						}
					}
					else {
						if (x[q] == x[q % (i + 1LL)]) {
							if (x[q] == '0') {
								ok = 0;
							}
							break;
						}
					}
				}
				Go += ok;
				Go += geko[i];
				long long hoge = (long long)x.size() * 2LL;
				hoge -= (long long)(i + 1) * 2LL;
				hoge *= Go;
				hoge %= MOD;
				ans += (MOD - hoge) % MOD;
				ans %= MOD;
				for (long long j = (i + 1)*2LL; j < x.size(); j += (i + 1)) {
					geko[j-1] += 2LL * MOD - Go;
					geko[j-1] %= MOD;
				}
				Go -= geko[i];
				Go -= ok;
			}
		}
	}
	cout << ans << endl;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.fi << ", " << p.se << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n;
    cin >> n;
    int h[n];
    bitset<100> b;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (h[i] > 0) {
            b[i] = true;
        }
    }
    int times = 0;
    while (b.any()) {
        int start = 0;
        int end = 0;
        vector<pi> splits;
        for (end = 0; end < n; end++) {
            if (h[start] == 0 && h[end] > 0) {
                start = end;
            }
            if (h[end] == 0 && h[start] > 0) {
                splits.push_back(mp(start, end - 1));
                start = end;
            }
        }
        if (h[start] > 0 && h[end - 1] > 0) {
            splits.push_back(mp(start, end - 1));
        }
        for (auto &s : splits) {
            times++;
            for (int i = s.fi; i <= s.se; i++) {
                h[i]--;
                if (h[i] == 0) {
                    b[i] = false;
                }
            }
        }
    }
    cout << times << endl;
}


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

const int MAXN = 5e5;
int N;
multiset<int> A;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a; cin >> a; A.insert(a);
    }
    int res = 0;
    while (!A.empty()) {
        auto it = A.end();
        it--;
        int v = *it;
        A.erase(it);
        int i = 0;
        while (v >= (1ll << i)) i++;
        assert(v < (1ll << i));
        int o = int((1ll << i) - v);
        assert(o <= v);
        auto jt = A.find(o);
        if (jt == A.end()) continue;
        res++;
        A.erase(jt);
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    double a, b, c;
    cin >> a >> b >> c;
    double S, L, h;
    double rad = (c * 2 * PI) / 360;
    S = (a * b * sin(rad)) / 2;
    L = a*a + b*b - 2*a*b*cos(rad);
    L = a + b + sqrt(L);
    h = (2*S) / a;
    cout << fixed;
    cout << setprecision(10) <<S << endl;
    cout << setprecision(10) << L << endl;
    cout << setprecision(10) << h << endl;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e6 + 10;
int vis[M];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1, x; i < n; i++) {
        scanf("%d", &x);
        vis[x]++;
    }
    for(int i = 1; i <= n; i++) printf("%d\n", vis[i]);
    return 0;
}


Measured memory_bytes: 4540
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int n = sc.nextInt();
      int counter = 0;
      boolean[] isprime = new boolean[n+1];
      for (int i = 2; i <= n; i++) {
        isprime[i] = true;
      }
      for (int i = 2; i*i <= n; i++) {
        if(isprime[i]) {
          for (int j = 2*i; j <= n; j += i) {
            isprime[j] = false;
          }
        }
      }
      for (int i = 0; i <= n; i++) {
        if(isprime[i]) {
          counter++;
        }
      }
      System.out.println(counter);
    }
  }
}

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

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;
	Point(double _x = 0, double _y = 0) :x(_x), y(_y){};

	Point operator+(const Point &p){ return Point(x + p.x, y + p.y); }
	Point operator-(const Point &p){ return Point(x - p.x, y - p.y); }
	Point operator*(const Point &p){ return Point(x * p.x, y * p.y); }
	Point operator*(double k){ return Point(x * k, y * k); }
	Point operator/(const Point &p){ return Point(x / p.x, y / p.y); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point &p) const{
		return (x != p.x) ? x < (p.x) : (y < p.y);
	}

	bool operator==(const Point &p){
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;
struct Segment{
	Point p1, p2;
};

double dot(Vector a, Vector b){
	double res = a.x*b.x + a.y*b.y;
	return res;
}

double cross(Vector a, Vector b){
	double res = a.x*b.y - a.y*b.x;
	return res;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0.0);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

Point project(Segment s, Point p){
	Vector base = s.p2 - s.p1;
	Vector v = p - s.p1;
	double l = dot(v, base) / base.norm();
	return s.p1 + base * l;
}

int main(){
	Segment s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	int n;
	cin >> n;
	cout.precision(20);
	for (int i = 0; i < n; ++i){
		Point pp;
		cin >> pp.x >> pp.y;
		Point res = project(s, pp);
		cout << res.x << " " << res.y << endl;
	}
	return 0;
}

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

int main(void){
    // Your code here!
    int H, W;
    int field[50][50] = {};
    int sp[50][50] = {{}};
    int count_white = 0;
    
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        string s;
        cin >> s;
        for(int j = 0; j < W; j++){
            if(s[j] == '.'){
                field[i][j] = 0;
                count_white++;
            }
            else
                field[i][j] = 1;
        }
    }
    
    sp[0][0] = 1;
    queue<vector<int>> q;
    vector<int> init{0, 0};
    q.push(init);
    while(q.size() > 0){
        vector<int> front = q.front();
        int y, x;
        y = front[0];
        x = front[1];
        
        if(front[0] == H-1 && front[1] == W-1)
            break;
        if(y-1 >= 0 && field[y-1][x] == 0 && sp[y-1][x] == 0){
            vector<int> temp{y-1, x};
            q.push(temp);
            sp[y-1][x] = sp[y][x] + 1;
        }
        if(y+1 < H && field[y+1][x] == 0 && sp[y+1][x] == 0){
            vector<int> temp{y+1, x};
            q.push(temp);
            sp[y+1][x] = sp[y][x] + 1;
        }
        if(x-1 >= 0 && field[y][x-1] == 0 && sp[y][x-1] == 0){
            vector<int> temp{y, x-1};
            q.push(temp);
            sp[y][x-1] = sp[y][x] + 1;
        }
        if(x+1 < W && field[y][x+1] == 0 && sp[y][x+1] == 0){
            vector<int> temp{y, x+1};
            q.push(temp);
            sp[y][x+1] = sp[y][x] + 1;
        }
        q.pop();
    }
    if(sp[H-1][W-1] == 0)
        cout << -1 << endl;
    else
        cout << count_white - sp[H-1][W-1] << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int n = sc.nextInt();
    int a = (int)Math.pow(100, d);
    int ans = a * n;
    if(n == 100) ans = a * 101;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
read_and_unspace() = strip(replace(readline(), r"\s+", " "))
read_ints() = [parse(Int, x) for x in split(read_and_unspace(), " ")]
a,b,c = read_ints()
k=read_ints()
m=max(a,b,c)
score=a+b+c-m
for i in 1:k[1]
    m=2*m
end
score=score+m
println(score)

Measured memory_bytes: 110076
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
         
      string s;
      cin>>s;
      map<ll,ll>m;
      ll i;
      f(i,s.size())
      {
          m[s[i]-'a']++;
      }
         ll f=1;
         fa(i,m)
         {
             ll z=i.S;
             if(z%2!=0)
             {
                 f=0;
                 break;
             }
         }
         
         if(f==1)
         {
             Yes
         }
         else
         {
             No
         }
        
	re
}

Measured memory_bytes: 256
use std::cmp;
fn main() {
    let mut sc = Scanner::new();
    let n = sc.read();
    let k: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);
    let mut pos = 0;
    for i in 0..n {
        if a[i] == 1 {
            pos = i;
        }
    }

    let mut ans = n;
    for i in 0..k {
        if pos < i {
            continue;
        }
        let prefix = pos - i;
        if n < prefix + k {
            continue;
        }
        let suffix = n - prefix - k;
        let k = k - 1;
        let p = (prefix + k - 1) / k;
        let s = (suffix + k - 1) / k;
        ans = cmp::min(ans, p + s + 1);
    }

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

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define k 10001
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> A(n),B(n);
  for(int i=0;i<n;i++) cin>>A[i];
  int C[k];
  for(int i=0;i<k;i++) C[i]=0;
  for(int j=0;j<n;j++) C[A[j]]++;
  for(int i=1;i<k;i++) C[i]=C[i]+C[i-1];
  for(int j=n-1;j>=0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  for(int i=0;i<n;i++) cout<<B[i]<<" \n"[i==n-1];
  return 0;
}

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

using namespace std;


int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }

    int pos = 0;
    int ans = 1;
    for (int i = 0; i < N; ++i) {
        pos += L[i];
        if (pos <= X) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

int main() {
  std::vector<std::pair<int, int>> sp;
  while (true) {
    int p, s;
    scanf("%d,%d", &p, &s);
    if (p == 0 && s == 0)
      break;

    sp.emplace_back(-s, p);
  }

  std::sort(sp.begin(), sp.end());

  while (true) {
    int s;
    if (scanf("%d", &s) == EOF)
      return 0;

    int res=0, last=100;
    for (size_t i=0; i<sp.size(); ++i) {
      if (-sp[i].first < last)
        ++res;

      last = -sp[i].first;
      if (sp[i].second == s) {
        printf("%d\n", res);
        break;
      }
    }
  }
}



Measured memory_bytes: 2676
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll h,w,hh,ww;
  cin>>h>>w;
  cin>>hh>>ww;
  ll ans=0;
  ans=h*w-hh*w-ww*h+hh*ww;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int X;
	cin >> X;
	int res = 0;
	for(ll i = 0; ; i++) {
		if(i*(i+1)/2 >= X) {
			res = i;
			break;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int h,w,a,b;
    scanf("%d%d%d%d", &h, &w, &a, &b);

    int i,j;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            if((i<b && j<a)||(i>=b && j>=a)) {
                printf("0");
            }
            else {
                printf("1");
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 1152
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
//#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int main()
{
	fastIO;
	int a,b,k;
	cin >> k >> a >> b ;
	int flag = 0;
	rep(i,a,b + 1) {
		if(i % k == 0) {
			flag = 1;
			break;
		}
	}	
	if(flag) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
  int i, j, minj, temp, n, a[100], k = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++)  {
    scanf("%d", &a[i]);
  }

  for (i = 0; i < n - 1; i++)  {
    minj = i;
    for (j = i + 1; j < n; j++)  {
      if (a[j] < a[minj])  {
        minj = j;
      }
    }
    if (minj != i)  {
      k++;
      temp = a[i];
      a[i] = a[minj];
      a[minj] = temp;
    }
  }

  for (i = 0; i < n - 1; i++) {
    printf("%d ", a[i]);
  }

  printf("%d\n%d\n", a[n - 1], k);

  return 0;
}

Measured memory_bytes: 600