akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    vector<bool> s(h*w);
    vector<vector<int>> g(h*w);
    for(int i = 0; i < h; i++){
        string temp;
        cin >> temp;
        for(int j = 0; j < w; j++){
            if(temp[j] == '.') s[i*w + j] = true;
            else s[i*w + j] = false;
            if(i != 0){
                if(s[i*w + j] == true && s[(i-1)*w + j] == true){
                    g[i*w + j].push_back((i-1)*w + j);
                    g[(i-1)*w + j].push_back(i*w + j);
                }
            }
            if(j != 0){
                if(s[i*w + j] == true && s[i*w + j-1] == true){
                    g[i*w + j].push_back(i*w + j-1);
                    g[i*w + j-1].push_back(i*w + j);
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h*w; i++){
        if(g[i].size() == 0) continue;
        // BFS
        queue<int> q;
        vector<int> depth(h*w, -1);
        q.push(i);
        depth[i] = 0;
        while(q.empty() != true){
            int v = q.front();
            q.pop();
            for(int x : g[v]){
                if(depth[x] == -1){
                    depth[x] = depth[v] + 1;
                    q.push(x);
                    ans = max(ans, depth[x]);
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <unordered_map>
#include <cmath>

using namespace std;

const int m = 1e9 + 7;

long long mpow(long long a, long long b) {
    long long ans = 1;
    while (b > 0) {
        if (b % 2 == 1) ans = ans * a % m;
        b >>= 1;
        a = a * a % m;
    }
    return ans;
}

void lcmf(const vector<int>& prime, unordered_map<int, int>& lcm, int x) {
    double root_x = sqrt(x);
    for (auto p: prime) {
        int e = 0;
        while ( x % p == 0 ) {
            x /= p;
            e++;
        }
        lcm[p] = max(lcm[p], e);
        if (x == 1) break;
        if (root_x < p) {
            lcm[x] = max(lcm[x], 1);
            break;
        }
    }
}

int main() {
    int n;
    vector<int> v;
    cin >> n;
    long long l = 1;
    vector<int> prime;
    unordered_map<int, int> lcm;
    int a;
    int p[1000001] = {0};
    for (int i = 2; i <= 1e6; i++) {
        if (p[i] == 1) continue;
        prime.push_back(i);
        lcm[i] = 0;
        for (int j = i*2; j <= 1e6; j += i) {
            p[j] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        cin >> a;
        v.push_back(a);
        lcmf(prime, lcm, a);
    }
    for (auto pair: lcm) {
        l = (l * mpow(pair.first, pair.second)) % m;
    }
    long long ans = 0;
    for (auto x: v) {
        ans = (ans + l * mpow(x, m-2)) % m;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7964
n,m=map(int,input().split())
side=[]
for i in range(m):
    a,b=map(int,input().split())
    side.append((a-1,b-1))

#Union-Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]


ans=0
for i in range(m):
    #初期化
    par = [-1]*n
    for j in range(m):
        if j==i:
            continue
        else:
            unite(side[j][0],side[j][1])
    if not same(side[i][0],side[i][1]):
        ans+=1
print(ans)

Measured memory_bytes: 9204
#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>;

void judge(int &i, unordered_map<char, char> &map, string &S1, string &S2, string &ans) {
    if (map.count(S1.at(i)) == 1 && map[S1.at(i)] != S2.at(i)) {
        ans = "No";
    } else map[S1.at(i)] = S2.at(i);
}

int main() {
    string S, T;
    cin >> S >> T;
    unordered_map<char, char> Smap, Tmap;
    string ans = "Yes";
    rep(i,S.size()) {
        judge(i, Smap, S, T, ans);
        judge(i, Tmap, T, S, ans);
    }
    cout << ans << endl;
}


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

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

i64 n;
int main() {
  cin >> n;
  for (i64 x = 1; x <= 50000; ++x) {
    if (x * 108 / 100 == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	string S;
	cin >> S;
	ll K;
	cin >> K;
	for (ll i = 0; i < K; i++) {
		if (S[i] == '1')continue;
		else if(S[i]!=1)
		cout << S[i] << endl;
      	return 0;
	}
  	cout<<1<<endl;
}










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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = min(A, K);
    K -= ans;

    if (K > 0)
    {
        auto m = min(K, B);
        K -= m;
    }

    if (K > 0)
        ans -= K;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x;

		if(a > b){
			x = a;
			a = b;
			b = x;
		}if(b > c){
			x = b;
			b = c;
			c = x;
		}if(a > b){
			x = a;
			a = b;
			b = x;
		}
		System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 26324
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

void solve(ll A, ll B) { cout << max({A + B, A - B, A * B}) << endl; }

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(A, B);
  return 0;
}


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

int main(){
	string s,t,z;
	int len,i,flag=0;
	cin>>s>>t;
	len=s.length();
	for(i=len-1;i>=0;i--){
		z=s.substr(i,len-i);
		z=z+s.substr(0,i);
		if(z==t){
			flag=1;
			break;
		}
	}
	if(flag){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
	system("pause");
}

Measured memory_bytes: 256
from sys import stdin
rr = lambda: stdin.readline().strip()

N = int(rr())
A = map(int, rr().split())
MOD = 10**9 + 7
ct, ans = 0, 1
for x in A:
    ct += 1
    while ct > (x + 1)/2:
        ans *= ct
        ans %= MOD
        ct -= 1
for k in xrange(1, ct+1):
    ans *= k
    ans %= MOD
print ans


Measured memory_bytes: 42476
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
const int maxn = 300005;
const int inf = 1000000007;

int a[3][3];

bool solve(int x){
    a[0][2]=x;
    int sum=x+a[0][0]+a[0][1];
    a[2][1]=sum-a[0][1]-a[1][1];
    a[2][2]=sum-a[0][0]-a[1][1];
    a[2][0]=sum-a[2][1]-a[2][2];
    a[1][0]=sum-a[0][0]-a[2][0];
    a[1][2]=sum-a[0][2]-a[2][2];
    for(int i=0;i<3;i++){
        int tmp=0;
        for(int j=0;j<3;j++)tmp+=a[i][j];
        if(tmp!=sum)return false;
    }
    for(int i=0;i<3;i++){
        int tmp=0;
        for(int j=0;j<3;j++)tmp+=a[j][i];
        if(tmp!=sum)return false;
    }
    int tmp=0;
    for(int i=0;i<3;i++)tmp+=a[i][i];
    if(tmp!=sum)return false;
    tmp=0;
    for(int i=0;i<3;i++)tmp+=a[i][2-i];
    if(tmp!=sum)return false;
    return true;
}

int main() {
 //   freopen("in.cpp","r",stdin);
    cin>>a[0][0]>>a[0][1]>>a[1][1];
    for(int i=-1000;i<=1000;i++)
    if(solve(i)){
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
            cout<<a[i][j];
            if(j<2)cout<<" ";
            }
            cout<<endl;
        }
        break;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
ary = [int(input()) for _ in range(N)]


def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

        while j >= 0 and ary[j] > v:
            ary[j + g] = ary[j]
            j -= g
            cnt += 1

        ary[j + g] = v

    return cnt


def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary]


shell_sort(ary)



Measured memory_bytes: 53204
#include <bits/stdc++.h>
// #define rep(i,n) for(int i=0;i<n;i++)
// #define all(x) (x).begin(),(x).end()
using namespace std;
// const int INF=1145141919,MOD=1e9+7;
// const long long LINF=8931145141919364364,LMOD=998244353;
// inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

struct Combination{
    const int MAX=2010;
    const int MOD;
    vector<vector<int>> COM;
    vector<vector<int>> PER;
    Combination(const int MOD):
        MOD(MOD)
        {
            COM=vector<vector<int>>(MAX,vector<int>(MAX));
            PER=vector<vector<int>>(MAX,vector<int>(MAX));
            COM[0][0]=PER[0][0]=1;
            for(int i=1;i<MAX;i++){
                COM[i][0]=PER[i][0]=1;
                for(int j=1;j<MAX;j++){
                    COM[i][j]=(COM[i-1][j-1]+COM[i-1][j])%MOD;
                    PER[i][j]=PER[i][j-1]*(i-j+1)%MOD;
                }
            }
        }
    int C(int n,int r){
        assert(0<=n&&n<MAX&&0<=r&&r<MAX);
        return COM[n][r];
    }
    int P(int n,int r){
        assert(0<=n&&n<MAX&&0<=r&&r<MAX);
        return PER[n][r];
    }
    int H(int n,int r){
        assert(0<=n+r-1&&n+r-1<MAX&&0<=r&&r<MAX);
        return COM[n+r-1][r];
    }
};

int main(){
    const int MOD=100000007;
    Combination com(MOD);
    int r,c,a1,a2,b1,b2; cin>>r>>c>>a1>>a2>>b1>>b2;
    int h1=abs(a1-b1),h2=r-abs(a1-b1);
    int h=min(h1,h2);
    int w1=abs(a2-b2),w2=c-abs(a2-b2);
    int w=min(w1,w2);
    int ans=com.C(h+w,h);
    if(h1==h2) ans=ans*2%MOD;
    if(w1==w2) ans=ans*2%MOD;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 34400
let readCharArray _ = stdin.ReadLine().ToCharArray()

let rec solve next (a, b, c) =
    match next with
    | 'a' ->
        if a |> Array.length |> (=) 0 then
            "A"
        else
            let n = a |> Array.head
            solve n (a |> Array.tail, b, c)
    | 'b' ->
        if b |> Array.length |> (=) 0 then
            "B"
        else
            let n = b |> Array.head
            solve n (a, b |> Array.tail, c)
    | _ ->
        if c |> Array.length |> (=) 0 then
            "C"
        else
            let n = c |> Array.head
            solve n (a, b, c |> Array.tail)

(readCharArray (), readCharArray (), readCharArray ())
|> solve 'a'
|> printfn "%s"


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

#undef false
#undef true

using namespace std;

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

/* [💭] [💡] [🎈] */

int deg[100001], comp[100001], cnt[100001], res[100001];

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

    int n, m, k;
    cin >> n >> m >> k;

    vector<vector<int>> graph(n + 1);
    while (m--) {
        int u, v;
        cin >> u >> v;
        graph[u].emplace_back(v);
        graph[v].emplace_back(u);
        deg[u]++, deg[v]++;
    }

    int id = 1;
    for (int i = 1; i <= n; i++) {
        if (comp[i]) continue;
        queue<int> q;
        q.emplace(i);
        comp[i] = id;
        cnt[id]++;
        while (q.size()) {
            int u = q.front();
            q.pop();
            for (int v : graph[u]) {
                if (comp[v]) continue;
                comp[v] = id;
                cnt[id]++;
                q.emplace(v);
            }
        }
        id++;
    }

    for (int i = 1; i <= n; i++) {
        res[i] = cnt[comp[i]] - deg[i];
    }

    while (k--) {
        int u, v;
        cin >> u >> v;

        if (comp[u] == comp[v]) {
            res[u]--;
            res[v]--;
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << res[i] - 1 << ' ';
    }

    return 0;
}


Measured memory_bytes: 8312
a,b,c,d,e,f=map(int,input().split())

if a>b:
    a, b = b, a

ans1 = a*100
ans2 = 0
    
flag = True

for _a in range(f//(a*100) + 1):
    for _b in range((f - _a*100)//(b*100) + 1):
        for _c in range((f - _a*100 - _b*100)//c + 1):
            for _d in range((f - _a*100 - _b*100 - _c * c)//d + 1):
                if a*100*_a+b*100*_b+c*_c+d*_d == 0:
                    continue                
                if a*100*_a+b*100*_b+c*_c+d*_d > f:
                    continue  
                    
                if (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) == e/(100+e):
                    print(a*100*_a+b*100*_b+c*_c+d*_d, c*_c+d*_d)
                    flag = False
                    break
                elif (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) > e/(100+e):
                    continue
                else:
                    if ans2/ans1 < (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d):
                        ans1 = a*100*_a+b*100*_b+c*_c+d*_d
                        ans2 = c*_c+d*_d
            if flag:
                continue
            else:
                break
        if flag:
            continue
        else:
            break
    if flag:
        continue
    else:
        break

else:
    print(ans1, ans2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b>=c){
        puts("No");
        return 0;
    }
    long long x=2*a*b,y=a*a+b*b+c*c-2*c*a-2*c*b;
    if(x<y)puts("Yes");
    else puts("No");
    return 0;
}

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

int lyuka(int i) {
  int64_t L;
  if (i==0) L=2;
  else if (i==1) L=1;
  else L = lyuka(i-1) + lyuka(i-2);
  return L;
}

int main() {
  int N;
  cin >> N;
  
  long long L[87];
  L[0] = 2LL;
  L[1] = 1LL;
  for(int i=2; i<=N; i++) L[i]=L[i-2]+L[i-1];
  cout << L[N] << endl;

  return 0;
}


Measured memory_bytes: 3480
#include <cstdio>

int main(void)
{
    int n;
    int ice[10];
    
    int tmp;
    while (scanf("%d", &n)){
        for (int i = 0; i < 10; i++){
            ice[i] = 0;
        }
        if (n == 0) break;
        for (int i = 0; i < n; i++){
            scanf("%d", &tmp);
            ice[tmp]++;
        }
        
        for (int i = 0; i < 10; i++){
            if (0 < ice[i]){
                while (ice[i] != 0){
                    printf("*");
                    ice[i]--;
                }
            }
            else {
                printf("-");
            }
            printf("\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int cnt[2][100005];
int a[100005];
int ma[2][2],val[2][2];
int n;
void pro(int lab,int pos)
{
	int nv=cnt[lab][pos];
	if(nv>ma[lab][0])
	{
		ma[lab][1]=ma[lab][0];
		val[lab][1]=val[lab][0];
		ma[lab][0]=nv;
		val[lab][0]=pos;
	}
	else
		if(nv>ma[lab][1])
		{
			ma[lab][1]=nv;
			val[lab][1]=pos;
		}
}
int main()
{
	int i;
	memset(cnt,0,sizeof(cnt));
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),cnt[i&1][a[i]]++;
	memset(ma,0,sizeof(ma)),memset(val,0,sizeof(val));
	for(i=1;i<=100000;i++)
		pro(0,i),pro(1,i);
	int mi=n;
	for(int i1=0;i1<=1;i1++)for(int j1=0;j1<=1;j1++)
	{
		int v1=val[0][i1],v2=val[1][j1],ans=0;
		if(v1==v2)continue;
		for(i=1;i<=n;i++)
		{
			if(i%2==0)if(a[i]!=v1)ans++;
			if(i%2==1)if(a[i]!=v2)ans++;
		}
		mi=min(mi,ans);
	}
	printf("%d\n",mi);
	return 0;
}


Measured memory_bytes: 1408
lis_NKQ = list(map(int, input().split()))

lis_A = []
lis_K = [lis_NKQ[1] for i in range(lis_NKQ[0])]
lis_K = list(map(lambda x: x - lis_NKQ[2],lis_K))

for i in range(lis_NKQ[2]):
    inp = int(input())
    lis_A.append(inp)
    lis_K[inp - 1] += 1  

for i in lis_K:
    if i > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11804
k=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

from collections import deque

q=deque([1,2,3,4,5,6,7,8,9])
ansl=[]
s=1
while len(str(s))<=10:
    s=q.popleft()
    ansl.append(s)
    sl=list(str(s))
    last_digit=int(sl[-1])
    for digit in range(max(0,last_digit-1),min(last_digit+1,9)+1):
        newval=int(str(s)+str(digit))
        #ansl.append(int(str(s)+str(digit)))
        q.append(newval)
print(ansl[k-1])

Measured memory_bytes: 26484
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) {
            continue;
        } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
      if(a.at(i)==0){
          cout << 0 << endl;
          return 0;
      }
  }
  int128_t ans = 1;
  for(int i=0;i<n;i++){
      ans *= a.at(i);
      if(ans > 1000000000000000000 || ans < 0){
          cout << -1 << endl;
          return 0;
      }
  }
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int f(int n)
{
	return (n * (n - 1)) / 2;
}

int32_t main()
{
	c_p_c();
	int n, m; cin >> n >> m;

	int ans = f(n) + f(m);

	cout << ans << '\n';
	return 0;
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
 
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}


void tle(){
	int n, ans=0;
	string s;
	cin >> n >> s;
	if(n<3) {
		cout << 0 << en;
		return ;
	}
	for(int i=0; i<n-2; i++){
		for(int j=i+1; j<n-1; j++) {
			if(s[i] == s[j]) continue;
			for(int k=j+1; k<n; k++){
				if(s[i]==s[k]) continue;
				if(s[j]==s[k]) continue;
				if(j-i == k-j) continue;
				ans++;
			}
		}
	}
	cout << ans << en;
}

void solve(){
	ll n, r=0,g=0,b=0;
	string s;
	cin >> n >> s;
	for(int i=0; i<s.size();i++){
		if(s[i]=='R') r++;
		if(s[i]=='G') g++;
		if(s[i]=='B') b++;
	}
	ll ans = r*g*b;
	fork(i,n) fork(h,n){
		int j = i+h, k=j+h;
		if(k>=n) break;
		if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k])ans--;
	}
	cout << ans << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
    int t = 1;
    while(t--)
        solve();
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a=0,w=0,t=0,r=0;
  for(int i=0;i<n;i++){
    string x;
    cin>>x;
    if(x=="AC"){
      a++;
    }
    else if(x=="WA"){
      w++;
    }
    else if(x=="TLE"){
      t++;
    }
    else{
      r++;
    }
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;

}

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

typedef vector<pair<int, int>> vii;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
//bool isValid(int i, int j){
//
//}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
//	freopen("sort.in", "r", stdin);
//	freopen("sort.txt", "w", stdout);
	int MOD = (1e9) + 7;
	int h, w;
	cin >> h>> w;
	vector<string> grid(h);
	int ways[h][w];
	ways[0][0]=1;
	for (int i = 0; i < h; i++)
		cin >> grid[i];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if(i !=0 || j!=0)
				ways[i][j] =0;
			if (grid[i][j] == '.') {
				if (i > 0)
					ways[i][j] += ways[i - 1][j];
				if (j > 0)
					ways[i][j] += ways[i][j - 1];
				ways[i][j] %= MOD;
			}
		}
	cout<<ways[h-1][w-1];
	return 0;
}



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


int main(){
    ll n, sum = 0LL, tmp = 0LL;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        if(i&1 && 0 < i && i < n-1){
            tmp += a[i];
        }
    }
    ll x[n];
    x[0] = sum - 2*tmp;
    cout << x[0] << " ";
    for(int i = 1; i < n; i++){
        x[i] = 2*a[i-1] - x[i-1];
        cout << x[i] << " ";
    }
    cout << "\n";
}



Measured memory_bytes: 2816
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()
cnt = 0
cur = -k
num = 1
for i in range(n):
    if t[i] > cur + k or num == c:
        cur = t[i]
        cnt += 1
        num = 1
    else:
        num += 1
print(cnt)

Measured memory_bytes: 7384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int inf = (int)1e17+9;
int dp[102][100002];
int32_t main(){


	FASTIO;
	int n,w,s=0;
	cin >> n >> w;
	vector<int>wt(n),val(n);
	REP(i,0,n){
		cin >> wt[i] >> val[i]; 
		s += val[i];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=s;j++)
			dp[i][j] = inf;
	}
	for(int i = 0;i<=n;i++)
		dp[i][0] = 0;
	for(int i=1;i<=n;i++){
		for(int j = 0;j<=s;j++){
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j >= val[i-1]){
				dp[i][j] = min(dp[i][j],dp[i-1][j-val[i-1]]+wt[i-1]);
			}
		}
	}
	int ans = -1;
	for(int j = 1;j<=s;j++){
		if(dp[n][j] <= w){
			ans = max(ans,j);
		}
	}
	cout << ans << endl;
    return 0;

}

Measured memory_bytes: 79232
n, k = map(int, input().split())
s = str(input())
Sb = []
zero = 0
for i in range(n):
  if int(s[i]):
    if len(Sb) == 0 or Sb[-1][0] == 0:
      Sb.append([1, 1])
    else:
      Sb[-1][1] += 1
  else:
    if len(Sb) == 0 or Sb[-1][0]:
      Sb.append([0, 1])
      zero += 1
    else:
      Sb[-1][1] += 1
if zero <= k:
  print(n)
else:
  if Sb[0][0] != 1:
    Sb.insert(0, [1, 0])
  if Sb[-1][0] != 1:
    Sb.append([1, 0])
  ans = sum([Sb[i][1] for i in range(2 * k + 1)])
  tmp = ans
  for i in range(zero - k):
    tmp += Sb[2 * k + 2 * (i+1)][1] + Sb[2 * k + 2 * (i+1) - 1][1] - Sb[2 * i][1] - Sb[2 * i + 1][1]
    ans = max(ans, tmp)
  print(ans)

Measured memory_bytes: 54508
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (n == i * j) {
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");

        sc.close();
    }

}


Measured memory_bytes: 23764
/**
*    created: 25.07.2020 21:06:37
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8]={0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8]={1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep2(i,k,n) {
        if (a[i]-a[i-k] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)

masu = []
char = ""
for i, s in enumerate(S):
    if char == "":
        char += s
        continue
    if char[-1] == s:
        char += s
        continue
    if char[-1] != s:
        masu.append(len(char))
        char = s
        continue
if char:
    masu.append(len(char))

import math

ans = []
for l, r in zip(*[iter(masu)]*2):
    n = len(ans)
    pos_l = n + l
    pos_r = pos_l + 1
    l_num = math.ceil(l / 2) + r // 2
    r_num = l // 2 + math.ceil(r / 2)
    for _ in range(l-1):
        ans.append(0)
    ans.append(l_num)
    ans.append(r_num)
    for _ in range(r-1):
        ans.append(0)

print(*ans)

Measured memory_bytes: 7836
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  for (ll &x : p) cin >> x;
  for (ll &x : q) cin >> x;
  for (ll &x : r) cin >> x;
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());
  priority_queue<ll> pq;
  for (int i = 0; i < x; ++i) {
    pq.emplace(-p[i]);
  }
  for (int i = 0; i < y; ++i) {
    pq.emplace(-q[i]);
  }
  for (ll t : r) {
    if (t > -pq.top()) {
      pq.pop();
      pq.emplace(-t);
    } else {
      break;
    }
  }
  ll tot = 0;
  while (pq.size()) {
    tot -= pq.top();
    pq.pop();
  }
  cout << tot;
}


Measured memory_bytes: 4852
#include <stdio.h>

int main(void)
{
	int field[25][25];
	int i, j;
	int n, x, y, a, b;
	
	while (1){
		scanf("%d %d", &x, &y);
		
		if (x == 0 && y == 0) break;
		
		
		for (i = 0; i < 20; i++)
			for (j = 0; j < 20; j++) field[i][j] = 0;
		
		
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			field[b][a] = -1;
		}
		
		if (field[1][1] == -1) field[1][1] = 0;
		
		else field[1][1] = 1;
		
		for (i = 1; i < y + 1; i++){
			for (j = 1; j < x + 1; j++){
				
				if (i == 1 && j == 1) continue;
				
				else if (field[i][j] == -1){
					field[i][j] = 0;
					continue;
				}
				
				field[i][j] = field[i][j - 1] + field[i - 1][j];
			}
		}
		printf("%d\n", field[y][x]);
	}
	return (0);
}
			

Measured memory_bytes: 600
l = map(int, input().split())
l = list(l)
l.sort()

ans = 0
while l[2] > l[1]:
    ans += 1
    l[1] += 1
    l[0] += 1

while l[1] > l[0]:
    ans += 1
    l[0] += 2

if l[0] > l[1]:
    ans += 1

print(ans)


Measured memory_bytes: 9184
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
ll n, r;
int main() {
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100 * (10 - n) << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
const int MAXN = 123456;
const LL INF = (LL)1e9;
vector<pil> G[MAXN];
LL s1[MAXN], s2[MAXN], tmpx[MAXN];
bool visit[MAXN];
LL cur_x = -1;

bool dfs(int cur, int par) {
     visit[cur] = 1;
     bool OK = true;
     for (auto i : G[cur]) {
         int to = i.first;
         if (to != par) {
            if (visit[to]) {
               LL tmp_cs = s2[to] - (i.second - s2[cur]);
               LL tmp_coe = (s1[cur] * -1) - s1[to];
               if (tmp_coe == 0) {
                  if (tmp_cs != 0) {
                     printf("0\n");
                     exit(0);
                  }
               } else {
                  cur_x = tmp_cs / tmp_coe;
                  OK = false;
               }
            } else {
               s1[to] = s1[cur] * -1;
               s2[to] = i.second - s2[cur];
               if (!dfs(to, cur)) OK = false;
            }
         }
     }
     return OK;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        G[x].push_back(make_pair(y, (LL)c));
        G[y].push_back(make_pair(x, (LL)c));
    }
    s1[1] = 1;
    if (!dfs(1, 1)) {
       for (int i = 1; i <= n; i++) tmpx[i] = s1[i] * cur_x + s2[i];
       bool ans = (cur_x > 0 ? true : false);
       for (int i = 1; i <= n; i++) {
           if (tmpx[i] <= 0) ans = false;
           for (auto j : G[i]) {
               int to = j.first;
               if (tmpx[to] + tmpx[i] != j.second) ans = false;
           }
       }
       puts(ans ? "1" : "0");
    } else {
       LL up = INF, low = 1;
       for (int i = 1; i <= n; i++) {
           if (s1[i] < 0) up = min(up, s2[i] - 1);
           else low = max(low, -1 * s2[i] + 1);
       }
       if (low > up) printf("0\n");
       else printf("%lld\n", up - low + 1);
    }
    return 0;
}


Measured memory_bytes: 18048
#include<iostream>
int main(){
  int n,i,*A;
  std::cin >> n;
  A = new int [n];
  for(i=n-1; i>=0; i--) std::cin >> A[i];
  for(i=0; i<n; i++) std::cout << A[i] << (n - 1 == i ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b; cin >> a>>b;
	int ans = 0;
  	int count = 1;
  	while(1){
      if (count >= b) break;
      count+=a-1;
      ans++;
    }
  	cout << ans <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int n;

bool isbig(mp pa,mp pb){
	int da = pa.fir*pa.fir+pa.sec*pa.sec;
	int db = pb.fir*pb.fir+pb.sec*pb.sec;
	if(da!=db)return (da>db);
	return (pa.fir>pb.fir);	
}

int main(void){
	for(;;){
		int w,h;
		scanf("%d%d",&h,&w);
		if(h==0)break;
		mp cp(h,w);
		mp pa(1000,1000);
		reg(y,1,150){
			reg(x,y+1,150){
				mp np(y,x);
				if(!isbig(np,cp))continue;
				if(isbig(pa,np))pa=np;
			}
		}
		printf("%d %d\n",pa.fir,pa.sec);
	}
	return 0;
}

Measured memory_bytes: 1028
# スペース区切りの整数の入力
N, K = map(float, input().split())
ans = 0.0

import math #mathだとatcoderでは怒られる

for i in range(int(N)):
  #print(i+1)
  
  if i+1 <= K:
    #print("coin")
    coin_flip_number = (math.ceil(math.log(K/(i+1), 2)))
    ans = ans + (1/N)*(1/(2**coin_flip_number))
    #print((1/N)*(1/(2**coin_flip_number)))
  else:
    #print("No coin")
    ans = ans + (1/N)
    #print(1/N)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 200
int V;
struct edge{int to, cost;};
vector<edge> G[MAX_V];

void add_edge(int from, int to, int cost){
    G[from].push_back(edge({to, cost}));
}

void add_edge2(int v1, int v2, int cost){
    G[v1].push_back(edge({v2, cost}));
    G[v2].push_back(edge({v1, cost}));
}

int d2[MAX_V][MAX_V];
void waeshall_floyd(){
    REP(i, V){
        REP(j, V){
            if(i == j){
                d2[i][j] = 0;
            }else{
                d2[i][j] = INF;
            }
        }
    }
    REP(v, V){
        REP(i, G[v].size()){
            edge e = G[v][i];
            d2[v][e.to] = e.cost;
        }
    }
    REP(k, V){
        REP(i, V){
            REP(j, V){
                d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
            }
        }
    }
}

bool is_used[8];

void calcdist(vector<int> &s, vector< vector<int> > &t, int i, int R, int &ans){
    if(i == R){
        int tmp = 0;
        REP(i, R - 1) tmp += t[s[i]][s[i + 1]];
        ans = min(ans, tmp);
    }else{
        for(s[i] = 0; s[i] < R; s[i]++){
            if(!is_used[s[i]]){
                is_used[s[i]] = true;
                calcdist(s, t, i + 1, R, ans);
                is_used[s[i]] = false;
            }
        }
    }
}

signed main(){

    fill(is_used, is_used + 8, false);

    int N, M, R;
    cin >> N >> M >> R;
    V = N;
    vector<int> r(R);
    readindex(r);
    int A, B, C;
    REP(i, M){
        cin >> A >> B >> C;
        add_edge2(A - 1, B - 1, C);
    }

    waeshall_floyd();

    vector< vector<int> > t(R, vector<int>(R));
    REP(i, R){
        REP(j, R){
            t[i][j] = d2[r[i]][r[j]];
        }
    }

    int ans = INF;

    vector<int> s(R);
    calcdist(s, t, 0, R, ans);

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1408
# include <iostream>
# include <deque>
# include <math.h>
# include <algorithm>
using namespace std;

int N;
int H;
int a[100005];
int b[100005];
deque< pair<int, char> > katanas;
long long counter=0;
long long throws=0;

bool sortkatanas(pair <int, char> a, pair <int, char> b)
{
    if (a.first>b.first)
    {
        return true;
    }

    return false;
}

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

    for (int i=1; i<=N; i++)
    {
        cin>>a[i]>>b[i];
    }

    for (int i=1; i<=N; i++)
    {
        katanas.push_back(make_pair(a[i], 'a'));
        katanas.push_back(make_pair(b[i], 'b'));
    }

    sort(katanas.begin(), katanas.end(), sortkatanas);

    for (int i=0; i<katanas.size(); i++)
    {
        if (katanas[i].second=='b')
        {
            counter=counter+katanas[i].first;
            throws=throws+1;
            if (counter>=H)
            {
                break;
            }
        }

        if (katanas[i].second=='a')
        {
            throws=throws+ceil((double)(H-counter)/katanas[i].first);
            break;
        }
    }

    cout<<throws<<endl;
}

Measured memory_bytes: 6088
#include <stdio.h>
int main(void)
{
    int n, r;
    scanf("%d %d", &n, &r);
    if (10 <= n)
    {
        printf("%d\n", r);
    }
    else
    {
        printf("%d\n", r + (100 * (10 - n)));
    }
}

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

using namespace std;

bool cmp(const pair<int, int> &a1, const pair<int, int> &a2){
    return (a1.second > a2.second);
}

int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w, m;
    cin >> h >> w >> m;
    unordered_map<int, int> dict1, dict2;
    map<pair<int, int>, bool> dict3;
    for(int i=0; i<m; i++){
        cin >> h >> w;
        dict1[h] += 1;
        dict2[w] += 1;
        dict3[{h, w}] = true;
    }
    vector<pair<int, int>> vec1, vec2;
    for(auto it = dict1.begin(); it!=dict1.end(); it++){
        vec1.push_back({it->first, it->second});
    }
    
    for(auto it = dict2.begin(); it!=dict2.end(); it++){
        vec2.push_back({it->first, it->second});
    }
    sort(vec1.begin(), vec1.end(), cmp);
    sort(vec2.begin(), vec2.end(), cmp);
    // cout << 100 << '\n';
    // return 0;
    int ans = vec1[0].second + vec2[0].second;
    //int combis = vec1[0].second * vec2[0].second;
    unordered_map<int, bool> dict11, dict22;
    
    for(int i=0; i<vec1.size(); i++){
        if(vec1[i].second == vec1[0].second){
            dict11[vec1[i].first] = true;
        }
        else{
            break;
        }
    }
    for(int i=0; i<vec2.size(); i++){
        if(vec2[i].second == vec2[0].second){
            dict22[vec2[i].first] = true;
        }
        else{
            break;
        }
    }
    int combis = dict11.size() * dict22.size();
    //cout << "combis : " << combis << '\n';
    //bool found = false;
    //map<pair<int, int>, bool> dict4;
    for(auto it=dict3.begin(); it!=dict3.end(); it++){
        int hh = (it->first).first;
        int ww = (it->first).second;
        if(dict11[hh] && dict22[ww]){
            combis --;
        }
        else{
            continue;
        }    
    }
    //cout << "after combis : " << combis << '\n';
    if(combis==0)
        cout << ans - 1 << '\n';
    else
        cout << ans << '\n';
    
    return 0;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    int place=n;
    int rog=0,check=0;
    int ans[n];
    rep(i,n)ans[i]=0;
    string s;
    cin>>s;
    while(place>0){
        for(int j=max(0,place-m);j<place;j++){
            if(s[j]=='0'){
                ans[rog]=place-j;
                place=j;
                rog++;
                //cout<<place<<rog;
                break;
            }
        }
        if(rog==check){
            cout<<-1;
            break;
        }
        check++;
    }
    if(place==0){
        for(int k=rog-1;k>=0;k--){
            cout<<ans[k]<<' ';
        }
    }
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>

using namespace std;


int main(){
    int n; cin >> n;
    int max = 0;
    int l = 0;
    int total = 0;
    for (int i = 0; i < n; i++){
        cin >> l;
        if (max < l){
            max = l;
        }
        total += l;
    }

    cout << (total > max*2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;
    if(N == K - 1){
        cout << 1 << endl;
        return 0;
    }
    long long ans = 0;
    long long mod = 1e9 + 7;
    long long x = 0;
    long long y = 0;
    x = N * (N + 1) / 2;
    y = x;
    for(long long i = N + 1, j = 0, p = N; i >= K; i--, j++, p--){
        long long t = y - x + 1;
        ans = (ans % mod + t % mod) % mod;
        y -= j;
        x -= p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] a = new int[N];
		int min = 101;
		int max = -101;
		int sum = 1000000000;
		int tmp = 0;
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			if(min > a[i]) {
				min = a[i];
			}
			if(max < a[i]) {
				max = a[i];
			}
		}
		
		for(int i = min; i <= max; i++) {
			for(int j = 0; j < N; j++) {
				tmp += (int)Math.pow(a[j] - i, 2);
			}
			if(tmp < sum) {
				sum = tmp;
			}
			tmp = 0;
		}
		
		System.out.println(sum);
		
		scan.close();
	}

}


Measured memory_bytes: 23508
#include <cstdio>
 
/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)
 
(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]
 
 
[z^N] (N f(z) - z * f'(z))/(1-z)
[z^N] (f(z)(N - z * f'(z)/f(z)))/(1-z)
 
f'(z)/f(z) = 1/(1-z) + 2(2z/(1-z^2) + 3z^2/(1-z^3) + ...
 
log f = \sum_{i=2}^{N/2}
 
f(z) = (1-z)(1-z^{N/2+1})^2(1-z^{N/2+2})^2... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1})(1-2z^{N/2+2})... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1}-2z^{N/2+2}-...) / [(1-z)(1-z^2)...]^2
f(z) = (1-z-2z^{N/2+1}) / [(1-z)(1-z^2)...]^2

[z^N] (Nz^N + (N-1)z^{N-1} + .. z + 0) f(z)
[z^{N-1}] (Nz^{N-1} + (N-1)z^{N-2} + .. 2z + 1) f(z)
[z^{N-1}] 1/(1-z)^2 f(z)
 
f(z) = 1/[(1-z)(1-z^2)(1-z^3)...(1-z^{N/2})]^2
f(z) = (1-2z^{N/2+1} - ... )/[(1-z)(1-z^2)...]^2
f(z) = (1-z-2z^{N/2+1})/{(1-z)[(1-z)(1-z^2)...]^2}
*/

 
int n, m;
 
int dp[5000];

int main(){
  scanf("%d%d", &n, &m);

  for(int i = 0; i <= n/2; i++) dp[i] = 1;
  for(int i = (n+1)/2+1, j = 0; i < n; i++, j++) dp[i] = m - (1+2*j);
  
  for(int t = 0; t < 2; t++){ 
    for(int i = 0; i < n; i++){
      long long int tmp = dp[i];
      for(int j = 1; ; j++){
        int k = j * (3 * j - 1) / 2;
        if(k > i) break;
        if(j&1){
          tmp += dp[i - k];
        }
        else {
          tmp -= dp[i - k];
        }
        k += j;
        if(k > i) break;
        if(j&1){
          tmp += dp[i - k];
        }
        else {
          tmp -= dp[i - k];
        }
      }
      dp[i] = tmp % m;
    }
  }

  if(n & 1){
    if(dp[n-1] < 0) dp[n-1] += m;
    if(dp[n-1-(n+1)/2-1] < 0) dp[n-1-(n+1)/2-1] += m;
    dp[n-1] -= dp[n-1-(n+1)/2-1];
    if(dp[n-1] < 0) dp[n-1] += m;
  }

  if(dp[n-1] < 0) dp[n-1] += m;
 
  printf("%d\n", (int) dp[n-1]);
 
 
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int x,y;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) {break;
  }
    else if(x>y)printf("%d %d\n",y,x);
    else printf("%d %d\n",x,y);
  }
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin >> S;
    
    string res;
    if (S <= "2019/04/30") {
        res = "Heisei";
    } else {
        res = "TBD";
    }
    
    cout << res << endl;
    
    return 0;

}



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

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

struct UFweight
{
    int i;
    vector<int> par;
    vector<int> size;
    vector<int> rank;
    vector<ll> diff_weight;
    UFweight(int n, ll sum_unity = 0){
        par.resize(n);  rank.resize(n); size.resize(n); diff_weight.resize(n);
        for(i = 0;i < n;++i){
            par.at(i) = i;
            rank.at(i) = 0;
            size.at(i) = 1;
            diff_weight.at(i) = sum_unity;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            int r = root(par.at(x));
            diff_weight.at(x) += diff_weight.at(par.at(x));
            return par.at(x) = r;
        }
    }
    
    ll weight(int x){
        root(x);
        return diff_weight.at(x);
    }
    
    ll get_diff(int x, int y){
        return weight(y) - weight(x);
    }
    
    // weight(y) - weight(x) = wとなるようにmerge
    bool merge(int x, int y, ll w){
        w += weight(x); w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            ll weight_diff = get_diff(rx, ry);
            if(weight_diff == w) return true;
            else return false;
        }
        
        if(rank.at(rx) < rank.at(ry)){
            swap(rx,ry);
            w *= -1;
        }
        if(rank.at(rx) == rank.at(ry)) ++rank.at(rx);
        par.at(ry) = rx;
        diff_weight.at(ry) = w;
        size.at(rx) += size.at(ry);
        
        return true;
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    UFweight ufw(n);
    for(i = 0;i < m;++i){
        ll l,r,d;
        cin >> l >> r >> d;
        --l;    --r;
        bool flag = ufw.merge(l,r,d);
        if(!flag){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

    return 0;
}

Measured memory_bytes: 5096
def modpow(a, n, m)
  return 1 if n == 0

  tmp = modpow(a, n / 2, m)
  n % 2 == 0 ? tmp * tmp % m : tmp * tmp * a % m
end

def modinv(a, m)
  modpow(a, m - 2, m)
end

s = gets.chomp.to_i
M = (1e9+7).to_i

fa = (1..s).inject([1]) { |acc, i| acc << acc[-1] * i % M; acc }
fi = fa.map { |f| modinv(f, M) }

puts (1..(s / 3)).inject(0) { |acc, i| (acc + fa[s - 1 - 2 * i] * fi[i - 1] * fi[s - 3 * i]) % M }

Measured memory_bytes: 14368