akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b + c == 17)
	{
		if (a + b == 10)
		{
			if (a == 5)
				printf("YES\n");
			else printf("NO\n");
		}
		else if (a + b == 12)
		{
			if (a == 5 || a == 7)
				printf("YES\n");
			else printf("NO\n");
		}
		else printf("NO\n");
	}
	else printf("NO\n");
	
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
int INF = (1e9) *2+1;
double EPS=1.0e-9;
double PI=atan2(0,-1);


int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    vector<int> t(n);
    REP(i,n)
        cin>>t[i];
    sort(ALL(t));
    int cnt=0;
    REP(i,n)
        if(!(a<=t[i]&&t[i]<b))
            cnt++;
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll a; cin >> a;
    ll b; cin >> b;
    ll m; cin >> m;
    vector <ll> as;
    REP(i, a){
        ll aa; cin >> aa;
        as.push_back(aa);
    }
    vector <ll> bs;
    REP(i, b){
        ll bb; cin >> bb;
        bs.push_back(bb);
    }
    vector <ll> aas = as;
    vector <ll> bbs = bs;
    sort(aas.begin(), aas.end());
    sort(bbs.begin(), bbs.end());
    ll ans = aas[0] + bbs[0];
    REP(i, m){
        ll x; cin >> x; x--;
        ll y; cin >> y; y--;
        ll c; cin >> c;
        ll val = as[x] + bs[y] - c;
        if (val < ans){
            ans = val;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	a := ""
	for i := 0; i < len(s); i++ {
		if s[i] != 'B' {
			a += string(s[i])
		} else if len(a) > 0 {
			a = a[:len(a)-1]
		}
	}
	fmt.Println(string(a))
}


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

int main()
{
    int n;
    cin>>n;
    int dist[n+10];
    for(int i=0; i<n+10; i++) dist[i] = 10000000;
    deque<int> dq;
    dq.push_front(1);
    dist[1] = 1;
    while(!dq.empty()){
        int u = dq.front();
        dq.pop_front();
        if(u==0) break;
        int v = (u+1)%n;
        if(dist[v]>dist[u]+1 && u!= v){
            dist[v] = dist[u] + 1;
            dq.push_back(v);
        }
        v = (u*10)%n;
        if(dist[v]>dist[u] && u!= v){
            dist[v] = dist[u];
            dq.push_front(v);
        }
    }
    cout<<dist[0]<<endl;
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
int main(){
char a;
int b=0;
while(b==0){
scanf("%c",&a);
if(a=='\n'){
break;
}
else{
if('A'<=a && a<='Z'){
a=a+32;
printf("%c",a);
}
else if('a'<=a && a<='z'){
a=a-32;
printf("%c",a);
}
else{
printf("%c",a);
}
}
}
printf("\n");
return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  string res = "NO";
  if (b - a == c - b) {
    res = "YES";
  }
  cout << res << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

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

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    int N, cnt = 0;
    cin >> N;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                Yes;
                return 0;
            }
        }
    }
    No;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

int compare( int a, int tai){

  return a < tai ? a : tai;
}


void enqueue(P x){
  
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;

}

P dequeue(){
  
  P y = Q[head];
  head = ( head + 1) % LEN;
  return y;
  

}


int main(){
  int elaps = 0, c;
  int i, q;
  P z;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n + 1;

  while( head != tail){

    z = dequeue();
    c = compare( q, z.t);
    z.t -= c;
    elaps += c;
    if ( z.t > 0 ) enqueue(z);
    else{
      printf("%s %d\n",z.name,elaps);
    }
  }
  return 0;
}



Measured memory_bytes: 12012
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

bool comp(P a, P b) {
	return a.second < b.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n, a, b;
	cin >> n >> a >> b;

	if (a > b) {
		out(0);
		return 0;
	}
	if (n == 1) {
		if (a != b) {
			out(0);
		}
		else {
			out(1);
		}
		return 0;
	}

	out((n - 2) * (b - a) + 1);

	return 0;
}

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

#define MAX 100000
#define INFTY 100000000
#define WHITE 0
#define BLACK -1

typedef struct{
  int k;
  int *weight;
  int *num;
}LIST;

int n;
LIST M[MAX];

void difkstra()
{
  int i, u, v, minv, temp;
  int d[n], color[n];

  for( i=0; i<n; i++ )
    {
      d[i] = INFTY;
      color[i] = WHITE;
    }

  d[0] = 0;                  /*スタート地点を０に設定する*/              
  while(1)
    {
      minv = INFTY;          
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )   
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( minv == INFTY ) break;  /*全てのノードの色が黒になっていたら*/
      color[u] = BLACK;
      for( v=0; v<M[u].k; v++ )
	{
	  temp = M[u].num[v];    /*uが繋っているノードの番号をtempに代入*/
	  
	  if( color[temp] != BLACK )
	    {
	      if( d[temp] > d[u] + M[u].weight[v] )
		{
		  d[temp] = d[u] + M[u].weight[v];
		}
	    }
	}
    }

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

}


int main()
{
  int i, j, u, k, v, c,unp;
  
  scanf("%d", &n);
  
  for( i=0; i<n; i++ )
    {
      scanf("%d%d", &unp, &M[i].k);
      M[unp].weight = (int *)malloc( M[i].k * sizeof(int));
      M[unp].num = (int *)malloc( M[i].k * sizeof(int));

      for( j=0; j<M[i].k; j++ )
	{
	  scanf("%d%d", &M[unp].num[j], &M[unp].weight[j]);
	}
    }

  difkstra();

  for( i=0; i<n; i++ )
    {
      free( M[i].weight );
      free( M[i].num );
    }

  return 0;
}
      



Measured memory_bytes: 5424
n,k = map(int, input().split())
mod = 10 ** 9 + 7
dp = [0] * (k+1)
ans = 0
for i in range(k,0,-1):
  mini_ans = pow(k//i,n,mod)
  for j in range(i,k+1,i):
    mini_ans -= dp[j]
  dp[i] = mini_ans
  ans += mini_ans * i
print(ans%mod)
    

Measured memory_bytes: 69096
from collections import  deque
def is_bin_graph(edges,st):
    """
    :param edges: 辺のdictionary,0-indexedを想定
    :param st: start
    :return:is_bin:二部グラフかどうか
    """
    que = deque()
    v = [0 for i in range(len(edges))]
    que.append([st,0])
    v[st] = 1
    is_bin = True
    while True:
        if len(que) > 0:
            top = que.popleft()
            col = v[top[0]]
            cos = top[1]
            for nex in edges[top[0]]:
                if v[nex] == 0:
                    v[nex] = -col
                    que.append([nex,cos+1])
                else:
                    if v[nex] == col:
                        is_bin = False
                    else:
                        continue
        else:
            break
        if not is_bin:
            break

    return  is_bin

def dfs(edges,st):
    que = deque()
    v = [0 for i in range(len(edges))]
    que.append([st,0])
    v[st] = 1
    max_cos = 0
    while True:
        if len(que) > 0:
            top = que.popleft()
            cos = top[1]
            for nex in edges[top[0]]:
                if v[nex] == 0:
                    v[nex] = 1
                    que.append([nex,cos+1])
                    if cos +1 > max_cos:
                        max_cos = cos+1
        else:
            break

    return max_cos

n = int(input())
edges = {}
for i in range(n):
    edges[i] = []
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == "1":
            edges[i].append(j)
            edges[j].append(i)

if is_bin_graph(edges,0):
    tp = 0
    for i in range(n):
        cos = dfs(edges,i)
        if tp < cos:
            tp = cos
    print(tp+1)
else:
    print(-1)



Measured memory_bytes: 42932
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()

    for a in A:
        if a % 2 == 0:
            if a % 3 != 0 and a % 5 != 0:
                print("DENIED")
                sys.exit()

    print("APPROVED")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
character(10) :: s
logical :: flg
integer :: n, ans, i,j,k

read *,s
n = len_trim(s)

ans = 0
do i = 1,n
   do j = i,n
      flg = .true.
      do k = i, j
         if (.not. isAGTC(s(k:k))) then
            flg = .false.
            exit
         endif
      enddo
      if (flg) then
         if (ans < j-i+1) then
            ans = j-i+1
         endif
      endif
   enddo
enddo

print '(i0)',ans
stop

contains
logical function isAGTC (c)
   character(1) :: c
   isAGTC = .false.
   if (c == 'A' .or. c == 'G' .or. c == 'T' .or. c == 'C') isAGTC = .true.
   return
end function isAGTC

end

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=3e2+10;
long long a[N][N],b[N][N],n,m,l;
int main(){
	for(int i=0;i<N;i++) for(int j=0;j<N;j++) a[i][j]=b[i][j]=1e17;
	cin>>n>>m>>l;
	for(int i=0;i<m;i++){
		int x,y;
		long long z;
		cin>>x>>y>>z;
		a[x][y]=min(a[x][y],z);
		a[y][x]=min(a[y][x],z);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				a[j][k]=min(a[j][i]+a[i][k],a[j][k]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j) continue;
			if(a[i][j]<=l) b[i][j]=1LL;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				b[j][k]=min(b[j][k],b[j][i]+b[i][k]);
			}
		}
	}
	int q;
	cin>>q;
	while(q--){
		int x,y;
		cin>>x>>y;
		if(b[x][y]==1e17) cout<<-1<<"\n";
		else cout<<b[x][y]-1<<'\n';
	}
	return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(){
  int x,a,b,c;
  scanf("%d",&x);
  a=x/100;
  c=x%10;
  b=(x-a*100-c)/10;
  if(a==7||b==7||c==7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}

Measured memory_bytes: 1656
#include <stdio.h>
void insertionSort(int a[],int n);

int main(void) {
	int a[1000],n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	insertionSort(a,n);
	
	return 0;
}

void insertionSort(int a[],int n){
	int v,i,j,k;
	for(i=1;i<n;i++){
	    for(k=0;k<n;k++){
			printf("%d",a[k]);
			if(k==n-1) printf("\n");
			else printf(" ");
		}
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
	}
	for(k=0;k<n;k++){
	    printf("%d",a[k]);
		if(k==n-1) printf("\n");
		else printf(" ");
	}
	return ;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main() {
    int p;
    bool first=1;
    while(scanf("%d",&p),p) {
        if(!first) printf("\n");
        first=0;
        int sum=0;
        int cnt[4];
        for(int i=0;i<4;i++) {scanf("%d",&cnt[i]);sum+=cnt[i];}
        int ans[4],best=114514;
        for(int i=0;i<=cnt[0];i++) {
            for(int j=0;j<=cnt[1];j++) {
                for(int k=0;k<=cnt[2];k++) {
                    for(int l=0;l<=cnt[3];l++) {
                        int tot=i*10+j*50+k*100+l*500;
                        if(tot<p) continue;
                        int tmp=sum-i-j-k-l;
                        int change=tot-p;
                        tmp+=change/500;change%=500;
                        tmp+=change/100;change%=100;
                        tmp+=change/50;change%=50;
                        tmp+=change/10;
                        if(best>tmp) {
                            best=tmp;
                            ans[0]=i,ans[1]=j,ans[2]=k,ans[3]=l;
                        }
                    }
                }
            }
        }
        if(ans[0]>0) printf("10 %d\n",ans[0]);
        if(ans[1]>0) printf("50 %d\n",ans[1]);
        if(ans[2]>0) printf("100 %d\n",ans[2]);
        if(ans[3]>0) printf("500 %d\n",ans[3]);
    }
}

Measured memory_bytes: 3152
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC044-A.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 N PIC 9(5).
       77 K PIC 9(5).
       77 X PIC 9(5).
       77 Y PIC 9(5).
       77 ANS PIC 9(9).
       77 ANSS PIC Z(9).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT N FROM SYSIN.
               ACCEPT K FROM SYSIN.
               ACCEPT X FROM SYSIN.
               ACCEPT Y FROM SYSIN.
               IF K < N THEN
                   COMPUTE ANS = K * X + (N - K) * Y
               ELSE
                   COMPUTE ANS = N * X
               END-IF.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM ABC044-A.


Measured memory_bytes: 636
# include <stdio.h>
int main ()
{
  int n,a;
  while (scanf ("%d",&n)==1&&n)
       {
    	int sum=0; 
    	while (n--)
    	    {
    	     scanf ("%d",&a);
			 sum+=a-1;	
			}
	  printf ("%d\n",sum);
	  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
    cin>>n;
    vi v(n);
    for(i=0;i<n;i++)cin>>v[i];
    vi dp(n,0);
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(v[i-2]-v[i]),dp[i-1]+abs(v[i-1]-v[i]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int K,N,i;
    int forw[1000000];
    int sa[1000000];
    scanf("%d",&K);
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&forw[i]);
    }
    int max,temp;
    max=K-(forw[N-1]-forw[0]);
    for(i=0;i<N-1;i++){
        temp=forw[i+1]-forw[i];
        if(temp>max){
            max=temp;
        }
    }
    temp=K-max;
    printf("%d",temp);
    
    return 0;

}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

const ll N = 2e5+7;
const ll INF = 1e9+7;
ll n, ahihi, ahuhu, ans, pos1, pos2, f[N], a[N];
vector<ll> arr;
ll cnp(ll l, ll r){
	ll tb = (f[r]-f[l-1])/2;
	ll k = l-1;
	for(ll i = n/2; i >= 1; i/=2){
		while(k + i < r && f[k+i] - f[l-1] < tb) k+=i;
	}
	return k;
}
ll add[] = {1, 0};
signed main(){
	scanf("%lld", &n);
	f[0] = 0;
	f(i,1,n){
		scanf("%lld", &a[i]);
		f[i] = f[i-1] + a[i];
	}
	ans = INF;
	f(i,2,n-2){
		ahihi = cnp(1, i);
		ahuhu = cnp(i+1, n);
		ff(j,0,2){
			ff(k,0,2){
				pos1 = ahihi + add[j];
				pos2 = ahuhu + add[k];
				if(pos1 == i || pos2 == n) continue;
				arr.push_back(f[pos1]-f[0]);
				arr.push_back(f[i]-f[pos1]);
				arr.push_back(f[pos2]-f[i]);
				arr.push_back(f[n]-f[pos2]);
				sort(arr.begin(), arr.end());
				ans = min(ans, arr.back() - arr[0]);
				arr.clear();
			}
		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

  LL r = 0, g = 0, b = 0;
  for (int i = 0; i < n; i ++) {
    if (s[i] == 'R') r ++;
    else if (s[i] == 'G') g ++;
    else if (s[i] == 'B') b ++;
  }

  LL cnt = 0;
  for (int i = 0; i < n; i ++) {
    for (int j = i + 1; j < n; j ++) {
      int k = j + (j - i);
      if (k >= n) continue;
      if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) cnt ++;
    }
  }

  cout << r * g * b - cnt << endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	map<char, bool> m;
	int size = s.size();
	for (int i = 0; i < size; i++)
		m[s[i]] = true;
	for (int i = 0; i < 26; i++)
		if (!m['a' + i])
		{
			cout << (char)('a' + i) << endl;
			return 0;
		}
	cout << "None" << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

double p, q, a, n;
const double base = 100;

int dfs(int k, int n, int start, double sum){
	int res = 0;
	if(n != 0){
		range(i,start,a){
			if(k * i > a) break;
			if(p * i - q < sum * i * q) continue;

			res += dfs(k * i, n - 1, i, sum + base / i);
		}
	}

	if(abs(p / q - sum) < 1e-10) res++;
	return res;
}

int main(){
	while(cin >> p >> q >> a >> n, n) {
		p *= base;
		cout << dfs(1, n, 1, 0) << endl;
	}
}

Measured memory_bytes: 3164
#!/usr/bin/env python3
import sys


def solve(S: str):
    if len(S)%2==1:
        S = S[:-1]
    else:
        S = S[:-2]

    while len(S):
        N = len(S) // 2
        if S[:N]==S[N:]:
            break
        S = S[:-2]

    print(len(S))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

//update 2019/12/29

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = nextInt();  int Q = nextInt();
    String[] S = splitString(next()); //N == S.length()

    //List<Integer> where = new ArrayList<Integer>();

    for(int i=0;i<N-1;i++){
      if(S[i].equals("A") && S[i+1].equals("C")){
        S[i+1] = "c";
      }
    }

    int[] num = new int[N+1];

    for(int i=1;i<=N;i++){
      num[i] += num[i-1]; //今までのを追加
      if(S[i-1].equals("c")){
        num[i] += 1; //i文字目にcがあるので、新たに1追加
        //System.out.println("i="+i);
      }

    }

    //num[i] i文字目までにあるACの数

    for(int i=0;i<Q;i++){
      int l = nextInt();
      int r = nextInt();
      // s[l]-s[r]
      int ans = num[r]-num[l];
      System.out.println(ans);
    }
/*
    for(int i=1;i<N+1;i++){
      System.out.println("num["+i+"]="+num[i]);
    }
*/
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 56660
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <cstdlib>
using namespace std;
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	a = a[0] - 32;
	b = b[0] - 32;
	c = c[0] - 32;

	cout << a<< b<< c<< endl;
	return 0;
}

Measured memory_bytes: 256
from math import gcd

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime=get_sieve_of_eratosthenes_new(32000)

def euler_phi(n):
    res=n
    for x in prime:
        if n%x==0:
            res=(res//x)*(x-1)
            while n%x==0:
                n//=x
    if n!=1:
        res=(res//n)*(n-1)
    return res


def biggcd(n,m):
    g=gcd(n,m)
    res=g
    count=2
    while True:
        test=gcd(g**count,m)
        if test>res:
            res=test
            count+=1
        else:
            break
    return res


def solve(a,m,n):
    #print(a,m,n)
    if gcd(a,m)==1:
        if m==1:
            return 1
        phi=euler_phi(m)
        G=gcd(phi,m)
        r0=solve(a,G,n)
        mod=m*phi//G
        return ((((pow(a,n*r0,mod)-n*r0)%mod)//G)*pow(n*phi//G,phi-1,m)*phi+r0)%mod
    else:
        big=biggcd(a,m)
        k0=solve(a,m//big,n*big)
        return big*k0

for i in range(int(input())):
    A,M=map(int,input().split())
    print(solve(A,M,1))
    #ans=solve(A,M,1)
    #print(pow(A,ans,M)%M==ans%M)

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

int main() {
    int R[3000][2];
    int cnt = 0;

    REP(i, 10000) {
        cin >> R[i][0] >> R[i][1];
        if (R[i][0] == 0 && R[i][1] == 0) break;
        cnt += 1;
    }

    REP(i, cnt) {
        sort(R[i], R[i] + 2);
        cout << R[i][0] << " " << R[i][1] << endl;
        
    }
    
    return 0;

}


Measured memory_bytes: 3032
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
struct node {
    int x,y,id;
    node(int _x = 0,int _y = 0,int c = 0):x(_x),y(_y),id(c) {};
} f[maxn],g[maxn * 2];

bool cmp1(const node &a,const node &b) {
    return a.x < b.x;
}

bool cmp2(const node &a,const node &b) {
    return a.y < b.y;
}

bool cmp3(const node &a,const node &b) {
    return a.id < b.id;
}

int p[maxn];

int ff(int x){
    if(p[x] != x) p[x] = ff(p[x]);
    return p[x];
}

LL build(int n,int m) {
    int i,u,v;
    LL s = 0;
    for(i = 1;i <= n; i++) p[i] = i;
    sort(g,g + m,cmp3);
    for(i = 0;i < m; i++){
        u = ff(g[i].x);
        v = ff(g[i].y);
        if(u != v){
            s += g[i].id;
            p[u] = v;
        }
    }
    return s;
}

int main() {
    int n,i,m;
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
        scanf("%d%d",&f[i].x,&f[i].y);
        f[i].id = i + 1;
    }
    m = 0;
    sort(f,f + n,cmp1);
    for(i = 1; i < n; i++) g[m++] = node(f[i].id,f[i - 1].id,f[i].x - f[i - 1].x);
    sort(f,f + n,cmp2);
    for(i = 1; i < n; i++) g[m++] = node(f[i].id,f[i - 1].id,f[i].y - f[i - 1].y);
    printf("%lld\n",build(n,m));
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define pll pair<ll, ll>
#define mp(x, y) make_pair(x, y)
using namespace std;

const ll N = 3e5 + 5, inf = 1e18, mod = 1e9 + 7;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

inline ll getPow(ll a,ll b) {
    ll res = 1ll, tp = a;
    while (b){
       if (b&1ll) {
           res *= tp;
       }
       tp *= tp;
       //tp %= mod; res %= mod;
       b >>= 1ll;
    }
    return res;
}

ll vec_mult(const pll & t1, const pll & t2, const pll & t3) {
   const ll & x1 = t1.first, y1 = t1.second;
   const ll & x2 = t2.first, y2 = t2.second;
   const ll & x3 = t3.first, y3 = t3.second;
   return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
}

vector<ll> fact(ll n) {
    n = abs(n);
    ll t = 0;
    vector<ll> ans;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans.push_back(i);
            if (i != n / i) ans.push_back(n / i);
        }
    }
    return ans;
}

void ok() {
   cout << "YES" << endl;
   exit(0);
}

void no() {
   cout << "NO" << endl;
   exit(0);
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll n = nxt();
    vector<ll> mas(n);
    for (int i = 0; i < n; i++) {
        mas[i] = nxt();
    }
    vector<ll> buf = fact(mas[0]);
    for (auto x : fact(mas[1])) {
        buf.push_back(x);
    }
    sort(all(buf));
    ll ans = 1;
    for (auto x : buf) {
        ll ct = 0;
        for (auto y : mas) {
            if (y % x) ct++;
        }
        if (ct <= 1) ans = x;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		int N = Integer.parseInt(in.readLine());
		int count = 0;
		if (N <= 9) {
			count = N;
		} else if (N <= 99) {
			count = 9;
		} else if (N <= 999) {
			count = 9 + (N - 99);
		} else if (N <= 9999) {
			count = 9 + (999 - 99);
		} else if (N <= 99999) {
			count = 9 + (999 - 99) + (N - 9999);
		} else {
			count = 9 + (999 - 99) + (99999 - 9999);
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;

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

		if (s.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (s.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 25044
object Main extends App {

  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n != 0){
      println(Array.tabulate(n){_ ⇒
        val Array(p, h, w) = readLine.trim.split(' ').map(_.toInt)
        Person(p, h, w)
      }.sortWith{
        case (a, b) if math.abs(22 - a.bmi) != math.abs(22 - b.bmi) ⇒ math.abs(22 - a.bmi) < math.abs(22 - b.bmi)
        case (a, b) ⇒ a.id < b.id
      }.head.id
      )
      solve
    }
  }
  case class Person(id: Int, height: Double, weight:Double) {
    def bmi: Double = weight / height / height * 10000
  }
  implicit class ScopeFunc[T](val value:T){
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 48372
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    int[] xs, ys;
    foreach (_; 0..N) {
        auto rc = readln.split.to!(int[]);
        xs ~= rc[1];
        ys ~= rc[0];
    }
    xs.length = 8;
    ys.length = 8;

    bool solve(int p, int n) {
        if (n == 8) return true;
        if (p == 64) return false;

        auto x = p%8;
        auto y = p/8;
        foreach (i; 0..n) {
            if (x == xs[i] || y == ys[i] || x+ys[i] == y+xs[i] || x+y == xs[i]+ys[i]) goto ng;
        }
        xs[n] = x;
        ys[n] = y;
        if (solve(p+1, n+1)) return true;
        ng:
        return solve(p+1, n);
    }

    solve(0, N);
    auto res = new char[][](8, 8);
    foreach (ref r; res) r[] = '.';
    foreach (i; 0..8) res[ys[i]][xs[i]] = 'Q';
    foreach (r; res) writeln(r);
}


Measured memory_bytes: 2500
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
using namespace std;
void solve(){
    int h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    char a[h+1][w+1];
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++) cin>>a[i][j];
    }
    vector <pair <int,int> > g[h*w+1];
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            if (a[i][j]=='#') continue;
            for (int k=-2; k<=2; k++){
                for (int l=-2; l<=2; l++){
                    if (abs(k)+abs(l)>0&&i+k>0&&i+k<=h&&j+l>0&&j+l<=w&&a[i+k][j+l]=='.'){
                        int boo=1;
                        if (abs(k)+abs(l)==1) boo=0;
                        g[w*(i-1)+j].pb(mp(w*(i-1+k)+(j+l),boo));
                    }
                }
            }
        }
    }
    int dist[h*w+1];
    for (int i=1; i<=h*w; i++) dist[i]=1e9;
    dist[w*(ch-1)+cw]=0;
    priority_queue <pair <int,int>,vector <pair <int,int> >,greater<pair <int,int> > > pq;
    for (int i=1; i<=h*w; i++) pq.push(mp(dist[i],i));
    int prev[h*w+1];
    bool visited[h*w+1];
    for (int i=1; i<=h*w; i++) visited[i]=0;
    while (!pq.empty()&&!visited[w*(dh-1)+dw]){
        int t1=pq.top().first,t2=pq.top().second;
        pq.pop();
        if (!visited[t2]){
            for (int i=0; i<g[t2].size(); i++){
                int t3=g[t2][i].first,t4=g[t2][i].second;
                if (!visited[t3]&&dist[t2]!=1e9&&dist[t2]+t4<dist[t3]){
                    dist[t3]=dist[t2]+t4;
                    prev[t3]=t2;
                    pq.push(mp(dist[t3],t3));
                }
            }
        }
        visited[t2]=1;
    }
    if (dist[w*(dh-1)+dw]==1e9) cout<<-1;
    else cout<<dist[w*(dh-1)+dw];
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Measured memory_bytes: 191812
#include <iostream>
using namespace std;
int main()
{
	int A,B;
	cin>>A>>B;
	if(A==B)
    {
		cout<<"Draw";
	}
	else if(A==1)
	{
		cout<<"Alice";
	}
	else if(B==1)
	{
		cout<<"Bob";
	}
	else if(A>B)
	{
		cout<<"Alice";		
	}
	else if(B>A)
	{
		cout<<"Bob";
	}	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,k,q;cin>>n>>k>>q;
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
  }
  ll ans = LINF;
  rep(i,n){
    ll minA = A[i];
    ll ok = 1e12+3;
    ll ng = minA - 1;
    while(ok - ng >= 2){
      ll mid = (ok + ng) / 2;
      ll sum = 0;
      ll count = 0, count_min = 0;
      rep(j,n){
        if(A[j] >= minA){
          count++;
          if(A[j] <= mid){
            count_min++;
          }
        }else{
          sum += max(0ll, min(count - k + 1, count_min));
          count = 0;
          count_min = 0;
        }
      }
      sum += max(0ll, min(count - k + 1, count_min));
      if(sum >= q){
        ok = mid;
      }else{
        ng = mid;
      }
    }
    if(ok - minA == 28592228){
      cout<<minA << " " << ok<<endl;
    }
    chmin(ans, ok - minA);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
    ll ans = 1;
    while (n) 
    {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}

void solve() 
{
    int n,r; cin >> n >> r;
    if (n >= 10)
    {
        cout << r << endl;
        return;
    }    
    cout << r + 100 * (10 - n) << endl;
}

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

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

const int64_t mod = 1000000007;

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

  int64_t n;
  cin >> n;
  map<int64_t, int64_t> prime;
  for(int64_t num = 2; num <= n; num++) {
    int64_t N = num;
    for(int64_t i = 2; i * i <= N; i++) {
      while(N % i == 0) {
        N /= i;
        prime[i]++;
      }
    }
    if(N != 1) prime[N]++;
  }

  int64_t res = 1;
  for(auto p : prime) {
    res *= (p.se+1);
    res %= mod;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

constexpr int MAX = 300000;

int main()
{
    int N,a,b;
    vector<int> v(MAX, 0);
    cin >> N;
    while (N--) {
        scanf("%d %d", &a, &b);
        v[a + b]++;
    }
    
    for (int i = 0; i < (int)v.size(); i++) {
        if (v[i] > 1) {
            v[i + 1] += v[i] / 2;
            v[i] = v[i] & 1;
        }
        if (v[i] == 1) {
            printf("%d %d\n", i, 0);
        }
    }
    return 0;
}

Measured memory_bytes: 3708
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
string s,t;
int sa[100001];
int ta[100001];
int main(){
    
    cin >> s;
    cin >> t;
  
    for(int i=0;i<s.size();i++) sa[i+1] = sa[i] + ((s[i]=='A') ? 1 : 2);
    for(int i=0;i<t.size();i++) ta[i+1] = ta[i] + ((t[i]=='A') ? 1 : 2);

    int q,a,b,c,d;
    cin >> q;
    while(q--){
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if( (sa[b] - sa[a-1])%3 == (ta[d]-ta[c-1])%3) cout << "YES" <<'\n';
        else cout << "NO" << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(){
	while(1){
	int n; cin >> n ;if(n==0) break;
	string* way=new string[n];
	for(int i=0;i<n;i++) cin >> way[i] ;
	int dice[3]={1,2,3}; //上、手前（南）、右（東）
	int temp;int sum=1;
	for(int i=0;i<n;i++){
		if(way[i]=="North") do{temp=dice[0];dice[0]=dice[1];dice[1]=7-temp;}while(0);
		else if(way[i]=="East") do{temp=dice[2];dice[2]=dice[0];dice[0]=7-temp;}while(0);
		else if(way[i]=="West") do{temp=dice[0];dice[0]=dice[2];dice[2]=7-temp;}while(0);
		else if(way[i]=="South") do{temp=dice[1];dice[1]=dice[0];dice[0]=7-temp;}while(0);
		else if(way[i]=="Right") do{temp=dice[1];dice[1]=dice[2];dice[2]=7-temp;}while(0);
		else if(way[i]=="Left") do{temp=dice[1];dice[1]=7-dice[2];dice[2]=temp;}while(0);
		sum+=dice[0];
	};
	cout << sum << '\n' ;
	delete[] way;
	};
}

Measured memory_bytes: 1484
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t a;
    
    std::cin>> a;

    std::vector< int > list( a, 0 );
    std::vector< int > balllist( a, 0 );
    std::vector< int > ball;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    for( int i = a - 1; 1 <= i; i-- )
    {
        int count = 0;

        int check = ( i + 1 ) * 2;

        while( check <= a )
        {
            if( balllist[check-1] == 1 )
            {
                count += 1;
            }

            check += ( i + 1 );
        }
        
        if( count % 2 != list[i] )
        {
            ball.push_back( i + 1 );
            balllist[i] += 1;
        }
    }

    if( ball.size() % 2 != list[0] )
    {
        ball.push_back( 1 );
    }
    
    std::cout<< ball.size() <<"\n";
    
    for( int i = ball.size() - 1; 0 <= i; i-- )
    {
        std::cout<< ball[i] << " ";
    }

}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=200005;

void solve()
{
	ll n,ans=0;
	map<string,ll>mp;
	string s;
	cin>>n;
	while(n--)
	{
		cin>>s;
		sort(all(s));
		ans+=mp[s];
		mp[s]++;
		
	}
	cout<<ans;
	
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 11264
I=lambda:[int(i)for i in input().split()]
F=1<<65
r=range
n,m=I()
X=set([0,F,-F])
Y=set(X)
R=[((-F,F),F),((-F,F),-F)]
H=[(F,(-F,F)),(-F,(-F,F))]
for i in r(n):
    a,b,c=I()
    R.append(((a,b),c))
    Y.add(c)
    X.add(a)
    X.add(b)

for i in r(m):
    a,b,c=I()
    H.append((a,(b,c)))
    X.add(a)
    Y.add(b)
    Y.add(c)

xdc=dict(enumerate(sorted(X)))
nx=len(xdc)
ydc=dict(enumerate(sorted(Y)))
ny=len(ydc)
 
h=dict(zip(xdc.values(),xdc.keys()))
w=dict(zip(ydc.values(),ydc.keys()))
 
V=[[0]*(nx+1+1)for i in r(ny+1+1)]
U=[i[:]for i in V]

for (a,b),c in R:
    U[w[c]][h[a]]+=1
    U[w[c]][h[b]]+=-1
for i in r(ny+1):
    for j in r(nx):
        U[i][j+1]+=U[i][j]
        
for d,(e,f) in H:
    V[w[e]][h[d]]+=1
    V[w[f]][h[d]]+=-1
for j in r(nx+1):
    for i in r(ny):
        V[i+1][j]+=V[i][j]

v=[[0]*(nx+1) for i in r(ny+1)]
q=[(h[0],w[0])]
v[w[0]][h[0]]=1

a=0
while q:
    cx,cy=q.pop()
    a+=(xdc[cx]-xdc[cx+1])*(ydc[cy]-ydc[cy+1])
    for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
        nbx=cx+dx
        nby=cy+dy
        if (0>nbx>=nx)or(0>nby>=ny)or v[nby][nbx]==1:
            continue
        if dy!=0:
            if U[-~dy//2+cy][cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
        else:
            if V[cy][-~dx//2+cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
if a>=F:a='INF'
print(a)


Measured memory_bytes: 535356
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 998244353
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 200
ll a[4][4];
ll mark[ma];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j,x,y,n,m;
    while(cin>>n)
    {
        memset(mark,-1,sizeof(mark));
        cin>>m;
        vector<pair<ll,ll> >v;
        ll max1=n;
        for(i=0;i<m;i++)
        {
            cin>>x>>y;
            v.pb({x,y});
            mark[x]=y;
            max1=max(max1,x);
        }
        for(i=1;i<=max1;i++)
        {
            if(mark[i]==-1)
            {
                if(i==1&&max1>1)mark[i]=1;
                else mark[i]=0;
            }
        }
        bool f=0;

        for(i=0;i<v.sz;i++)
        {
            if(mark[v[i].ff]!=v[i].ss)f=1;
        }
        if(mark[1]==0&&max1>1)f=1;
        if(f)cout<<"-1"<<endl;
        else
        {
            for(i=1;i<=max1;i++)cout<<mark[i];
            cout<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3616
object Main extends App {

  val n = io.StdIn.readLine.toInt
  val a = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = {
    var va = a
    var cnt = 0;
    var b = true;
    while(b) {
      if(va.forall(e => (e & 1) == 0 && e != 0)){ cnt += 1; va = va.map(e => e >> 1) }
      else b = false
    }
    cnt
  }
  println(ans)
}

Measured memory_bytes: 25532