akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lowbit(x) (x&-x)
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int M=8000010;
const int N=200010;
template<typename T>inline T chkmax(T _A,T _B){return _A>_B?_A:_B;}
template<typename T>inline T chkmin(T _A,T _B){return _A<_B?_A:_B;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
LL n,K,a[N],sum[N],s[N],ans;
int Sum[M],lc[M],rc[M],num,cnt,root;
struct node
{
	LL x,id;
	node(LL A=0,LL B=0):x(A),id(B){}
}da[N];
bool operator<(node A,node B){return A.x<B.x;}
int t[N];
int query(int x)
{
	int ret=0;
	while(x)
	{
		ret+=t[x];
		x-=lowbit(x);
	}
	return ret;
}
void add(int x)
{
	while(x<=num)
	{
		t[x]++;
		x+=lowbit(x);
	}
}
int main()
{
	read(n);read(K);
	For(i,1,n)
	{
		read(a[i]);
		sum[i]=sum[i-1]+a[i];
		da[i]=node(sum[i]-i*K,i);
	}
	da[0]=node(0,0);
	sort(da,da+n+1);
	For(i,0,n)
	{
		if(i==0||da[i].x!=da[i-1].x)num++;
		s[da[i].id]=num;
	}
	rFor(i,n,0)
	{
		int x=query(s[i]-1);
		ans+=(n-i)-x;
		root=++cnt;
		add(s[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

typedef long long ll;


int main(void){
    string c[2];
    cin >> c[0] >> c[1];
    for(int i=0;i<3;i++){
        if(c[0][i] != c[1][2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	
	char str[19];
	scanf("%[^\n]", str);
	
	for (int i=0; str[i] != '\0'; i++){
		if (str[i] >= 'a' && str[i] <= 'z'){
			printf("%c",  str[i]);
		}
		else printf(" ");
	}
	
	return 0;
}

Measured memory_bytes: 1596
#include <iostream>

 

using namespace std;

 

int main()
{
   int a, b, ans1, ans2;
   cin >> a >> b;
   ans1=a*b;
   ans2=2*a+2*b;
   cout << ans1 << " " << ans2 << endl; 
   
   return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    cin >> s;
    if(s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(void){
   while(true){
       int a;
       cin>>a;
       if(a==0) break;
       else{
           int s=0;
           int b;
           b=1000-a;
           if(b>=500){
               s=s+1;
               b=b-500;
           }
           s=s+b/100;
           b=b%100;
           if(b>=50){
               s=s+1;
               b=b-50;
           }
           s=s+b/10;
           b=b%10;
           if(b>=5){
               s=s+1;
               b=b-5;
           }
           s=s+b;
           cout<<s;
           cout<<endl;
       }
   }
}


Measured memory_bytes: 3084
#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 H, W;
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));
  rep(i,H) rep(j,W) cin >> a[i][j];

  vector<int> r(H, 0), c(W, 0);

  rep(i,H) rep(j,W) {
    if(a[i][j] == '#') {
      r[i] = 1;
      c[j] = 1;
    }
  }

  rep(i,H) {
    if(!r[i]) continue;
    rep(j,W) {
      if(!c[j]) continue;
      cout << a[i][j];
    }
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	double a,b,x;
	scanf("%lf %lf %lf",&a,&b,&x);
	double vol = a*a*b;
	double pi = acos(-1);
	if(x>=(vol/2.0)){
		x = vol-x;
		double t = (2.0*x)/(a*a);
		double ans = atan(t/a);
		printf("%.7f",ans*180/pi);
	}
	else {
		double t = (2.0*x)/(a*b);
		double ans = atan(t/b);
		ans = pi/2.0-ans;
		printf("%.7f",ans*180/pi);
	}
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if (e-a <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

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

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;


void solve(){
	int n;
	cin >> n;
	vector<ll> d(n+1);
	forn(i,n+1) cin >> d[i];
	vector<ll> cnt(n+1,0);ll bef=1;
	ll mx=1e17;
	forn(i,n+1){
		if(bef<d[i]){
			cout << -1;
			return;
		}
		bef-=d[i];
		cnt[i]=bef;
		bef=min(mx,2*bef);
	}
	ll ans=0,pre=0;
	for(int i=n;i>=1;i--){
		pre+=d[i];
		ll cur=min(cnt[i-1],pre);
		ans+=(d[i]+cur);
		pre=cur;
	}
	ans+=d[0];
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
    #define hell                         1000000007 
    #define M                            1000000007
    #define Maxi                      10000000000000000
        #define lcm(a,b)                     (a*b)/__gcd(a,b)
        #define ll                           long long

        #define vll                          vector<ll>
        #define vi                           vector<long long>
        #define pll                          vector< pair<ll,ll> >
        #define pb                           push_back
        //#define mp                           make_pair
        #define all(v)                       v.begin(),v.end()
        #define lbnd                         lower_bound
        #define ubnd                         upper_bound
        #define bs                           binary_search
        #define F                            first
        #define S                            second
        #define rep(i,a,b)                   for(i=a;i<b;i++)
        #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
        #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
        #define ret(x)                       return cout<<x,0;
        #define dbg(x)                       cout << #x << " is " << x << endl;
        //#define endl                           '\n'
     
     
        // Debug //
     
        #define trace(x)                 cerr << #x << ": " << x << endl;
        #define trace1(x)                cerr << #x << ": " << x << endl;
        #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
        #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
        #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
        #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
        #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


    using namespace std;
    
    //ll parent
    ll arr[100005];
    map<ll,vector<ll>>m1;
    int main()
    {

         ios_base::sync_with_stdio(false);
         cin.tie(NULL);cout.tie(NULL);
      
      ll a;
      string s;
      cin>>a>>s;
      if(a>=3200)
      {
        cout<<s<<endl;
      }
      else
        cout<<"red"<<endl;
      return 0;
  }
        

        
    


  



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

    long long a,b,c,d,e,f,g;
    cin>>a>>b;
    char ch;
    char arr[105][105];
    for(long long i=1; i<=a; i++)
        for(long long j=1; j<=b; j++)

        {
            cin>>ch;
            arr[i][j]=ch;
        }

    for(long long j=1; j<=b+2; j++)
        cout<<"#";
    cout<<endl;

    for(long long i=1; i<=a; i++)
    {
        cout<<"#";
        for(long long j=1; j<=b; j++)

        {

            cout<<arr[i][j];
        }

        cout<<"#"<<endl;
    }


    for(long long j=1; j<=b+2; j++)
        cout<<"#";




}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> X(M), D(M-1); cin >> X;
  sort(X.begin(), X.end());
  for (int i = 0; i < M - 1; ++i) D[i] = X[i + 1] - X[i];
  sort(D.begin(), D.end());

  int num = 0;
  for (int i = 0; i < M - N; ++i) {
    num += D[i];
  }
  cout << num << endl;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#define ll long long


using namespace std;

ll mod=998244353;
ll dp[3001][3001];
int main(){
	int a,b;cin>>a>>b;
	int c,d;cin>>c>>d;
	dp[a][b]=1;
	for(int i=a+1;i<=c;i++){
		dp[i][b]=dp[i-1][b]*b;
		dp[i][b]%=mod;
	}
	for(int j=b+1;j<=d;j++){
		dp[a][j]=dp[a][j-1]*a;
		dp[a][j]%=mod;
	}
	for(int i=a+1;i<=c;i++){
		for(int j=b+1;j<=d;j++){
			dp[i][j]=(dp[i-1][j]*(j%mod)+dp[i][j-1]*(i%mod))%mod;
			dp[i][j]-=(dp[i-1][j-1]*((i-1)%mod)*((j-1))%mod);
			dp[i][j]+=mod;
		
			dp[i][j]%=mod;
		}
	}

	cout<<dp[c][d];
}


Measured memory_bytes: 73900
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
  string ABCD;
  cin >> ABCD;
  int A = ABCD[0] - '0',
      B = ABCD[1] - '0',
      C = ABCD[2] - '0',
      D = ABCD[3] - '0';

  if (A - B - C - D == 7) {
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  } else if (A - B - C + D == 7) {
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  } else if (A - B + C - D == 7) {
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  } else if (A - B + C + D == 7) {
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  } else if (A + B - C - D == 7) {
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  } else if (A + B - C + D == 7) {
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  } else if (A + B + C - D == 7) {
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  } else if (A + B + C + D == 7) {
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  } else {
  }
}

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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 5005;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

int Fac[N];
int Inv[N];

int Ckn(int n,int k)    {
    if (n < k)  return  0;
    if (k < 0)  return  0;

    return  mul(Fac[n],mul(Inv[k],Inv[n - k]));
}
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int k;  cin >> k;
    int n;  cin >> n;

    for(int i = 2 ; i <= k + k ; ++i)   {
        int l = max(1,i - k);
        int r = min(k,i - 1);

        int CntPairs  = (r - l + 1) / 2;
        int CntSingle = k - (r - l + 1);

        int ans = 0;

        for(int j = 0 ; j <= CntPairs ; ++j)    {
            int val = Pow(2,j);
            val = mul(val,Ckn(CntPairs,j));
            val = mul(val,Ckn(CntSingle + n - 1,j + CntSingle - 1));

            add(ans,val);
        }
        if (i & 1)  {   cout << ans << "\n";    continue;   }

        for(int j = 0 ; j <= CntPairs ; ++j)    {
            int val = Pow(2,j);
            val = mul(val,Ckn(CntPairs,j));
            val = mul(val,Ckn(CntSingle + n - 2,j + CntSingle - 1));

            add(ans,val);
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class9
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split();
            long s = long.Parse(NM[0]);
            long c = long.Parse(NM[1]);
            long count = 0;
            if (s*2 <= c)
            {
                count += s;
                
                c -= 2 * s;
                s = 0;
            }
            else
            {
                count += c / 2;
                c = 0;
            }

            count += c / 4;

            Console.WriteLine(count);
        }
    }
}


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

int main(){
	int n;
	int set;
	while(cin >> n){
		set = 0;

		for(int a = 0; a <= 9; a++){
			for(int b = 0; b <= 9; b++){
				for(int c = 0; c <= 9; c++){
					for(int d = 0; d <=9; d++){
						if(a + b + c + d == n){
							set += 1;
						}
					}
				}
			}
		}
		
		cout << set << endl;
	}

	return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int ketasu(int x){
    int result = 0;
    while(x != 0){
        result++;
        x /= 10;
    }
    return result;
}
bool judge753(int num){
    ostringstream oss;
    oss << num;
    string s = oss.str();
    bool j1 = false;
    bool j2 = false;
    bool j3 = false;
    for(int i = 0; i < (int)s.size(); i++)
    {
        if(s[i] == '7')j1 = true;
        if(s[i] == '5')j2 = true;
        if(s[i] == '3')j3 = true;
    }
    return j1 && j2 && j3;
    
}
vector<int> gen753(vector<int> v){
    vector<int> result;
    for(int i = 0; i < (int)v.size(); i++)
    {
        
        result.push_back(v[i]);
        result.push_back(v[i] * 10 + 3);
        result.push_back(v[i] * 10 + 5);
        result.push_back(v[i] * 10 + 7);
    }

    
    return result;
}

int main (){
    int N;
    cin >> N;
    int keta = ketasu(N);
    int count = 0;
    vector<int> storage;
    storage.push_back(7);
    storage.push_back(5);
    storage.push_back(3);
    for(int i = 1; i < keta; i++)
    {
        storage = gen753(storage);
    }
    sort(storage.begin(),storage.end());
        for(int i = 0; i < (int)storage.size(); i++)
    {
        //cout << storage[i] << endl;
    }
    int tmp = 0;
    for(int i = 0; i < (int)storage.size(); i++)
    {
        if(tmp != storage[i] && storage[i] <= N && judge753(storage[i])){
            count++;
            tmp = storage[i];
        }
    }
    cout << count << endl;
    
    
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define N 200010
int n,a[N],b[N],c[N],d[N];
const int INF = 1000000000;
int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n+1)c[i]=d[i]=0;
    rep(i,n)c[a[i]]++,d[b[i]]++;
    rep(i,n+1){
	if(c[i]+d[i]>n){
	    cout<<"No\n";
	    return 0;
	}
    }
    for(int i=1;i<=n;i++){
	c[i]+=c[i-1];
	d[i]+=d[i-1];
    }
    int x=INF;
    for(int i=1;i<=n;i++)x=min(x,c[i-1]+n-d[i]);
    cout<<"Yes\n";
    rep(i,n){
	if(i)cout<<" ";
	cout<<b[(i+n-x)%n];
    }
    cout<<"\n";
}

Measured memory_bytes: 6680
#include <stdio.h>

int main(){
	int N,count=1,flag=0;
	scanf("%d",&N);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}

	for(int i=1;i<N;i++){
		flag=0;
		for(int j=0;j<i;j++){
			if(H[i]>=H[j]){
				flag++;
			}else{
				break;
			}
			if(flag==i)count++;
		}
	}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    cin>>s;
    bool c[4]={};
    REPARR(i,s){
        switch(s[i]){
            case 'N':
                c[0]=true;
                break;
            case 'S':
                c[1]=true;
                break;
            case 'E':
                c[2]=true;
                break;
            case 'W':
                c[3]=true;
                break;
        }
    }
    Yes((c[0]==c[1])&&(c[2]==c[3]));
    return 0;
}


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

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

	int	n;
	int	minv;
	int	count;

	cin >> n;
	minv = INT_MAX;
	count = 0;
	rep(i, n)
	{
		int	x;

		cin >> x;
		if (x < minv)
		{
			minv = x;
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2540
// https://atcoder.jp/contests/abc106/tasks/abc106_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    cout << A * B - (A + B - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool chP(int n){
for(int i=3; i*i<=n; i+=2){ if(n%i==0){ return false; } }
return true;
}
int main(){
int X, ans=0; cin >> X;
if(X<=2){ans=2;}
else{
if(X%2==0){X++;}
while(!chP(X)){X+=2;}
ans=X;
}  
  
cout << X << "\n";
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

aa = A
r=[]
if !A.find_index(1)
  result = -1
else
  for i in 1..N
    if aa.find_index(i) != nil
      aa.shift(aa.find_index(i)+1)
      r.push(i)
    else
      break
    end
  end
  result = N - r.size
end
puts result

Measured memory_bytes: 20740
def inputs(): return [int(x) for x in input().split()]
h,w = inputs()
meiro=[list(input()) for _ in range(h)]
visit = [[-1]*w for _ in range(h)]
if meiro[0][0]=="#":
    visit[0][0]=1
else:
    visit[0][0]=0
for j in range(1,w):
    if meiro[0][j]=="#":
        if meiro[0][j-1]=="#":
            visit[0][j]=visit[0][j-1]
        else:
            visit[0][j]=visit[0][j-1]+1
    if meiro[0][j]==".":
        visit[0][j]=visit[0][j-1]
for i in range(1,h):
    if meiro[i][0]=="#":
        if meiro[i-1][0]=="#":
            visit[i][0]=visit[i-1][0]
        else:
            visit[i][0]=visit[i-1][0]+1
    if meiro[i][0]==".":
        visit[i][0]=visit[i-1][0]
#print(visit)
for i in range(1,h):
    for j in range(1,w):
        if meiro[i][j]=="#":
            if meiro[i-1][j]=="#" and meiro[i][j-1]=="#":
                visit[i][j]=min(visit[i-1][j],visit[i][j-1])
            elif meiro[i-1][j]=="#":
                visit[i][j]=min(visit[i-1][j],visit[i][j-1]+1)
            elif meiro[i][j-1]=="#":
                visit[i][j]=min(visit[i-1][j]+1,visit[i][j-1])
            else:
                visit[i][j]=min(visit[i-1][j]+1,visit[i][j-1]+1)
        else:
            visit[i][j]=min(visit[i-1][j],visit[i][j-1])
print(visit[h-1][w-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

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

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vi a(n);

  rep(i, n) cin >> a[i];
  map<int,int> m;

  ll ans = 0;
  rep(i, n) {
    ans += m[i - a[i]];
    ++m[i + a[i]];
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 21064
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Feb  4 14:11:22 2019
//
package main

import "fmt"

func main() {

	var m [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&m[i][j])
		}
	}

	var diff [3][4]int
	for i := 0; i < 3; i++ {
		diff[i][0] = m[i][1] - m[i][0]
		diff[i][1] = m[i][2] - m[i][1]
		diff[i][2] = m[1][i] - m[0][i]
		diff[i][3] = m[2][i] - m[1][i]
	}

	for i := range diff[0] {
		if diff[0][i] != diff[0][i] || diff[1][i] != diff[2][i] {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    vector<string>tmod(k);
    
    for(int i=0;i<n;i++){
        tmod[i%k]+=t[i];
    }
    int ans=0;
    for(int i=0;i<k;i++){        
        vector<vector<int>> dp(tmod[i].length(),vector<int>(3));
        //0:グー、1:チョキ、2:パー
        if('s'==tmod[i][0]) {//チョキ
            dp[0][0]+=r;
        }else if('p'==tmod[i][0]){//パー
            dp[0][1]+=s;
        }else{//グー
            dp[0][2]+=p;
        }
        for(int j=0;j<tmod[i].length()-1;j++){
            if('s'==tmod[i][j+1]) {
                dp[j+1][0]+=max(dp[j][1],dp[j][2])+r;
                dp[j+1][1]+=max(dp[j][0],dp[j][2]);
                dp[j+1][2]+=max(dp[j][1],dp[j][0]);
            }else if('p'==tmod[i][j+1]){
                dp[j+1][0]+=max(dp[j][1],dp[j][2]);
                dp[j+1][1]+=max(dp[j][0],dp[j][2])+s;
                dp[j+1][2]+=max(dp[j][1],dp[j][0]);
            }else{
                dp[j+1][0]+=max(dp[j][1],dp[j][2]);
                dp[j+1][1]+=max(dp[j][0],dp[j][2]);
                dp[j+1][2]+=max(dp[j][1],dp[j][0])+p;
            }
        }
        ans+=*max_element(dp[tmod[i].length()-1].begin(),dp[tmod[i].length()-1].end());
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int main(){
    int X,Y,a=0;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++)
    {
        if(2*(X-i)+4*i == Y)a++;
        if(a!=0)break;
    }
    if(a==0)cout << "No" << endl;
    else cout << "Yes" << endl;
    
}

Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
bool cmp(long long x, long long y){
   return x>y;
}
long long a[100005];
int main()
{
    long long n;
    cin>>n;
    for (long long i = 0; i < n; i++)
        cin>>a[i];
    sort(a,a+n,cmp);
    long long f=0,s=0;
    bool flag = false;
    for (long long i = 0; i < n-1; i++){
        if (a[i]==a[i+1]&&!flag){
            f = a[i];
            i+=2;
            flag = true;
        }
        if (a[i]==a[i+1]&&flag){
          //  cout<<i<<endl;
            s = a[i];
            break;
        }
    }
     cout<<f*s<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

int a[10010 * 2];

int main() {
  int N, K; scanf("%d%d", &N, &K);
  if (N / 2 < K) {
      cout << -1 << endl;
      return 0;
  }

  REP(i, N) a[i] = a[i + N] = i + 1;
  if (N % 2) {
      vector<int> v;
      while (K--) {
          v.clear();
          v.push_back(a[K]);
          int right = 0;
          int left = N;
          REP(i, N / 2) {
              right++;
              left--;
              v.push_back(a[K + right]);
              v.push_back(a[K + left]);
          }
          for (int i = 0; i + 1 < (int)v.size(); i++)
              printf("%d %d\n", v[i], v[i + 1]);
          if (K) printf("\n");

      }
  } else {
      vector<int> v;
      REP(k, K) {
          v.clear();
          int right = -1;
          int left = N;
          REP(i, N / 2) {
              right++;
              left--;
              v.push_back(a[k + right]);
              v.push_back(a[k + left]);
          }
          if (k) printf("\n");
          for (int i = 0; i + 1 < (int)v.size(); i++)
              printf("%d %d\n", v[i], v[i + 1]);
      }

  }

  return 0;
}

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

int main() {
    int a, b, c, d, e, k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

int solve(){
    int n, m; cin >> n >> m;
    vint a(n); rep(i,n) cin >> a[i];
    sort(rall(a));
    if(a[m-1]*4*m >= accumulate(all(a),0)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    char s[110];
    cin>>N;
    scanf("%s",s);
    int ans=0;
    map<char,int>m;
    for(int i=1;i<N;i++){
            int counted=0;
        for(int j=0;j<=i;j++){
                m[s[j]]++;
        }
        for(int j=i+1;j<N;j++){
            if(m[s[j]]){
                counted++;
                m[s[j]]=0;
            }
        }
        ans=max(ans,counted);
        m.clear();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;

int N,M;
vector<int> G[100010];
int ans[100010];
bool used[100010];

int main()
{
    cin >> N >> M;
    REP(i,M) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<tuple<int,int>> que;
    for (int i = 0; i < G[1].size(); i++) {
        que.push(make_tuple(1, G[1][i]));
    }

    used[1] = true;

    while (que.size() > 0) {
        int pre,cur;
        tie(pre, cur) = que.front();
        que.pop();
        if (used[cur]) continue;
        used[cur] = true;
        ans[cur] = pre;
        for (int i = 0; i < G[cur].size(); i++) {
            que.push(make_tuple(cur, G[cur][i]));
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 12428
import numpy as np
h,w=map(int,input().split())
a=[]
for i in range(h):
  a.append([0 if i=='#' else h+w for i in list(input())])
a=np.array(a)
for i in range(h-1):
  a[i+1,:]=np.minimum(a[i,:]+1,a[i+1,:])
for i in range(h-1,0,-1):
  a[i-1,:]=np.minimum(a[i,:]+1,a[i-1,:])
for i in range(w-1):
  a[:,i+1]=np.minimum(a[:,i]+1,a[:,i+1])
for i in range(w-1,0,-1):
  a[:,i-1]=np.minimum(a[:,i]+1,a[:,i-1])
print(np.max(a))

Measured memory_bytes: 60408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  vector<i64> s(n + 1);
  for (i64 i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i - 1];
  map<i64, i64> mp;
  i64 ans = 0;
  for (i64 i = 0; i <= n; ++i) {
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt(), E = sc.nextInt();
                System.out.println(A - Math.max((B - 1) / D + 1, (C - 1) / E + 1));
        }
}

Measured memory_bytes: 26284
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int a, b, cnt = 0;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		if (((i / 10000) == (i % 10)) && (((i / 1000) - (10 * (i / 10000))) == ((i / 10) % 10))) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var message = IO.Read();
			var halfLength = message.Length / 2;
			IO.Write(message.Substring(0 , halfLength) == message.Substring(halfLength + 1));
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

int main()
{
	string s;
  	cin>>s;
  	int a=s.size();
  	if(s[a]=='s'||s[a]=='x'||s[a]=='h'&&s[a-1]=='c'||s[a-1]=='s'){
  		cout<<s<<"es";	
	}
	else{
		cout<<s<<"s";
	}
	return 0;
}

Measured memory_bytes: 3584
if __name__ == "__main__":
    s = input()
    t = input()

    ans = float('inf')
    for i in range(0, len(s) - len(t) + 1):
        diff_sum = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff_sum += 1
        if ans > diff_sum:
            ans = diff_sum

    print(ans)


Measured memory_bytes: 9116
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n,t;
vll ti;
lli ans = 0;
lli p;

int main(){
    cin >> n >> t;
    ti = vll(n);
    for(lli i = 0;i < n;i++) cin >> ti[i];
    p = 0;
    for(lli i = 0;i < n;i++){
        ans += max((ti[i] - p) - t,0ll);
        p = ti[i];
    }
    cout << ti.back()+t-ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import itertools
 
s = str(input())
 
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1

M = 1
INF = 10 ** 9 + 7
      
for i in range(n):
  if s[n-1-i] == '?':
    for k, j in itertools.product(range(10), range(13)):
      x = (j+k*M)%13
      dp[i+1][x] += dp[i][j]
      dp[i+1][x] %= INF
  else:
    for j in range(13):
      x = (j+int(s[n-1-i])*M)%13
      dp[i+1][x] += dp[i][j]
      dp[i+1][x] %= INF
  M = (M*10)%13

print(dp[-1][5])
#print(dp[-1][5]%(10**9+7))
#print(dp)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	ll k;
	cin>>k;
	if(k%2==0 || k%5==0) cout<<-1<<'\n';
	else
	{
		int cnt=1;
		ll val=7;
		while(val%k)
		{
			val=val*10%k;
			val=(val+7)%k;
			cnt++;
		}
		cout<<cnt<<'\n';
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  string s;
  cin >> s;
  int c=0;
  for (int i = 1; i < s.length(); i++) {
    if(s[i]!=s[i-1])c++;
  }
  cout << c<<endl;
}


Measured memory_bytes: 512
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1005,V=505;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void Add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int fa[N],dis[N],f[N][N<<1],n,D;
void dfs(int u){go(u)if(v!=fa[u])dis[v]=dis[u]+1,fa[v]=u,dfs(v);}
void get(int u,int lim,int ex){
	go(u)if(v!=fa[u])get(v,lim,ex);
	R int l=dis[u]-lim+ex,r=lim-dis[u]+ex;
	fp(k,l+V,r+V){
		f[u][k]=1;
		go(u)if(v!=fa[u])f[u][k]=mul(f[u][k],add(f[v][k-1],f[v][k+1]));		
	}
}
inline int even(R int s){
	dis[s]=fa[s]=0,memset(f,0,sizeof(f));
	dfs(s),get(s,D,0);
	R int res=0;
	fp(i,0,V<<1)upd(res,f[s][i]);
	return res;
}
inline int odd(R int s,R int t,R int ex){
	fa[s]=t,fa[t]=s,dis[s]=dis[t]=0;
	memset(f,0,sizeof(f));
	dfs(s),dfs(t);
	get(s,D+(!ex),0),get(t,D,ex);
	R int res=0;
	fp(i,1,V<<1)upd(res,mul(f[s][i],add(f[t][i-1],f[t][i+1])));
	return res;
}
int main(){
	scanf("%d",&n);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),Add(u,v),Add(v,u);
	dis[1]=fa[1]=0,dfs(1);
	R int rt=1;
	fp(i,1,n)if(dis[i]>dis[rt])rt=i;
	dis[rt]=fa[rt]=0,dfs(rt);
	fp(i,1,n)if(dis[i]>dis[rt])rt=i;
	if(dis[rt]&1^1){
		D=dis[rt]>>1;
		fp(i,1,D)rt=fa[rt];
		printf("%d\n",even(rt));
	}else{
		D=dis[rt]>>1;
		fp(i,1,D)rt=fa[rt];
		R int s=rt,t=fa[s];
		R int res=add(odd(s,t,0),odd(t,s,0));
		res=dec(res,add(odd(s,t,1),odd(s,t,-1)));
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 8192
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
ll x, now = 100;
int ans;
int main() 
{
	rd(x);
	while (now < x)
	{
		ans++;
		now = now + now / 100;
	}
	pt(ans);
    return 0;
}

Measured memory_bytes: 1492
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

K = int(input())
nums = []
def make_num(keta, str_num):
    if len(str_num) == keta:
        nums.append(str_num)
        return
    if str_num[-1] == '0':
        # for i in [0,1,9]:
        for i in [0,1]:
            make_num(keta, str_num + str(i))
    elif str_num[-1] == '9':
        # for i in [0,8,9]:
        for i in [8,9]:
            make_num(keta, str_num + str(i))
    else:
        for i in range(-1, 2):
            make_num(keta, str_num + str(int(str_num[-1])+i))

def enum(keta):
    for i in range(1,10):
        make_num(keta, str(i))

keta = 0
while len(nums) < K:
    keta += 1
    enum(keta)

# print(nums[K-20:])
print(nums[K-1])

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

string s,s1,s2;
int main()
{
    int n, m, i, j=0,sum=0;
    cin>>s>>s1>>n>>m>>s2;
    s==s2?cout<<n-1<<' '<<m<<endl:cout<<n<<' '<<m-1<<endl;
    return 0;
}



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

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

    int A, X;
    cin >> X >> A;
    if (X < A)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 10 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[3][3];
  int n;
  int b[10];
  int count = 0;

  for (int i = 0; i < 3 ; i++){
    for (int j = 0; j < 3; j++) scanf("%d", &a[i][j]);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);

  for (int i = 0; i < n; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        if (a[j][k] == b[i]) a[j][k] = 0;
      }
    }
  }

  for (int i = 0; i < 3; i++){
    if (a[i][0] == a[i][1] && a[i][0] == a[i][2]) count++;
  }

  for (int i = 0; i < 3; i++){
    if (a[0][i] == a[1][i] && a[0][i] == a[2][i]) count++;
  }

  if (a[0][0] == a[1][1] && a[0][0] == a[2][2]) count++;

  if (a[0][2] == a[1][1] && a[0][2] == a[2][0]) count++;


  if (count == 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 128
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = List.fill(n)(sc.next())

  val cs = "MARCH".map(c => s.count(_.head == c).toLong)
  var ans = 0L
  for {
    i <- 0 until 5
    j <- i+1 until 5
    k <- j+1 until 5
  } {
    ans += cs(i) * cs(j) * cs(k)
  }
  println(ans)
}


Measured memory_bytes: 65012
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int t;
	cin >> t;

	if (t >= 30)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <tuple>
#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOR_INV(var, min, max) for (ui (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

const static ui NMAX = 1000000000;

static ul N;

void solve(void) {
  cout << ((N * (N - 1)) / 2) << endl;
}

int main(void) {
  cin >> N;
  solve();
  return 0;
}


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

using namespace std;
const int MOD = 1000000007;

int mul(int n)
{
    int tmp = n / 2;
    int ans = 1;
    for (int i = 0; i < tmp; ++i) {
        ans = 2 * ans % MOD;
    }
    return ans;
}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    int h = n - 1;
    vector<int> x(n, 0);
    int ans = 0;

    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) {
        if (a[i] > h) goto end;
        ++x[a[i]];
    }

    int num;    
    if (n % 2) {
        if (x[0] != 1) goto end;
        num = 2;
    } else num = 1;

    for (int i = num; i < n; i += 2) {
        if (x[i] != 2) goto end;
    }

    ans = mul(n);    

    end:;
        cout << ans << endl;

    return 0;
}

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

int main() {
   long long int a,b,d[60][60];
  cin >>a>>b;
  char c[60][60];
  for(int i=1;i<a+1 ;i++){
  for(int j=1;j<b+1;j++){
    cin >> c[i][j];
  }
  }
    
  for(int i=1;i<a+1;i++){
    for(int j=1;j<b+1;j++){
     
    if(c[i][j] =='#'){
     d[i-1][j-1]++;
     d[i][j-1]++; 
      d[i+1][j-1]++;
      d[i+1][j]++;
      d[i+1][j+1]++;
      d[i][j+1]++;
      d[i-1][j+1]++;
      d[i-1][j]++;
    }
    }
    
  }
  
  for(int i=1;i<a+1;i++){
    for (int j=1;j<b+1;j++)
      
      if(c[i][j] != '#'){
       cout << d[i][j];
      }
      else{
        cout <<'#';
      }
    cout <<endl;
  
  }  
  
}


Measured memory_bytes: 256