akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<ll> edge[100000+5];
vector<bool> visited(100000+5,false);
vector<ll> dist(100000+5);
vector <ll> incoming(100000+5,0);
void dfs(ll a)
{
	if(visited[a]==false)
	{
		visited[a]=true;
		for(ll i=0;i<edge[a].size();i++)
		{

			dist[edge[a][i]]=max(dist[edge[a][i]],dist[a]+1);
			//if(edge[a][i]==3)
		//	{
			//	cout<<a<<" "<<dist[edge[a][i]]<<endl;
			//}
			incoming[edge[a][i]]--;
			if(incoming[edge[a][i]]==0 && visited[edge[a][i]]==false)
			{
                //visited[edge[a][i]]=true;
				dfs(edge[a][i]);
			}
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;

	for(ll i=0;i<m;i++)
	{
		ll temp1,temp2;
		cin>>temp1>>temp2;
		edge[temp1].pb(temp2);
		incoming[temp2]++;
	}
	for(ll j=1;j<=n;j++)
	{
		if(visited[j]==false && incoming[j]==0)
		{
			dfs(j);
		}
	}
	ll ans=0;
	ll index;
	for(ll j=1;j<=n;j++)
	{
		if(dist[j]>ans)
		{
			ans=dist[j];
			index=j;
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 2005;

ll ans;
int n, x, a[N], dp[N][N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;
	
	cin >> n >> x;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i][0] = a[i];
		ans += a[i];
	}

	for (int i = 1; i <= n; i++) {
		ll sum = 0;
		for (int j = 1; j <= n; j++) {
			int prv = j - i;
			if (prv <= 0) prv += n;
			dp[j][i] = min(dp[j][i - 1], a[prv]);
			sum += dp[j][i];
		}
		ans = min(ans, sum + i * 1ll * x);
	}

	cout << ans;

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 15872
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	var s string
	fmt.Scan(&n, &a, &b, &s)

	count := 0
	countF := 0
	for i := 0; i < n; i++ {
		if s[i] == 'a' && count < a+b {
			fmt.Println("Yes")
			count++
		} else if s[i] == 'b' && count < a+b && countF < b {
			fmt.Println("Yes")
			count++
			countF++
		} else {
			fmt.Println("No")
		}
	}

}


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

int main(void) {
	string s,m,u;
	cin >> s;
	m = { s[0],s[1] };
	u = { s[2],s[3] };
	int mi = stoi(m), ui = stoi(u);
	if (1 <= mi && mi <= 12) {
		if (1 <= ui && ui <= 12) {
			cout << "AMBIGUOUS" << endl;
			return 0;
		}
		else {
			cout << "MMYY" << endl;
			return 0;
		}
	}
	else if (1 <= ui && ui <= 12) {
		cout << "YYMM" << endl;
		return 0;
	}
	else {
		cout << "NA" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int H[10000], W[10000];
  int i=0, j, k;
  int num;

  while(1)
    {
      scanf("%d %d", &H[i], &W[i]);
      if (H[i]==0 && W[i]==0)
	{
	  break;
	}
      i++;
    }

  num=i;
  for(i=0;i<num;i++)
    {
      for(j=1;j<=H[i];j++)
	{
	  for(k=1;k<=W[i];k++)
	    {
	      if (j==1 || j==H[i])
		{
		  printf("#");
		}
	      else
		{
		  if (k==1 || k==W[i])
		    {
		      printf("#");
		    }
		  else
		    {
		      printf(".");
		    }
		}
	    }
	  printf("\n");
	}
      printf("\n");
    }

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007

using namespace std;
				

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll ans = 0;
    for (int i = 0; i < 60; i++)
    {
        ll x = 0;
        for (int j = 0; j < N; j++)
        {
            if((A[j]>>i)&1) x++;
        }
        x = x*(N-x);
        for (int j = 0; j < i; j++)
        {
            x = x*2%MOD;
        }
        ans += x;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	string A;
	int tmp = -2;

	while (N != 0) {
		int prevN = N;
		A = (char)((N % 2 + 2) % 2 + '0') + A;
		N /= tmp;
		if ((prevN % 2) < 0) N++;
	}
	cout << A << endl;


    return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())
if s[0] != "1":
  print(s[0])
else:
  # print(list(set(s[0:k]))[0])
  # print(set(s[0:k]))
  # print(len(s[0:k]))
  if list(set(s[0:k]))[0] == "1" and len(set(s[0:k])) == 1:
    print(1)
  else:
    for s_s in s:
      if s_s != "1":
        print(s_s)
        break


Measured memory_bytes: 3060
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

#define FOR(t,x,v) for(t x=0, v_=(v);x < v_; x++)
#define FORR(t,x,v) for(t x=(v); x >= 0; x--)

int main() {
    int A, B; cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


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

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sl = s.Length;
            var s1 = s.Substring(0, sl / 2);
            var s2 = s.Substring(sl / 2 + 1, sl / 2);

            if (isKaibun(s) && isKaibun(s1) && isKaibun(s2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
        static bool isKaibun(string s)
        {
            var sl = s.Length;
            var ans = true;
            for (int i = 0; i < sl / 2; i++)
            {
                if (s[i] != s[sl - 1 - i])
                {
                    ans = false;
                }
            }
            return ans;
        }

    }
}

Measured memory_bytes: 11092
function Main(input) {
  input = input.split("\n");
  var N = input[0];
  var S = input[1].split("");
  var Nsum = N;
  var Mem = 0;
  for(var i = 0; i < N ;i++){
    if(S[i] == Mem){
      Nsum--;
    }
    Mem = S[i];
  }
  
console.log(Nsum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8396
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
ll solve(ll n,ll K) {
	if(K&1) return (n/K)*(n/K)*(n/K);
	return solve(n/2,K/2);
}
int main() {
	ll n,K;
	scanf("%lld%lld",&n,&K);
	ll n1=(1.0*n/K+0.5);
	ll tmp=solve(n,K);
	// printf("%lld %lld\n",n1/K,tmp);
	if((K&1)) printf("%lld\n",tmp);
	else printf("%lld\n",tmp+(n1)*(n1)*(n1));
}


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

int main(){
	int e;
	while(cin>>e and e>0){
		int ans=10000000;
		for(int i=0;i*i*i<=e;i++){
			for(int j=0;j*j<=e-i*i*i;j++){
				int m=i+j+e-(i*i*i+j*j);
				if(ans>m) ans=m;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3076
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define N 200000

int n, a[N], x[N];

int main(){
    int allXor=0; 
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        allXor = allXor^a[i];
    }

    for (int i = 0; i < n; i++){
        x[i] = allXor^a[i];
        printf("%d ",x[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3964
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a* b << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}
*/


void solve(){
  string S;
  cin >> S;
  rep(i, S.size()){
    cout << "x";
  }
  cout << endl;
}


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


Measured memory_bytes: 256
n, k, q = list(map(int, input().split()))
a = []

for i in range(q):
    a.append(int(input().strip()))

reps = [k - q] * n

for i in range(q):
    reps[a[i] - 1] += 1

for e in reps:
    if (0 < e):
        print("Yes")
    else:
        print("No")


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

int main(){
  int a,b,s;
  cin >> a >> b;
  if(b<10)s=a*10+b;
  else if(b<100)s=a*100+b;
  else s=a*1000+b;
  for(int i=1;i<350;i++){
    if(i*i==s){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N; cin>>N;
  int a[N]; CINA(a,N);
  ll money = 1000;
  ll stock = 0LL;
  for(int i=0;i<N;++i){
    if(i<N-1 && a[i]<a[i+1]){
      ll sp = money/a[i];
      stock += sp;
      money -= sp*a[i];
    }else{
      money += stock * a[i];
      stock = 0;
    }
  }
  cout << money << "\n";
}

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

long long n, k;

long long solve(long long x, long long y){
	 if(y >= x) return min(x, y - x);
	 else return solve(x % k, y);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	cout << solve(n, k) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN             10001

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
// vector<int>adj[100001];
// int vis[100001]={0};
// vector<int>v1;


void solve()
{
   int k,n;
   cin>>k>>n;
   int a[n];
   rep(i,0,n)
   cin>>a[i];
   int mx=0;
   rep(i,1,n)
   {
        if(a[i]-a[i-1]>mx)
            mx=a[i]-a[i-1];
   }
   int r=k-a[n-1];
   r+=a[0]-0;
   if(r>mx)
    mx=r;
cout<<k-mx;
}   
    


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
	int n,m,a[1001],b[1001],s[1001];
	pair<int,int> S[1001];
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		s[i]=0;
	}
	for(int j=1;j<=m;++j){
		cin>>b[j];
		int i=1;
		while(i<=n){
			if(a[i]<=b[j]){
				break;
			}
			++i;
		}
		++s[i];
	}
	for(int i=1;i<=n;++i){
		S[i]=pair<int,int> (s[i],i);
	}
	sort(S+1,S+n+1);
	cout<<S[n].second<<endl;
}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    char c;
    cin>>c;
    if(c=='A') cout<<'T'<<endl;
    if(c=='T') cout<<'A'<<endl;
    if(c=='C') cout<<'G'<<endl;
    if(c=='G') cout<<'C'<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define f(i,n)  for(i=0;i<n;i++)
#define em emplace_back
#define mp make_pair

int main() {
    float a,b,c,d;
    cin>>a>>b>>c>>d;
    int r2=ceil(c/b),r1=ceil(a/d);
    if(r1==r2)  cout<<"Yes";
    else if(r1>r2)  cout<<"Yes";
    else    cout<<"No";
	return 0;
}//1236895

Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	string S;
	cin >> S;
	int N = S.size();
	int ok = 1;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 0) {
			if (S[i-1] == 'L' || S[i-1] == 'U' || S[i-1] == 'D')continue;
			else ok = 0;
		}
		else {
			if (S[i-1] == 'R' || S[i-1] == 'U' || S[i-1] == 'D')continue;
			else ok = 0;
		}
	}
	if (ok)puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;


int main()
{
	int n;
    scanf("%d",&n);
    int flag[10001]={0};
    for(int x=1;x<100;x++)
    {
        for(int y=1;y<100;y++)
        {
            for(int z=1;z<100;z++)
            {
                int s=x*x+y*y+z*z+z*x+x*y+z*y;
                if(s<=10000)
                    flag[s]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    cout<<flag[i]<<endl;

	return 0;
}
    

Measured memory_bytes: 3660
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        int n,A[114514],ans = 0;
        memset(A,0,sizeof(A));
        scanf("%d",&n);
        int l,r;
        for(int i=0;i<n;i++){
            scanf("%d %d",&l,&r);
            for(int k=l-1;k<r;k++){
                A[k]++;
            }
        }
        for(int i=0;i<100000;i++) ans += A[i];
        printf("%d\n",ans);
    }

Measured memory_bytes: 640
from sys import stdin
from collections import Counter
c = Counter()
for _ in range(int(stdin.readline())):
    v = stdin.readline().strip()
    c[v] += 1
print(f'AC x {c["AC"]}')
print(f'WA x {c["WA"]}')
print(f'TLE x {c["TLE"]}')
print(f'RE x {c["RE"]}')

Measured memory_bytes: 9476
S = input()
dic_S = {}
flag  = True
for i in range(len(S)):
    if S[i] in dic_S:
        dic_S[S[i]] += 1
    else:
        dic_S[S[i]] = 1
dic_ans = {"N":"S", "W":"E", "S":"N", "E":"W"}
for k, v in dic_S.items():
    if v>=1:
        if dic_ans[k] not in dic_S:
            flag = False
            break
print("Yes") if flag else print("No")

Measured memory_bytes: 3188
// AtCoder ABC133: D - Rain Flows into Dams
// 2019.9.3 bal4u

#include <stdio.h>

typedef long long ll;

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(ll n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

ll  b[100005];

int main()
{
	int i, N; ll a, x;
	
	N = in();
	for (i = 1; i <= N; i++) {
		a = in();
		b[i] = (a << 1) - b[i-1];
	}
	x = b[N] >> 1, out(x);
	for (i = 1; i < N; i++) {
		pc(' ');
		if (i & 1) out(b[i]-x);
		else       out(b[i]+x);
	}
	pc('\n');
	return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> color(3);
    long long ans = 1;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        auto c = find(color.begin(), color.end(), A);
        if(c == color.end()) {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * count(color.begin(), color.end(), A)) % 1000000007;
        int d = distance(color.begin(), c);
        color.at(d) += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
dp = [[0] * 4001 for _ in range(4)]
for i in range(1001):
    dp[0][i] = 1
for i in range(1, 4):
    for j in range((i + 1) * 1000 + 1):
        dp[i][j] += sum(dp[i - 1][max(0, j - 1000): j + 1])

while 1:
    try:
        print dp[3][input()]
    except:
        break

Measured memory_bytes: 4460
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N=input()
    if N.lower()==N:
        print("a")
    else:
        print("A")
#%%submit!
resolve()


Measured memory_bytes: 61672
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  int n, q, t;
  string s;
  queue<pair<string, int> > l;
  
  cin >> n >> q;
  lp(n) {
    cin >> s >> t;
    l.push(make_pair(s, t));
  }
  t = 0;
  while(!l.empty()) {
    pair<string, int> tp = l.front();
    l.pop();
    if(tp.second <= q){
      t += tp.second;
      cout << tp.first << " " << t << endl;
    }
    else if(tp.second != 0){
      t += q;
      tp.second -= q;
      l.push(tp);
    }
  }
  return 0;
}



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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >A(N);
	vector < vector < pair < int, int >>>xy;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		vector < pair < int, int >>testimony;
		for (int j = 0; j < A[i]; j++) {
			int x, y;
			cin >> x >> y;
			testimony.push_back(make_pair(x, y));
		}
		xy.push_back(testimony);
	}

	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++) {
		bool isOK = true;
		int honest = 0;
		for (int i = 0; i < N; i++) {
			if (((bits >> i) & 1) == 0) {
				continue;
			}
			honest++;
			for (int j = 0; j < A[i]; j++) {
				if (((bits >> (xy[i][j].first - 1)) & 1) ^
				    xy[i][j].second) {
					isOK = false;
				}
			}
		}
		if (isOK) {
			ans = max(ans, honest);
		}
	}

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int h, w;
    int inf = pow(10, 9);
    cin >> h >> w;
    string temp[h];
    rep(i, h) { cin >> temp[i]; }

    int a[h][w];
    queue<pair<int, int>> que;

    int max_num = 0;
    rep(i, h) {
        rep(j, w) {
            if (temp[i][j] == '#') {
                a[i][j] = 0;
                que.push(make_pair(i, j));
            } else {
                a[i][j] = inf;
            }
        }
    }

    int move_0[4] = {1, 0, 0, -1};
    int move_1[4] = {0, -1, 1, 0};

    while (!que.empty()) {

        pair<int, int> pointer = que.front();
        que.pop();
        rep(l0, 4) {
            int y = pointer.first + move_0[l0];
            int x = pointer.second + move_1[l0];
            if (0 <= y && y < h && 0 <= x && x < w) {
                if (a[y][x] == inf) {
                    a[y][x] = a[pointer.first][pointer.second] + 1;
                    que.push(make_pair(y, x));
                    max_num = a[y][x];
                }
            }
        }
    }

    cout << max_num << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 13456
import math
a,b = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if a<2:
    p1=0
else:
    p1 = combinations_count(a, 2)

if b<2:
    p2=0
else:
    p2 = combinations_count(b, 2)


total = p1 + p2
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  bool findSet(int x,int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int>> f(n);
    vector<vector<int>> block(n);
    UnionFind uni(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        f[a].push_back(b);
        f[b].push_back(a);
        uni.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin >> a >> b;
        a--;b--;
        block[a].push_back(b);
        block[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        int sz = f[i].size(); // i番目の人の友人の数
        int ans = uni.size(i) - 1 - f[i].size();
        for(auto x:block[i]){
            if(uni.findSet(i,x))ans--;
        }
        cout << ans << " ";
    }
}

Measured memory_bytes: 12280
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

#include <bits/stdc++.h>
using namespace std;

class ANumberOfMultiples {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int l,r,d;
cin>>l>>r>>d;
int a,b;
if (l%d==0) a=l/d;
else a=l/d+1;
b=r/d;
cout<<b-a+1;
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    ANumberOfMultiples solver;
    solver.solve(in, out);
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++){
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

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

    for (int i = 0; i < n; i++){
        cin >> k;
        pre.push_back(k);
    }

    for (int i = 0; i < n; i++){
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}


Measured memory_bytes: 3156
def partition(a, p ,r)
  x = a[r][1]
  i = p-1
  (p...r).each do |j|
    if a[j][1] <= x
      i += 1
      a[i], a[j] = a[j], a[i]
    end
  end
  a[i+1], a[r] = a[r], a[i+1]
  return i+1
end

def quick_sort(a, p, r)
  if p < r
    q = partition(a, p, r)
    quick_sort(a, p, q-1)
    quick_sort(a, q+1, r)
  end
end

n = gets.to_i

a = Array.new(n){ Array.new(2) }

n.times do |i|
  a[i] = gets.split
  a[i][1] = a[i][1].to_i
end
arr = a.clone

quick_sort(a, 0, n-1)
i = 0
arr.sort_by! do |item|
  i += 1
  [item[1], i]
end
bool = true
(0...n).each do |i|
  if a[i][0] != arr[i][0] || a[i][1] != arr[i][1]
    bool = false
    break
  end 
end
puts "Stable" if bool
puts "Not stable" unless bool
a.each do |ele|
  puts ele.join(" ")
end

Measured memory_bytes: 42836
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n;
	cin >> n;
	vi num(n);
	REP(i, n)
		cin >> num[i];
	vi ans(n);
	if (n % 2 == 0) {
		REP(i, n) {
			if (i % 2 == 0) {
				ans[n / 2 + (i / 2)] = num[i];
			}
			else {
				ans[n / 2-1 - (i / 2)] = num[i];
			}

		}
	}
	else {
		REP(i, n) {
			if (i % 2 == 0) {
				ans[n / 2 - (i / 2)] = num[i];
			}
			else {
				ans[n / 2 + 1 + (i / 2)] = num[i];
			}

		}
	}
	REP(i, n) {
		cout << ans[i];
		if (i != n - 1)
			cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3712
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=3e5+10;
int ans[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	n=read();k=read();
	if(n==1){
		for(i=1;i<=(k+1)/2;i++)printf("1 ");
		puts("");
		return 0;
	}
	if(n%2==0){
		printf("%d",n/2);
		for(i=2;i<=k;i++)printf(" %d",n);
		puts("");
		return 0;
	}
	for(i=1;i<=k;i++)ans[i]=(n+1)/2;
	int tmp=k;
	tmp=k/2;
	while(tmp--){
		if(ans[k]>=0)ans[k]--;
		int pos=k;
		while(ans[pos]==0){
			if(tmp==0)
				break;
			else tmp--;
			for(i=pos;i<=k;i++)ans[i]=n;
			ans[pos-1]--;
			pos--;
		}
	}
	for(i=1;i<=k;i++){
		if(ans[i]==0)break;
		printf("%d ",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <limits>

using namespace std;

const int Inf = numeric_limits<int>::max();

struct edge {
    int from, to, cost;
};

int main(int argc, char** argv){
    int V, E, P;
    cin >> V >> E >> P;
    edge es[E];
    for (int i=0; i<E; i++){
        int A, B, C;
        cin >> A >> B >> C;
        es[i].from = A - 1;
        es[i].to   = B - 1;
        es[i].cost = P - C;
    }
    int d[V];
    for (int i=0; i<V; i++) d[i] = Inf;
    d[0] = 0;
    int tmp;
    for (int j=1; j<=2*(V-1); j++) {
        for (int i=0; i<E; i++){
            edge e = es[i];
            if (d[e.from] != Inf && d[e.to] > d[e.from] + e.cost)
                d[e.to] = d[e.from] + e.cost;
        }
        if (j == V-1) tmp = d[V-1];
    }

    if (tmp != d[V-1] || d[V-1] == Inf) cout << "-1\n";
    else cout << max(-d[V-1], 0) << "\n";

    return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    string str;
    cin >> str;
    int ans=0;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='A') {
            if(i+1<str.size() && str[i+1]=='B') {
                if(i+2<str.size() && str[i+2]=='C') {
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    ll X,Y;
    cin >> X >> Y;
    ll ans = 0;
    ll now = X;
    while (true)
    {
        if(now * 2 <= Y){
            now *= 2;
            ans++;
        }
        else{
            break;
        }
    }
    cout << ans+1 << endl;
}

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

int main()
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int inf=1000000007;
int max2(int a,int b){
  int ans=a;
  if(ans<b)ans=b;
  return ans;
}
bool compare(pair<int,int> a,pair<int,int> b){
  if(a.first==b.first)return a.second<b.second;
  else return a.first<b.first;
}
int dp[3050][3050];
int main(){
  int n,t;
  cin>>n>>t;
  vector<pair<int,int>> ab(n);
  vector<int> a(n+1);
  vector<int> b(n+1);
  rep(i,n){
    cin>>ab[i].first>>ab[i].second;
  }
  sort(ab.begin(),ab.end(),compare);
  rep(i,n){
    a[i+1]=ab[i].first;
    b[i+1]=ab[i].second;
    //    cout<<a[i+1]<<" "<<b[i+1]<<endl;
  }
  rep(i,n+5){
    rep(j,t+5){
      dp[i][j]=0;
    }
  }
  rep1(i,n){
    rep(j,t+1){
      if(j-a[i]>=0)
      dp[i][j]=max2(dp[i-1][j],dp[i-1][j-a[i]]+b[i]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  int max=0;
  int tmp;
  int add2=b[n];
  rep(i,n){
    if(add2<b[n-i])add2=b[n-i];
    if(max<dp[n-i-1][t-1]+add2){
      max=dp[n-i-1][t-1]+add2;
      tmp=i;
    }
  }
  int max3=max;
  int tmp_max=tmp;
  vector<int> list(n+1,0);
  for(int i=n;i>0;i--){
    if(dp[i][tmp]!=dp[i-1][tmp]){
      tmp-=a[i];
      list[i]++;
      //      cout<<i<<endl;
    }
  }
  int add=0;
  rep1(i,n){
    if(list[i]==0){
      if(b[i]>add)add=b[i];
    }
  }
  int ans=max2(dp[n][t],max+add);
  cout<<max3<<endl;
  return 0;
}


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

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

int main(){
int a,b,c;
cin >> a >> b >> c;

cout <<(a^b^c)<<endl;


return 0;
}

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

int count_digits(int x) {
    int count = 0;
    while (x) {
        count += x % 10;
        x /= 10;
    }
    return count;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int count = count_digits(i);
        if (count >= a && count <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;

public static class Program
{
    public static void Main(string[] args)
    {
        var input = long.Parse(Console.ReadLine());
        var x1 = 0L;
        var x2 = (long)Math.Pow(10,9);
        var x3 = 0L;
        var y1 = 0L;
        var y2 = 1L;
        var y3 = 0L;

        y3 = (input + x2 - 1) / x2;
        x3 = (y3 * x2) - input;

        Console.WriteLine(x1+" "+ y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
    }
}

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

int main() {
  int x, y, b;

  cin >> x >> y;

  for (int a = 0; a < x + 1; a++) {
    b = x - a;
    if (y == 2 * a + 4 * b) {
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3644
import sys
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
# A = [0]*N
# for i in range(N):
#     A[i] = int(input())
S = str(input())
ll = list("abcdefghijklmnopqrstuvwxyz")
for al in ll:
    if not (al in S):
        print(al)
        sys.exit()
print("None")

Measured memory_bytes: 3188
using System;

class P
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int n = int.Parse(Console.ReadLine());
        char moji = s[n - 1];
        for (int i = 0; i < N; i++)
        {
            Console.Write(moji == s[i] ? s[i] : '*');
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main()
{
  char a,b;
  cin >>a>>b;
  
  if(a=='H')
  {
    if(b=='H')
      cout << "H";
    else
      cout << "D";
  }
  else if (a=='D')
  {
    if(b=='D')
      cout << 'H';
    else
      cout << 'D';
      
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<ll> A(n); 
    map<int, int> mp;
    rep(i, n){
        cin >> A[i];
        mp[A[i]]++;
    }
    ll sum = 0;
    for(auto m: mp){
        ll tmp = m.second;
        sum += tmp * (tmp-1) / 2;
    }
    //クエリ
    rep(i, n){
        ll tmp = mp[A[i]];
        ll res = sum - tmp * (tmp-1) / 2 + (tmp-1)*(tmp-2) / 2;
        cout << res << ln;
    }
}

Measured memory_bytes: 10652
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String o = sc.next();
        String e = sc.next();
        sc.close();

        // 主処理
        char[] co = o.toCharArray();
        char[] ce = e.toCharArray();
        String result = "";
        for (int i = 0; i < co.length; i++) {
            result += co[i];
            if (i < ce.length) {
                result += ce[i];
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    ll n = s.size();
    ll l = 0, r = n-1;
    ll a = 0, b = n;
    while(l < r) {
        if(s[l] != s[l+1]) a = l + 1;
        if(s[r-1] != s[r]) b = r;
        l++, r--;
    }
    cout << min(n-a, b) << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n;
    string s;

    cin >> n >> s;
    int ans = 0;

    for(int head = 0;head < n-2;++head){
        if(s[head] == 'A' && s[head+1] == 'B' && s[head+2] == 'C'){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n,W;cin>>n>>W;
    vi w(n), v(n);
    rep(i,n){
        cin>>w[i]>>v[i];
    }
    vvi dp(W+1, vi(n));
    dp[w[0]][0] = v[0];

    int ans = 0;
    rep(i, 1, n){
        rep(j, 0, W+1){
            chmax(dp[j][i], dp[j][i-1]);
            if(j+w[i]<=W) chmax(dp[j+w[i]][i], dp[j][i-1]+v[i]);
        }
    }
    rep(j, W+1) chmax(ans, dp[j][n-1]);
    dump_2d(dp, W+1, n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82304
h, w = map(int, input().split())
arr = [list(input()) for i in range(h)]
 
arr = [x for x in arr if "#" in x]
arr = list(zip(*arr)) # transpose
arr = [x for x in arr if "#" in x]
arr = list(zip(*arr)) # transpose
for x in arr:
  print("".join(x))

Measured memory_bytes: 3188
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
def div_ceil(x, y): return (x + y - 1) // y
 
N, M = map(int, input().split())
*A, = map(int, input().split())
A = list(set([a // 2 for a in A]))
L = A[0]
for a in A[1:]:
    L *= a // gcd(L, a)
for a in A:
    if (L // a) % 2 == 0:
        ans = 0
        break
else:
    ans = div_ceil(M // L, 2)
print(ans)

Measured memory_bytes: 15060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
m = map(int,read().split())
AB = zip(m,m)
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
dist = [-1] * (N+1)
stack = [1]
dist[1] = 0
while stack:
    v = stack.pop()
    for w in graph[v]:
        if dist[w] == -1:
            dist[w] = dist[v] + 1
            stack.append(w)
 
ev = [i for i,x in enumerate(dist) if x % 2 == 0 and i > 0]
od = [i for i,x in enumerate(dist) if x % 2 == 1 and i > 0]
 
def make_perm(N, ev, od, x0, x1, x2, y0, y1, y2):
    assert len(ev) == x0 + x1 + x2
    assert len(od) == y0 + y1 + y2
    P = [0] * (N+1)
    for i in ev:
        if x0:
            P[i] = (x0 + y0) * 3
            x0 -= 1
            continue
        if x1:
            P[i] = (x1 + y1) * 3 - 2
            x1 -= 1
            continue
        if x2:
            P[i] = (x2 + y2) * 3 - 1
            x2 -= 1
            continue
    for i in od:
        if y0:
            P[i] = (x0 + y0) * 3
            y0 -= 1
            continue
        if y1:
            P[i] = (x1 + y1) * 3 - 2
            y1 -= 1
            continue
        if y2:
            P[i] = (x2 + y2) * 3 - 1
            y2 -= 1
            continue
    return P[1:]
 
def solve(N, ev, od):
    x0 = N // 3
    x1 = (N+2) // 3
    x2 = (N+1) // 3
    perm = [0] * (N+1)
    LE = len(ev)
    LO = len(od)
    if LE <= x0:
        return make_perm(N, ev, od, LE, 0, 0, x0-LE, x1, x2)
    if LO <= x0:
        return make_perm(N, ev, od, x0-LO, x1, x2, LO, 0, 0)
    if LE == x1:
        return make_perm(N, ev, od, 0, x1, 0, x0, 0, x2)
    if LO == x1:
        return make_perm(N, ev, od, x0, 0, x2, 0, x1, 0)
    # どちらも x1 よりたくさんある
    return make_perm(N, ev, od, LE-x1, x1, 0, LO-x2, 0, x2)
 
P = solve(N, ev, od)
print(' '.join(map(str, P)))

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

int main(int argc, const char * argv[]) {
    int N, A, B;
    
    cin >> N >> A >> B;
    
    int plan1 = N * A;
    int plan2 = B;
    int min_plan = 0;
    
    if (plan1 > plan2) {
        min_plan = plan2;
    } else {
        min_plan = plan1;
    }
    
    cout << min_plan << endl;
    
    return 0;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin>>s;
	for(i=0;i<4-1;i++){
		if(s[i]==s[i+1]){
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}
//.........

Measured memory_bytes: 256