akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

class UnionFindTree
{
   private:
      int N;
      int *rootnum;
      int *rank;
      int *unionnum;

   public:
      UnionFindTree(int n){
         /*0からn-1までの要素をunionとしてもつ*/
         N = n;
         rootnum = new int[N];
         rank = new int[N];
         unionnum = new int[N];
         for( int i = 0 ; i < N ; i++ ){
            rootnum[i] = i;
            rank[i] = 0;
            unionnum[i] = 1;
         }
      }
      
      int Find( int j ){
         if( rootnum[j] == j ){
            return j;
         }
         else{
            return rootnum[j] = Find(rootnum[j]);
         }
      }

      void Union( int i , int j ){
         int x = Find(i);
         int y = Find(j);
         if( x == y ) return;
         N--;
         if( rank[x] < rank[y] ){
            rootnum[y] = x;
            unionnum[x] += unionnum[y];
         }else{
            rootnum[x] = y;
            unionnum[y] += unionnum[x];
            if( rank[x]==rank[y] ) rank[x]++;
         }
      }

      int Num( int j ){
         /*与えられた要素の入っている集合の要素数を答える*/
         int x = Find(j);
         return unionnum[x];
      }

      int UnionNum(){
         /*集合の数を答える*/
         return N;
      }

      ~UnionFindTree(){
         delete rootnum;
         delete rank;
         delete unionnum;
      }

};

int main(){
   int N,M;
   cin >> N >> M;
   UnionFindTree uft(N);
   vector<pair<int,int>> v;
   for(int i=0;i<M;i++){
      int a,b;
      cin >> a >> b;
      v.push_back(make_pair(a,b));
   }
   long long A = N;
   A*=(N-1);
   A/=2;
   long long ans[M];
   for(int i=M-1; i>=0; i--){
      int a=v[i].first;
      int b=v[i].second;
      a--;
      b--;
      ans[i]=A;
      if(uft.Find(a)!=uft.Find(b)){
         long long an = uft.Num(a);
         long long bn = uft.Num(b);
         A-=an*bn;
      }
      uft.Union(a,b);
   }
   for(int i=0;i<M;i++){
      cout << ans[i] << endl;
   }
   return 0;
}


Measured memory_bytes: 4212
import java.util.Scanner;

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

		int sum = 0;
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
			if (sum <= X) {
				cnt++;
			} else {
				break;
			}
		}

		System.out.println(cnt + 1);
	}
}

Measured memory_bytes: 23764
import java.util.*;
public class Main {

		
	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);
	        boolean [] prime = new boolean[50000];
	        
	        for(int i=2;i<prime.length;i++)prime[i]=true;
	        for(int i=2;i<=Math.sqrt(prime.length-1);i++){
	        	if(prime[i]){
	        		for(int j=i*2;j<=prime.length-1;j+=i)prime[j]=false;
	        	}
	        }
	        
	        while(true){
	        	int k=scan.nextInt();
	        	if(k==0)break;
	        	int ans=0;
	        	for(int i=2;i<=k/2;i++){
	        		if(prime[i]&&prime[k-i])ans++;
	        	
	        	}
	        	
	        	System.out.println(ans);
	        }
	    }
}
	    

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

int main(){
    int N,M,X;
  	cin >> N >> M >> X;
    int A[M]={};
    //goal are N or 0
    //M is total A
    //X is first place
  
    int count1,count2 = 0;
    for(int i = 0;i<M;i++){
        cin >> A[i];
        if(A[i]<=X){
            count1 ++;
          
        }
        if(A[i]>X){
            count2 ++;
          
        }
    }

    cout << min(count1,count2);
    




    

}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >>  N;

  int ans = 0;
  for ( int i = 1; i*i <= N; i++ ) {
    if ( N%i ) continue;
    int a = i-1, b = N/i-1;
    if ( a && N/a == N%a ) ans += a;
    if ( b && N/b == N%b ) ans += b;    
  }

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


Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)

if b == 0
  puts 0
  exit
end

$bits = Math.log2(b).ceil

def func(n)
  1.upto($bits).map do |i|
    if i == 1
      if [1, 2].include?(n % 4) then 1 else 0 end
    else
      case n % (2**i)
      when ->(x) {((x >= 2**(i-1))) && (x % 2 == 0)}
        1
      else
        0
      end
    end
  end.reverse.join('').to_i(2)
end

ans = func(a-1) ^ func(b)

if b == 2**$bits
  ans ^= b
end

puts ans


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;
constexpr ll INF = (1LL << 60);
constexpr int CMAX = 25000;
int main(){ 
  int n, m, s;
  cin >> n >> m >> s;
  vector<vector<pair<int,pair<int, ll>>>> g(n);
  rep(i,m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    g[u].emplace_back(make_pair(v, make_pair(a, b)));
    g[v].emplace_back(make_pair(u, make_pair(a, b)));
  }

  vector<int> c(n), d(n);
  rep(i,n) cin >> c[i] >> d[i];
  s = min(s, CMAX);
  auto dijkstra = [&](){
    vector<vector<ll>> dp(n, vector<ll>(CMAX + 1,INF));
    priority_queue<pair<ll, pair<int,int>>, vector<pair<ll, pair<int,int>>>, greater<pair<ll, pair<int,int>>>> que;
    dp[0][s] = 0;
    que.push(make_pair(0, make_pair(0, s)));
    while (!que.empty()) {
      auto p = que.top();
      que.pop();
      int u = p.second.first;
      int now = p.second.second;
      if (dp[u][now] < p.first) continue;
      int cnum = min(CMAX, now + c[u]);
      ll ndp = p.first + d[u];
      if (ndp < dp[u][cnum]) {
        dp[u][cnum] = ndp;
        que.push(make_pair(dp[u][cnum], make_pair(u, cnum)));
      }
      for (auto e : g[u]) {
        int v = e.first;
        int next = now - e.second.first;
        ll cost = e.second.second;
        if (next < 0 || next > CMAX) continue;
        if (dp[v][next] > dp[u][now] + cost) {
          dp[v][next] = dp[u][now] + cost;
          que.push(make_pair(dp[v][next], make_pair(v, next)));
        }
      }
    }
    return dp;
  };
  auto res = dijkstra();
  for (int i = 1; i < n; i++) {
    ll ans = INF;
    for (int j = 0; j <= CMAX; j++) {
      ans = min(ans, res[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
} 

Measured memory_bytes: 29600
#include<bits/stdc++.h>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,g[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u) {
    for(int v=nt[u];v<n;v++) {
        nt[u]=v+1;
        if(g[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r) {
    for(int i=0;i<n;i++) nt[i]=0;
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty()) {
        int u=S.top();
        int v=next(u);
        if(v!=-1) {
            if(color[v]==WHITE) {
                color[v]=GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs() {
    for(int i=0;i<n;i++) {
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;
    for(int u=0;u<n;u++) {
       if(color[u]==WHITE) dfs_visit(u);
    }
    for(int i=0;i<n;i++) {
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main(void) {
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            g[i][j]=0;
        }
    }
    for(int i=0;i<n;i++) {
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++) {
            cin>>v;
            v--;
            g[u][v]=1;
        }
    }
    dfs();
    return 0;
}

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

using namespace std;
typedef long long ll;

const int maxn=1e5+5;
struct node{
	int a,b;
	bool operator<(node x)const{
		return a<x.a;
	}
}v[maxn];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d %d",&v[i].a,&v[i].b);
	sort(v+1,v+1+n);
	ll ans=0;
	for(int i=1;i<=n;i++){
		int t=min(m,v[i].b);
		ans+=(ll)t*v[i].a;
		m-=t;
		if(m==0)break;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  const int N = 4;
  int a[N], b[N];
  while(cin >> a[0]) {
    for(int i = 1; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cin >> b[i];
    int hit, blow;
    hit = blow = 0;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
	if(a[i] == b[j]) {
	  if(i == j) ++hit;
	  else ++blow;
	}
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
blue_cards = []
red_cards = []
n = gets.chomp.to_i
n.times do
  blue_cards << gets.chomp
end
m = gets.chomp.to_i
m.times do
  red_cards << gets.chomp
end

blue_words = blue_cards.each_with_object(Hash.new(0)) {|s, hash| hash[s] += 1}
result = blue_words.map{|word, count| count - red_cards.count(word)}.max

print result > 0 ? result : 0

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	int a[100000], n, m, i, k, cnt = 0;
	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	while (n>0) {
		if (cnt == 0) {
			n -= k;
			cnt++;
		}
		else {
			n -= (k - 1);
			cnt++;
		}
	}
	printf("%d", cnt);

}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int s_num,t_num,i,j=0,count=0,key;
  int s[100001],t[10000];

  scanf("%d",&s_num);
  for(i = 0; i < s_num; i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&t_num);
  for(i = 0; i < t_num; i++){
    scanf("%d",&t[i]);
  }

  for(i = 0; i < t_num; i++){
    key = t[i];
    s[s_num]=key;
    while(s[j] != key){
      j++;
    }
    if(j != s_num)count++;
    j=0;
  }

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

Measured memory_bytes: 1080
from collections import Counter


def main():
    MOD = 2019
    s = input()
    n = len(s)
    t = [0] * (n + 1)
    # n-1,n-2,...,0
    for i in range(n - 1, -1, -1):
        t[i] = t[i + 1] + pow(10, n - i - 1, MOD) * int(s[i])
        t[i] %= MOD
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v * (v - 1) // 2
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70748
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int main() {
    int num[26] = {};
    char ch;
    while (cin >> ch) {
        if (islower(ch)) num[ch-'a'] += 1;
        else if (isupper(ch)) num[ch-'A'] += 1;
    }
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", i+'a', num[i]);
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
#define mp make_pair

const int N = (int)1e6 + 5;
int n, m;
vector<pil> g[N];
ll a[N][2];
bool used[N];

void dfs(int v) {
//	cerr << "dfs " << v << endl;
	used[v] = 1;
	for (pil e : g[v]) {
		int u = e.first;
		if (used[u]) continue;
		a[u][0] = -a[v][0];
		a[u][1] = e.second - a[v][1];
		dfs(u);
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	while(m--) {
		int v, u;
		ll w;
		scanf("%d%d%lld", &v, &u, &w);
		v--;u--;
		g[v].push_back(mp(u, w));
		g[u].push_back(mp(v, w));
	}
	a[0][0] = 1;
	dfs(0);

	ll L = (ll)1;
	ll R = (ll)1e10;
	ll F = -1;

	for (int v = 0; v < n; v++) {
		//cerr << "for " << v << endl;
		if (a[v][0] == 1) {
			L = max(L, 1 - a[v][1]);
		} else {
			R = min(R, a[v][1] - 1);
		}
		for (pil e : g[v]) {
			int u = e.first;
			ll x = a[v][0] + a[u][0];
			ll y = a[v][1] + a[u][1];
			if (x == 0) {
				if (y != e.second) {
					printf("0\n");
					return 0;
				}
			} else {
				ll z = e.second - y;
				if (z % 2 != 0) {
					printf("0\n");
					return 0;
				}
				z /= x;
				if (z <= 0) {
					printf("0\n");
					return 0;
				}
				if (F == -1) F = z;
				if (F != z) {
					printf("0\n");
					return 0;
				}
			}
		}
	}

	if (F == -1)
		printf("%lld\n", max(0LL, R - L + 1));
	else {
		if (L <= F && F <= R)
			printf("1\n");
		else
			printf("0\n");
	}

	return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5
1 1 1 1 1
)");
#define cin input
#endif

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

	int max = 0;
	int min = 1000000000;

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

		if(vec[i]>max)
			max=vec[i];
		if(vec[i]<min)
			min=vec[i];
	}

	cout << max-min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,a,b;
    scanf("%d",&n);
    if (n==1){
            printf("%s\n","Hello World");
    }else{
            scanf("%d",&a);
            scanf("%d",&b);
            printf("%d\n",a+b);
    } 
    return 0;
}


Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	int out=0;
	rep(i,k){
		vi dp(3);
		int w=i;
		while(w<n){
			vi ndp(3);
			ndp[0]=max(dp[1],dp[2])+r*(t[w]=='s');
			ndp[1]=max(dp[0],dp[2])+s*(t[w]=='p');
			ndp[2]=max(dp[0],dp[1])+p*(t[w]=='r');
			dp=ndp;
			w+=k;
		}
		out+=max({dp[0],dp[1],dp[2]});
	}

	cout<<out<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  long ans=0;
  cin >> n;
  map<string, int> ex;

  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (ex[s]) ans+=ex[s];
    ex[s]++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

void trace(int n, int a[])
{
	for (int i = 0; i < n; ++i)
	{
		cout << a[i];
		if (i < n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}

void insertSort(int n, int a[])
{
	int i, j, key;
	for (i = 1; i < n; ++i)
	{
		key = a[i];
		for (j = i - 1; j >= 0; --j)
		{
			if (a[j] > key)
			{
				a[j + 1] = a[j];
				continue;
			}
			break;
		}
		a[j + 1] = key;
		trace(n, a);
	}
}


int main()
{
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	trace(n, arr);
	insertSort(n, arr);
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=K;i<N;i++){
    if(A.at(i-K)>=A.at(i)){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#define MAX 1000
#define INFTY 1<<30 // 2^30
using namespace std;
typedef long long llong;

static const int VMAX = 10000;
int n, A[MAX+10], s;
int B[MAX+10], T[VMAX+10];

int solve()
{
  int ans = 0;
  bool V[MAX+10];
  for(int i = 0; i < n; i++)
  {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B,B+n);
  for(int i = 0; i < n; i++) T[B[i]] = i; // ????????????????????????????????????????????????
  for(int i = 0; i < n; i++)
  {
    if(V[i]) continue;
    int cur = i; // current point
    int S = 0; // sum of mass
    int m = VMAX; // min of the cycle
    int an = 0; // the number of material the cycle have
    while(1)
    {
      V[cur] = true; //already visited
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    ans += min(S+(an-2)*m, S+(an+1)*s+m);
  }
  return ans;
}

int main()
{
  cin >> n;
  s = VMAX;
  for(int i = 0; i < n; i++)
  {
    cin >> A[i];
    s = min(s,A[i]);
  }
  cout << solve() << endl;
  return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n,a,b;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  cin >> a >> b;
  cout << a + b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  const double PI=3.14159265358979323846;

  double theta_A = 2*PI*(H+M/60)/12;
  double theta_B = 2*PI*M/60;
  double x_A = A*sin(theta_A);
  double x_B = B*sin(theta_B);
  double y_A = A*cos(theta_A);
  double y_B = B*cos(theta_B);

  double ans = sqrt( (A*sin(theta_A) - B*sin(theta_B))*(A*sin(theta_A) - B*sin(theta_B)) + (A*cos(theta_A) - B*cos(theta_B))*(A*cos(theta_A) - B*cos(theta_B))) ;
  char num[100];
  sprintf(num,"%.11f",ans);
  cout << num << endl;

}


Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char,int> mpl,mpr;

    REP(i,n){
        mpl[s[i]]++;
        mpr[s[i]]=0;
    }
    int result = 0,tmpresult;
    REP(i,n-1){
        tmpresult = 0;
        mpl[s[n - i - 1]]--;
        mpr[s[n - i - 1]]++;
        for (char c = 'a'; c <= 'z'; c++){
            if(mpl[c]&&mpr[c]){
                tmpresult++;
            }
        }
        result = max(result, tmpresult);
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int N;

void dfs(int n, string S, int count){
  if(n == N){
    cout << S << endl;
  }
  else{
    rep(i,count+1){
      if(count == i){
        char c = 'a' + i;
        string T = S + c;
        dfs(n+1, T, count+1);
      }
      else{
        char c = 'a' + i;
        string T = S + c;
        dfs(n+1, T, count);
      }
    }
  }
}

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

  cin >> N;
  if(N == 1){
    cout << 'a' << endl;
  }
  else{
    dfs(1, "a", 1);
  }
}

Measured memory_bytes: 1536
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  s = get_str
  ans = 1
  pre_c = s[0]
  1.upto(s.size - 1) do |i|
    c = s[i]
    if pre_c != c
      ans += 1
    end
    pre_c = c
  end
  puts ans
end

if __FILE__ == $0
  main
end



Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    
    T *= 1000;
    A *= 1000;
    int M = -100000000;
    int ans = -1;
    rep(i, N) {
        if (abs(M - A) > abs(T - 6 * H[i] - A)) {
            M = T - 6 * H[i];
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    char ch;
    cin >> ch;
    if ('A' <= ch && ch <= 'Z')
        cout << 'A';
    else
        cout << 'a';

    cout << endl;
    return 0;
}


Measured memory_bytes: 3620
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/14
# Filename: main 
# Author: acto_mini

def main():
    N = int(input())
    power = 1

    for i in range(N):
        power = power * (i + 1)
        power = power % (10 ** 9 + 7)

    print(power)
    return


if __name__ == '__main__':
    main()


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

int main(){
    int a,b;
    cin >> a >> b;
    while(!(a == 0 && b == 0)){
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    for(int i = 0; i < T; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int t = a[T - 1];
    for(int i = 0; i < T - 1; i++){
        t -= a[i];
    }
    if(t <= 0) cout << 0 << endl;
    else cout << t - 1 << endl;
}

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007

typedef vector<int> vec;
typedef long long ll;

int main() {
    fast_cin();
    int n;cin>>n;
    vec v(n);
    FOR(i, 0, n)
        cin>>v[i];
    int sum=0;
    trav(a, v)
        sum+=a;
    //cout<<cc<<endl;
    int co=round((double)sum/n);
    ll ans = 0;
    //cout<<cc<<endl;
    trav(a, v){
        int x = a-co;
        ans+=(ll)x*x;
        //cout<<pow((a-cc), 2)<<endl;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,c,d,tmp,tmpp,m,h,w,x,y,sum[ohara],pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),t,b;
bool fl;
struct edge{int to,cost;};
ll dp[2000][2000];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>t>>b;
    rep(i,Size(t)+1)dp[i][0]=1;
    rrep(i,1,Size(t)+1){
        rrep(j,1,Size(b)+1){
            if(t[i-1]==b[j-1]){
                (dp[i][j]+=dp[i-1][j]+dp[i-1][j-1])%=MOD;
            }
            else{
                (dp[i][j]+=dp[i-1][j])%=MOD;
            }
        }
    }
    Cout(dp[Size(t)][Size(b)]);
    return 0;
}



Measured memory_bytes: 15016
#include<iostream>
using namespace  std;
int H, W,ans;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};
char field[100][100];
bool used[100][100];
bool in(int y, int x)
{
	if (y < 0 || x < 0 || y >= H || x >= W)return false;
	return true;
}
void dfs(int y, int x)
{
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (!in(ny, nx))continue;
		if (field[ny][nx] != field[y][x])continue;
		if (used[ny][nx])continue;
		used[ny][nx] = true;
		dfs(ny, nx);
	}
	return;
}
int main()
{
	while (cin >> H >> W && H != 0 || W != 0)
	{
		ans = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				used[i][j] = false;
			}
		}
		for (int i = 0; i < H; i++)
		{
			cin >> field[i];
		}

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (used[i][j])continue;
				used[i][j] = true;
				dfs(i, j);
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1648
#include<stdio.h>
#include<string.h>
int main(){

	int a=0,b=0,c=0,d=0,e=0,f=0;
	
	scanf("%d %d %d %d",&a,&b,&c,&f);
	e=a+b+c+f;
	while(e>59){
		d+=1;
		e-=60;
		}
	printf("%d\n%d\n",d,e);
        return 0;

} 

Measured memory_bytes: 0
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n;
  cin >> n;
  vl a(n);
  REP(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll ans = 0;
  REP(i,n-1){
    ans += a[(i+1)/2];
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int n,a[20];
map<pair<int,int>,ll>dp[22][22];

ll dfs(int l,int r,ll mul_l,ll mul_r){
	if(l>r)return 0;
	if(dp[l][r].count(make_pair(mul_l,mul_r)))return dp[l][r][make_pair(mul_l,mul_r)];
	ll &ret=dp[l][r][make_pair(mul_l,mul_r)];ret=1e18;
	for(int mid=l;mid<=r;mid++){
		ret=min(ret,dfs(l,mid-1,mul_l,mul_l+mul_r)+dfs(mid+1,r,mul_l+mul_r,mul_r)+a[mid]*(mul_l+mul_r));
	}
	return ret;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<a[1]+a[n]+dfs(2,n-1,1,1)<<endl;
	return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n), l(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> l[i];

    vector<P> vec(n);
    for (int i = 0; i < n; ++i)
        vec[i].first = x[i] + l[i], vec[i].second = x[i] - l[i];
    sort(vec.begin(), vec.end()); // x_i + l_i に関してソート
    ll ans = 0;
    ll right = -1000000000;
    for (int k = 0; k < n; ++k)
    {
        if (right <= vec[k].second)
        {
            ++ans;
            right = vec[k].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6264
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <math.h> //円周率はM_PI
#include <map>
#include <bitset>
using namespace std;


int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int S;
	int h;
	int m;
	int s;
	scanf("%d",&S);

	s = S % 60;
	m = S / 60 % 60;
	h = S / 3600;

		printf("%d:%d:%d\n", h, m, s);

	getchar();
	return 0;
}

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

const int N = 100010;

int n, k;
int f[N], a[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for(int i = 2; i <= n; ++i) {
        f[i] = 0x3f3f3f3f;
        if(i >= 2) f[i] = min(f[i], f[i - 1] + abs(a[i] - a[i - 1]));
        if(i >= 3) f[i] = min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
    }
    printf("%d\n", f[n]);
}


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

int main(){

    int n,m;
    int cntm=0;
    double sum=0;
    bool check=false;
    cin>>n>>m;
    vector<int> a(n);

    for(int i=0;i<n;i++){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    for(int i=0;i<n;i++){
        if(a.at(i)>=sum/4/m) cntm++;
        if(cntm>=m){
            check=true;
            break;
        }
    }

    if(check) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;




    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)



#ifndef CF
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(vector<T> v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#endif


const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

void solve(){
    int a, b,c, k;
    cin >> a >> b >> c;
    cin >> k;
    int cnt =0;
    while(a >= b){
        b*=2;
        cnt++;
    }
    while(b >= c){
        c*=2;
        cnt++;
    }
    if(cnt > k){
        cout <<"No";
    }
    else{
        cout <<"Yes";
    }
}


signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
//        cout << "Case #" << t << ": ";
        solve();
    }
}


Measured memory_bytes: 3652
N=int(input())
S=list(map(int,list(input())))
#print(S)

A=[[] for i in range(10)]

for i in range(N):
  A[S[i]].append(i)
#print(A)

cnt=0
for a in range(10):
  if len(A[a])==0:
    continue
  for c in range(10):
    if len(A[c])==0:
      continue
    cnt+=len(set(S[A[a][0]+1:A[c][-1]]))
print(cnt)

Measured memory_bytes: 64500
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} char ch[200];
signed main() {
    scanf ("%s", ch + 1);
    putchar (ch[1]), putchar (ch[2]), putchar (ch[3]); puts ("");
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int N; cin >> N;
	vector<int> a(N); 
	int max_num = -1, min_num = 1001;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		max_num = max(max_num, a[i]);
		min_num = min(min_num, a[i]);
	}
	int ans = max_num - min_num;
	cout << ans;
	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(0);
  cin.tie(0);

  int A,B;
  cin >> A >> B;

  cout << A*B << " " << endl;
  return 0;
}


Measured memory_bytes: 3576
N, M = map(int, raw_input().split())
S = [map(int, raw_input().split()) for _ in xrange(N)]
P = [map(int, raw_input().split()) for _ in xrange(M)]
C = []

def dist(s, p):
	return abs(s[0]-p[0])+abs(s[1]-p[1])

for s in S:
	min_dist = dist(s, P[0])
	min_p = 0
	for i in xrange(1, M):
		d = dist(s, P[i])
		if  d < min_dist:
			min_dist = d
			min_p = i
	C.append(min_p+1)
for c in C:
	print c 


Measured memory_bytes: 2692
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int Mo=998244353;

map<string,int> f;

int Dp(string s) {
	if (f.count(s)) return f[s];
	if (s.size()==0) return f[s]=1;
	if (s.size()==1) return f[s]=s[0]-'0'+1;
	int n=s.length(),ans=(s[0]-'0'+1)*Dp(s.substr(1,n))%Mo;
	fo(i,1,n) {
		string a,b;
		fo(j,1,i) a=a+s[j-1];
		fo(j,2,n/i) {
			int st=(j-1)*i+1;
			fo(k,(j-1)*i+1,j*i) a[k-st]=min(a[k-st],s[k-1]);
			string b;fo(k,j*i+1,n) b=b+s[k-1];
			(ans+=(ll)Dp(a)*Dp(b)%Mo)%=Mo;
		}
	}
	return f[s]=ans;
}

int main() {
	string s;cin>>s;
	printf("%d\n",Dp(s));
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

  vector <int> wa,su;
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  a*=100;
  b*=100;
  for(int i=0;i*a<=f;i++) for(int j=0;j*b<=f;j++) if(i*a+j*b<=f) wa.push_back(i*a+j*b);
  sort(wa.begin(),wa.end());
  int can=f*e/100;
  for(int i=0;i*c<=can;i++) for(int j=0;j*d<=can;j++) if(i*c+j*d<=can) su.push_back(i*c+j*d);
  sort(su.begin(),su.end());
  int rsum,rsu;
  double per=0;
  for(int i=0;i<wa.size();i++){
    for(int j=0;j<su.size();j++){
      if(wa[i]+su[j]<=f && (double)su[j]*100/wa[i]<=e){
        if((double)su[j]*100/(wa[i]+su[j])>=per){
          per=(double)su[j]*100/(wa[i]+su[j]);
          rsum=wa[i]+su[j];
          rsu=su[j];
        }
      }
    }
  }
  cout<<rsum<<" "<<rsu<<endl;
  return 0;

}


Measured memory_bytes: 1400
#include<stdio.h>

int main() {
  int i, k, n, data[10001] = {0};
  for(i = 2; i <= 10000; i++) {
    data[i] = 1;
  }
  for(i = 2; i * i <= 10000; i++) {
    if(data[i] == 1) {
      for(k = i * i; k <= 10000; k += i) {
        data[k] = 0;
      }
    }
  }
  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    for(i = n; n >= 3; i--) {
      if(data[i] == 1 && data[i - 2] == 1) {
        printf("%d %d\n", i - 2, i);
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main(){
        string s;
        int k;
        cin >> s >> k;
        int n = s.size();
        vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(k+1,vector<int>(2,0)));
        dp[0][0][0] = 1;

        for(int i=1;i<=n;i++){
                int sd = s[i-1] - '0';
                rep(cnt,k+1){
                        rep(d,10){
                                if(d ==0){
                                        if(sd ==0){
                                                dp[i][cnt][0] += dp[i-1][cnt][0];
                                                dp[i][cnt][1] += dp[i-1][cnt][1];
                                        }else{
                                                dp[i][cnt][1] += dp[i-1][cnt][0] + dp[i-1][cnt][1];
                                        }
                                }
                                else if(d < sd && cnt > 0){
                                        dp[i][cnt][1] += dp[i-1][cnt-1][0] + dp[i-1][cnt-1][1];
                                }
                                else if(d == sd && cnt > 0){
                                        dp[i][cnt][0] += dp[i-1][cnt-1][0];
                                        dp[i][cnt][1] += dp[i-1][cnt-1][1];
                                }
                                else if(d > sd && cnt > 0){
                                        dp[i][cnt][1] += dp[i-1][cnt-1][1];
                                }
                        }
                }
        }

        /*rep(i,n+1){
                rep(j,k+1){
                        rep(p,2){
                                cout << dp[i][j][p] << " ";
                        }
                        cout << " ";
                }
                cout << endl;
        }*/

        cout << dp[n][k][0] + dp[n][k][1] << endl;
        return 0;
}






Measured memory_bytes: 384
/*
 * Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
 *       Example:-   $ g++ -std=c++11 c++Template.cpp
 *
 * Author : Denzil Bernard  / Edgar Monis
 * Handle: 1_mn_RMY / the_king_in_the_north
 *
 */

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define read(type) readInt<type>()
#define ll long long
typedef pair< ll, ll> PII;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;

ll SI(){
    ll x;
    cin>>x;
    return x;
}


ll mod(ll a){
	return a<0?-a:a;
}


/********** Main()  function **********/
int main()
{
    ll n = SI(), m = SI(), c = SI();
    VI A[n];
    VI B;
    ll num = 0;
    REP(i,n+1){
    	if(i==0){
    		REP(i,m){
    			B.push_back(SI());
    		}
    	}
    	else{
    		ll sum = 0;
    		REP(i,m){
    			ll x =  SI();
    			sum += x*B[i];
    		}
    		sum += c;
    		if(sum>0){
    			num++;
    		}
    	}
    }
    cout<<num<<"\n";
    
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int check(int year,int month);
int main(){
  int month,day,year;
  int count;
  cin>>count;
  for(int i=0;i<count;i++){
    int co=0;
    cin>>year>>month>>day;
    co=check(year,month)-day+1;
    day=1;
    month++;
    if(month==11){
      month=1;
      year++;
    }
    while(year<1000){
      //cout<<co<<endl;
      co+=check(year,month);
      month++;
      if(month==11){
	month=1;
	year++;
      }
    }
    cout<<co<<endl;
  }
}
int check(int year,int month){
  if(year%3==0)
    return 20;
  else if(month%2!=0){
    return 20;
  }
  else
    return 19;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int n;
int deg[N], ans[N];
vector<pair<int, int> > g[N];
 
int32_t main()
{
	IOS;
	
	int t = 1;
	
	while(t--){
	    int h,n;
	    cin >> h >> n;
      	vector<int> v;
      	for(int i = 0 ; i < n ; i++){
        	int x;
          	cin>>x;
          	v.push_back(x);
        }
      if(accumulate(v.begin(),v.end(),0) >= h)
       		cout << "Yes";
      else
        	cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3704
def D():
    n = int(input())
    s = input()
    r,g,b = [],[],[]
    for i in range(n):
        if s[i]=="R": r.append(i)
        elif s[i]=="G": g.append(i)
        else: b.append(i)
    ans = len(r)*len(g)*len(b)
    for i in range(n):
        for j in range(i,n):
            if j + (j-i) >= n: continue
            if s[i]!=s[j] and s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
                ans -= 1
    print(ans)

D()

Measured memory_bytes: 9212
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

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

    // length is 2
    for ( int i = 0; i <= (int)(s.size() - 2); i++ ) {
	char a = s[i];
	char b = s[i+1];

	if ( a == b ) {
	    printf("%d %d\n", i+1, i+2);
	    return 0;
	}
    }

    // length is 3
    for ( int i = 0; i <= (int)(s.size() - 3); i++ ) {
	char a = s[i];
	char b = s[i+2];

	if ( a == b ) {
	    printf("%d %d\n", i+1, i+3);
	    return 0;
	}
    }

    printf("-1 -1\n");

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int N) : par(N), rank(N)
    {
        REP(i, N)
        {
            par[i] = i;  //the parent of the node
            rank[i] = 0; //the rank of the tree
        }
    }
    int find(int x)
    { //Find the root of x
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    { //Unite (the set of x) and (the set of y)
        x = find(x), y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
        { //larger rank is above
            par[x] = y;
        }
        else
        {
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    ciosup;
    ll n, m;
    cin >> n >> m;
    int A[m], B[m];
    REP(i, m)
    {
        int a,b;
        cin >> a >> b;
        A[i] = a - 1;
        B[i] = b - 1;
    }
    ll par[n];
    REP(i,n)par[i]=1;

    ll huar[m], hu = n * (n - 1) / 2;
    huar[m - 1] = hu;
    UnionFind s(n);
    IFOR(i, 1, m)
    {
        int x = s.find(A[i]), y = s.find(B[i]);
        if (x != y)
        {
            hu -= par[x]*par[y];
            s.unite(x, y);
            par[s.find(x)] = par[x] + par[y];
        }
        huar[i - 1] = hu;
    }
    REP(i,m)cout << huar[i] << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X)
{
    if(K*500>=X)
        cout<<YES<<endl;
    else
        cout<<NO<<endl;
}

int main()
{
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
     static int dp[];
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;


        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        double r=sc.nextDouble();
        double c=Math.PI*(2*r);
        System.out.println(c);
    }
}
/*

 */

Measured memory_bytes: 33052
#include<bits/stdc++.h>
using namespace std;
#define int long long
string S;
int rec(int idx,int out,int val)
{
	if(idx==S.size()) return (out*(val==0));
	return (rec(idx+1,out,val*10+S[idx]-'0')+rec(idx+1,out+val*10+S[idx]-'0',0));
}
signed main()
{
	cin>>S;
	cout<<rec(0,0,0);
	return 0;
}

Measured memory_bytes: 256