akhauriyash/Code-Regression huggingface dataset:
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	int dp[k+1] = {0};
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		dp[v[i]] = 1;
	}
	dp[0] = 0;
	for(int i=1;i<=k;i++){
		bool ans = false;
		for(int j=0;j<n;j++){
			if((i-v[j])>=0){
				ans = (ans | (dp[i-v[j]]^1));
			}
		}
		dp[i] = dp[i] | ans;
	}
	if(dp[k]){
		cout<<"First";
	}else{
		cout<<"Second";
	}
    return 0;
}
//.........

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(k <= a) cout << k << endl;
    else if(k <= a+b) cout << a << endl;
    else cout << a - (k-a-b) << endl;
    return 0;
}

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

int dfs(int64_t v, int N, int& count){
	if(v > N){
		return 0;
	}
	
	int tmp = v;
	bool thr = false, fiv = false, sev = false;
	while(0 < tmp){
		int digit = tmp % 10;
		thr |= (digit == 3);
		fiv |= (digit == 5);
		sev |= (digit == 7);
		tmp /= 10;
	}
	if(thr && fiv && sev){
		count++;
	}
	//cout << v << endl;
	dfs(v * 10 + 3, N, count);
	dfs(v * 10 + 5, N, count);
	dfs(v * 10 + 7, N, count);
	return 0;
}

int main(){
	int N;
	cin >> N;
	
  	int count = 0;
	dfs((int64_t)0, N, count);
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
gcd_list=[]
reverse_gcd_list = []


def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)

gcd_list.append(A[0])
reverse_gcd_list.append(A[-1])

for i in range(1,N):
    gcd_list.append(gcd(gcd_list[i-1], A[i]))
    # reverse_gcd_list.insert(0,gcd(reverse_gcd_list[0], A[-1-i]))
    reverse_gcd_list.append(gcd(reverse_gcd_list[-1], A[-1-i]))

reverse_gcd_list.reverse()
num = [gcd_list[-2], reverse_gcd_list[1]]
for i in range(N-2):
    num.append(gcd(gcd_list[i], reverse_gcd_list[i+2]))

print(max(num))


Measured memory_bytes: 14076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

double dist(pair<int, int> x0, pair<int, int> x1) {
  double dx = x1.first - x0.first;
  double dy = x1.second - x0.second;
  return sqrt(dx*dx + dy*dy);
}

int main() {
  int N; cin >> N;
  vector<pair<int, int>> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());

  double ans = 0.0;
  int M = 0;
  do {
    for (int i = 1; i < N; i++) {
      auto from = v[i-1], to = v[i];
      ans += dist(from, to);
    }
    M++;
  } while(next_permutation(v.begin(), v.end()));

  cout << setprecision(20) << fixed << ans/M << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B;
  string S;
  cin>>A>>S>>B;
  if(S=="+") cout<<A+B;
  else cout<<A-B;
return 0;}

Measured memory_bytes: 3616
/**
 *    author:  RM07
 *    created: July 05, 2020 5:31 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    int n;
    cin >> n;
    if(n % 1000){
        cout << 1000 - (n % 1000) << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int solve(string line, int s, int t) {
    if (line[s] != '[') {
        return stoi(line.substr(s, t - s)) / 2 + 1;
    }
    vector<int> CS;
    while (s < t) {
        int ns = s + 1;
        int bs = 1;
        while (bs) {
            s++;
            if (line[s] == '[') bs++;
            if (line[s] == ']') bs--;
        }
        CS.push_back(solve(line, ns, s));
        s++;
    }
    sort(all(CS));
    int ans = 0;
    loop (CS.size() / 2 + 1, i) ans += CS[i];
    return ans;
}

int main()
{
    int n; cin >> n;
    while (n--) {
        string line; cin >> line;
        cout << solve(line, 1, line.size() - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  char a,b,c,d,e,f;
  cin >> a>>b>>c>>d>>e>>f;
 
  cout << (a==f && b==e && c==d ? "YES":"NO") << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std; 
 int main() {
    pair<int, int> arr[5];
    int total = 0;
    for (int i = 0; i < 5; i++) {
        arr[i].first = 0;
    }
    for (int i = 0; i < 5; i++) {
        cin >> arr[i].second;
    }
    for (int i = 0; i < 5; i++) {
        while (((arr[i].second+arr[i].first) % 10) != 0) {
            arr[i].first++;
        }
    }
    sort(arr, arr+5);
    for (int i = 0; i < 4; i++) {
        total = total + arr[i].first+arr[i].second;
    }
    total = total + arr[4].second;
    cout << total;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
using ll=long long;
const int M=100010;

int main(){
	int n,x[110],y[110],h[110];
	cin>>n;
	rep(i,0,n)cin>>x[i]>>y[i]>>h[i];
	rep(i,0,101){
		rep(j,0,101){
			rep(k,0,n){
				int ch=h[k]+abs(i-x[k])+abs(j-y[k]);
				rep(l,0,n){
					if(max(ch-abs(i-x[l])-abs(j-y[l]),0)!=h[l])break;
					if(l==n-1){
						cout<<i<<" "<<j<<" "<<ch<<endl;
						return 0;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

int e[16][16];

void solve(ll N, ll M, vector<ll> a, vector<ll> b) {
  REP(i,M) {
    e[a[i]-1][b[i]-1] = 1;
    e[b[i]-1][a[i]-1] = 1;
  }
  vector<int> p(N);
  REP(i,N) p[i] = i;
  int res = 0;
  do {
    bool ok = true;
    if (p[0] != 0) break;
    REP(i,N-1) {
      if (!e[p[i]][p[i+1]]) ok = false;
    }
    res += ok;
  } while (next_permutation(ALL(p)));
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll M;
	scanf("%lld", &N);
	scanf("%lld", &M);
	vector<ll> b(M-1+1);
	vector<ll> a(M-1+1);
	for (int i = 0 ; i <= M-1 ; i++) {
	  scanf("%lld", &a[i]);
	  scanf("%lld", &b[i]);
	}
	solve(N, M, a, b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

bool check(const vl& L,const ll& N){
	FOR(i,0,N-1)if(L[i+1] < L[i])return 0;
	return 1;
}

vl Sort(vl L,ll N){
	random_device rnd;
	while(!check(L,N)){
		ll a = rnd()%N;
		ll b = rnd()%N;
		if(L[a] > L[b])swap(L[a],L[b]);
	}
	return L;
}

signed main(){
	ll N;
	cin >> N;
	vl L(N);
	FOR(i,0,N)cin >> L[i];
	vl ans = Sort(L,N);
	ll SUM = 0;
	FOR(i,0,N)SUM += ans[i];
	Yes(SUM-ans[N-1] > ans[N-1]);
}


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

i = int(0)
best_times = int(0)
while i <= N:
    x = i
    answer_times = 0
    while x % 2 == 0 and x != 0:
        answer_times += 1
        x /= 2
    if best_times < answer_times:
        best_times = answer_times
    i += 1

answer = int(2 ** best_times)
print(answer)

Measured memory_bytes: 3060
import math
data = input().rstrip().split(" ")
ap = int(data[0])
bp = int(data[1])
max = int(data[2])
one = 0
two = 0
answer = 0
if bp - 1 <= max:
    change = bp - 1
else:
    change = max

one = math.floor(ap * change / bp)
two = math.floor(change / bp)
answer = one - two * ap
print(answer)

Measured memory_bytes: 9196
n=int(input())
d=[int(input())-1for i in range(n)]
s=set()
s.add(0)
ans=0
b=0
while 1>0:
  if d[b] in s:
    ans=-1
    break
  b=d[b]
  s.add(b)
  ans+=1
  if b==1:
    break
print(ans)

Measured memory_bytes: 13220
#include<stdio.h>
#define MAX 100000
#define MIN -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];

void preOrder(int);
void inOrder(int);
void postOrder(int);

int main(){
  int i,n,x,y,z,root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].parent=MIN;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d%d%d",&x,&y,&z);
    T[x].left= y;
    T[x].right= z;
    if ( y!=MIN) T[y].parent=x;
    if ( z!=MIN) T[z].parent=x;
  }

  for ( i = 0; i < n; i++ ) {
    if ( T[i].parent==MIN){
      root=i;
    }
  }
  printf("Preorder\n");
  preOrder(root);
  printf("\n");
  printf("Inorder\n");
  inOrder(root);
  printf("\n");
  printf("Postorder\n");
  postOrder(root);
  printf("\n");

  return 0;
}

void preOrder(int u){
  if (u==MIN) return;
  printf(" %d", u);
  preOrder(T[u].left);
  preOrder(T[u].right);
}
void inOrder(int u){
  if (u==MIN) return;
  inOrder(T[u].left);
  printf(" %d", u);
  inOrder(T[u].right);
}
void postOrder(int u){
  if (u==MIN) return;
  postOrder(T[u].left);
  postOrder(T[u].right);
  printf(" %d", u);
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(int i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;

int main() {
	cin >> n;
	REP(i, n) {
		ll x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	ll a;
	ll b = 1;
	ll c = 0;

	if (n % 2 == 0) {
		a = n / 2;
	}
	else if (n % 2 == 1) {
		a = (n - 1) / 2;
	}

	REP(i, n - 2) {
		if (v[i] == v[i + 2]) {
			c = 1;
		}
	}
	if (v[1] == 0) {
		c = 1;
	}
	REP(i, a) {
		b = b * 2 % 1000000007;
	}
	if (c == 0) {
		cout << b << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 1404
#include<cstdio>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
int sum[100500],a[100500],tree[200500];
	int n;
int low(int x){
	return x&-x;
}
void adde(int i){
	for (;i<=2e5+50;i+=low(i)) tree[i]++;
}
ll ask(int i){
	ll s=0;
	for (;i>0;i-=low(i)) s+=tree[i];
	return s;
}
bool check(int x){
	ll num=0;
	for (int i=1;i<=2e5+50;i++)
	tree[i]=0;
	for (int i=1;i<=n;i++){
		sum[i]=sum[i-1]+((a[i]>=x)?(1):(-1));
	}
	for (int i=0;i<=n;i++){
		num+=ask(sum[i]+1e5+1);
		adde(sum[i]+1e5+1);
	}
	if (num>=1ll*n*(n+1)/4) return 1;else return 0;
}
int main(){
	scanf("%d",&n);
	int l=0,r=0;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		r=max(r,a[i]);
	}
	while (l<=r){
		int m=(l+r)>>1;
		if (check(m)) l=m+1;else r=m-1;
	}
	printf("%d",r);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2,tmp3;
//int a[100001] = {};
//int b[100010] = {};
int a,b,c,d;
deque<PII> que;
string s;
VPII kukan[100002];
int dp[1005][1005];

const int CMAX = 2000000;
long long fact[CMAX] = {};
long long revFact[CMAX] = {};
void setFact(int N)
{
  fact[0] = 1;
  for (int i = 1; i<N; i++)
  {
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  revFact[N-1] = powmod(fact[N-1],mod-2);
  for (int i=N-2;i>=0;i--)
  {
    revFact[i] = revFact[i+1]*(i+1);
    revFact[i] %= mod;
  }
}

long long getC(int a, int b)
{
  return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
}

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n>>a>>b>>c>>d;
    dp[0][0] = 1;
    setFact(n*2);
    rep(i,1,n+1){
        int wari = powmod(revFact[i],c-1);
        if (a<= i && i <= b){
        rep(j,c,d+1){
            wari *= revFact[i];
            wari %= mod;
            rep(k,0,n+1){
                if(k + j*i <=n){
                    dp[i][k+j*i] += (dp[i-1][k] * getC(n-k,j*i))%mod * fact[j*i]%mod * revFact[j]%mod*wari;
                    dp[i][k+j*i] %= mod;
                }
            }
        }
        }
        rep(j,0,n+1){
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod;
        }
    }
    cout<<dp[n][n]<<endl;
//    rep(i,0,n+1){
 //       rep(j,0,n+1){
//            cout<<dp[i][j]<<" ";
//        }
//        cout<< endl;
//    }
}

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

int main(){
int n;
  cin >> n;
vector<pair<int,int>> a(n);
  for(int i =0;i<n;i++)
    cin >> a.at(i).second >> a.at(i).first;

  int ans=0;
  int time =0;
  sort(a.begin(),a.end());
  
  for(pair<int,int> x : a){
  int s,t;
    tie(s,t) = x;
    time += t;
    if(time >s){
    ans ++;
      break;
    }
      
  }
    
  if(ans >0) cout <<"No";
  else cout << "Yes";
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    coin = [6**i for i in range(10) if 6**i <= N]
    coin += [9**i for i in range(10) if 9**i <= N]
    coin.sort()
    dp = [INF]*(N+1)
    dp[0]=0
    for c in coin:
        for i in range(N+1):
            if i>=c:
                dp[i] = min(dp[i-c]+1, dp[i])
    print(dp[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 6900
# coding: utf-8
import sys
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, K = lr()
g = gcd(A, B)

def make_divisors(n):  # nの約数を列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = make_divisors(g)
divisors.reverse()
answer = divisors[K-1]
print(answer)


Measured memory_bytes: 5076
answerers, num_foods = map(int, input().split(' '))
favorites = []

for i in range(answerers):
  current_ans = list(map(int, input().split(' ')))
  favorites.extend(current_ans[1:])

res = [ favorites.count(food) == answerers for food in list(set(favorites)) ]
print(res.count(True))

Measured memory_bytes: 3060
# AGC013
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()
for i in range(N):
    if A[i] == A[i+1]:
        pass
    elif A[i] > A[i+1]:
        now = "N"
        break
    else:
        now = "P"
        break
ans = 1
for i in range(N-1):
    if now == "?":
        if A[i] == A[i+1]:
            pass
        elif A[i] > A[i+1]:
            now = "N"
        else:
            now = "P"
    elif now == "P":
        if A[i] <= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
    else:
        if A[i] >= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X,Y,a,b,result;
    cin >> X;

    a = X / 500;
    b = (X - (a * 500)) / 5;

    result = (a * 1000) + (b * 5);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll S = 0;
    rep(i,n) {
        cin >> a[i];
        S += a[i];
    }
    ll x1 = S;
    for(int i = 2; i <= n - 1; i += 2){
        x1 -= (2 * a[i - 1]);
    }
    cout << x1 << " ";

    ll prev_x = x1;
    for(int i = 2; i <= n; i++){
        ll xi = 2 * a[i - 2] - prev_x;
        cout << xi << " ";
        prev_x = xi;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

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

  long M = (long)ceil(sqrt(N));
  long ans = 30000000000000;

  rep2(i, 1,  M+1){
    if(N % i == 0){
      if(ans > (i + N / i - 2))
	ans = i + N / i - 2;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i * 108 / 100 == n){
            cout << i << endl;
            return 0;
        }
    } 
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

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

    vector<int> num(n);
    for(int i = 0; i < n; ++i){
        cin >> num[i];
    }
    
    int ans = 0;
    for(int i = 1; i < n - 1; ++i){
        bool b1 = (num[i - 1] < num[i] && num[i] < num[i + 1]);
        bool b2 = (num[i - 1] > num[i] && num[i] > num[i + 1]);
        ans += (b1 || b2);
    }

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

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
    
using namespace std;
using ll = long long;
using pii = pair<int, int>;
    
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 200200;
const double PI = acos(-1);
ll memo[maxn];

ll fexp(ll a, ll b){
    ll ans = 1;

    while (b){
        if (b&1){
            ans = (ans*a)%mod;
        }
        a = (a*a)%mod;
        b = b >> 1;
    }
    return ans;
}

ll fat(ll num){
    if (num <= 1) return 1;
    if (memo[num] != -1) return memo[num];
    return memo[num] = (num*fat(num-1))%mod;
}

ll combina(ll a, ll b){
    ll x = 1, y = 1;
    for (ll i=1; i<=b; i++){
        x = (x *(i+(a - b)))%mod;
        y = (y*i)%mod;
    }
    return (x*fexp(y, mod - 2))%mod;
}
int main(){
    ll n, a, b, x, y, cnt;
    memset(memo, -1, sizeof memo);
    cin >> n >> a >> b;

    ll ans = (fexp(2, n) - 1 + mod)%mod;
    ans = (ans - combina(n, a) + mod)%mod;
    ans = (ans - combina(n, b) + mod)%mod;

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

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL n;
  cin >> n;
  LL a,b,c,d;
  cin >> a >> b >> c >> d;
  for(LL i=0;i<n;i++){
    if(i>n-i+1){
      if(c*(2*i-n+1)-(d-c)*(n-i-1)<=b-a&&b-a<=d*(2*i-n+1)+(d-c)*(n-i-1)){
        cout << "YES" << endl;
        return 0;
      }
    }else{
      if(d*(2*i-n+1)-(d-c)*i<=b-a&&b-a<=c*(2*i-n+1)+(d-c)*i){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
  ll n;
  cin>>n;
  
  ll a[n],b[n],c[n],i,sum=0;
  
  for(i=0;i<n;i++)
  cin>>a[i];
  
  for(i=0;i<n;i++)
  cin>>b[i];
  
  for(i=0;i<n-1;i++)
  cin>>c[i];
  
  
  for(i=0;i<n-1;i++)
  {
      if(a[i+1]==a[i]+1)
      sum+=(b[a[i]-1]+c[a[i]-1]);
      else
      sum+=b[a[i]-1];
  }
  
  sum+=b[a[n-1]-1];
  cout<<sum;
}

int main()
{
  solve();
  return 0;
}

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

using namespace std;	
int a[30]; 
int main()
{
	long long int a , b = 0;
	cin >> a;
	long long int m[a] , n[a];
	for(int i = 0; i < a; i++){
		cin >> m[i] >> n[i];
	}
	for(int i = a - 1; i >= 0; i--){
		m[i] += b;
		if(m[i] % n[i] != 0)
		b += n[i] - (m[i] % n[i]);
	}
	cout << b;
}


Measured memory_bytes: 1920
#include<stdio.h>
int main(void)
{
	int n,m,d,i,j,l,g=0;
	char a[300][300];
	scanf("%d %d %d",&n,&m,&d);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				l=0;
				while(l<=d-1){
					if(a[i+l][j]=='.' && l!=d-1){
						l++;
					}
					else if(a[i+l][j]=='.' && l==d-1){
						g+=1;
						l++;
					}
					else{
						l=100;
					}
				}
				l=0;
				while(l<=d-1){
					if(a[i][j+l]=='.' && l!=d-1){
						l++;
					}
					else if(a[i][j+l]=='.' && l==d-1){
						g+=1;
						l++;
					}
					else{
						l=100;
					}
				}
			}
		}
		printf("%d\n",g);
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000003
   
int main(){
	int h,w,m,i,maxr=INT_MIN,maxc=INT_MIN,a,b,r,c;
	cin>>h>>w>>m;
	set<pair<int,int>> target;

	for(i=0;i<m;i++){
		cin>>a>>b;
		target.insert({a,b});
	}
	map<int,int> row;
	map<int,int> col;
	for(auto it=target.begin();it!=target.end();it++){
		row[it->first]++;
		col[it->second]++;
		if(row[it->first]>maxr){
			maxr=row[it->first];
		}
		if(col[it->second]>maxc){
			maxc=col[it->second];
		}
		
	}
	int ans=maxr+maxc-1;
	unordered_set<int> candir;
	unordered_set<int> candic;
	for(auto k:row){
		if(k.second == maxr)
			candir.insert(k.first);
	}
	for(auto k:col){
		if(k.second == maxc)
			candic.insert(k.first);
	}

	for(auto m:candir){
		for(auto n:candic){
			if(!target.count({m,n})){
				ans++;
				cout<<ans<<endl;
				return 0;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 72800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,T[200001],A[200001],D[200001][2],ans=1,mod=1e9+7;
    cin>>n;
    rep(i,n) cin>>T[i];
    rep(i,n) cin>>A[i];
    if(T[n-1]!=A[0]) ans=0;
    int t,a;
    rep(i,n) if(T[i]==A[0]){
        t=i;
        break;
    }
    rep(i,n) if(A[i]==A[0]) a=i;
    if(t>a) ans=0;
    rep(i,n){
        if(i==0) D[0][0]=T[0],D[0][1]=1;
        else{ 
            D[i][0]=T[i];
            if(T[i]!=T[i-1]) D[i][1]=1;
            else D[i][1]=0;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            D[n-1][0]=A[n-1],D[n-1][1]=1;
        }
        else if(!D[i][1]){
            D[i][0]=min(T[i],A[i]);
            if(A[i]!=A[i+1]) D[i][1]=1;
        }
    }
    rep(i,n) if(!D[i][1]) ans=ans*(D[i][0])%mod;
    cout<<ans;
}

Measured memory_bytes: 6400
// 2011/04/03 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string str;
		cin >> str;
		if(cin.eof())
			break;

		int num[10];
		for(int i=0; i<10; i++)
			num[i] = str[i]-'0';

		for(int i=9; i>=1; i--)
			for(int j=0; j<i; j++)
				num[j] = (num[j]+num[j+1])%10;

		cout << num[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())

duplas = 0
sim = 0
for i in range(n):
    a,b = map(int,input().split())

    if a==b:
        duplas += 1
    else:
        duplas = 0
    
    if duplas >= 3:
        sim = 1
        break

if sim:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c-=b;
    if(c <= 0){
      cout << "Yes\n";
      break;
    }
    a-=d;
    if(a <=0){
      cout << "No\n";
      break;
    }
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	vector<int> d;
	pair<long double, long double> pos[8];
	for (int i = 0; i < n; i++)
	{
		d.push_back(i);
		long double tmpX, tmpY;
		cin >> tmpX >> tmpY;
		pos[i] = make_pair(tmpX, tmpY);
	}

	long double sum = 0;
	int count = 0;
	do 
	{
		for (int i = 0; i < n - 1; i++)
		{
			sum += sqrt(pow(pos[d[i]].first - pos[d[i + 1]].first, 2) + pow(pos[d[i]].second - pos[d[i + 1]].second, 2));
		}
		count++;
	}
	while (next_permutation(d.begin(), d.end()));
	cout.precision(20);
	cout << (long double)(sum / count);
}


Measured memory_bytes: 31488
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
char color[500][500];
int a_search(int i, int j);
int colm,row;
  
int main()  {

  int a,b,c,d;
  // 空白文字で区切られた数字を 3 つ取得
  std::cin >> a >> b >> c >> d;
  int flg;
  flg = 0;
  for (int i = 0;i<4;i++){
	  if(a==1 || b==1 || c==1 || d==1){
	  }
	  else{
		flg = 1;
   	 }	
  }
  for (int i = 0;i<4;i++){
	  if(a==9 || b==9 || c==9 || d==9){
	  }
	  else{
		flg = 1;
   	 }	
  }
  for (int i = 0;i<4;i++){
	  if(a==7 || b==7 || c==7 || d==7){
	  }
	  else{
		flg = 1;
   	 }	
  }
  for (int i = 0;i<4;i++){
	  if(a==4 || b==4 || c==4 || d==4){
	  }
	  else{
		flg = 1;
   	 }	
  }
  if(flg == 0){
  printf("YES");
  }
  else{
  printf("NO");
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	priority_queue<pi> s;
	
	auto ins = [&](int i){
		int l = (i + n - 1) % n, r = (i + 1) % n;
		if(b[l] < b[i] && b[i] > b[r] && a[i] + b[l] <= b[i] - b[r]) s.emplace(b[i], i);
	};
	
	ll ans = 0;
	rep(i, n) ins(i);
	
	while(s.size()){
		pi p = s.top(); s.pop();
		int i = p.second, sum = b[(i + n - 1) % n] + b[(i + 1) % n];
		int d = p.first - a[i];
		if(d <= 0) continue;
		ans += d / sum;
		b[i] -= d / sum * sum;
		ins((i + n - 1) % n);
		ins((i + 1) % n);
	}
	cout << (a == b ? ans : -1) << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
using namespace std;
#include <string>
#include <stack>

int main(){
	string u;
  	cin >> u;
    
    
    int count = 0;

    stack<char> S;

    for(int i = 0; i<u.size();i++){
        char x = u[i];

        if(S.size()==0){
            S.push(x);
        }else{
            if(S.top() == x){
                S.push(x);
            }else{
                S.pop();
                count += 2;
            }
        }
    }

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

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

int main () {
        long long n;
        cin >> n;
        int ans = 30;
        for (long long i = 1; i * i <= n; i++) {
                if (n % i == 0) {
                        int j = n / i;
                        int now = i, cnt = 0;
                        while (now) {
                                cnt++;
                                now /= 10;
                        }
                        now = j;
                        int c2 = 0;
                        while (now) {
                                c2++;
                                now /= 10;
                        }
                        cnt = max (cnt, c2);
                        ans = min (ans, cnt);
                }
        }
        printf ("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[] c = new int[26];
        for (int i = 0; i < h; i++) {
            char[] a = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                c[a[j] - 'a']++;
            }
        }
        int f = (h/2)*(w/2)*4;
        int t = 0;
        int o = 0;
        if(h%2==1)t+=w;
        if(w%2==1)t+=h;
        if(h%2==1 && w%2==1){
            o++;
            t -= 2;
        }
        for (int i = 0; i < 26; i++) {
            int ff = Math.min(f, c[i]) /4 *4;
            f -= ff; c[i] -= ff;
            int tt = Math.min(t, c[i]) /2 *2;
            t -= tt; c[i] -= tt;
            int oo = Math.min(o, c[i]);
            o -= oo; c[i] -= oo;
        }
        System.out.println(f==0 && t==0 && o==0 ? "Yes" : "No");
        sc.close();

    }

}


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

#define ll long long
#define N 100005
#define mod 1000000007


int main() 
{
    ll n,a[N],i,cnt;
    vector<ll> v;
    
    cin>>n;
    
    for(i=0;i<n;i++) cin>>a[i];
    
    sort(a,a+n);
    reverse(a,a+n);
    cnt=1;
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        cnt++;
        if(cnt>=2)
        {
            v.push_back(a[i]);
            cnt=1;
            if(v.size()>=2)
            break;
            i++;
        }
        if(a[i]!=a[i-1])
        {
            cnt=1;
        }
    }
    if(v.size()<2)
    {
        cout<<0<<endl;
        return 0;
    }
    cout<<v[0]*v[1]<<endl;
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    vi a(26, 0); REP(i, S.length()) a[S[i]-'A']++;
    int count = 0;
    REP(i, 26) if(a[i] == 2) count++;
    if(count == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

dic = {}
cnt = 0
for i in range(N):
    if s[i] in dic:
        cnt += dic[s[i]]
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
print(cnt)





Measured memory_bytes: 67032
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(x) cout<<x<<endl
#define int long long 
using namespace std;
string s[2010];
int a[2010][2010],b[2010][2010];
int numa[2010*2010],numb[2010*2010];
//a,b数组表示这个点在序号为几的块中，numa和numb表示各个块的有多少个连续的'.'。 
signed main() {
	int i,j,k,n,m,x,y,h=0;
	scanf("%d%d",&n,&m);
	for(i=0; i<n; i++) {//存图 
		cin>>s[i];
	}
	for(i=0; i<n; i++) {
		x=0;
		for(j=0; j<m; j++) {
			if(s[i][j]=='#') {
				if(x>0) { 
					numa[h]=x;
					x=0;
					h++;
				}
			} else {
				a[i][j]=h;
				x++;
			}
		}
		if(x>0) {
			numa[h]=x;
			h++;
		}
	}
	h=0;
	for(i=0; i<m; i++) {
		x=0;
		for(j=0; j<n; j++) {
			if(s[j][i]=='#') {
				if(x>0) {
					numb[h]=x;
					x=0;
					h++;
				}
			} else {
				b[j][i]=h;
				x++;
			}
		}
		if(x>0) {
			numb[h]=x;
			h++;
		}
	}
	int ma=0;
	for(i=0; i<n; i++) {
		for(j=0; j<m; j++) {
			ma=max(ma,numa[a[i][j]]+numb[b[i][j]]-1);
		}
	}
	printf("%lld",ma);
	return 0;
}



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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  int cnt_a = 0, cnt_b = 0, cnt_ba = 0;
  for(int i = 0;i < N;i++){
    string s;
    cin >> s;
    for(int j = 0;j < (int)s.size()-1; j++){
      if(s[j] == 'A' && s[j+1] == 'B'){
        ans++;
      }
    }
    if(s[0] == 'B' && s[(int)s.size()-1] == 'A'){
      cnt_ba++;
    }else{
      if(s[0] == 'B'){
        cnt_b++;
      }else if(s[(int)s.size()-1] == 'A'){
        cnt_a++;
      }
    }
  }
  if(cnt_ba > 0){
    ans += cnt_ba-1;
    if(cnt_b > 0){
      cnt_b--;
      ans++;
    }
    if(cnt_a > 0){
      cnt_a--;
      ans++;
    }
  }
  ans += min(cnt_a, cnt_b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;
const long long INF = 1e9;

int main()
{
  int n, k; cin >> n >> k;
  vector<ll> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  
  vector<ll> dp(n + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++){
    for (int j = 1; j <= k; j++){
      if (i + j >= n) continue;
      
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    } 
  }
  
  cout << dp[n - 1] << endl;
  return 0;
}


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

int main()
{
  int N, cnt = 0;
  cin >> N;
  vector<pair<int64_t, int64_t>> robots(N);
  for (int i = 0; i < N; i++)
  {
    int64_t x, l;
    cin >> x >> l;
    robots.at(i) = make_pair(x + l, x - l);
  }
  int64_t x = 0;
  sort(robots.begin(), robots.end());
  for (int i = 0; i < N; i++)
  {
    if (i == 0)
    {
      cnt++;
      x = robots.at(i).first;
      continue;
    }
    else if (x == robots.at(i).first || robots.at(i).second < x)
    {
      continue;
    }
    else
    {
      cnt++;
      x = robots.at(i).first;
    }
  }
  cout << cnt << endl;
}

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

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 gcd(int x, int y){
	if(x % y == 0) return y;
	return gcd(x, x % y);
}
int lcm(int x, int y){
	return x * y / gcd(x, y);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  reverse(a.begin(), a.end());
  rep(i,n){
    if(i == n-1) cout << a[i] << endl;
    else cout << a[i] << " ";
  }
}





Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main()
{
	long long int n,cnt=0,i,j,z;
	char a[105],b[105],c[105];
	cin>>n;
	cin>>a>>b>>c;
	for(i=0;i<n;i++)
	{
		if((a[i]==b[i])&&(b[i]==c[i]))
		{
			continue;
		}
		else
		{
			if((a[i]==b[i])||(a[i]==c[i])||(b[i]==c[i]))
			{
				cnt++;
			}
			else
			{
				cnt+=2;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
 
signed main() {
    FAST_IO;
 
    int n;
    cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define p 1000000007
using namespace std;
int n,K,ans,to[1010],f[1010][1010],g[1010],num[1010][1010];
bool check(int x,int y)
{
	if((x^y^1)&1) return 0;
	for(int i=x;i<=y;i++)
	if(to[i]&&(to[i]<x||to[i]>y)) return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1,x,y;i<=K;i++)
	scanf("%d%d",&x,&y),to[x]=y,to[y]=x;
	int sum=(n-K)<<1;
	n<<=1;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
		num[i][j]=num[i][j-1]+(!to[j]);
	g[0]=1;
	for(int i=2;i<=n;i+=2) g[i]=1LL*g[i-2]*(i-1)%p;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
		if(check(i,j))
		{
			f[i][j]=g[num[i][j]];
			for(int k=i+1;k<j;k++)
			if(f[i][k]&&g[num[k+1][j]])
			(f[i][j]+=p-1LL*f[i][k]*g[num[k+1][j]]%p)%=p;
			ans=(ans+1LL*f[i][j]*g[sum-num[i][j]]%p)%p;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6656
<?php

fscanf(STDIN, "%d", $n);
$a_arr = [];
$x_arr = [];
$y_arr = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d", $a);
    $a_arr[] = $a;

    for ($j = 0; $j < $a; ++$j) {
        $inputs = explode(' ', trim(fgets(STDIN)));
        $x_arr[$i][$j] = $inputs[0];
        $y_arr[$i][$j] = $inputs[1];
    }
}


$max = 0;
for ($bit = 0; $bit < (1 << $n); ++$bit) {

    $honests = [];
    for ($i = 0; $i < $n; ++$i) {
        if ($bit & (1 << $i)) {
            $honests[] = $i;
        }
    }

    $flg = true;
    foreach ($honests as $honest) {
        for ($i = 0; $i < $a_arr[$honest]; ++$i) {
            if (
                // x_arr[$honest][$i]は正直出なくてはならない
                ($y_arr[$honest][$i] == 1 && ! in_array($x_arr[$honest][$i] - 1, $honests))
                || ($y_arr[$honest][$i] == 0 && in_array($x_arr[$honest][$i] - 1, $honests))
            ) {
                $flg = false;
                break 2;
            }
        }
    }

    if ($flg) {
        $max = max($max, count($honests));
    }
}

echo $max, PHP_EOL;



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

using namespace std;

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

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> a(n);
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ret = 0, cnt;
    bool flag = 1;
    while(flag) {
        for(i = 0; i < n; i++) {
            if(a[i] >= n) {
                cnt = a[i] / n;
                ret += cnt;
                a[i] %= n;
                for(j = 0; j < n; j++) {
                    if(j != i) {
                        a[j] += cnt;
                    }
                }
            }
        }
        flag = false;
        for(i=0;i<n;i++){
            if(a[i]>=n)flag = true;
        }
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

int main() {
    int d,t,s;
    cin >> d >> t >> s;
    if ((d / s + (d % s == 0 ? 0 : 1)) > t) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 3604