akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,n,k;
  string s;
  cin >> n >> s >> k;
for (i=0;i<n;i++)
  {if (s[i] != s[k-1]) s[i] = '*';}
 cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, n;
    cin >> h >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        h -= a.at(i);
    }

    if(h > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  int n;
  cin >> n;
  double rev = 0;
  rep(i, n){
    int a;
    cin >> a;
    rev += 1.0 / a;
  }
  printf("%.6lf", 1.0 / rev);
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
using P = pair<int, int>;
void add(ll &a, ll b)
{
    a = (a+b)%MOD;
}
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<P>> v(n+1);
    for(int i = 0; i < m; i++)
    {
        int l, r, x;
        cin >> l >> r >> x;
        v[r].push_back(P(l, x));
    }
    ll dp[310][310][310];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    ll ans = 0;
    for(int r = 0; r <= n; r++)
    {
        for(int g = 0; g <= n; g++)
        {
            for(int b = 0; b <= n; b++)
            {
                int ma = max(r, max(g, b));
                int mi = min(r, min(g, b));
                int md = r+g+b-ma-mi;
                for(P p : v[ma])
                {
                    int l = p.first;
                    int x = p.second;
                    if(x == 1)
                    {
                        if(l <= md) dp[r][g][b] = 0;
                    }
                    else if(x == 2)
                    {
                        if(l <= mi || md < l) dp[r][g][b] = 0;
                    }
                    else
                    {
                        if(mi < l) dp[r][g][b] = 0;
                    }
                }
                add(dp[ma+1][g][b], dp[r][g][b]);
                add(dp[r][ma+1][b], dp[r][g][b]);
                add(dp[r][g][ma+1], dp[r][g][b]);
                if(ma == n)
                {
                    add(ans, dp[r][g][b]);
                }
            }
        }
    }
    cout << (ans+MOD) % MOD << endl;
}


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

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  vector<vector<int>> d(n,vector<int>(n));
  rep(i,m){
    int l,r;
    cin>>l>>r;
    l--; r--;
    d[n-l-1][r]++;
  }
  
  rep(i,n)for(int j=1;j<n;j++){
    d[i][j]+=d[i][j-1];
    if(i){
      if(d[i-1][j-1]!=d[i-1][j]){
        d[i][j]+=d[i-1][j]-d[i-1][j-1];
      }
    }
  }
  
  rep(i,q){
    int p,q;
    cin>>p>>q;
    p--; q--;
    cout<<d[n-p-1][q]<<endl;
  }
}

Measured memory_bytes: 4588
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
//using ll = long long;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#define push_back pb
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
    speed;
	int x,y,z,cnt=0,ans;
	cin>>x>>y>>z;
	for(int i =y;i>=1;i--){
        if(x%i==0&&y%i==0){
            cnt++;
            if(cnt==z){
            ans=i;
            break;
        }
        }
	}
	cout<<ans<<endl;
return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/

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

int field[3000][3000];
ll dp[4][3000][3000];


int main() {
  int r, c, k;
  cin >> r >> c >> k;
  rep(i, r) rep(j, c) {
    field[i][j] = 0;
  }
  rep(i, k) {
    int ri, ci, vi;
    cin >> ri >> ci >> vi;
    ri--; ci--;
    field[ri][ci] = vi;
  }

  rep(i, c) {
    dp[0][0][i] = 0;
    if (i > 0) dp[1][0][i] = max( dp[0][0][i - 1] + field[0][i], dp[1][0][i - 1] );
    else dp[1][0][i] = field[0][i];
    if (i > 1) dp[2][0][i] = max( dp[1][0][i - 1] + field[0][i], dp[2][0][i - 1] );
    else if (i == 1) dp[2][0][i] = dp[1][0][i - 1] + field[0][i];
    else dp[2][0][i] = 0;
    if (i > 2) dp[3][0][i] = max( dp[2][0][i - 1] + field[0][i], dp[3][0][i - 1] );
    else if (i == 2) dp[3][0][i] = dp[2][0][i - 1] + field[0][i];
    else dp[3][0][i] = 0;
  }

  for(int i = 1; i < r; i++) {
    rep(j, c) {
      ll dpup = max ( max( dp[0][i - 1][j], dp[1][i - 1][j] ), max( dp[2][i - 1][j], dp[3][i - 1][j] ) );
      dp[0][i][j] = dpup;
      dp[1][i][j] = dpup + field[i][j];
      if (j > 0) dp[1][i][j] = max( max( dp[1][i][j], dp[1][i][j - 1] ), dp[0][i][j - 1] + field[i][j] );
      if (j > 1) dp[2][i][j] = max( dp[2][i][j - 1], dp[1][i][j - 1] + field[i][j] );
      else if (j == 1) dp[2][i][j] = dp[1][i][j - 1] + field[i][j];
      else dp[2][i][j] = 0;
      if (j > 2) dp[3][i][j] = max( dp[3][i][j - 1], dp[2][i][j - 1] + field[i][j] );
      else if (j == 2) dp[3][i][j] = dp[2][i][j - 1] + field[i][j];
      else dp[3][i][j] = 0;
    }
  }

  //rep(i, r) { rep(j, c) { cout << dp[0][i][j] << " "; } cout << endl; } cout << endl;
  //rep(i, r) { rep(j, c) { cout << dp[1][i][j] << " "; } cout << endl; } cout << endl;
  //rep(i, r) { rep(j, c) { cout << dp[2][i][j] << " "; } cout << endl; } cout << endl;
  //rep(i, r) { rep(j, c) { cout << dp[3][i][j] << " "; } cout << endl; } cout << endl;

  ll ans = max( max( dp[0][r - 1][c - 1], dp[1][r - 1][c - 1] ), max( dp[2][r - 1][c - 1], dp[3][r - 1][c - 1] ) );
  cout << ans << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 320032
implicit none
integer :: i,n,ans
integer,allocatable,dimension(:) :: a
read*,n
allocate(a(n))
ans = 0
read(*,*)(a(i),i=1,n)
do i=1,n
  if(a(a(i))==i)then
    ans = ans + 1
  endif
enddo
write(*,'(I0)')ans/2
end

Measured memory_bytes: 1152
//
//  abc150_c.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

void permute(int *a, int l, int r)
{
    // Base case
    if (l == r) {
      int number=0;
      for (int i = 0; i <= r; i++) {
        number = number*10 + a[i];
      }
      permutations.push_back(number);
    }
    else
    {
        // Permutations made
        for (int i = l; i <= r; i++)
        {

            // Swapping done
            swap(a[l], a[i]);

            // Recursion called
            permute(a, l+1, r);

            //backtrack
            swap(a[l], a[i]);
        }
    }
}


int main() {
  int n;
  std::cin >> n;
  int p=0;
  int q=0;
  int a[n];

  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    p = p*10 + t;
  }
  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    q = q*10 + t;
  }
  for (int i = 0; i < n; i++) {
    a[i] = i+1;
  }


  permute(a, 0, n-1);
  sort(permutations.begin(), permutations.end());

  int x = 0;
  int y = 0;
  int i = 0;
  for (auto u: permutations) {
    if (u == p) {
      x = i;
    }
    if (u == q) {
      y = i;
    }
    i++;
  }

  std::cout << abs(x-y) << std::endl;

  return 0;
}



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

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


#define rEp(i, a, b) for (int i=a; i<(b); i++)
#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b);}
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll mod)  { return (a%mod+b%mod)%mod;       }
ll sub(ll a, ll b,ll mod) { return (a%mod+mod-b%mod)%mod;   }
ll mult(ll a,ll b,ll mod) { return ((a%mod)*(b%mod))%mod;   }

bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 





int main() {
    FAST
	ll a,b;cin>>a>>b;
	bool p = 0;
	ll k =0;
	ll t = (a+b)/2;

	if(a==b) cout<<0;
	else if(abs(a-t)==abs(b-t)) cout<<t; 
	else cout<<"IMPOSSIBLE";
	
	return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

m = gcd(A,B)
r = factorization(m)

for row in r:
  if row[0] == 1:
    print(len(r))
    exit()
print(len(r)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<bool> A(N);
    rep(i,M){
        ll a;
        cin>>a;
        a--;
        A[a]=1;

    }
    vector<ll>dp(N+1);
    dp[0]=1;
    if(A[0]==0){
        dp[1]=1;
    }
    
    rep(i,N-1){
        if(A[i+1] == 0){
            dp[i+2]=(dp[i+1]+dp[i])%mod;
        }
    }
    cout << dp[N] << endl;


    return 0;
    

}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int n;LL f[N],d[N],mi,E,T;
int main()
{
	n=read(),E=read(),T=read();
	for(RI i=1;i<=n;++i) d[i]=read();
	mi=1e15;
	for(RI i=1,j=0;i<=n;++i) {
		while(j<i&&(d[i]-d[j+1])*2>T) mi=min(mi,f[j]-2*d[j+1]),++j;
		f[i]=mi+2*d[i];
		if(j<i&&f[j]+T<f[i]) f[i]=f[j]+T;
	}
	printf("%lld\n",f[n]+E);
	return 0;
}

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

string s;
int c1,c2;

int main()
{
	cin>>s;
	for(int i=0;i<=2;++i) {
		if(s[i]=='A') c1++;
		else if(s[i]=='B') c2++;
	}
	if(c1&&c2) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 256
#include<iostream>


using namespace std;

int main(){
	int money = 100000;
	int N;
	cin >> N;
	
	for(int i=0;i<N;i++){
		money *= 1.05;
		if(money%1000 == 0) continue;
		
		money = (((int)money/1000)+1)*1000;
	}
	cout << money << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <math.h>
#include <limits.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ipair pair<int,int>
#define rep(I,N) for(int I=0; I<N; I++)
#define rrep(I,N) for(int I=N; I>=0; I--)
#define repj(i,j,n) for(int i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

int bitCount(uint bits) {
  int cnt = 0;
  for(; bits != 0; bits>>=1) {
    cnt += bits & 1;
  }
  return cnt;
}

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

  uint16_t F[100];
  int P[100][11];

  rep (i, N) {
    F[i] = 0;
    rep (j, 10) {
      bool tmp;
      cin >> tmp;
      F[i] |= tmp << j;
    }
  }
  rep (i, N) {
    rep (j, 11) {
      cin >> P[i][j];
    }
  }

  int res = INT_MIN;
  repj (i, 1, 1 << 10) {
    int total = 0;
    rep(j, N) {
      int i_and = F[j] & i;
      int cntone = bitCount(i_and);
      total += P[j][cntone];
    }
    res = max(res, total);
  }

  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,a) loop(i,0,a)

bool ok[256][256];
bool chk(string &s){
    rep(i,s.size()-1)if(!ok[s[i]][s[i+1]])return false;
    return true;
}

int main(){
    string ks[3]={"ABC","DEF","GHI"};
    rep(i,3)rep(j,3){
        if(j-1>=0) ok[ks[i][j]][ks[i][j-1]] = true;
        if(j+1< 3) ok[ks[i][j]][ks[i][j+1]] = true;
        if(i-1>=0) ok[ks[i][j]][ks[i-1][j]] = true;
        if(i+1< 3) ok[ks[i][j]][ks[i+1][j]] = true;
    }

    string s;
    while(cin>>s){
        if(chk(s)) cout<<s<<endl;
    }
}

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define vvll vector<vector<ll>>
#define mod 1e9+7
#define mxn 9e18
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve()
{
    ll a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    while(k!=0)
    {
        if(k<=a)
        {
            ans+=k;
            k=0;
        }
        else
        {
            ans+=a;
            k-=a;
        }
        
        if(k<=b)
        {
            k=0;
        }
        else
        {
            k-=b;
        }
        
        if(k<=c)
        {
            ans-=k;
            k=0;
        }
        else
        {
            ans-=c;
            k-=c;
        }
    }
    cout<<ans;
}

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


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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))
int main()
{
    int a,b;
    
    cin >> a >> b;
    
    cout << a*b << endl;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
	int i,runner;
	String time;
	Runner timeArray[] = new Runner[24];
	void doIt(){
		Scanner sc = new Scanner(System.in);
		for(i = 0; i < timeArray.length; i ++ ){
			runner = sc.nextInt();
			time = sc.next();
			timeArray[i] = new Runner(runner,time);
		}
		for(i = 0; i < 3; i ++ ){
			Arrays.sort(timeArray,i * 8,i * 8 + 8);
			System.out.println(timeArray[i * 8].runner+" "+timeArray[i * 8].time);
			System.out.println(timeArray[i * 8 + 1].runner+" "+timeArray[i * 8 + 1].time);
			timeArray[i * 8].time = "hoge";
			timeArray[i * 8 + 1].time = "hoge2";
		}
		Arrays.sort(timeArray);
		System.out.println(timeArray[0].runner+" "+timeArray[0].time);
		System.out.println(timeArray[1].runner+" "+timeArray[1].time);
	}
	class Runner implements Comparable<Runner>{
		int runner;
		String time;
		Runner(int runner,String time){
			this.runner = runner;
			this.time = time;
		}
		@Override
		public int compareTo(Runner r){
			return time.compareTo(r.time);
		}
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a,b,c;
    cin>> a>>b>>c;



    cout << a*b/2 << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int ans = 0;
    int n, k, q;

    scanf("%d%d%d", &n, &k, &q);
    int cnt[n];
    for (int i = 0; i < n; i++)
        cnt[i] = 0;
    for (int i = 0; i < q; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp - 1]++;
    }

    if (k > q)
    {
        for (int i = 0; i < n; i++)
            puts("Yes");
        return 0;
    }

    for (int i = 0; i < n; i++)
        if (cnt[i] >= q - k + 1)
            puts("Yes");
        else
            puts("No");

    return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Graph graph = new Graph(n);
      int[] ajacent;
      String[] vInfo;
      int id,degree;

      for(int i=0; i<n; i++) {
        vInfo  = br.readLine().split(" ");
        id     = Integer.parseInt(vInfo[0]);
        degree = Integer.parseInt(vInfo[1]);
        ajacent = new int[degree];
        for(int j=0; j<degree; j++) {
          ajacent[j] = graph.convIdToIndex( Integer.parseInt(vInfo[j+2]) );
        }
        graph.setVertex(id, ajacent);
      }

      graph.vertexSearch();

      graph.dispReport();
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }

  class Graph {

    Vertex[] vertices;
    int time;

    public Graph(int size ) {
      vertices  = new Vertex[size];
      time = 0;
    }

    public void setVertex(int id) {
      vertices[convIdToIndex(id)] = new Vertex(id);
    }
    public void setVertex(int id, int[] ajacent) {
      setVertex(id);
      setAjacent(id, ajacent);
    }
    public void setAjacent(int id, int[] ajacent) {
      vertices[convIdToIndex(id)].ajacent = ajacent;
    }
    public void vertexSearch() {
      for (Vertex v : vertices) {
        if(v.state == Vertex.WHITE)
          depthFirstSearch(v.index);
      }
    }
    public void dispReport() {
      StringBuilder buf = new StringBuilder();

      for (Vertex v : vertices) {
          buf.append(v.id).append(" ")
             .append(v.findTime).append(" ")
             .append(v.doneTime).append("\n");
      }

      System.out.print(buf);
    }
    public int convIdToIndex(int id) {
      return id-1;
    }

    private void depthFirstSearch(int index) {
      vertices[index].state = Vertex.GRAY;
      vertices[index].findTime = ++time;
      
      for(int ajcIndex: vertices[index].ajacent) {
        if(vertices[ajcIndex].state == Vertex.WHITE)
          depthFirstSearch(ajcIndex);
      }
      vertices[index].state = Vertex.BLACK;
      vertices[index].doneTime = ++time;
    }

    class Vertex {

      static final int WHITE = 0;
      static final int GRAY  = 1;
      static final int BLACK = 2;
      int id;
      int index;
      int state;
      int[] ajacent;
      int findTime;
      int doneTime;

      public Vertex(int id) {
        this.id = id;
        index = id-1;
        state = WHITE;
      }
    }
  }
}


Measured memory_bytes: 24408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n;
        string s,t,ans;
        cin>>n>>s>>t;
        for (int i = 0; i < n; i++)
        {
            /* code */
            cout<<s[i]<<t[i];
        }
        cout<<endl;
        
   }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 110000;
int n,s,x[N]; ll p[N];
ll calc(int l,int r,int to)
{
	if(s < x[l]) return x[r] - s; if(s > x[r]) return s - x[l];
	if(p[l] >= p[r]) {p[l] += p[r]; return calc(l,r - 1,l) + (to == r ? x[r] - x[l] : 0);}
	else {p[r] += p[l]; return calc(l + 1,r,r) + (to == l ? x[r] - x[l] : 0);}
}
int main()
{
	n = read(); s = read();
	for(int i = 1;i <= n;i ++) x[i] = read(),p[i] = read();
	cout << calc(1,n,p[1] < p[n] ? 1 : n);
	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============is_prime============================
bool is_prime(ll N)
{
  if (N == 1)
  {
    return false;
  }
  for (ll i = 2; i * i <= N; ++i)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}
//=================================================

ll N;

ll count(ll a, ll b, vector<ll>& cnt)
{
  ll over_a = 0, over_b = 0;
  for (ll i = 0; i < 101; ++i)
  {
    if (cnt.at(i) >= a - 1)
    {
      over_a += 1;
    }
    if (cnt.at(i) >= b - 1)
    {
      over_b += 1;
    }
  }
  // cout << over_a << ' ' << over_b << endl;
  return (over_a - 1) * over_b;
}


int main()
{
  cin >> N;
  ll over2 = 0, over5 = 0;
  vector<ll> cnt(101, -1);
  for (ll i = 2; i < 101; ++i)
  {
    if (is_prime(i))
    {
      cnt.at(i) = 0;
    }
  }
  for (ll i = 2; i < N + 1; ++i)
  {
    ll temp = i;
    while (temp != 1)
    {
      for (ll j = 2; j <= temp; ++j)
      {
        if (temp % j == 0)
        {
          temp /= j;
          cnt.at(j) += 1;
          break;
        }
      }
    }
  }
  ll two = 0, five = 0;
  for (ll i = 0; i < 101; ++i)
  {
    if (cnt.at(i) >= 2)
    {
      two += 1;
    }
    if (cnt.at(i) >= 4)
    {
      five += 1;
    }
  }
  ll ans = (two - 2) * (five - 1) * five / 2;
  ans += count(3, 25, cnt) + count(5, 15, cnt);
  for (ll i = 0; i < 101; ++i)
  {
    if (cnt.at(i) >= 74)
    {
      ans += 1;
    }
  }
  cout << ans << endl;
  // cout << "ans" << ans << endl;
  // cout << "1:" << count(1, 75, cnt) << endl;
  // cout << "3:" << count(3, 25, cnt) << endl;
  // cout << "5:" << count(5, 15, cnt) << endl;
  // for (ll i = 0; i < 101; ++i)
  // {
  //   if (cnt.at(i) == 0)
  //   {
  //     continue;
  //   }
  //   cout << i << ' ' << cnt.at(i) << endl;
  // }
  // ll test = 1;
  // for (ll i = 1; i < 101; ++i)
  // {
  //   test *= pow(i, cnt.at(i));
  // }
  // cout << test << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,a[N],d[N],num[N],ans=0;
map<ll,ll> mp;
int main(){
	ll i,cnt=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		d[i]=i-a[i];
		if(!mp.count(d[i]))
		{
			mp[d[i]]=++cnt;
		}
	}
	for(i=0;i<n;i++)
	{
		num[mp[d[i]]]++;
	}
	for(i=0;i<n;i++)
	{
		num[mp[d[i]]]--;
		ans+=num[mp[i+a[i]]];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 30888
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
    ll n;
    cin>>n;
    vector<ll> v;
    rep(i,0,n){
        ll a;
        cin>>a;
        v.pb(a);
    }
    ll ans = 0;
    rep(i,0,v.sz){
        while(v[i]%2==0){
            v[i]/=2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math
#import counter
import collections

N = int(input())
s = input().split()
p = [int(w) for w in s] #これで勝手にNまで拾ってくれます

'''
ans_list = [0 for i in range(N)]

for i in range(len(p)):
    ans_list[p[i]-1] += 1

for i in range(N):
    print(ans_list[i])
'''
c = collections.Counter(p)
#print(c)
for i in range(N):
    print(c[i+1])


Measured memory_bytes: 49380
#include<bits/stdc++.h>
using namespace std;
const int maxn=205;
int n,ans,last[maxn],f[maxn];
char ch[maxn];
int main()
{
	scanf("%s",ch);
	n=strlen(ch);
	memset(last,-1,sizeof(last));
	for (int i=0;i<n;i++)
	{
		int c=ch[i]-'a';
		f[c]=max(f[c],i-last[c]-1);
		last[c]=i;
	}
	for (int i=0;i<26;i++) f[i]=max(f[i],n-last[i]-1);
	ans=n;
	for (int i=0;i<26;i++) ans=min(ans,f[i]);
	printf("%d",ans);
	return 0;
}


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

signed main() {
  int N,M;
  cin>>N>>M;
  int x,ans;
  if(N>M){
    x=N;
    N=M;
    M=x;
  }
  if(N==1){
    if(M==1)ans=1;
    else ans=M-2;
  }
  else{
    ans=(N-2)*(M-2);
  }
  cout<<ans<<endl;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int x, y;
  cin >> x >> y;
  
  cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
from collections import Counter
import math
import sys
from bisect import bisect,bisect_left,bisect_right
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def mod(): return 10**9+7
 
for _ in range(INT()):
    n = INT()
    #s = input()
    #n,ma = MAP()
    arr = LIST()
    s = input()
    check = []
    flag = 0
    for i in range(n-1,-1,-1):
        #print(i)
        x = arr[i]
        for j in range(len(check)):
            x = min(x,x^check[j])

        if x == 0:
            continue
        if s[i] == '0':
            check.append(x)
        else:
            print(1)
            flag = 1
            break
    if flag == 0:
        print(0)

Measured memory_bytes: 9296
#include <iostream>
#include <string>

using namespace std;

bool state[3];
int point;
int out_count;

int init() {
    point = 0;
    out_count = 0;
    for (int i = 0; i < 3; i++) 
        state[i] = false;
}

void hit() {
    if (state[2]) point++;
    if (state[1]) state[2] = true;
    if (state[0]) state[1] = true;
    state[0] = true;
}

void homerun() {
    point++;
    for (int i = 0; i < 3; i++) {
        if (state[i]) {
            point++;
            state[i] = false;
        }
    }
}

void out() {
    out_count++;
}

void solve() {
    init();
    string s;
    while (cin >> s) {
        if (s == "HIT") hit();
        else if (s == "HOMERUN") homerun();
        else if (s == "OUT") {
            out();
            if (out_count == 3) {
                cout << point << endl;
                break;
            }
        }
    }
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
    return 0;
}

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

const ll INF =100000000009;
ll dp[100005];

ll ab(ll x,ll y){
	if(x>y)return x - y;
	else return y - x;
}

int main(){
	ll n,k; cin >> n >> k;
	vl h(n); rep(i,n)cin >> h[i];
	dp[0] = 0;
    dp[1] = ab(h[0] , h[1]);
	for(ll i = 2;i < n+k+10;i++)dp[i] = INF;
	for(ll i = 2;i<n;i++){
		for(ll j = 1;j<k+1;j++){
			dp[i] = min(dp[i] , dp[i - j] + ab(h[i] , h[i - j]));
			if(i - j == 0)break;
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  int a[100010];
  rep(i, n)
  {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  rep(i, n) cnt += (a[a[i]] == i);
  cout << cnt / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

string N;

int main () {
  cin >> N;

  rep(i,2) {
    if(N[i] == N[i+1] && N[i+1] == N[i+2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;

void solve(){
	cin >> n;
	vi freq(1e5+10,0);
	ll sum = 0;
	for(int i =0;i<n;i++){
		cin>>x;
		freq[x]++;
		sum+=x;
	}
	cin >> k;
	for(int i =0;i<k;i++){
		cin >> a >> b;
		int num = freq[a];
		sum-=(1ll*num*a);
		sum+=(1ll*num*b);
		freq[b]+=num;
		freq[a]=0;
		cout << sum<<endl;
	}
}

int main(){

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

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int t , n;
int x , y , z;
string s;

int main()
{
    _FastIO;
    
    cin >> x;
    cout << 1 - x << endl;
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

















Measured memory_bytes: 3608
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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() {
    string S;
    cin >> S;
    rep(i, 0, S.length()) {
        if (i % 2 == 0) {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	set<string> S;
	bool ans = true;
	char ch, ct;
	for (int i=0; i<N; ++i) {
		string s;
		cin >> s;
		if (i>0) {
			if (S.find(s) != S.end()) {
				ans = false;
			}
			ch = s[0];
			if (ch != ct) {
				ans = false;
			}
		}
		//cout << s << ":" << ans << endl;
		ct = s[s.size()-1];
		S.insert(s);
	}
	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}



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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n =sc.nextInt();
		char[] str = sc.next().toCharArray();
		long R = 0, G = 0, B = 0;	
		for(int i = 0; i < n; i++) {
			if (str[i] == 'R') R++;
			if (str[i] == 'G') G++;
			if (str[i] == 'B') B++;
		}
		long sum = R * G * B;
		
		for (int i = 0; i < n - 2; i++) {
			for(int j = i + 1; j < n - 1; j++) {
				int k = 2 * j - i;
				if (k >= n) continue;
				if (str[i] != str[j] && str[j] != str[k] && str[k] != str[i]) {
					sum--;
				}
			}
		}
		
		out.println(sum);

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 33064
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int Max[N],ans[N];
void dfs(int u,int pre,int fir,int sec,int pos)
{
	Max[u]=max(Max[pre],pre);
	cmax(sec,u);
	if(fir<u)fir=u,sec=0;
	if(Max[fir]>sec)ans[fir]++;
	else ans[pos]++;
	for(int v:E[u])if(v^pre)dfs(v,u,fir,sec,fir==u?v:pos);
}
void dfs2(int u,int pre)
{
	ans[u]+=ans[pre];
	for(int v:E[u])if(v^pre)dfs2(v,u);
}
void work()
{
	dfs(1,0,0,0,0);			
	ans[0]=ans[1]=0;
	dfs2(1,0);
	For(i,2,n)write(ans[i],' ');
}
int main()
{
	
	input();
	work();
	return 0;
}



Measured memory_bytes: 29696
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 1000001;

bool mark[MAXN] = {0};
int I[MAXN] = {0};

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

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

    ll a,b,c,d,e;

    cin >> n;
    vi A(n);
    map<ll,ll> M;
    ll ans = 0;
    rep(c1,0,n){
        cin >> a;
        b = a + c1 + 1;
        ans += M[c1+1-a];
        M[b]++;
    }
    cout << ans <<"\n";

    return 0;
}


Measured memory_bytes: 26572
#include <bits/stdc++.h>
 
int N;
std::vector<int> a;
int main(void){
    std::cin >> N;
    a.resize(N);
    for(int i=0; i<N; ++i){
        std::cin >> a[i];
        --a[i];
    }
    
    int b = 0;
    int ans = -1;
    for(int i=0; i<N;++i){
        b = a[b];
        if(b == 1){
            ans = i+1;
            break;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
N = int(input())
A = [int(i) for i in input().split()]

if len(A) > 1:
    result = sorted(A)[1]
else:
    result = min(A)

while True:
    counter = 0
    should_continue = False
    for e in A:
        if e % result != 0:
            counter += 1
            if counter > 1:
                should_continue = True
                break
    if should_continue:
        result -= 1
        continue
    if counter <= 1:  # 1つは書き換えられる
        break
    else:
        result -= 1

print(result)


Measured memory_bytes: 14060
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
long long int maxi(long long int A, long long int B) {
	return (A > B) ? A : B;
}
int main() {
	int H, W, c = 0;
	char ban;
	cin >> H >> W;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		cin >> ban;
		if (ban == '#')c++;
	}
	if (c == W + H - 1) {
		cout << "Possible";
	}
	else cout << "Impossible";
}


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

int main(){

    int x,a,b;
    cin >> x >> a >> b;
    
    if(a-b>=0){
        cout << "delicious" << endl;
    }else if(b-a<=x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
import numpy as np

N=int(input())
A = np.zeros(N)
B = np.zeros(N)
for i in range(N):
    A[i], B[i] = map(int, input().split())
idx = np.argsort(B)
A = A[idx]
B = B[idx]

A = np.cumsum(A)

for i in range(N):
    if A[i] > B[i]:
        print('No')
        exit()

print('Yes')

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	int count = 1;
	while(k--){
		if(count%2){
			// a をそうさ
			if(a%2) a--;
			b += a/2;
			a /= 2;
		} else{
			if(b%2) b--;
			a += b/2;
			b /= 2;
		}
		count ++ ;
	}
	cout << a << " " << b << endl; 
}


Measured memory_bytes: 256