akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cfloat>
#include<cmath>
#include<algorithm>
 
 
using namespace std;
 
double EPS = 1e-10;
 
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
 
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
 
  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};
 
bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}
 
bool Binary_search(vector<point>N, point x){
  int l=0,r=N.size(),mid=(l+r)/2;
 
  while(r-l>1){
    if(N[mid]==x)return true;
 
    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;
 
    mid=(l+r)/2;
  }
 
  if(N[mid]==x)return true;
  return false;
}
 
point solve(vector<point> M, vector<point> N){
 
  for(int i=0; i< N.size(); i++){
    int j=1;
    for(; j< M.size(); j++){
      point t=N[i]+M[j]-M[0];
      if(!Binary_search(N,t))break;  
    }
    if(j==M.size())return N[i]-M[0];
  }
  return M[0];
}
 
int main(void){
  int n,m;
  point in;
  vector<point>M,N;
 
  while(cin >> m,m){
    M.clear();
    N.clear();   
 
    for(int i=0; i< m; i++){
      cin >> in.x >> in.y;
      M.push_back(in);
    }
     
    cin >> n;
 
    for(int i=0; i< n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }
 
    sort(N.begin(),N.end(),cmp_x);
 
    point res=solve(M,N);
 
    cout << res.x <<" "<< res.y << endl;
 
  }
 
  return 0;
}

Measured memory_bytes: 1368
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int L;
    L = S.length();
    int c = 0;
    for (int i = 0; i < L; i++) {
        if (S[i] != T[i]) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3908
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int i;
    for(i = 0; i <= n-2; i++) {
        if(s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }

    if(n == 2) {
        cout << -1 << " " << -1 << endl;
        return 0;
    }

    int j;
    for(j = 0; j <= n-3; j++) {
        if(s[j] == s[j+2]) {
            cout << j+1 << " " << j+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(void){
    int n,k,i,tmp,flag;
    int d[10],c[10]={0};
    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++){
        scanf("%d",&d[i]);
        c[d[i]]++;
    }
    for(i=n;;i++){
        tmp = i;
        flag = 0;
        for(;;){
            if(tmp==0) break;
            if(c[tmp%10]!=0){
                flag = 1;
                break;
            }
            tmp/=10;
        }
        if(flag==0){
            printf("%d",i);
            break;
        }    
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

int gcd(int a,int b){while(a^=b^=a^=b%=a);return b;}

void solve() {
  VAR(ll, N, X);
  VEC(ll, p, N);
  sort(all(p));
  ll g = LINF;
  rep(i, 0, N) {
    g = min(g, abs(p[i] - X));
  }
  rep(i, 1, N) {
    g = gcd(g, abs(p[i] - p[i - 1]));
  }
  print(g);
}


Measured memory_bytes: 1152
a = list(str(input()))

ans = "No"
if a[0] == a[1]:
  if a[2] == a[3] and a[0] != a[2]:
    ans = "Yes"
elif a[0] == a[2]:
  if a[0] != a[1] and a[1] == a[3]:
    ans = "Yes"
elif a[0] == a[3]:
  if a[0] != a[1] and a[1] == a[2]:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  vector<int> g;
  cin>>a>>b>>k;
  for(int i=1;i<=100;++i)if(!(a%i)&&!(b%i))g.push_back(i);
  sort(g.begin(),g.end(),greater<>());
  cout<<g[k-1];
  return 0;
}

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

using namespace std;

int gcd(int x, int y) {
  while(y > 0) {
    int r = x % y; x = y; y = r;
  }
  return x;
}

int main() {
  int N, X; cin >> N >> X;
  vector<int> xx(N);
  for (int i = 0; i < N; i++) {
    cin >> xx.at(i);
    xx.at(i) -= X;
    xx.at(i) = abs(xx.at(i));
  }
  
  sort(xx.begin(), xx.end());
  
  int D = xx.at(0);
  for (int i = 1; i < N && D != 1; i++)
    D = gcd(D, xx.at(i));
    
  cout << D << endl;
}

Measured memory_bytes: 640
l = [list(map(int, input().split())) for i in range(3)]

t = True
for i in range(3):
  if not l[i][0] - l[i-1][0] == l[i][1] - l[i-1][1] == l[i][2] - l[i-1][2] or not l[0][i] - l[0][i-1] == l[1][i] - l[1][i-1] == l[2][i] - l[2][i-1]:
    t = False

if t == True:
  print("Yes")
else:
  print("No")

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

ll roundUp(ll a, ll b) {
  ll ans = a / b;
  if (a % b == 0) return ans;
  if (ans > 0) ans++;
  else if (ans == 0 && a * (abs(b) / b) > 0 ) ans++;
  return ans;
}
ll roundDown(ll a, ll b) {
  ll ans = a / b;
  if (a % b == 0) return ans;
  if (ans < 0) ans--;
  else if (ans == 0 && a * (abs(b) / b) < 0 ) ans--;
  return ans;
}

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

  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  // m 未満のものが K-1 個以下か？ => l が答え
  ll l = -2e18, r = 2e18;
  while(l + 1 < r) {
    ll m = (l + r) / 2;
    ll cnt = 0;
    ll temp, thre;
    for (ll i = 0; i < N; i++) {
      if (A[i] == 0) {
        if (m > 0) cnt += N;
      } else if (A[i] > 0) {
        thre = roundUp(m, A[i]);
        temp = lower_bound(A.begin(), A.end(), thre) - A.begin();
        cnt += temp;
      } else {
        thre = roundDown(m, A[i]);
        temp = A.end() - upper_bound(A.begin(), A.end(), thre);
        cnt += temp;
      }
    }
    for (ll i = 0; i < N; i++) {
      if (A[i] * A[i] < m) cnt--;
    }
    cnt /= 2;
    // cout << l << ' ' << r << ' ' << m << ' ' << cnt << '\n';
    if (cnt < K) l = m;
    else r = m;
  }
  cout << l << '\n';
  return 0;
}

Measured memory_bytes: 1792
import bisect
 
n = int(input())
as_ = list(map(int, input().split()))
bs_ = list(map(int, input().split()))
cs_ = list(map(int, input().split()))
 
as_.sort()
bs_.sort()
cs_.sort()
 
ans = 0
for b in bs_:
  ans += bisect.bisect_left(as_, b) * (n-bisect.bisect_right(cs_, b))
print(ans)

Measured memory_bytes: 23156
#include <stdio.h>
#include <math.h>
int main(void) {
	int N;
	int count = 0;
	int k[10];
	int a, b;
	scanf("%d", &N);
	int p[50];
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		if (p[i] != i + 1) {
			k[count] = p[i];
			count++;
		}
	}
	if (count == 2) {
		a = k[0];
		b = k[1];
		if (p[a - 1] == b && p[b - 1] == a) {
			printf("YES");
		}
	}
	else if (count == 0) {
		printf("YES");
	}

	else {
		printf("NO");
	}

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define positiverep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t h;
  cin >> h;
  int64_t cnt = 0;
  int64_t beki = 1;
  while(h > 0){
    cnt += beki;
    beki *= 2;
    h = h / 2;
  }
  cout << cnt << endl;
  

    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int a[10];
  int f,s;
  bool flg=true;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>a[j];
    }
    f=0;s=0;flg=true;
    for(int i=0;i<10;i++){
      if(a[i]<f){
	if(a[i]<s)flg=false;
	else s=a[i];
      }
      else f=a[i];
    }
    if(flg)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}
	
      
    

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

#define int long long
const int MOD = 1e9 + 7;

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

  int n, m;
  cin >> n >> m;

  if ( n == 1LL ) {
    cout << (m+1) % MOD << endl;
    return 0;
  }
  
  int b = m / (n-1LL);
  int sum = (b-1LL) % MOD;
  sum = (sum * (b % MOD)) % MOD;
  sum = (sum * ((n-1LL) % MOD)) % MOD;

  int sum2 = (2LL * b) % MOD;
  sum2 = (sum2 * ((m - ((n-1LL) % MOD) * (b % MOD) + 1LL) % MOD)) % MOD;
  //cout <<  2 * b * (m - (n-1) * b + 1) << endl;
  sum += (m+1LL);
  sum += sum2;

  cout << sum % MOD << endl;
  return 0;
}

Measured memory_bytes: 3164
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int H,W,i,j,l;
while(true){

H=scan.nextInt();
W=scan.nextInt();
if(H==0&&W==0){

  break;
}else{
for(j=0;j<H;j++){
if(j%2==0){
 for(i=0;i<W;i++){

  if(i % 2==0){
    System.out.print("#");
  }else if(i % 2!=0){
    System.out.print(".");

  }

}
// System.out.println("");

}


else if(j%2==1){
for(l=0;l<W;l++){

 if(l % 2==0){
   System.out.print(".");
 }else if(l % 2!=0){

   System.out.print("#");
 }
}

}System.out.println("");
}

}
System.out.println("");
}
}
}


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

#define inp 3005
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

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

    vector<int> v(n);
    for(int &x:v) cin>>x;

    ll dp[inp][inp];

    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(r==l) { dp[l][r]=v[l]; continue; }
            dp[l][r] = max( v[l]-dp[l+1][r] , v[r]-dp[l][r-1] );
        }
    }
    cout<<dp[0][n-1];

    return 0;
}


Measured memory_bytes: 49732
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i <= 1000; i++){
        int tmp = a * i - (i - 1);
        if(tmp >= b){
            cout << i << endl;
            return 0;
        }
    }
}


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, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll fac(ll n){  // 階乗
	ll sum = 1;
	for(ll i=1; i <= n; i++){ sum *= i; }
	return sum;
}

int main() {
  ll n, m, k, x, y = 0, z = 0, h, ans=0, w, sum = 0, Max = -1, Min = 1e9+1;
  string s, t, u;
  bool ok=true;
  cin >> n;
  w = n%11;
  ans = (n/11)*2;
  if(w>=7) ans += 2;
  else if(w>0) ans+=1;
  pri(ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,k,sum=0;
    scanf("%d%d",&n,&k);
    int a[n];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),asc);
    for(int i=0;i<k;i++) sum+=a[i];
    printf("%d",sum);
}

Measured memory_bytes: 1696
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n];unordered_map<int,int> mp;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i];
        mp[a[i]]++;
    }
    int q;cin>>q;
    while(q--)
    {
        int b,c;cin>>b>>c;
        ans=ans-mp[b]*b+mp[b]*c;
        int cnt=mp[b];mp[b]=0;
        mp[c]+=cnt;
        cout<<ans<<nl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 7924
//https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b
//B - Palindrome-phobia
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    string S; cin>>S;
    vector<ll> abc(3);
    for(const auto c:S){
        ++abc.at(c-'a');
    }
    sort(abc.begin(),abc.end(),greater<ll>());
    auto out_no=[](){
        cout<<"NO"<<endl;exit(0);
    };
    if (abc[1]==0){
        if (abc[0]!=1) out_no();
    }else if (abc[2]==0){
        if(abc[0]!=1||abc[1]!=1)out_no();
    }else{
        if(abc[0]==abc[2] || abc[0]-1==abc[2]){
            //ok
        }else{
            out_no();
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

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

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

    int count = 0;

    for(int i=0; i<str.size(); i++) {
        if(str.at(i) == '1') {
            count++;
        }
    }

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


Pll_ll twoDiv(ll h, ll w){
    ll W = w/2;
    return Pll_ll(h*W, h*(w-W));
}

ll threeDiv(ll h, ll w){
    ll ret = h * w;
    FOR(i, 1, h){
        ll S = i * w;
        VLL A(3);
        A[0] = S;
        Pll_ll p = twoDiv(h-i, w);
        A[1] = p.first; A[2] = p.second;
        SORT(A);
        if(A[0]) chmin(ret, A[2]-A[0]);
        A[0] = S;
        p = twoDiv(w, h-i);
        A[1] = p.first; A[2] = p.second;
        SORT(A);
        if(A[0]) chmin(ret, A[2]-A[0]);
    }
    return ret;
}

int main(){
    ll H, W; cin >> H >> W;
    cout << min(threeDiv(H, W), threeDiv(W, H)) << endl;
    return 0;
}


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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nLeft, nRigt;
    cin >> nParnt >> nLeft >> nRigt;

    rvoNod[nParnt].m_nLeft = nLeft;
    rvoNod[nParnt].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nParnt;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nParnt;
  }
}

void fnPreOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  cout << " " << nx;
  fnPreOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPreOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
}

void fnInOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  fnInOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  cout << " " << nx;
  fnInOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
  cout << " " << nx;
}

void fnTreeWalk(const vector<StNod> &cnrvoNod)
{
  int nx = 0;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  cout << "Preorder" << endl;
  fnPreOrder(cnrvoNod, nx);
  cout << endl;

  cout << "Inorder" << endl;
  fnInOrder(cnrvoNod, nx);
  cout << endl;

  cout << "Postorder" << endl;
  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnTreeWalk(voNod);
  return 0;
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
int n,x,cnt[MAXN],odd,even;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x),cnt[x]++;
	for(int i=1;i<=100000;i++)
		if(cnt[i]&&(cnt[i]&1)) odd++;
		else if(cnt[i]&&!(cnt[i]&1)) even++;
	if(even&1) printf("%d",odd+even-1);
	else printf("%d",odd+even);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();
  

    if(Math.abs(x-a)<Math.abs(x-b)){
      System.out.println("A");
    }
    if(Math.abs(x-a)>Math.abs(x-b)){
      System.out.println("B");
    }





  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,s,t;
  cin>>n>>s>>t;

  auto ask=
    [&](Int a,Int b){
      cout<<"? "<<a<<" "<<b<<endl;
      Int x;
      cin>>x;
      return x;
    };

  vector<Int> ds(n+1,0);
  vector<Int> dt(n+1,0);

  for(Int i=1;i<=n;i++){
    if(i==s||i==t) continue;
    ds[i]=ask(s,i);
    dt[i]=ask(t,i);
  }

  Int dist=ask(s,t);
  ds[t]=dt[s]=dist;

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=1;i<=n;i++){
    if(i==s||i==t) continue;
    if(ds[i]+dt[i]>dist) continue;
    vp.emplace_back(ds[i],i);
  }

  if(vp.empty()){
    cout<<"! "<<s<<" "<<t<<endl;
    return 0;
  }

  vp.emplace_back(ds[t],t);
  sort(vp.begin(),vp.end());

  Int pos=s;
  vector<Int> ans;
  ans.emplace_back(pos);

  Int i=0;
  while(pos!=t){
    while(1){
      //cerr<<":::"<<i<<" "<<vp.size()<<endl;
      Int k=vp[i].second;
      i++;
      if(ask(pos,k)+dt[k]==dt[pos]){
        pos=k;
        break;
      }
    }
    ans.emplace_back(pos);
  }

  cout<<"!";
  for(Int x:ans) cout<<" "<<x;
  cout<<endl;
  return 0;
}



Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n, i=0;
	cin>>n;
	int a[n+1];
	for(i=1; i<=n; i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(i=2; i<=n; i++){
		if(a[i]==a[i-1]){
		cout<<"NO";
		return 0;
		}
	}
	cout<<"YES";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string s;
   cin>>s;
   int ans=0;
   for(int i=0;i<3;i++){
      if(s[i]=='1'){
         ans++;
      }
   }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int A,B;
char field[110][110];
int main() {
    cin>>A>>B;
    REP(i,0,50){
        REP(j,0,100){
            field[i][j]='#';
        }
    }
    REP(i,50,100){
        REP(j,0,100){
            field[i][j]='.';
        }
    }
    REP(i,0,25){
        REP(j,0,50){
            if(A>1) field[i*2][j*2]='.';
            else break;
            A--;
        }
        if(A==1) break;
    }

    RREP(i,25,50){
        REP(j,0,50){
            if(B>1) field[i*2][j*2]='#';
            else break;
            B--;
        }
        if(B==1) break;
    }
    cout<<"100 100"<<endl;
    REP(i,0,100){
        REP(j,0,100){
            printf("%c",field[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s;
  int q;
  cin >> s >> q;
  string u1,u2;
  bool flag=true;
  while(q--){
    int t; cin >> t;
    if(t==1){
      flag = !flag;
    } else {
      int f; char c; cin >> f >> c;
      if(f==1&&flag) u1.push_back(c);
      if(f==1&&!flag) u2.push_back(c);
      if(f==2&&flag) u2.push_back(c);
      if(f==2&&!flag) u1.push_back(c);
    }
  }
  if(flag){
    reverse(u1.begin(),u1.end());
    cout << u1 << s << u2 << endl;
  } else {
    reverse(s.begin(),s.end());
    reverse(u2.begin(),u2.end());
    cout << u2 << s << u1 << endl;
  }

  return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b; cin >> a >> b;
    ll t = min(a, b/2);
    a -= t; b -= t+t;
    t += b/4;
    cout << t;
}

Measured memory_bytes: 3612
a,b,c,d = list(map(int,input().strip().split()))

if a <= c and d <= b:
  print(d-c)
elif a <= c and b >= c:
  print(b-c)
elif a >=c and b <=d:
  print(b-a)
elif a >=c and d >= a:
  print(d-a)

else:
  print(0)

Measured memory_bytes: 3060
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    S = SS()

    # 最初の幸福度
    h = 0
    for i in range(N - 1):
        if S[i] == S[i+1]:
            h += 1

    # YX...XYに対して操作をすると幸福人数を2増やせる
    # 端X...XYに対して操作をすると幸福人数を1増やせる
    cnt = 0
    for i in range(N - 1):
        if S[i] != S[i+1]:
            cnt += 1

    if cnt >= 2 * K:
        h += 2 * K
    else:
        h = N - 1 

    print(h)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10052
def calc_fib(n)
  fib_array = [0, 1]
  for i in 0..(n-1)
    fib_i = fib_array[i] + fib_array[i+1]
    fib_array.push(fib_i)
  end
  return fib_array[-1]
end

n = gets.chomp.to_i
puts calc_fib(n)

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


long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    const long long mod = 1e9 + 7;
    long long m, n;
    cin >> m >> n;
    cout << modpow(m, n, mod) << endl;
}




Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll a,b,c;

int main(){
  cin>>a>>b>>c;
  ll ans=0;
  ll n1,n2,n3;
  if(a>=b&&a>=c){
    n1=a;
    n2=b;
    n3=c;
  }
  else if(b>=a&&b>=c){
    n1=b;
    n2=a;
    n3=c;
  }
  else{
    n1=c;
    n2=b;
    n3=a;
  }
  if((abs(n2-n3))%2==1){
    n1++;
    if(n2>n3)n3++;
    else n2++;
    ans++;
  }
  ans+=((n1-n2)+(n1-n3))/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int t;
    cin>>t;
    char a[101];
    cin>>a;
    if(strlen(a)<=t) cout<<a;
    else {
        for(int i=0;i<t;i++){
            cout<<a[i];
        }
        cout<<"...";
    }
    return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <chrono>
#include <ctime>
#include <climits>
#include <stack>
#include <array>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam

void useiostream() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(8);
}

void drop(char const* bu) {
	printf("%s", bu);
	exit(0);
}

ull gcd(ull a, ull b) {
	return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ld const pi = acos(-1.0L);
ld const eps = 0.0001L;

template<typename T, typename TT> bool mi(T& a, TT b) { return a > b ? (a = b, true) : false; }
template<typename T, typename TT> bool ma(T& a, TT b) { return a < b ? (a = b, true) : false; }

mt19937 ran(996);

int const mod = 1000000007;

ull bm(ull a, ull p, ull mod) {
	return (a * p - (ll)((ld)a * p / mod) * mod + mod) % mod;
}

ull bp(ull a, ull p, ull mod) {
	ull re = 1;
	while (p) {
		if (p & 1)re = bm(re, a, mod);
		p >>= 1;
		a = bm(a, a, mod);
	}
	return re;
}



int main() {
	useiostream();
#ifdef _DEBUG
	(void)freopen("input.txt", "r", stdin);
	(void)freopen("output.txt", "w", stdout);
#else
	//(void)freopen("bisector.in", "r", stdin);
	//(void)freopen("bisector.out", "w", stdout);
#endif

	int a, b;
	cin >> a >> b;
	cout << 6 - a - b;
	


	return 0;
}

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

int main(){
  string S,T;
  long long ans=0;
  cin >> S >> T;
  int N = S.size() , M = T.size();
  
  vector<vector<int>> V('z'+1,vector<int>(0));
  for(int i=0;i<N;i++) V[S[i]].push_back(i);
  
  for(int i=0;i<M;i++){
    if(V[T[i]].size()==0){
      cout << -1 << endl;
      return 0;
    }
    int x = ans%N;
    int y;
    auto it = V[T[i]].end();
    it--;
    if(x>*it) y = V[T[i]][0];
    else y = *lower_bound(V[T[i]].begin(),V[T[i]].end(),x);
    if(y>=x) ans += y-x+1;
    else ans += (N-x)+y+1;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    if(s == t){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i=0;i<s.size();i++){
        string l=s.substr(s.size()-1,1);
        string k=s.substr(0,s.size()-1);
        s = l+k;
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int main(){
	string s;
	cin >> s;
	int len = s.length();
	if(s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}
	int cnt = 0, cidx;
	for(int i = 2; i < len - 1; i++){
		if(s[i] == 'C'){
			if(cnt){
				cout << "WA" << endl;
				return 0;
			}
			else{
				cnt++;
				cidx = i;
			}
		}	
	}
	if(cnt == 0){
		cout << "WA" << endl;
		return 0;
	}
	for(int i = 0; i < len; i++)
		if(i != 0 && i != cidx && s[i] >= 'A' && s[i] <= 'Z'){
			cout << "WA" << endl;
			return 0;
		}
	cout << "AC" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  ll max1,max2;
  max1 = max2 = 0;
  vector<ll> x(n);
  for(int i = 0;i < n;i++)cin >> x[i];
  sort(x.begin(),x.end(),greater<ll>());
  for(int i = 0;i < n-1;i++){
    if(max1 == 0){
      if(x[i] == x[i+1]){
        max1 = x[i];
      	i++;
      }
    }else if(max2 == 0){
      if(x[i] == x[i+1])max2 = x[i];
      //cout << x[i] << endl;
    }else{
      break;
    }
  }
  cout << max2*max1 << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    ll ans=0;
    ans+=n/25;n%=25;
    ans+=n/10;n%=10;
    ans+=n/5;n%=5;
    ans+=n;
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































Measured memory_bytes: 3232
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif



int main()
{
	int N, P;
	static int A[64];
	int nz = 0, no = 0;
	cin >> N >> P;
	int i;
	rep (i, N) {
		cin >> A[i];
		if (A[i]&1)
			no++;
		else
			nz++;
	}
	DEBUG("Z%i O%i\n", nz, no);
	ll ans;
	if (P&1) {
		if (no == 0)
			ans = 0;
		else
			ans = 1LL<<(no-1+nz);
	} else {
		if (no == 0)
			ans = 1LL<<nz;
		else
			ans = 1LL<<(no-1+nz);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> d(K);
  vector<int> A_tmp(0);
  for (int i=0; i<K; i++){
    cin >> d.at(i);
    for (int j=0; j<d.at(i); j++){
      int Aij;
      cin >> Aij;
      A_tmp.push_back(Aij);
    }
  }
  vector<vector<int> > A(K, vector<int>(0));
  int isum = 0;
  for (int i=0; i<K; i++){
    A.at(i).push_back(A_tmp.at(isum));
    isum += d.at(i);
  }
  sort(A_tmp.begin(),A_tmp.end());
  A_tmp.erase(unique(A_tmp.begin(), A_tmp.end()), A_tmp.end());
  cout << N - A_tmp.size() << endl;
}

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

using namespace std;

#define int long long
#define mem(v , val) memset(v , val , sizeof val)
#define endl '\n'


void solve()
{

    char c;
    cin >> c;
    if(c >= 'a')
    {
        cout << 'a' << endl;
        return;
    }
    cout << 'A' << endl;
    return;
}


int32_t main()
{
    int t = 1;
  
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628
use proconio::input;
use proconio::marker::Bytes;
// use itertools::*;
// use num::bigint::{BigInt};
// use ndarray::{Array2, Array};
use std::collections::HashMap;

// fn rem2019(s: &[u8]) -> u32 {
//   let ans = BigInt::parse_bytes(s, 10).unwrap();
//   (ans % 2019.into()).to_32().unwrap()
// }

fn modpow(x: u32, e :u32, m: u32) -> u32 {
  let mut ans = if e > 0 { modpow(x, e>>1, m) } else {1};
  ans = ans * ans;
  if e & 1 == 1 {
    ans = ans * 10 % m;
  }
  ans % m
}

fn main() {
  input!{
    s: Bytes
  };
  // let mut mat: Array2<u32> = Array::zeros((s.len(), s.len()));
  let mut dp : Vec<u32>= Vec::with_capacity(s.len()+1);
  let mut map : HashMap<u32, u64> = HashMap::new();
  let m = 2019;
  for _ in 0..=s.len() {
    dp.push(0);
  }

  map.entry(0).or_insert(1);
  for i in (0..s.len()).rev() {
    let a = (s[i] - '0' as u8) as u32;
    let e = modpow(10, (s.len() - i - 1) as u32, m);
    // dbg!(i, &s[i], a, e);
    dp[i] = (a * e + dp[i+1]) % m;
    let v = map.entry(dp[i]).or_insert(0);
    *v+=1
  }
  let mut ans : u64 = 0;
  // dbg!(&map);
  for (_, v) in map.iter() {
    ans += v * (v - 1) / 2;
  }
  // dbg!(&pairs);
  println!("{}", ans);
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
	
	vector<int> r(n, 0);
	vector<int> m(n, 0);

	for (int i = 0;i<n;i++){
		cin >> r[i];
	}

	m[n - 1] = r[n - 1];
	int maxx = -1000000000;
	for (int i = n - 2; i >= 0; i--) {
		m[i] = max(r[i], m[i+1]);
		if (m[i+1] - r[i] > maxx) { maxx = m[i+1] - r[i]; }
	}
	cout << maxx << endl;
}


Measured memory_bytes: 4332
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;

    if(op == '+') cout << a+b << endl;
    else cout << a-b << endl;
    
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
r,c,k = map(int,readline().split())
items = [[0]*c for _ in range(r)]
for i in range(k):
    a,b,v = map(int,readline().split())
    a,b = a-1,b-1
    items[a][b] = v

dp0 = [[0]*(c+1) for j in range(r+1)]
dp1 = [[0]*(c+1) for j in range(r+1)]
dp2 = [[0]*(c+1) for j in range(r+1)]
dp3 = [[0]*(c+1) for j in range(r+1)]

for i in range(1,r+1):
    for j in range(1,c+1):
        #dp[i][j][0] = max(maximam[i-1][j],dp[i][j-1][0])
        #dp[i][j][1] = max(maximam[i-1][j]+items[i-1][j-1],dp[i][j-1][1],dp[i][j-1][0]+items[i-1][j-1])
        dp1[i][j] = max(dp0[i][j]+items[i-1][j-1],dp1[i][j-1],dp0[i][j-1]+items[i-1][j-1])
        dp2[i][j] = max(dp2[i][j-1],dp1[i][j-1]+items[i-1][j-1])
        dp3[i][j] = max(dp3[i][j-1],dp2[i][j-1]+items[i-1][j-1])
        if i < r:
            dp0[i+1][j] = max(dp0[i][j],dp1[i][j],dp2[i][j],dp3[i][j])
        #maximam[i][j] = max(dp[i][j])

print(max(dp0[-1][-1],dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))

Measured memory_bytes: 429080
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;

using namespace std;



int main(void) {
	int n;
	cin >> n;
	vector<int> v(n),odd(n);
	rep(i, 0, n)cin >> v[i];

	int count = 0,cnt=0;
	rep(i, 0, n) {
		if ((v[i] - 1) % 2 == 1)odd[i]++;
		if (v[i] % 2 == 1)odd[i]++;
		if ((v[i] + 1) % 2 == 1)odd[i]++;
	}
	cnt /= n;
	int all = 1,allodd=1;
	rep(i, 0, n) all *= 3;
	rep(i, 0, n) allodd *= odd[i];

	cout << all - allodd << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5005,mo=1e9+7;
int n,p[N],i,j,g[N],sz[N],f[N],ans,z,kk,mi[N],fac[N];
bool b[N];
int gfa(int x){return g[x]==x?x:g[x]=gfa(g[x]);}
int main(){
	scanf("%d",&n);
	for(i=*mi=1;i<N;++i)mi[i]=1ll*mi[i-1]*(n-1)%mo;
	for(i=*fac=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%mo;
	for(i=1;i<=n;++i)g[i]=i;
	for(i=1;i<=n;++i){
		scanf("%d",p+i);
		if(p[i]!=-1)g[gfa(i)]=gfa(p[i]);else ++kk;
	}
	for(i=1;i<=n;++i)if(p[i]==-1)b[gfa(i)]=1;
	for(i=1;i<=n;++i)++sz[gfa(i)];
	for(i=1;i<=n;++i)if(gfa(i)==i && !b[i])++z;
	ans=1ll*(n-z)*mi[kk]%mo;
	int c=0,zz=0;
	f[0]=1;
	for(i=1;i<=n;++i)if(gfa(i)==i && b[i]){
		for(j=c;j>=0;--j)f[j+1]=(f[j+1]+1ll*f[j]*sz[i])%mo;
		zz=(zz+1ll*(sz[i]-1)*mi[kk-1])%mo;
		++c;
	}
	for(i=2;i<=c;++i)zz=(zz+1ll*fac[i-1]*mi[kk-i]%mo*f[i])%mo;
	ans=(ans+mo-zz)%mo;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

#define M 105

int n,W;

int main( )
{
    scanf("%d %d",&n,&W);
    ll MAT[n+1][W+1];
    int weight[n],price[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d %d",&weight[i],&price[i]);
    }
   // cout<<"YES"<<endl;

    for(int i=0; i<=n; i++)
    {
        for(int w=0; w<=W; w++)
        {
            if(i==0||w==0)
            {
                MAT[i][w]=0;
            }
            else if((weight[i-1]<=w)&&(price[i-1]+MAT[i-1][w-weight[i-1]])>MAT[i-1][w])
            {
                MAT[i][w]=price[i-1]+MAT[i-1][w-weight[i-1]];
            }
            else
            {
                MAT[i][w]=MAT[i-1][w];
            }
        }
    }
    printf("%lld\n",MAT[n][W]);

    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  std::vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.begin(), v.end(), greater<int>());
  int total = accumulate(v.begin(), v.begin() + k, 0);
  cout << total << endl;
}


Measured memory_bytes: 3592
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static class Solution {

        public void find() {

        }
    }

    public static void main(String[] args) {
        Solution sol = new Solution();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<>();
        sc.nextLine();
        for(int i=0; i<n; i++) {
            set.add(sc.nextLine());
        }
        System.out.println(set.size());
        sol.find();
    }
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {

  vector<int> count(4);
  REP(i, 3) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    count[a]++;
    count[b]++;
  }
  bool ans = true;
  REP(i, 4) if (count[i] >= 3) ans = false;
  cout << (ans ? "YES":"NO") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w, n;
	char dummy;
    cin>>w;
	cin>>n;
	int *data = new int [w];
	int *a = new int [n];
	int *b = new int [n];
	for(int i=0;i<n;++i)
	{
		cin>>a[i]>>dummy>>b[i];
	}
	for(int i=0;i<w;++i)
	{
		data[i]=i+1;
	}
	for(int i=0;i<n;++i)
	{
		swap(data[a[i]-1],data[b[i]-1]);
	}
	for(int i=0;i<w;++i)
	{
		cout<<data[i]<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
int main()
{
	int n;
	while(cin>>n){
		int four = 0, one = 0, two = 0;
		for(int i = 1; i <= n; i++){
			cin>> a[i];
			if (a[i] % 4 == 0) four++;
			else if (a[i] % 2 == 0) two++;
			else one++;
		}
		if (one < four + 1 || (one == four + 1 && two==0))
			cout << "Yes" <<endl;
		else
			cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 640