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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

vector<pii> getOdd(int k, int n){
	// 2 * k + 1
	vector<pii> ret;
	for(int i = 1; i <= k; i++){
		ret.push_back({1, 2 * i});
		ret.push_back({1, 2 * i + 1});
		ret.push_back({2 * i, n + 2 * i + 1});
		ret.push_back({2 * i + 1, n + 2 * i});
	}
	ret.push_back({n + 2, n + 1});
	return ret;
}

int main(){
	int n; cin >> n;
	int k = 0; while((1 << k) < n) k++;
	if((1 << k) == n){
		printf("No\n");
		return 0;
	}
	vector<pii> edges = getOdd(n & 1 ? n / 2 : n / 2 - 1, n);
	if(!(n & 1)){
		for(int r = 0; r < k; r++) if((n/2) >> r & 1){
			int p = (1 << r), q = (n/2) ^ p;
			trace(p, q);
			edges.push_back({n, 2 * p});
			edges.push_back({2 * n, 2 * q + 1});
			break;
		}
	}
	printf("Yes\n");
	// printf("%d\n", sz(edges));
	for(auto it : edges) printf("%d %d\n", it.F, it.S);
}

Measured memory_bytes: 5316
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N,x,i,j,flag=1,count=0;

  scanf("%d\n",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if (A[j]< A[j-1]) {
        i = A[j-1];
        A[j-1] = A[j];
        A[j] = i;
	count++;
	flag=1;
      }
    }
  }


    for(x=0;x<N;x++){
      if(x)printf(" ");
      printf("%d",A[x]);
    }
    printf("\n%d\n",count);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

ll n;
ll a=0LL;

inline void bkt(ll x,bool e3,bool e5,bool e7)
{
    if(x>n)
    {
        return;
    }
    if(e3 && e5 && e7)
    {
        a++;
    }
    bkt(x*10+3,1,e5,e7);
    bkt(x*10+5,e3,1,e7);
    bkt(x*10+7,e3,e5,1);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    bkt(0,0,0,0);
    cout<<a<<"\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    vector<int> ans;
    int y;
    while(n--)
    {
        cin>>y;
        ans.push_back(abs(x-y));
    }
    /*for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }*/
    int gcd=ans[0];
    for(int i=1;i<ans.size();i++)
    {
        gcd=__gcd(gcd,ans[i]);
    }
    cout<<gcd;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(u == s) cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}



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

int x,y;

void StoT(int tx,int ty){
  while(x!=tx || y!=ty){
    if(y < ty){
      y++; cout << "U";
    }else{
      x++; cout << "R";
    }
  }
}

void TtoS(int sx,int sy){
  while(x!=sx || y!= sy){
    if(y > sy){
      y--; cout << "D";
    }else{
      x--; cout << "L";
    }
  }
}

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  x = sx; y = sy;

  //s up -> t left
  cout << "U"; y++;
  StoT(tx-1,ty);
  cout << "R"; x++;

  // t down -> s right
  cout << "D"; y--;
  TtoS(sx+1,sy);
  cout << "L"; x--;

  // s left -> t up
  cout << "L"; x--;
  StoT(tx,ty+1);
  cout << "D"; y--;

  // t right -> s down
  cout << "R"; x++;
  TtoS(sx,sy-1);
  cout << "U"; y++;

  return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<int>> v(h, vector<int>(w, 0));
    rep(i, h){
        rep(j, w){
            char t;
            cin >> t;
            if(t=='#'){
                v[i][j] = 1;
            }else{
                v[i][j] = 0;
            }
        }
    }

    int ans = 0;

    for (int bit = 0; bit < (1<<(h+w)); bit++){
        int temp = 0;
        vector<int> hi, wi;
        for (int i = 0; i < h; i++){
            if(bit&(1<<i)){
                hi.push_back(i);
            }
        }
        for (int j = 0; j < w; j++){
            if(bit&(1<<(j+h))){
                wi.push_back(j);
            }
        }

        for (int i = 0; i < hi.size(); i++) {
            for (int j = 0; j < wi.size(); j++){
                temp += v[hi[i]][wi[j]];
            }
        }

        if(temp==k){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,a[101010],ans;
int gcd(int x,int y){
	return (y==0?x:gcd(y,x%y));
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	int l=0,r=n,s=0,t=0;
	while(l<r-1){
		int m=(l+r+1)/2;
		s=gcd(a[l],s);t=gcd(a[m],t);
		fo(i,l+1,m)s=gcd(s,a[i]);
		fo(i,m+1,r)t=gcd(t,a[i]);
		if(s>t){l=m;t=s;}
		else{r=m;s=t;}
	}
	if(l>0)ans=a[0];
	else ans=a[1];
	fo(i,0,n) if(i!=l)ans=gcd(ans,a[i]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll n,l;
    cin>>n>>l;
    ll a[n];
    rep(i,n)cin>>a[i];
    int index=-1;
    rep(i,n-1){
        if (a[i]+a[i+1]>=l){
            index=i;
            break;
        }
    }
    if (index==-1){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    for (int i=1;i<index+1;i++)cout<<i<<endl;
    for (int i=n-1;i>index+1;i--)cout<<i<<endl;
    cout<<index+1<<endl;

    return 0;
}

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

int main(void){

    int X,Y;
    cin >> X >> Y;
    int ans = 0;
    
    if(X == 3)ans += 100000;
    else if(X == 2)ans += 200000;
    else if(X == 1)ans += 300000;
    
    if(Y == 3)ans += 100000;
    else if(Y == 2)ans += 200000;
    else if(Y == 1)ans += 300000;
    
    if(X == 1 && Y == 1)ans += 400000;
    
    cout << ans <<endl;
    
}


Measured memory_bytes: 256
MASK=10**9+7
N,K=map(int,input().split())

F=[1]*(N+1)
for i in range(1,N+1):
  F[i] = i* F[i-1]

def cmb(n,r):
  return F[n]//F[r]//F[n-r]

for i in range(0,K):
  print((cmb(N+1-K,i+1)*cmb(K-1,i))%MASK)


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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;

  cout << min({P + Q, Q + R, R + P}) << endl;
  return 0;
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int is_square(int n){
   double x=sqrt(n);
   return (x-floor(x)==0);
}
void solve(){
   int n;
   cin>>n;
   if(n<=2)cout<<"0"<<endl;
   else cout<<n/3<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s,p;

int main()
{
    ft
    ll t,i,j,n,m,a,b,l,r;
    cin>>n>>a>>b;
    l=a+b;
    r=(n/l)*a;
    r+=min(a,(n%l));
    cout<<r<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>X(N);
  vector<int>Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  sort(Y.begin(), Y.end());
  
  for (int i = 0; i < N; i++) {
    if (X.at(i) <= Y.at(N/2 - 1)){
      cout << Y.at(N/2) << endl;
    }
    else {
      cout << Y.at(N/2 - 1) << endl;
    }
  }
}

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

#define N 100021
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define sortcmp(n, cmpfunc) sort(all(n), cmpfunc)
#define fastio ios::sync_with_stdio(false); cin.tie(0)

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll powm(ll a, ll b);
ll divm(ll a, ll b);
ll multm(ll a, ll b);
ll subm(ll a, ll b);
ll addm(ll a, ll b);

ll max(ll a, ll b){ return (a > b)? a : b;}

int main(){
	fastio;
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.in", "r", stdin);
 //    	freopen("output.out", "w", stdout);
	// #endif
	int n, a[N], ans, leftgcd[N], rightgcd[N];
	cin >> n;
	for(int i = 0 ; i < n ; i++) cin >> a[i];

	leftgcd[0] = a[0]; rightgcd[n-1] = a[n-1];
	for(int i = 1 ; i < n ; i++){
		leftgcd[i] = gcd(a[i], leftgcd[i-1]);
		rightgcd[n-i-1] = gcd(a[n-i-1], rightgcd[n-i]);
	}

	ans = max(leftgcd[n-2], rightgcd[1]);
	for(int i = 1 ; i < n-1 ; i++){
		ans = max(ans, gcd(leftgcd[i-1], rightgcd[i+1]));
	}
	
	cout << ans << endl;
	return 0;
}

// template function
ll gcd(ll a, ll b) { 
	if (b == 0) return a; 
	return gcd(b, a % b);  
} 

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

ll powm(ll a, ll b){
	ll x=1, y=a; 
    while (b > 0) {
        if (b%2) x = (x*y) % mod;
        y = (y*y) % mod;
        b /= 2;
    }
    return x % mod;
}

ll multm(ll a, ll b){
	return ((a%mod) * (b%mod)) % mod;
}

ll divm(ll a, ll b){
	return (a * powm(b, mod - 2)); 
}

ll subm(ll a, ll b){
	a -= b;
  	if (a < 0) a += mod;
	return a;
}

ll addm(ll a, ll b){
	a += b;
  	if (a >= mod) a -= mod;
  	return a;
}

Measured memory_bytes: 1408
import bisect

N,K = [int(zz) for zz in input().split()]
A = [int(zz) for zz in input().split()]
B = set(A)

A.sort()
ans = []
for i in B:
    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)
    ans.append(p)

ans.sort()
j = 0
for i in range(len(B)-K):
    j += ans[i]
print(j)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl choose;



int main(){

  ios_base::sync_with_stdio (false);
  cin.tie(NULL);

  choose = vl(101, 1);
  choose[0]=0;
  choose[1]=0;
  choose[2]=1;
  FOR(i, 3, 101){
    choose[i] = (choose[i-1]*i)/(i-2);
  }

  ll N, M;

  cin >> N >> M;

  cout << choose[N]+choose[M] << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> charge;
    charge.push_back(1);
    int i, j, k;
    for(i = 6; i <= n;i*=6){
        charge.push_back(i);
    }
    for(i = 9; i <= n; i *= 9){
        charge.push_back(i);
    }
    int cs = charge.size();
    int dp[n + 1];
    for(i = 0; i <= n;i++){
        dp[i] = 1e9;
    }
    dp[0] = 0;

    for(i = 0; i < cs;i++){
        for(j = charge[i]; j <= n;j++){
            dp[j] = min(dp[j], dp[j - charge[i]] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

int n,x,m;

void solve(){
	cin >> n >> x >> m;
	vector<int>cir;
	set<int>s;
	int ans = x;
	int sum = 0;
	while(1&&cir.size()<n){
		x = x*x%m;
		if(s.count(x))
			break;
		cir.pb(x);
		s.insert(x);
		sum += x;
	}
	int len = SZ(cir);
	ans += sum;
	n -= len;
	n--;
	int pos = -1;
	rep(i,0,len){
		if(cir[i]==x){
			pos = i;
			break;
		}
		sum -= cir[i];
	}
	int len2 = len-pos;
	int div = n/len2;
	ans += div*sum;
	n -= len2*div;
	rep(i,0,n)
		ans += cir[pos+i];
	cout << ans << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


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

using namespace std;

int cnt = 0;

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

    int a;
    string x;
    cin >> a >> x;

    for (int i = 0; i < a - 2; ++i)
        if (x[i] == 'A' && x[i + 1] == 'B' && x[i + 2] == 'C')
            ++cnt;

    cout << cnt;
}

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

int main() {
  int n; cin >> n;
  vector<int> arr(n);
  for (auto &a : arr) cin >> a;
  sort(arr.rbegin(), arr.rend());
  int ans = 0;
  for (int i=0; i<n; ++i) {
    if (i%2) ans -= arr[i];
    else ans += arr[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EThisMessageWillSelfDestructIn5s solver = new EThisMessageWillSelfDestructIn5s();
        solver.solve(1, in, out);
        out.close();
    }

    static class EThisMessageWillSelfDestructIn5s {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] height = new int[n];
            HashMap<Integer, Integer> hm = new HashMap<>();
            for (int i = 0; i < n; i++) {
                height[i] = in.nextInt();
                hm.merge(i - height[i], 1, Integer::sum);
            }
            long cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += hm.getOrDefault(height[i] + i, 0);
            }
            out.println(cnt);


        }

    }
}



Measured memory_bytes: 70092
import sys
import math
#15608119
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k >= sum(a) - n: #すべての丸太の長さを1以下にできる
  print(1)
else:
  ok, ng = max(a), 1
  while ok - ng > 1: # ok - ng = 1になったら、問題の答えはokで確定
    mid = (ok+ng)//2
    if sum(math.ceil(x/mid)-1 for x in a) <= k: # 「答えがmid以下」が正しいなら
      ok = mid
    else: # 「答えがmid以下」が正しくないなら
      ng = mid
  print(ok)
  

Measured memory_bytes: 104596
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  vector<vector<int> > A(3, vector<int>(3));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }
  vector<vector<bool> > B(3, vector<bool>(3, false));
  int N;
  cin >> N;
  for (int k = 0; k < N; ++k) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
	if (A[i][j] == b) {
	  B[i][j] = true;
	}
      }
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (B[i][0] and B[i][1] and B[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  for (int j = 0; j < 3; ++j) {
    if (B[0][j] and B[1][j] and B[2][j]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (B[0][0] and B[1][1] and B[2][2]) {
    cout << "Yes" << endl;
    return 0;
  }
  if (B[0][2] and B[1][1] and B[2][0]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (
    (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    || 
    (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
    || 
    (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])
    )
    cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.IntSet as S
import           Data.Maybe  (fromJust)


main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n = bfs 0 S.empty $ S.singleton n

bfs :: Int -> S.IntSet -> S.IntSet -> Int
bfs c s t
  | S.member 0 t = c
  | otherwise    = bfs (c + 1) s' t' where
      s' = S.union s t'
      t' = S.unions $ S.foldr' f [] t
      f x xs = S.fromList [y | y <- [ x - lookupLE x m6
                                    , x - lookupLE x m9]
                             , S.notMember y s] : xs

ms :: Int -> S.IntSet
ms m = S.fromList . takeWhile (< 100000) $ iterate (* m) 1

m6 :: S.IntSet
m6 = ms 6

m9 :: S.IntSet
m9 = ms 9

lookupLE :: Int -> S.IntSet -> Int
lookupLE x = fromJust . S.lookupLE x


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
std::vector<int> al(300000,0);
void dfs(std::vector<std::vector<int>> &g,std::vector<ll> &v,int p){
    al[p]=1;
    erep(i,g[p]){
        if(al[i])continue;
        v[i]+=v[p];
        dfs(g,v,i);
    }
}
int main(){
    int n,q;
    std::cin >> n>>q;
    Graph g(n);
    rep(i,n-1){
        int a,b;
        std::cin >> a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    std::vector<ll> v(n,0);
    rep(i,q){
        int p,x;
        std::cin >> p>>x;
        p--;
        v[p]+=x;
    }
//    ppri(g.size(),v.size());
    dfs(g,v,0);
  //  std::cout << 1 << std::endl;
    erep(i,v){
        std::cout << i <<  ' ';
    }
    std::cout  << std::endl;
}

Measured memory_bytes: 25472
a = int(input())

if 400<= a and 599>=a:
    print("8")
elif 600<=a and 799>=a:
    print("7")
elif 800<=a and 999>=a:
    print("6")
elif 1000<=a and 1199>=a:
    print("5")
elif 1200<=a and 1399>=a:
    print("4") 
elif 1400<=a and 1599>=a:
    print("3")
elif 1600<=a and 1799>=a:
    print(2)
elif 1800<=a and 1999>=a:
    print(1)

Measured memory_bytes: 61708
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  string s;in(s);
  string t=s;
  reverse(all(s));
  int n=s.size();
  int c=0;
  rep(i,n/2)if(s[i]!=t[i])c++;
  out(c);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        if (N % 2 == 1) {
            System.out.println(0);
            return;
        }
        int[] d = new int[N];

        for (int i = 0; i < N; i++) d[i] = sc.nextInt();

        Arrays.sort(d);

        System.out.println(d[N / 2] - d[N / 2 - 1]);

    }
}



Measured memory_bytes: 50132
class Node():
    key = 0
    l = None
    r = None
    def __init__(self, key):
        self.key = key
T = [None] * 5000005
def insert(z):
    if z == 0: return
    y = 0
    x = 0
    while x is not None:
        y = x
        x = (T[x].l if T[z].key < T[x].key else T[x].r)
    if T[z].key < T[y].key : T[y].l = z
    else : T[y].r = z
def inorder(x):
    if x == None: return;
    inorder(T[x].l);
    print("", T[x].key, end="")
    inorder(T[x].r);
def preorder(x):
    if x == None: return;
    print("", T[x].key, end="")
    preorder(T[x].l);
    preorder(T[x].r);
n = int(input())
for i in range(n):
    s = input()
    if s == "print":
        inorder(0)
        print()
        preorder(0)
        print()
    else:
        x = int(s.split()[1])
        T[i] = Node(x)
        insert(i)

Measured memory_bytes: 162044
#include<bits/stdc++.h>
using namespace std;
const int inf=99999999;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m],b[m],w[m];
	for(int i=0;i<m;i++){cin>>a[i]>>b[i]>>w[i];a[i]--;b[i]--;}

	int dist[n+1][n+1];
	
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			if(i==j)dist[i][j]=0;
			else dist[i][j]=inf;
		}

	for(int i=0;i<m;i++)
	{
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]], w[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]], w[i]);
	}

	//floyd warshall

	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j]);
			}

	int ans=m;
	for(int i=0;i<m;i++)
	{
		bool contained=false;
		for(int j=0;j<n;j++)
		{
			if(dist[j][a[i]]+w[i]==dist[b[i]][j])contained=true;
		}
		if(contained)ans--;

	}
	cout<<ans<<"\n";
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  
  int n;
  string s;
  cin >> n  >> s ;
  int ans = 1;
  
  for(int i=0;i<n-1;i++){
    if(s.at(i) != s.at(i+1))
      ans ++ ;
  }
  
  cout << ans ;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = int(s.size());
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if(s[i] != t[i]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3792
import sys
w=list(raw_input())
n=len(w)
per=-1

def zalg(s):
    z=[0]*n;c=0
    for i in range(1,n):
        if i+z[i-c]<c+z[c]:z[i]=z[i-c]
        else:
            j=max(0,c+z[c]-i)
            while i+j<n and s[j]==s[i+j]:j+=1
            z[i]=j;c=i
    z[0] = n
    return z

def good(s):
    g=[True]*n
    z=zalg(s)
    for p in range(1,n):
        for k in range(2,z[p]/p+2):g[k*p-1]=False
    return g
    
for j in range(1,n/2+1):
    if n%j==0:
        if w[:n-j]==w[j:]:
            per=j
            break
        
if per==-1:
    print 1
    print 1
    sys.exit()
if per==1:
    print n
    print 1
    sys.exit()
gl=good(w)
w.reverse()
gr=good(w)
cnt=0
for i in range(n-1):
    if gl[i] and gr[n-2-i]:cnt+=1
print 2
print cnt


Measured memory_bytes: 158708
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc172/D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

#define tep template <
#define tem template < typename T
#define tee typename ...E
#define szn size_t N
#define rge int x1=0, int x2=1e9
#define tst string to_string(const
tem, szn > int SIZE(const T (&t)[N]) {return N;}
tem > int SIZE(const T &t) {return t.size();}
tst string s, rge) {return x1<int(s.size())?s.substr(x1, x2-x1+1):"";}
tst char *s) {return to_string((string)s);}
tst bool b) {return b?"true":"false";}
tst char c) {return string({c});}
tep szn > tst bitset<N> &b, rge) {
    string t="";
    for(int s=min(x1,SIZE(b)), e=min(x2,SIZE(b)-1); s<=e; ++s)
    {t += b[s] + '0';} return t;}
tem, tee > tst T (&v), rge, E... rem);
tem, typename E > tst pair<T, E> &p)
{return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
tem, tee > tst T (&v), int x1, int x2, E... rem) {
    string res = "["; bool first = true;
    x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
    auto l = begin(v); advance(l, x1);
    auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v)));
    for (auto e = l; e != r; e = next(e), first=false)
    {if (!first) { res += ", "; } res += to_string(*e, rem...);}
    res += "]"; return res;}
void dbgm(){;}
tem, tee > void dbgm(T t, E... e) {cout<<to_string(t)<<", "; dbgm(e...);}
#define dbg(...) cout<<"[ "<<#__VA_ARGS__<<" : ";cout<<to_string(__VA_ARGS__)<< " ]"<<endl
#define dbgm(...) cout<<"[ "<<#__VA_ARGS__<<" : ";dbgm(__VA_ARGS__);cout<<" ]"<<endl


const int nax = 1000'000'1;
vector<int> p(nax), s(nax);

void init() {
    p[0] = p[1] = 1;
    s[0] = s[1] = 1;
    for(int i=2; i<nax; i++) {
        if(p[i]==0) {
            p[i] = i;
            if(1l * i * i >= nax) continue;
            for(int j=i*i; j<nax; j+=i) {
                p[j] = i;
            }
        }
    }
}

int main() {
    init();
    ll n;
    scanf("%lld", &n);
    ll rs = 1;
    // dbg(p, 0, 10);
    for(ll i=2; i<=n; i++) {
        ll c = 0;
        ll x = i;
        ll y = p[x];
        // dbgm(x, y);
        while(x%y == 0) {
            x /= y;
            c++;
        }
        ll z = s[x];
        z *= c + 1;
        // dbgm(c, x, s[x], z);
        rs += z * i;
        s[i] = z;
    }
    printf("%lld\n", rs);
}


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

int main()
{
  int n, l[200];
  cin >> n;
  for(int i = 0; i < n*2; i++){
    cin >> l[i];
  }

  sort(l, l+n*2);

  int ans = 0;
  for(int i = 0; i < n*2; i+= 2){
    ans += l[i]; 
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
a=[ int(input()) for i in range(5)]
b=[(a[i]-1)%10 for i in range(5)]
m=(10-((min(b)+1)%10))%10
def f(x):
  if x%10==0:
    return x
  else:
    return x-(x%10)+10
ans=-m
for i in range(5):
  ans+=f(a[i])
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    map<string,int>mp;
    while(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}



Measured memory_bytes: 3636
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power( ll a, ll b, ll m )
{
	 if (b == 0)
		  return( 1 );
	 ll sol = power( a, b / 2, m );
	 sol = ( sol * sol ) % m;
	 if (b % 2 == 1)
		  sol = ( sol * a ) % m;
	 return( sol );
}

ll gcd( ll a, ll b )
{
	 if (b == 0)
		  return a;
	 else
	 {
		  return gcd( b, a % b );
	 }
}
ll a[60];
void solve()
{
	ll n;
	cin >> n;
	if (n & 1)
	{
		cout << "0";
		return;
	}
	ll x = 5;
	for (int i = 1; i <= 25; i++)
	{
		a[i] = x;
		x = x * 5;
	}
	ll sol = 0;
	for (int i = 1; i <= 25; i++)
	{
		ll x = n/a[i];
		x = x / 2;
		sol = sol + x;
	}
	cout << sol;
}
int main()
{
	 int t = 1;
	 //cin >> t;
	 while (t--)
	 {
		  solve();
	 }
	 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

ll gcd(ll x, ll y)
{
    if (x % y == 0)
        return y;
    return gcd(y, x % y);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int j, k = 0;
    ll n, i;
    cin >> n;
    for (i = 2; i * i <= n; i++)
    {
        j = 0;
        while (n % i == 0)
        {
            n /= i;
            j++;
        }
        int cnt = 1;
        while (j >= cnt)
        {
            j -= cnt;
            cnt++;
            k++;
        }
    }
    if (n != 1)
        k++;
    cout << k << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 10200000,mo=998244353;
int n,a,b,fac[N],ifac[N];
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int main() {
	iniC(N-1);read(n);read(a);read(b);int res=0;
	if(!b){puts("1");return 0;}
	rep(k,0,n-b){
		int t=b-k;if(t>0&&t-(b-a)>=0){
			res=(res+1LL*(C(b-1+k,k)-C(b-1+k,k-1))*(n-b-k==0?(k==a):C(n+t+a-2*b-k-1,t-b+a)))%mo;
		}
	}
	cout<<(res%mo+mo)%mo<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

ll gcd(ll m, ll n) {
    ll tmp;
    while (m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }
    return n;
}

ll lcm(ll m, ll n) {
    return max(m, n)/gcd(m,n) * min(m,n);
}

using Graph = vector<vector<int>>;


int main() {
    int n; cin >> n;
    map<pair<int, int>, int> mp;
    EFOR(i, 1, n) {
        string s = to_string(i);
        mp[make_pair(s[0]-'0', s[s.size()-1]-'0')]++;
    }
    ll ans = 0;
    FOR(i, 1, 10) FOR(j, 1, 10) {
        ans += mp[make_pair(i, j)] * mp[make_pair(j, i)];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll short
bool mp[16002][16002],mp1[16002][16002];
ll n,sx,sy,gp,gs;
vector<ll>v;
string s;
bool solve(ll idx,ll sum)
{
    if(idx>=n)
    {
        if(sum==gs)
        return 1;
        return 0;
    }
    else if(mp1[idx][sum])
    return mp[idx][sum];
    else
    {
        bool val=0;
        if(v[idx]>=0)
        {
            val=val|solve(idx+4,sum+v[idx])|solve(idx+4,sum-v[idx]);
        }
        mp1[idx][sum]=1;
        return mp[idx][sum]=val;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll i,j,k;
    cin>>s;
    n=s.size();
    cin>>sx>>sy;
    sx+=8000;
    sy+=8000;
    ll cur=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='T')
        {
            v.push_back(cur);
            v.push_back(-1);
            cur=0;
        }
        else
        {
            cur++;
        }
    }
    v.push_back(cur);
    n=v.size();
    ll fg=0;
    gp=0;
    gs=sx;
    fg=solve(4,v[0]+8000);
    if(fg)
    {
        gp=1;
        gs=sy;
        memset(mp1,0,sizeof mp1);
        fg=solve(2,0+8000);
        if(fg)
        cout<<"Yes";
        else
        cout<<"No";
    }
    else
    cout<<"No";
    return 0;
}

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

ans = 0
for i in range(1, n+1):
  if i*2 > n:
    # 一気に足し上げて抜ける
    ans += (i + n) * (n - i + 1) // 2
    break

  # n 以下の最大の i の倍数
  last_term = n // i * i
  num_term = (last_term - i) // i + 1
  ans += (i + last_term) * num_term // 2
   

print(ans)


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
bool p[10001];
int main(){
  for(int i=2;i<10001;i++)p[i]=1;
  for(int i=2;i<10001;i++)
    if(p[i])for(int j=i+i;j<10001;j+=i)p[j]=0;
  int n,c;
  while(cin>>n){c=0;
    for(int i=1;i<=n;i++)
      if(p[i]&&p[n-i+1])c++; 
    cout<<c<<endl;
  }
}

Measured memory_bytes: 3064
const isSafeForSheeps = (sheeps: number, wolves: number): string => {
  return sheeps <= wolves ? 'unsafe' : 'safe';
}

const main = (standardInput) => {
  const lengthList: string[] = standardInput.split(' ');
  const sheeps = Number.parseInt(lengthList[0]);
  const wolves = Number.parseInt(lengthList[1]);
  
  console.log(isSafeForSheeps(sheeps, wolves));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

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

#define si(x) scanf("%d",&x)

using namespace std;

vector<vector<int> > child;
int dfs(int node){
    if(child[node].size()==0)return 0;
    vector<int> dist;
    for(int i=0;i<child[node].size();i++){
        dist.push_back(dfs(child[node][i]));
    }
    sort(dist.begin(),dist.end());
    int ans  = 0;
    for(int i=0;i<dist.size();i++){
        ans = max(ans,dist[i])+1;
    }
    return ans;
}

int main()
{
    int n;
    si(n);
    vector<int> parent(n+1);
    child.resize(n+1);
    for(int i=2;i<=n;i++){
        si(parent[i]);
        child[parent[i]].push_back(i);
    }
    cout << dfs(1);
    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#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()
{    
    i64 a,b,k;
    cin >> a >> b >> k;

    i64 c = max(i64(0), a-k);
    i64 d = max(i64(0), b-(k-(a-c)));
    cout << c << " " << d << endl;
    return 0;
}

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

int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[0]==s[2]){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
char chlit(char c){return c+32;}
char chbig(char c){return c-32;}

int main(){
  int a,b,c,d;cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int sum=0;
  
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(x<abs(x-K)){
      sum+=x;
    }
    else{
      sum+=abs(x-K);
    }
  }
  
  cout<<2*sum<<endl;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> grid(H+2,vector<char>(W+2));
  for(int i=0;i<H+2;i++){
    if(i==0||i==H+1){
      for(int j=0;j<W+2;j++){
        grid.at(i).at(j)='.';
      }
    }else{
      for(int j=0;j<W+2;j++){
        if(j==0||j==W+1){
          grid.at(i).at(j)='.';
        }else{
          cin>>grid.at(i).at(j);
        }
      }
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(grid.at(i).at(j)=='#'){
        int cnt=0;
        if(grid.at(i-1).at(j)=='.'){cnt++;}
        if(grid.at(i).at(j-1)=='.'){cnt++;}
        if(grid.at(i).at(j+1)=='.'){cnt++;}
        if(grid.at(i+1).at(j)=='.'){cnt++;}
        if(cnt==4){
          cout<<"No"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

class AAirplane {
 public:
  void solve(std::istream &in, std::ostream &out) {
    vector<int> v(3);
    forn(i, 3)in >> v[i];
    sort(all(v));
    out << v[0] + v[1] << endl;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  AAirplane solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

before_sumA=sum(A)
before_sumB=sum(B)
for i in range(N):
    if A[i]>B[i]:
        R=A[i]
        A[i]-=B[i]
        B[i]=0
    elif A[i]==B[i]:
        R=A[i]
        A[i]=0
        B[i]=0
    elif A[i]+A[i+1]>B[i]:
        R=A[i]
        A[i]=0
        B[i]-=R
        A[i+1]-=B[i]
        B[i]=0
    else:
        R=A[i]+A[i+1]
        A[i]=0
        A[i+1]=0
        B[i]-=R

after_sumA=sum(A)
after_sumB=sum(B)
#print(before_sumA-after_sumA)
print(before_sumB-after_sumB)


Measured memory_bytes: 18476
fun main (args:Array<String>){
    val a : MutableList<String> = mutableListOf("SUN","MON","TUE","WED","THU","FRI","SAT")
    val b = readLine()!!
    for (i in 0..6){
        if (b==a[i]){
            println(7-i)
        }
    }
}

Measured memory_bytes: 33668
#include <bits/stdc++.h>
using namespace std;
int n;
long long mod = 998244353;
int main() {
    cin >> n;
    vector<int> d(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }

    long long total = 0;
    vector<long long> tre;

    if(d.at(0) != 0) {
        total = 0;
    }else {
        total = 1;
        sort(d.begin(), d.end());
        d.push_back(-1);
        long long cnt = 1;
        int check = 0;
        for(int i = 0; i < n; ++i) {
            if(d.at(i) == check) {
                if(d.at(i) == d.at(i+1)) {
                    cnt++;
                }else {
                    tre.push_back(cnt);
                    cnt = 1;
                    check++;
                }
            }else {
                total = 0;
            }
        }
        if(tre.at(0) != 1) {
            total = 0;
        }else {
            int trelen = tre.size();
            for(int j = 1; j < trelen; ++j) {
                for(int k = 0; k < tre.at(j); ++k) {
                    total = (total % mod) * tre.at(j-1);
                }
            }
        }
    }

    cout << total % mod << endl;
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n],s[n+1]={};
	s[0]=0;
	rep(i,n){
		cin>>a[i];
		s[i+1]=s[i]+a[i];
	}
	ll d=INF;
	for(int i=1;i<n;i++){
		ll r=s[i],l=s[n]-s[i];
		d=min(d,abs(r-l));
	}

	cout<<d<<"\n";
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    for(int i = 0; i <= A;++i){
        int sum = B * i + C;
        if(sum % A == 0){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n,m,c = list(map(int,input().split()))
b = np.array([list(map(int,input().split()))]).T
co_li = []
for x in range(n):
    co_li.append(list(map(int,input().split())))
a = np.array(co_li)
ans_li = np.dot(a,b) - (-1 * c)
print(np.count_nonzero(ans_li > 0))


Measured memory_bytes: 19456
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int a,b;
  cin >> a  >> b;
  if(a==1 && b==13)cout << "Alice" << endl;
  else if(a==13 && b==1)cout << "Bob" << endl;
  else if(a>b)cout << "Alice" << endl;
  else if(b>a)cout << "Bob" << endl;
  else cout << "Draw" << endl;
  
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
int main(){
    int n;
    cin >> n;
    vector<ll> d(n);
    int i,j;
    ll sum=0;
    for(i=0;i<n;i++)cin >> d.at(i);
    for(i=0;i<n;i++){
        for(j=1;i+j<n;j++){
            sum+=(d.at(i)*d.at(i+j));
        }   
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_A=1e6,MAX_N=2e5,MOD=998244353;
ll N,cnt[MAX_A+1],w[MAX_A+1];
ll mpw(ll n,ll m){
	ll r=1;
	while(m){
		if(m&1){
			r*=n;
			r%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return r;
}
ll minv(ll n){
	return mpw(n,MOD-2);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		ll a;
		cin>>a;
		cnt[a]++;
	}
	FOR(i,1,MAX_A+1)w[i]=minv(i);
	FOR(i,1,MAX_A+1){
		for(ll j=i*2;j<=MAX_A;j+=i){
			w[j]+=MOD-w[i];
			w[j]%=MOD;
		}
	}
	ll ans=0;
	FOR(d,1,MAX_A+1){
		ll sm=0,sm2=0;
		for(ll a=d;a<=MAX_A;a+=d){
			sm+=a*cnt[a];
			sm%=MOD;
			sm2+=a*a*cnt[a];
			sm2%=MOD;
		}
		ans+=(sm*sm%MOD+MOD-sm2)%MOD*minv(2)%MOD*w[d]%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15872