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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int64_t pow3(int64_t x) {
    return x * x * x;
}

int main() {
    int n, k;
    cin >> n >> k;
    if (2 * n < k) {
        cout << 0 << '\n';
        return 0;
    }
    int64_t ans = pow3(n / k);
    if (k % 2 == 0) {
        ans += pow3((n - k/2) / k + 1);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int LL;
LL t[3][100005];
int main(){
	LL a,b,c;
	int n,m;
	int i,j,k;
	LL s=0;
	cin>>n>>m;
	for(i=0;i<n;i++,a=b){
		cin>>b;
		if(i==0)continue;
		if(a<b)c=b-a,t[2][0]+=c;
		else c=b+m-a,t[2][0]+=b+1,t[1][0]--;
		t[0][a]--,t[0][b-1]+=c,t[0][b]-=c-1;
	}
	for(i=1;i<=2;i++){
		for(j=1;j<=m;j++){
			t[i][j]=t[i][j-1]+t[i-1][j-1];
		}
	}
	for(i=1,s=t[2][1];i<=m;i++){
		if(s>t[2][i])s=t[2][i];
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define N 100005
#define maxn 10005
#define INF 0x3f3f3f3f
#define mase(a,b) memset(a,b,sizeof(a))
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
#define DS DisputeSegement
using namespace std;
struct DisputeSegement
{
    int x,y;

}SENode[N];
bool Cmp(DS A,DS B)
{
    /*if(A.y!=B.y)
    {
        return A.y<B.y;
    }
    else
    {
        return A.x<B.x;
    }*/
    return A.y<B.y;
}
int main()
{
    int n,m;
    int miny=INFINITY;
    int re;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&SENode[i].x,&SENode[i].y);
        miny=MIN(miny,SENode[i].y);
    }
    sort(SENode,SENode+m,Cmp);
    re=1;
    for(int i=0;i<m;i++)
    {
        if(SENode[i].x>=miny)
        {
            re++;
            miny=SENode[i].y;
        }

    }
    printf("%d\n",re);
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll X, Y; cin >> X >> Y;

  ll i = 0;
  ll ans = -1;
  while(true) {
    if(X % Y == 0) {
      break;
    }

    i = i + X;
    if(i % Y != 0) {
      ans = i;
      break;
    }

    if(i > pow(10, 18)) break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#define MAX 100000000

int n, q;
int S[MAX],T[MAX];

int sum;

int binarySearch(int key) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if ( S[mid] == key ) {
            return 1;
        } else if ( S[mid] < key ) {
            left = mid + 1;
        } else if ( S[mid] > key ) {
            right = mid;
        }
    }
    return 0;
}

int main() {
    sum = 0;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &T[i]);
        sum += binarySearch(T[i]);
    }
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

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

    string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ans;
    rep(i, s.size()) rep(j, 26) {
        if (s[i] == alphabet[j]) {
            ans += alphabet[j + n];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x) - 1, input().split())
ty, tx = map(lambda x: int(x) - 1, input().split())
s, t = sy * W + sx, ty * W + tx
graph = [input() for _ in range(H)]

INF = 1 << 30
dist = [INF] * (H * W)
que = []

def push(v, d):
    if(dist[v] <= d):
        return
    dist[v] = d
    heapq.heappush(que, (d, v))

def move(ny, nx, d):
    if ny < 0 or ny >= H or nx < 0 or nx >= W:
        return
    if graph[ny][nx] == '.':
        push(ny * W + nx, d)

push(s, 0)

while que:
    d, v = heapq.heappop(que)
    if d > dist[v]:
        continue
    if v == t:
        break
    y, x = divmod(v, W)
    for dy in range(-2, 3):
        for dx in range(-2, 3):
            move(y + dy, x + dx, d + (abs(dy) + abs(dx) > 1))

if dist[t] == INF:
    print(-1)
else:
    print(dist[t])


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

using namespace std;


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


    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    long long ans = 0;

    for (int i = 0; i < N; i++) {
        ans += A[i] / 2;
        A[i] %= 2;
        if (i < N && A[i + 1] > 0 && A[i] > 0) {
            A[i]--;
            A[i + 1]--;
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  cin >>N;
  
  if (N>81){
    cout <<"No"<<endl;
  }
  else{
    int n=1;
    for (int i=9;i>0;i--){
      if (N%i==0){
        n=i;
        break;
      }
    }
    if (N/n<10){
      cout << "Yes" <<endl;
    }
    else{
      cout << "No" <<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int mn=1000000009;
  cin>>s;
  for(int i=0; i<=s.length()-3; i++){
    int x = 0;
  	for(int j=0; j<3; j++){
    	x+=((s[i+j]-48)*pow(10,2-j));
    }
    mn = min(mn,abs(x-753));
  }
  cout<<mn<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

int main(void) {
  ll a, b;
  cin >> a >> b;

  ll ans=0;

  if(a==1 || b==1){
    ans=1; prt(ans); return 0;
  } else if (a%2==1 && b%2==1){
    ans=a*b/2+1;
  } else {
    ans=a*b/2;
  }
  prt(ans);
}


Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=1e5+100;
vector<int>gfo[N];
bool vst[N];

void dfs(int u){
	vst[u]=true;
	for(int v:gfo[u])if(!vst[v])dfs(v);
}

int main(){	
	int n,m;cin>>n>>m;
	For(i,0,m){
		int x,y,z;cin>>x>>y>>z;
		x--,y--;
		gfo[x].pb(y);
		gfo[y].pb(x);
	}
	int cnt=0;
	For(i,0,n)if(!vst[i])cnt++,dfs(i);
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N, K;
  cin >> N >> K;
  int P = 1;
  rep(i, N)
  {
    if (P < K)
      P *= 2;
    else
      P += K;
  }
  cout << P << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a==7 && b==5 && c==5) {
        cout << "YES" << endl;
    } else if (a==5 && b==7 && c==5) {
        cout << "YES" << endl;
    } else if (a==5 && b==5 && c==7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    if b % a == 0:
        print(a + b)
    else:
        print(b - a)


if __name__ == '__main__':
    main()


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

class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	
	Point operator + (Point p){
		return Point(x+p.x,y+p.y);
	}
	Point operator - (Point p){
		return Point(x-p.x,y-p.y);
	}
	Point operator * (double a){
		return Point(a*x,a*y);
	}
	double norm(){
		return x*x+y*y;
	}	
};
typedef Point Vector;

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


Point project(Point p1,Point p2,Point w){
	
	Vector base=p2-p1;
	double r=dot(w-p1,base)/base.norm();
	return p1+base*r;
}

int main(){
	
	double g,h,j,k;
	scanf("%lf%lf%lf%lf",&g,&h,&j,&k);
	Point p1(g,h);
	Point p2(j,k);
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		double o,p;
		scanf("%lf%lf",&o,&p);
		Point w(o,p);
		Point u=project(p1,p2,w);
		printf("%.10lf %.10lf\n",u.x,u.y);
	}
	return 0;
}



Measured memory_bytes: 3252
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF 99999999

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef unordered_map<int,Edges> Graph;

void shortestPath(Graph &g, int s,
    unordered_map<int,Weight> &dist, unordered_map<int,int> &prev) {
  for(auto &f:g)dist[f.first]=INF; dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev.find(e.dst) != prev.end()) continue;
    prev[e.dst] = e.src;
    for(auto &f:g[e.dst]) {
      if (dist[f.dst] > e.weight+f.weight) {
        dist[f.dst] = e.weight+f.weight;
        Q.push(Edge(f.src, f.dst, e.weight+f.weight));
      }
    }
  }
}

char buf[1001];
int W;
int coor(int x,int y){return (y)*(W*2+2)+x;}
int main(){
	int H,N,X1,Y1,X2,Y2;
	scanf("%d%d%d%d%d%d%d",&W,&H,&N,&X1,&Y1,&X2,&Y2);
	X1=coor(X1*2,Y1*2),X2=coor(X2*2,Y2*2);
	vector<vector<int> >m(H*2+1);
	for(auto &&e:m)e.resize(W*2+1);
	for(int i=0;i<N;i++){
		int x,y,t,l;
		scanf("%d%d%d%s",&x,&y,&t,buf);
		l=strlen(buf);
		x=2*x+1,y=2*y+1;
		for(int j=0;j<t;j++){
			for(int k=0;k<l;k++){
				int c=buf[k];
				if(c=='L'&&1<x)m[y][x-1]++,x-=2;
				if(c=='U'&&1<y)m[y-1][x]++,y-=2;
				if(c=='R'&&x<W*2-1)m[y][x+1]++,x+=2;
				if(c=='D'&&y<H*2-1)m[y+1][x]++,y+=2;
			}
		}
	}
	Graph g;
	for(int h=0;h<=H*2;h+=2)for(int w=0;w<=W*2;w+=2){
		int a=coor(w,h),b;
		if(h<H*2)b=coor(w,h+2),g[a].push_back(Edge(a,b,m[h+1][w])),g[b].push_back(Edge(b,a,m[h+1][w]));
		if(w<W*2)b=coor(w+2,h),g[a].push_back(Edge(a,b,m[h][w+1])),g[b].push_back(Edge(b,a,m[h][w+1]));
	}
	unordered_map<int,Weight> dist;
	unordered_map<int,int> prev;
	shortestPath(g,X1,dist,prev);
	printf("%d\n",dist[X2]);
}

Measured memory_bytes: 56948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    ll n; cin >> n;
    vll l(2*n);
    rep(i,2*n)cin >> l[i];
    sort(all(l));
    //rep(i,2*n)cout << l[i] << ((i < 2*n - 1)?" ":"\n");
    ll ans = 0;
    rep(i,n){
        ans += l[2*i];
        //cout << l[2*i] <<  " ";    
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}  

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  ll ans = (N - 1) / 2;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
S = list(input())

def Word(i, a, b):
    if S[i] != S[i + a] and S[i] != S[i + a + b] and S[i + a] != S[i + a + b]:
        return True
    else:
        return False

R = S.count("R")
G = S.count("G")
B = S.count("B")

ans = R * G * B
for i in range(0, N - 1):
    for a in range(1, math.ceil(N / 2)):
        if i + a * 2 >= N:
            break
        if S[i] != S[i + a] and S[i] != S[i + a * 2] and S[i + a] != S[i + a * 2]:
            ans -= 1

print(ans)

Measured memory_bytes: 9256
#include <stdio.h>

int main() {
	int N, t, sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &t);
		sum += t; 
	}
	printf("%d\n", sum - N); 
	
	return 0; 
} 

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>//next_permutation
using namespace std;

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

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

    int tg[n];
    for(int i=0;i<n;i++){
       tg[i] = i+1 ;
    }

    int p_ind = -1 ;
    int q_ind = -1 ;
    int i = 1 ;
    do{
        bool pflag = 1 ;
        bool qflag = 1 ;

    if(pflag && qflag){
     for(int j=0;j<n;j++){
        if(pflag==0 && qflag==0) break ;  
        if(pflag && tg[j]!=p[j]) pflag = 0 ;
        if(qflag && tg[j]!=q[j]) qflag = 0 ;
        }
     }
       if(pflag) p_ind = i;
       if(qflag) q_ind = i;
       if(p_ind!=-1 && q_ind!=-1) break ;
       i++ ;
    }while(next_permutation(tg,tg+n));

    cout << abs(p_ind-q_ind) << endl ;

    return 0;
}

Measured memory_bytes: 256
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

A,B,N = inpl()
if B <= N:
  x = B-1
else:
  x = N
    
print(A*x//B)
  
      

Measured memory_bytes: 27092
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    int A,B,C;
    int N,M,K,X,Y;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;

int main(){
    cin>>A>>B>>C;
    ans=(A+B)*C/2;

    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
<?php
$input=explode(' ',trim(fgets(STDIN)));
$n=intval($input[0]);

$cnt_1 = 0;
for($i = 1; $i <= $n; $i+=2){
  $cnt_2 = 0;
  for($j = 1; $j <= $i; $j++){
    if($i % $j == 0){
      $cnt_2++;
    }
  }
  if($cnt_2 == 8){
    $cnt_1++;
  }
}

echo $cnt_1;
?>

Measured memory_bytes: 4856
import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
i=int(math.sqrt(n))
while i>0:
    if n%i==0:
        ans=i+n//i-2
        break
    i-=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  cout << (x/500)*1000 + (x%500)/5*5 << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  if (input[input.length -1 ] === "") {
    input.pop();
  }
  var people = input.shift();
  var time = 0;
  var minCapacity = Math.min(...input);

  if (people > minCapacity) {
    time += Math.ceil(people / minCapacity);
  }
  if (time === 0) {
    time = 1;
  }
  time += 4;
  console.log(time);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
int A1,A2,A3,sum;
cin >> A1 >> A2 >> A3;
sum = A1 + A2 + A3;
if(sum >= 22)
 cout << "bust" << endl;
if (sum <= 21)
 cout << "win" << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
long long ans;
int N,M;
long long dp[100005][50];

int soinnsuu(int N,int k,int cnt){
    if (N%k == 0 && N>1){
        cnt += 1;
        return soinnsuu(N/k,k,cnt);
    }else{
        return cnt;
    }
}
int beki(int N,int k){
    int anss = 1;
    for (int i = 0;i<k;i++){
        anss *= N;
    }
    return anss;
}

int main() {
    cin >> N >> M;
    dp[0][0] = 1;
    for (int i = 0;i<100001;i++){
        dp[i+1][0] = 1;
        for ( int j = 1;j<50;j++){
            dp[i+1][j] = (dp[i+1][j-1] +dp[i][j])%1000000007;
        }
    }
    ans = 1;
    for (int j = 2;j<100000000;j++){
        if (M == 1){
            break;
        } else {
            if (M % j == 0){
                int s= soinnsuu(M,j,0);
                M = M /(beki(j,s));
                ans *= dp[N][s];
                ans %= 1000000007;
            }
        }
    }
    if ( M== 1){
      cout << ans << endl;
    } else {
        cout << N << endl;
    }
    
}

Measured memory_bytes: 39424
#include<iostream>
#include<vector>
#include<assert.h>

using namespace std;

int main(void) {
    int i,n;
    bool ans = false;
    cin >> n;
    int A[n];
    for (i=0; i<n; i++) {
        cin >> A[i];
    }
    int one=0;
    int two=0;
    int four=0;
    for (i=0; i<n; i++) {
        if (A[i]%4 == 0) {
            four++;
        } else if (A[i]%2 == 0) {
            two++;
        } else {
            one++;
        }
    }
    if (two == 1) {
        two--;
        one++;
    }
    if (two == 0) {
        if (four >= one-1) {
            ans = true;
        }
    } else {
        if (four >= one) {
            ans = true;
        }
    }
    if (ans) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
int N;
vector<string> a;

bool ok(vector<string> &t){
    rep(i,N) rep(j,N){
        if(t[i][j]=='.') return false;
    }
    return true;
}

bool ok2(vector<string> &t){
    rep(i,N) rep(j,N){
        if(t[i][j]=='#') return false;
    }
    return true;
}


int main(){
    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        a.push_back(s);
    }

    if(ok(a)){
        cout << 0 << endl;
        return 0;
    }

    if(ok2(a)){
        cout << -1 << endl;
        return 0;
    }

    /*
     * 少なくとも1列がすべて#になれば良い
     */
    ll col=0;
    rep(c,N){
        bool f=true;
        rep(r,N) if(a[r][c]=='.'){
            f=false;
            break;
        }
        if(!f) col++;
    }

    ll cnt=LINF;
    rep(i,N){
        ll x=0;
        rep(j,N) if(a[i][j]=='.') x++;
        bool f=false;
        rep(j,N) if(a[j][i]=='#'){
            f=true;
            break;
        }
        if(!f){
            x++;
        }
        cnt=min(cnt,x);
    }
    cout << col+cnt << endl;
    return 0;
}


Measured memory_bytes: 512
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vector<ll> A(3*N);
	rp(i, 3*N) cin>>A[i];

	vector<ll> F(3*N);
	F[0] = A[0];
	priority_queue<int> fque;
	fque.push(-A[0]);
	for(int i=1; i<3*N; ++i){
		fque.push(-A[i]);
		ll minA = 0;
		if(fque.size() > N){
			minA = -fque.top();
			fque.pop();
		}
		F[i] += F[i-1] + A[i] - minA;
	}

	reverse(all(A));

	vector<ll> B(3*N);
	B[0] = A[0];
	priority_queue<int> bque;
	bque.push(A[0]);
	for(int i=1; i<3*N; ++i){
		bque.push(A[i]);
		ll minA = 0;
		if(bque.size() > N){
			minA = bque.top();
			bque.pop();
		}
		B[i] += B[i-1] + A[i] - minA;
	}

	ll maxfb = LLONG_MIN;
	rp(i, N+1){
		int f = N - 1 + i;
		int b = 3*N - 1 - N - i;
		maxfb = max(maxfb, F[f]-B[b]);
	}
	cout<< maxfb <<endl;

}

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i(0); i < s.size(); ++i) {
		if (s[i] != t[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3888
n = gets.chomp.to_i
ls = gets.chomp.split.map(&:to_i).sort
cnt = 0
n.times do |i|
    j=i-1
    k=0
    while k<j do
        if ls[i] < ls[k]+ls[j]
            cnt+=j-k
            j-=1
        else
            k+=1
        end
    end
end
puts cnt

Measured memory_bytes: 1912
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define debug(x) cout<<#x<<": "<<x<<" "
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
const int N=200010;
int main()
{
    IO;
    int n;
    string s;
    cin>>n>>s;
    
    int i=0,j=n-1;
    int res=0;
    while(i<j)
    {
        if(s[i]=='R'&&s[j]=='W') i++,j--;
        else if(s[i]=='W'&&s[j]=='R') 
        {
            swap(s[i],s[j]);
            res++,i++,j--;
        }
        else if(s[i]=='W'&&s[j]=='W') j--;
        else i++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3772
N,C = map(int,input().split())
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

Sum_right_maxA = [0] * (N+1)
Sum_right_maxB = [0] * (N+1)
for i in range(1,N+1):
    Sum_right_maxA[i] = max(Sum_right_maxA[i-1], Sum_right[i] - 2 * (C - XV[N+1-i][0]))
    Sum_right_maxB[i] = max(Sum_right_maxB[i-1], Sum_right[i] - (C - XV[N+1-i][0]))

ans = 0
for i in range(N+1):
    ans = max(ans, Sum_left[i] + Sum_right_maxA[N-i] - XV[i][0], Sum_left[i] + Sum_right_maxB[N-i] - 2*XV[i][0])
print(ans)


Measured memory_bytes: 38512
(let* ((str (read-line))
       (ans nil))
  (map nil (lambda (n) (cond ((char= n #\0) (push #\0 ans))
                             ((char= n #\1) (push #\1 ans))
                             ((char= n #\B) (pop ans)))) str)
  (princ (concatenate 'string (reverse ans))))

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

using namespace std;

const int N = 1e5 + 1;
int a[N], n, m;

class FastIO {
public:
	FastIO() {
		///nothing
	}
	int get_int() {
		bool neg = 0;
		register int c;
		c = getchar();
		int res = 0;
		if (c == '-') {
			neg = true;
			c = getchar();
		}
		for(; '0' <= c && c <= '9'; c = getchar())
			res = res * 10 + c - '0';
		if (neg) return -res;
		return res;
	}
private:
	
};

int main() {
	FastIO io;
	n = io.get_int();
	m = io.get_int();
	for (int i = 1; i <= m; ++i)
		a[i] = io.get_int();
	sort(a + 1, a + 1 + m);
	vector<int> f;
	int sum = 0, sub = 0;
	for (int i = 1; i < m; ++i) {
		f.push_back(a[i + 1] - a[i]);
		sum += f.back();
	}
	sort(f.begin(), f.end(), greater<int>());
	for (int i = 0; i < min(n - 1, int(f.size())); ++i)
		sub += f[i];
	printf("%d", sum - sub);
	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 100007;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC\n";
	else  cout << "ABC\n";
    return 0;
}

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


int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> line(h);
    for(int i=0;i<h;++i){
        cin >> line.at(i);
    }
    
    const int dx[4] = {0,1,0,-1};
    const int dy[4] = {1,0,-1,0};
    bool can = 1;

    for(int i=0;i<h;++i){
        if (!can) break;

        for(int j=0;j<w;++j){
            if (line.at(i).at(j)=='.') continue;
            bool flag = 0;
            for(int k=0;k<4;++k){
                const int x = i + dx[k];
                const int y = j + dy[k];
                if (x<0||x>=h) continue;
                if (y<0||y>=w) continue;

                if (line.at(x).at(y) == '#' ) flag = 1;
            }
            if (!flag){
                can = 0;
                break;
            }
        }
    }
    if (can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=["."*(w+2)]
for i in range(h):
  l+=["."+input()+"."]
l+=["."*(w+2)]
ans=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]==".":
      continue
    if l[i+1][j]=="#" or l[i-1][j]=="#" or l[i][j+1]=="#" or l[i][j-1]=="#":
      continue
    ans=1
print("YNeos"[ans::2])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int calc(int l,int r){
    return max(0LL,r-l+1);
}

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

    int N; cin>>N;
    vector<pair<int,int>> v;
    for(int i=0;i<N;i++){
        int l,r; cin>>l>>r;
        v.push_back({r,l});
    }
    sort(v.begin(),v.end());
    vector<int> l(N),r(N);
    for(int i=0;i<N;i++){
        l[i]=v[i].second;
        r[i]=v[i].first;
        // cout<<l[i]<<' '<<r[i]<<endl;
    }

    multiset<int> st;
    for(int i=1;i<N;i++) st.insert(l[i]);

    int ans=0;
    int curL=l[0],curR=r[0];
    for(int i=1;i<N;i++){
        st.erase(st.find(l[i]));
        if(i==N-1){
            int x=calc(curL,curR)+calc(l[i],r[i]);
            // cout<<curL<<' '<<curR<<' '<<x<<endl;
            chmax(ans,x);
        }else{
            int mx=*st.rbegin();
            int x=calc(max(curL,mx),curR)+calc(l[i],r[i]);
            int y=calc(curL,curR)+calc(max(l[i],mx),r[i]);
            chmax(ans,x); chmax(ans,y);
            // cout<<curL<<' '<<curR<<' '<<mx<<' '<<x<<' '<<y<<endl;
            chmax(curL,l[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8048
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,sum=0,k; cin>>n>>k;
    int ar[n];
  
  for(int i=0;i<n;i++)
    cin>>ar[i];
  sort(ar,ar+n);
  for(int i=0;i<k;i++)
    sum+=ar[i];
  cout<<sum;
}


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

int main(){
	int sanka[1001],i,j,n,m,imo;
	
	while(~scanf("%d%d",&n,&m)){
		if(n==0 && m==0)break;
		
		memset(sanka,0,sizeof(sanka));
		i=n;
		imo=1;
		j=1;
		while(i>1){
			if(sanka[j]==0){
				if(imo==m){
//					printf("%d %d\n",j+1,n-i+1);
					sanka[j]=1;
					imo=1;
					--i;
				}else{
					++imo;
				}
			}
			j=j%n+1;
		}
		
		for(i=1;i<=n;i++){
			if(sanka[i]==0){
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 4010;
const int oo = 1e9;
struct edges
{
	int to, next;
}edge[maxn << 1];
int point[maxn] = {0}, te = 0;
void add(int a, int b)
{
	te ++;
	edge[te].to = b;
	edge[te].next = point[a];
	point[a] = te;
}
int n;
bool flag[maxn];
int len[maxn], dp[maxn], num[maxn] = {0};
void dfs(int now, int p)
{
	num[now] = flag[now];
	len[now] = 0;
	int sum = 0, ans = 0;
	for(int e = point[now]; e; e = edge[e].next)
		if(edge[e].to != p)
		{
			dfs(edge[e].to, now);
			num[now] += num[edge[e].to];
			int a = num[edge[e].to] + len[edge[e].to];
			len[now] += a;
			sum += a;
			ans += num[edge[e].to] + dp[edge[e].to];
		}
	dp[now] = ans;
	bool asd = 0;
	for(int e = point[now]; e; e = edge[e].next)
		if(edge[e].to != p)
		{
			int tmp = sum - num[edge[e].to] - len[edge[e].to];
			if(num[edge[e].to] + dp[edge[e].to] > tmp)
			{
				asd = 1;
				dp[now] = min(dp[now], num[edge[e].to] + dp[edge[e].to] - tmp);
			}
		}
	if(!asd)
		dp[now] = (sum & 1);
}
int ans = oo;
void work(int root)
{
	dfs(root, 0);
	if(dp[root] == 0)
		ans = min(ans, len[root] / 2);
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		char a;
		cin >> a;
		flag[i] = a - '0';
	}
	for(int i = 1; i < n; i ++)
	{
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
	}
	for(int i = 1; i <= n; i ++)
		work(i);
	if(ans >= oo)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <climits>
#include <vector>
#include <cmath>
#include <cstring>
#include <set>

using namespace std;

int main(void)
{

    uint64_t N, A, B;
    cin >> N >> A >> B;

    uint64_t AB = A + B;

    uint64_t wari = (N / AB) * A;

    uint64_t amari = N % AB;
    amari = min(amari, A);

    cout << wari + amari << 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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), v(1000010);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        auto u = factorize(A[i]);
        for(auto&p:u){
            v[p.first]++;
        }
        /*
        ll cur = A[i];
        while(cur <= 1000010){
            v[cur]++;
            cur += A[i];
        }*/
    }
    bool flag = 1;
    rep(i,1000010){
        if(v[i] > 1){
            flag = 0;
            break;
        }
    }
    if(flag){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    ll now = A[0];
    rep(i,N){
       now =  __gcd(now,A[i]);
    }
    if(now == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "not coprime" << endl;
}

Measured memory_bytes: 18680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using vi = vector<int>;
using pii = pair<int, int>;
#define fir first
#define sec second

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

int main() {
    // input
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }
    // solve
    int min_c = 1000;
    rep(bit, 1<<d) {
        int cnt = 0, scr = 0;
        rep(i, d) {
            if (bit & 1<<i) {
                scr += p[i] * 100 * (i+1) + c[i];
                cnt += p[i];
            }
        }
        if (scr >= g) chmin(min_c, cnt);
        else {
            repr(i, d) {
                if (not (bit & 1<<i)) {
                    for (int j = 0; j < p[i]-1; j++) {
                        scr += 100 * (i+1);
                        cnt++;
                        if (scr >= g) break;
                    }
                }
                if (scr >= g) break;
            }
            if (scr >= g) chmin(min_c, cnt);
        }
    }
    // output
    cout << min_c << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

	int find(int e) {
		return d[e];
	}
};

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

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}

signed main() {
    string s;
    cin>>s;
    map<char,int>mp;
    rep(i,s.size())mp[s[i]]++;
    if(mp.size()!=2)cout<<"No"<<endl;
    else if(mp.begin()->second!=2)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int main()
{
    int a[4], i, sum;

    for(i=0; i<3; i++)
    {
        cin >> a[i];

    }

    sort(a, a+3);

    sum=a[2]-a[0];

    cout << sum;



    return 0;

}


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

bool dp[40000];

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

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < (1 << n); i++) {
        int s = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) s += A[j];
        }
        dp[s] = true;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        if (dp[m])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}



Measured memory_bytes: 3196
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  bool flag = true;
  int curx = 0, cury = 0;
  int curt = 0;
  for(int i = 0; i < n; i++){
    int t, x, y;
    cin >> t >> x >> y;
    int dis = abs(curx - x) + abs(cury - y);
    int tdis = t - curt;
    if(tdis < dis || (tdis - dis) % 2 ==1)flag = false;
    curx = x;
    cury = y;
    curt = t;
  }
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  if (s == "Sunny")
    cout << "Cloudy" << endl;
  else if (s == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

long long factorial(int n) {
	long long f = 1;
	for (int i = 2; i <= n; ++i) {
		f *= (long long) i;
		f %= mod;
	}

	return f;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	if (abs(n - m) > 1) {
		cout << "0\n";
		return 0;
	}


	if (n == m) {
		long long fact_n = factorial(n);
		cout << (2 * fact_n * fact_n) % mod << "\n";
	} else {
		long long fact = factorial(min(n, m));
		cout << (((max(n, m) * fact) % mod) * fact) % mod << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long f[100][10];
long long p[100][11];
long long d[10];
long long n;

int main() {
	cin >> n;
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j <= 10; j++) {
			cin >> p[i][j];
		}
	}
	int res = -(1 << 31);
	for (int i = 1; i < 1024; i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			int c = 0;
			for (int k = 0; k < 10; k++) {
				if (i >> k & 1 && f[j][k]) {
					c++;
				}
			}
			sum += p[j][c];
		}
		res = max(res, sum);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
A = [[int(i) for i in input().split()] for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
 
d  = [[0]*3 for i in range(3)]
 
for B in b:
  for i in range(3):
    for j in range(3):
      if A[i][j]==B:
        d[i][j] = 1
 
ans = "No"
for i in range(3):
  if d[i][0]==d[i][1]==d[i][2]==1:
    ans = "Yes"
    break
  elif d[0][i]==d[1][i]==d[2][i]==1:
    ans = "Yes"
    break
if d[0][0]==d[1][1]==d[2][2]==1:
  ans ="Yes"
elif d[2][0]==d[1][1]==d[0][2]==1:
  ans ="Yes"
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  
  public static void main(String[] args){
    
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int count=0;
    for(int i=1;i<=N;i++){
      String x = Integer.toString(i);
      int length = x.length();
      if(length%2!=0){
        count++;
      }
    }
    System.out.println(count);
    
  }
  
}

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

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll inf = 0x3f3f3f3f3f3f3f3f;

ll n, k, a[maxn], b[maxn], c[maxn], cnt1, cnt2, cnt3;

bool check(ll mid) {
    ll res = 0;
    if (mid < 0) {
        res = cnt1 * cnt2;
        for (int i = 1, j = cnt3; i <= cnt3; i++) {
            j = max(j, i);
            while (j > i && c[i] * c[j] >= -mid) j--;
            res = res - (j - i);
        }

        for (int i = 1, j = cnt1; i <= cnt1; i++) {
            j = max(j, i);
            while (j > i && a[i] * a[j] >= -mid) j--;
           res = res + j - i; 
        }

        for (int i = 1, j = cnt2; i <= cnt2; i++) {
            j = max(j, i);
            while (j > i && b[i] * b[j] >= -mid) j--;
            res = res + j - i;
        }
    } else {
        for (int i = 1, j = cnt1; i <= cnt1; i++) {
            j = max(j, i);
            while (j > i && a[i] * a[j] > mid) j--;
            res = res + j - i;
        }

        for (int i = 1, j = cnt2; i <= cnt2; i++) {
            j = max(j, i);
            while (j > i && b[i] * b[j] > mid) j--;
            res = res + j - i;
        }
        res += cnt1 * cnt2 + (n - cnt1 - cnt2) * (cnt1 + cnt2) + (n - cnt1 - cnt2) * (n - cnt1 - cnt2 - 1) / 2;
    }
    return res >= k;
}

int main() {
    ll x, l, r, mid;
    scanf("%lld%lld", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &x);
        if (x < 0) a[++cnt1] = -x;
        if (x > 0) b[++cnt2] = x;
        if (x) c[++cnt3] = max(x, -x);
    }
    sort(a + 1, a + 1 + cnt1);
    sort(b + 1, b + 1 + cnt2);
    sort(c + 1, c + 1 + cnt3);

    l = -inf, r = inf;
    while (l < r) {
        mid = l + r >> 1;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    printf("%lld\n", r);
    return 0;
}


Measured memory_bytes: 4224
#!/usr/bin/env python3
import sys


def solve(r: int):
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    r = int(input())
    print(int(3*(r*r)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
const int mod = 1e9+7;
const int inf = 1e9+7;
typedef long long ll;
#define sa(n) scanf("%d",&(n))
int main(void)
{
    int a,b;
    cin>>a>>b;
    if(a>9 || b>9) cout<<-1<<endl;
    else cout<<(a*b)<<endl;
    return 0;
}


Measured memory_bytes: 256