akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define All(a) (a).begin(),(a).end()

vector<int> X(1000001);

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



void solve(){
  int n,m;
  scanf("%d",&n);
  vector<int> A(n);
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
    X[A[i]]++;
  }
  sort(All(A));

  int tmp=A[0];
  for (int i = 1; i < n; i++)
  {
    tmp=gcd(tmp,A[i]);
  }
  if(tmp>1){ 
    printf("not coprime\n");
    return;
  }

  for (int i = 2; i <  1000001; i++){
    int cnt=0;
    for (int j = i; j <1000001; j+=i)
    {
      cnt+=X[j];
    }
      if(cnt>1){
        printf("setwise coprime\n");
        return;
      }
      //auto a=find(All(X),f[j]);
      //if(a!=X.end())goto setwise;
      //else{
      //X.push_back(f[j]);
      //}
    
    
  }
  printf("pairwise coprime\n");
  return;
}
int main(){
  
  // int q=3;
  // while(q--){
  //   solve();
  // }
 solve();
  return 0;
}

Measured memory_bytes: 11180
using System;

class Program {
  static void Main(string[] args) {
    int a, b, c;
    string[] str = Console.ReadLine().Split();
    a = int.Parse(str[0]);
    b = int.Parse(str[1]);
    c = int.Parse(str[2]);

    if((a+b) != c && (a+c) != b && (b+c) != a) 
      Console.WriteLine("No");
    else
      Console.WriteLine("Yes");
    
  }
}


Measured memory_bytes: 13140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	list := getStdinIntArr64()
	N := list[0]
	K := list[1]
	A := getStdinIntArr64()
	var i int64
	var j int64

	for idx,val := range A {
		A[idx] = val - 1
	}
	Mati := make([]int64, N)	// 町１からの距離
	for i=0 ; i<N ; i++ {
		Mati[i] = -1
	}

	// 町探索
	var prev int64 = 0
	var now int64 = 0 
	for i=0 ; i<K ; i++ {
		prev = now
		now = A[now]
		if Mati[now] == -1 {
			Mati[now] = i
		} else {
			// ループした
			loop := Mati[prev] - Mati[now] + 1
			if loop <= 1 {
				break
			}
			var rem int64 = (K-(i+1)) % loop
			if (K-(i+1)) < 0 {
				rem = (K-(i+1))+loop % loop
			}
			for j=0 ; j<rem ; j++ {
				now = A[now]
			}
			break
		}
	}

	fmt.Printf("%d", now+1)
	fmt.Printf("\n")
}

func getStdinIntArr64() []int64 {
	str := readLine()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
    buf := make([]byte, 0, 1024*1024*10)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

Measured memory_bytes: 13172
#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node { int p,l,r; };

struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, ");
  else if(T[u].l == NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u] = p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}

Measured memory_bytes: 5300
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,ac=0,wa=0,tle=0,re=0;
  cin >> n;
  for ( int i = 0 ; i < n ; i++ ) {
    string str;
    cin >> str;
    if (str == "AC") {
      ac++;
    }
    else if(str ==  "WA") {
       wa++;
    }
    else if (str == "TLE" ){
      tle++;
    }
    else if (str == "RE") {
      re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

int r, g, b, n;

int solve()
{
	int cnt = 0;
	for(int i = 0; i <= n/r; i++)
	{
		int res = n - i * r;
		if(res < 0) break;

		for(int j = 0; j <= res/g; j++)
		{ 
			if((res-j*g)%b == 0) 
			{ 
				//printf("i = %d, j = %d, res = %d, j*g = %d, res-j*g = %d\n", i, j, res, j*g, res-j*g); 
				cnt++; 
			}
			else if((res-j*g) < 0) break;
		}
	}
	return cnt;
}
int main()
{
	scanf("%d %d %d %d", &r, &g, &b, &n);
	printf("%d\n", solve());
}

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

int main(){
  int H,W,K,a=0;
  cin>>H>>W>>K;
  vector<string> B(H),b(H);
  string st;
  REP(i,H){
    cin>>st;
    B[i]='#'+st+'#';
  }
  for(int i=1;i<H;i++) for(int j=1;j<W+1;j++){
    REP(k,H) b[k]=B[k];
    for(int i2=i;i2>0;i2--) b[i2][j]=b[i2-1][j];
    b[0][j]='s';
    int p=0,x=0,f=1;
    while(f){
      f=0;
      char pn,nn;
      REP(i1,H){
        int num=0;
        for(int j1=1;j1<W+2;j1++){
          pn=b[i1][j1-1];
          nn=b[i1][j1];
          if(nn==pn){
            num++;
            continue;
          }else if(num>=K&&pn!='s'){
            p+=(pn-'0')*num*pow(2,x);
            for(int i2=i1;i2>0;i2--){
              b[i2].replace(j1-num,num,b[i2-1].substr(j1-num,num));
            }
            b[0].replace(j1-num,num,num,'s');
            f=1;
          }
          num=1;
        }
      }
      x++;
    }
    a=max(a,p);     
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)


using namespace std;
typedef long long ll;
const ll MOD = 1000000007;


ll dp[200005];
int main(){
    int N;
    int C[200005];
    cin>>N;
    ll ans = 1;
    rep(i,N){
        cin>>C[i];
        C[i]--;
        if(i==0||C[i]!=C[i-1]){
            ans += dp[C[i]];
            ans %= MOD;
        }
        dp[C[i]] = ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
int n, k, gz, gf, m, l;
long long ans=1, a[200005], b[200005];
int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++){
		scanf("%d", &k);
		if(k>0) a[++gz]=k;
		else if(k<0) b[++gf]=0-k;
		else l++;
	}
	sort(a+1, a+gz+1);
	sort(b+1, b+gf+1);
	if(m%2){
		if(gz) ans=a[gz--];
		else if(l){
			printf("0");
			return 0;
		}
		else{
			for(int i=1; i<=m; i++){
				ans=ans*b[i]%M;
			}
			printf("%lld", M-ans);
			return 0;
		}
	}
	m/=2;
	while(m){
		if(gz<2){
			ans=ans*b[gf]%M*b[gf-1]%M;
			gf-=2;
		}
		else if(gf<2){
			ans=ans*a[gz]%M*a[gz-1]%M;
			gz-=2;
		}
		else if(a[gz]*a[gz-1]<b[gf]*b[gf-1]){
			ans=ans*b[gf]%M*b[gf-1]%M;
			gf-=2;
		}
		else{
			ans=ans*a[gz]%M*a[gz-1]%M;
			gz-=2;
		}
		m--;
		if(gz<2 && gf<2) break;
	}
	if(m){
		if(l) printf("0");
		else printf("%lld", M-ans*a[1]%M*b[1]%M);
	}
	else printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5328
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

n =int(input())

m = -1
a = 9999988888999991

# n行の数をリストへ
t = [int(input()) for i in range(5)] 

for i in range(5):
    if t[i] <= a:
        m=i
        a=t[i]

answer = n//a 
if n % a == 0:
    answer -= 1
answer += 5
print( answer )



Measured memory_bytes: 14492
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1000000;
char s[MAXN];
int a[MAXN],ss[MAXN];
int n,k,m,ans=0;

int main()
{
	cin >> n >> k;
	cin >> (s+1);
	int hhf=0;
	char ti;
	if (s[1]=='0') 
	
	
	
		a[++m]=0;
	for (int i = 1; i <= n; i++){
		if (hhf==0){
			ti=s[i];
			hhf++;
		} else if (s[i]!=ti){
			a[++m]=hhf;
			hhf=1;
			ti=s[i];
		} else hhf++;
	}
	if (hhf) a[++m]=hhf;
	if (s[n]=='0') a[++m]=0;
	for (int i = 1; i <= m; i++) 
		ss[i]=ss[i-1]+a[i];
	if (m<=2*k+1)
		 ans=ss[m];
	else {
		for (int i = 1; i <= m-2*k; i++) 
		if (i%2)ans=max(ss[i+2*k]-ss[i-1],ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6784
n = int(input())
list3 =[]

def include3(x):
    if x%10==3:
        return True
    if x//10>=1:
        if include3(x//10):
            return True


for i in range(1, n+1):
    if i%3==0:
        list3.append(str(i))
    elif include3(i):
        list3.append(str(i))

print(" ", end="")
print(" ".join(list3))



Measured memory_bytes: 6004
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        var prime = PrimeFact(n);
        var prime2 = new Dictionary<long, long>();
        foreach (var p in prime)
        {
            if (prime2.ContainsKey(p))
            {
                prime2[p]++;
            }
            else
            {
                prime2[p] = 1;
            }
        }
        long c = 0;
        foreach (var x in prime2.Values)
        {
            c += (long) Math.Floor((Math.Sqrt(x * 8 + 1) - 1) / 2);
        }
        Console.WriteLine(c);
    }

    static IEnumerable<long> PrimeFact(long n)
    {
        var temp = n;
        long p = 2;
        while (p * p <= n)
        {
            if (temp % p == 0)
            {
                temp /= p;
                yield return p;
            }
            else
            {
                p++;
            }
        }
        if (temp != 1) yield return temp;
    }
}

Measured memory_bytes: 27876
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	cin>>n;
	int a[200001];
	int r[200002];
	int l[200002];
	r[0]=0;
	l[n+1]=0;
	for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        r[i]=r[i-1]^a[i];
    }
    for(int i=n;i>=1;i--)
    {
        l[i]=l[i+1]^a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<(r[i-1]^l[i+1])<<' ';
    }
    cout<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
int a[N];

int main() {
    int n, L;
    scanf("%d%d", &n, &L);
    int idx = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        if (i && a[i] + a[i-1] >= L) idx = i;
    }
    if (!idx) puts("Impossible");
    else {
        puts("Possible");
        for (int i = 1; i < idx; i++) printf("%d\n", i);
        for (int i = n - 1; i >= idx; i--) printf("%d\n", i);
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v.at(i);
    }
    int maxE = *max_element(v.begin(), v.end());
    int minE = *min_element(v.begin(), v.end());
    cout << maxE - minE << "\n";
}

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

int main() {
  int N;
  int sum = 0;
    int l;
    int r;
  
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    
    cin >> l >> r ;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = 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(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll X, Y;
  cin >> X >> Y;
  ll cnt = 0;
  ll now = X;
  while(now <= Y){
    cnt++;
    now *= 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N; ll T;
  cin >> N >> T;
  vector<ll> t(N);
  rep(i,N) cin >> t[i];
  vector<ll> start;
  vector<ll> end;
  start.pb(0);
  for(int i=1;i<N;i++){
    if(t[i] - t[i-1] > T){
      end.pb(t[i-1]);
      start.pb(t[i]);
    }
  }
  end.pb(t[N-1]);
  

  ll ans = 0;
  for(int i=0;i<(int)start.size();i++){
    ans += (end[i] - start[i]);
    ans += T;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 510 
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
ll f[N][N],pre[2][N][N],a[N][N]; int n;
ll calc(int ty,int xl,int xr,int yl,int yr){return pre[ty][xr][yr]-pre[ty][xl-1][yr]-pre[ty][xr][yl-1]+pre[ty][xl-1][yl-1];}
void init()
{
	for(int i=1;i<=n;i++)	for(int j=1;j<=n;j++)
	{
		for(int t=0;t<2;t++)	pre[t][i][j]=pre[t][i-1][j]+pre[t][i][j-1]-pre[t][i-1][j-1];
		pre[i>j][i][j]+=a[i][j];
	}
}
void upd(ll &x,ll y){x=x<y?x:y;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<i;j++)	a[i][j]=read();
		for(int j=i+1;j<=n;j++)	a[i][j]=read();
	}
	init(); memset(f,48,sizeof(f)); f[0][0]=0;
	for(int i=0;i<=n;i++)	for(int j=0;j<max(1,i);j++)
		for(int k=i+1;k<=n;k++) if(f[i][j]!=f[0][1])
			upd(f[k][i],f[i][j]+calc(0,i+1,k,i+1,k)+calc(1,k+1,n,j+1,i));
	ll ans=f[0][1];
	for(int i=1;i<=n;i++)	upd(ans,f[n][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


int N;
int a[110];
int m,sum,mn;
int main() {
    mn=110;
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
        sum += a[i];
    }
    int ans;
    REP(i,0,N){
        m = abs(sum - a[i]*N);
        if(mn>m){
            ans = i;
            mn = m;
        }
    }
    p(ans);
    return 0;
}


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

int main()
{
	char s[101];
	char t[101];
	scanf("%s", &s);
	int j = strlen(s);

	sprintf(t, "x");
	for (int i = 1; i != j; i++) {
		sprintf(t, "%sx", t);
	}
	printf("%s", t);
	return 0;
}


Measured memory_bytes: 128
import itertools
N = int(input())
S = [input() for i in range(N)]
listWork = list(set(S))
listMARCH = ["M","A","R","C","H"]
# print(int(listPat[0][0]))
listPat = list(itertools.combinations("01234", 3))
m,a,r,c,h = 0,0,0,0,0

def nCr():
    cnt = 0
    for i in range(len(listPat)):
        cnt += listMARCHcnt[int(listPat[i][0])] * listMARCHcnt[int(listPat[i][1])] * listMARCHcnt[int(listPat[i][2])]
    return cnt


for i in range(N):
    if listWork[i][0] in listMARCH[0]:
        m += 1
    elif listWork[i][0] in listMARCH[1]:
        a += 1
    elif listWork[i][0] in listMARCH[2]:
        r += 1
    elif listWork[i][0] in listMARCH[3]:
        c += 1
    elif listWork[i][0] in listMARCH[4]:
        h += 1

listMARCHcnt = [m,a,r,c,h]

print(nCr())

Measured memory_bytes: 16036
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int N; cin >> N;
  unordered_map<ll, ll> mp;
  vector<ll> h(N+1);
  ll res = 0;
  for (int i = 1; i <= N; i++) {
    cin >> h[i];
    mp[i + h[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    res += mp[i - h[i]];
  }
  cout << res << endl;
  
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 19956
from collections import deque
s = input()
q = int(input())
r = False
S = deque(s)
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    r = ~r
  else:
    if (d[1]=='1' and ~r) or (d[1]=='2' and r):
      S.appendleft(d[2])
    else:
      S.append(d[2])
s = ''.join(S)
if r:
  s = s[::-1]
print(s)

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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            long N = IO.ReadLineToLong();

            long min = long.MaxValue;

            for(long i = 1; i <= Math.Sqrt(N); i++)
            {
                if (N % i == 0)
                {
                    min = Math.Min(min, i + N / i - 2);
                }
            }


            //ここまで
            Console.WriteLine(min);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13140
def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

n, a, b = map(int, input().split())
ans = 0

for i in range(n+1):
    sd = sum_digits(i)
    if a <= sd and sd <= b:
        ans += i

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int ans;

bool isprime(int a)
{
	if (a == 2 || a == 3)
		return true;
	else {
		bool ok = true;
		//cout << static_cast<int>(sqrt(a) + 0.5) << endl;
		for (int i = 2; i <= static_cast<int>(sqrt(a) + 0.5); i++) {
			if (a%i == 0) {
				ok = false;
				break;
			}
		}
		return ok;
	}
}

int main(void)
{
	int n;
	cin >> n;
	vector<int>A(n), B;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (isprime(A[i]))
			B.push_back(i);
	}
	cout << B.size() << endl;
	return 0;
}


Measured memory_bytes: 3144
K,S= list(map(int, input().split()))
ans=0
for i in range(S//3,K+1):
    for j in range(i+1):
        if i+j>S:
            break
        if i+j*2<S:
            continue
        if S-i-j<=j:
            k=S-i-j
            if i==j==k:
                ans+=1
            elif i==j or j==k:
                ans+=3
            else:
                ans+=6
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  auto dp = make_v<ll>(n, 3);
  dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
  FOR(i, 1, n) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
  }
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;

  return 0;
}


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

using namespace std;

using int64 = long long;

int dp[500][501];

int is_cat(string &S, int L, int R) {
  if(L > R) return true;
  if(S[L] != 'm') return dp[L][R] = false;
  if(S[R] != 'w') return dp[L][R] = false;
  if(~dp[L][R]) return dp[L][R];
  for(int i = L + 1; i + 1 <= R; i++) {
    if(is_cat(S, L + 1, i - 1) && S[i] == 'e' && is_cat(S, i + 1, R - 1)) {
      return dp[L][R] = true;
    }
  }
  return dp[L][R] = false;
}

int main() {
  memset(dp, -1, sizeof(dp));
  string S;
  cin >> S;
  if(is_cat(S, 0, S.size() - 1)) cout << "Cat\n";
  else cout << "Rabbit\n";
}




Measured memory_bytes: 4204
#include <iostream>

using namespace std;

int main(){
    int m,f,b;
    cin >> m >> f >> b;
    if (m>=b)
    {
        cout << 0 << endl;
    }else if (b-m<=f)
    {
        cout << b-m << endl;
    }else
    {
        cout << "NA" << endl;
    }
    
    
    
}


Measured memory_bytes: 3080
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn read_bytes(length: usize, skip_next: bool) -> Vec<u8> {
    let mut bytes = vec![0; length];
    let stdin = stdin();
    let mut stdin = stdin.lock();
    stdin.read_exact(&mut bytes).unwrap();
    if skip_next {
        stdin.bytes().next();
    }
    bytes
}

fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

#[derive(Copy, Clone)]
struct ConsecutiveBytes {
    unit_byte: u8,
    count: usize,
}

impl ConsecutiveBytes {
    fn new(unit_byte: u8) -> ConsecutiveBytes {
        ConsecutiveBytes {
            unit_byte: unit_byte,
            count: 0,
        }
    }

    fn count(&mut self, byte: u8) -> usize {
        if byte == self.unit_byte {
            self.count += 1;
        } else {
            self.count = 0;
        }

        self.count
    }
}

// ------------------------------------------------------------------------

fn main() {
    let header = parse_line_vec::<usize>();
    let n = header[0];
    let a = header[1] - 1; // zero-origin
    let b = header[2] - 1;
    let c = header[3] - 1;
    let d = header[4] - 1;
    let s = read_bytes(n, false);

    let mut rocks = ConsecutiveBytes::new(b'#');

    for index in a..std::cmp::max(c, d) {
        if rocks.count(s[index]) >= 2 {
            println("No");
            return;
        }
    }

    if c < d {
        // does not need to overtake
        println("Yes");
        return;
    }

    let mut spaces = ConsecutiveBytes::new(b'.');

    for index in b - 1..std::cmp::min(d + 2, n) {
        if spaces.count(s[index]) >= 3 {
            println("Yes");
            return;
        }
    }

    println("No");
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

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

		int r = sc.nextInt();
		int c = sc.nextInt();

		int[][] sheet = new int[r + 1][c + 1];

		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sheet[i][j] =  sc.nextInt();
			}
		}

		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c; j++) {
				sheet[i][c] += sheet[i][j];
			}
		}

		for (int i = 0; i < r ; i++) {
			for (int j = 0; j < c + 1; j++) {
				sheet[r][j] += sheet[i][j];
			}
		}

		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c + 1; j++) {
				System.out.print(sheet[i][j]);

				if (j < c) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}

		sc.close();

	}

}



Measured memory_bytes: 43564
from collections import Counter

N = int(input())

str_lis = [str(input()) for i in range(N)]
c = Counter(str_lis)
a = c.most_common()
num = a[0][1]
b = []
for i in a:
  if i[1] == num:
    b.append(i[0])
    num = i[1]
  else:
    break
    
new_b = sorted(b)
for i in new_b:
  print(i)

Measured memory_bytes: 49196
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  int a[n+1];
  for(int i = n; i>=0; i--){
    cin>>a[i];
  }
  vector<int> primes;
  REPP(i,n){
    if(prime_(i)){
      primes.push_back(i);
    }
  }
  int an = abs(a[n]);
  for(int i = 2; i<=sqrt(an); i++){
    if(!prime_(i)){
      continue;
    }
    if(an%i != 0){
      continue;
    }
    primes.push_back(i);
    while(an%i == 0){
      an /= i;
    }
  }
  if(an != 1){
    primes.push_back(an);
  }
  sort(ALL(primes));
  primes.erase(unique(primes.begin(), primes.end()), primes.end());
  
  int cnt = primes.size();
  vector<int> ans;
  REP(i,cnt){
    int p = primes[i];
    if(p > n){
      bool flag = true;
      REP(i,n){
        if((a[i]%p+p)%p == 0){
          continue;
        }else{
          flag = false;
          break;
        }
      }
      if(flag){
        ans.push_back(p);
      }
      continue;
    }
    int coeff[p] = {};
    REP(j,n+1){
      if(0<= j && j<p){
        coeff[j] = a[j];
        //coeff[j] %= p;
        coeff[j] = (coeff[j]%p+p)%p;
      }else{
        if(j%(p-1) != 0){
          coeff[j%(p-1)] += a[j];
          //coeff[j%(p-1)] %= p;
          coeff[j%(p-1)] = (coeff[j%(p-1)]%p+p)%p;
        }else{
          coeff[p-1] += a[j];
          //coeff[p-1] %= p;
          coeff[p-1] = (coeff[p-1]%p+p)%p;
        }
      }
    }
    bool flag = true;
    REP(j,p){
      if(coeff[j] == 0){
        continue;
      }else{
        flag = false;
        break;
      }
    }
    if(flag){
      ans.push_back(p);
    }
  }
  
  for(int p:ans){
    cout<<p<<endl;
  }
    
  return 0; 
}


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

int main() {
    int H;
    cin >> H;
    int W;
    cin >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a.at(i).at(j);
        }
    }

    for (int i = 0; i < W + 2; ++i) {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < H; ++i) {
        cout << "#";
        for (int j = 0; j < W; ++j) {
            cout << a.at(i).at(j);
        }
        cout << "#" << endl;
    }

    for (int i = 0; i < W + 2; ++i) {
        cout << "#";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  ll n,ans=0;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int x,y;
  for(int i=0; i<n-2; i++) {
    for(int j=i+1; j<n-1; j++) {
      x=a[i],y=a[j];
      int ite=lower_bound(a.begin(),a.end(),x+y)-a.begin()-1;
      int xx=ite-j;
      ans+=xx;
    }
  }
  cout << ans << endl;
}

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

#define ll long long

using namespace std;

int sum(int a){
    if(a < 10) return a;
    return sum(a/10) + a%10;    
}

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

    cin >> a;

    if(!(a%sum(a))) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    map<int,int> m;
    REP(i,n-1){
        for(int j=i+1;j<n;j++){
            int tmp=j-i;
            if(i<=x){
                if(y<=j){
                    tmp-=(y-x);
                    tmp++;
                }
                else{
                    if(j-x>y-j+1){
                        tmp = x-i+y - j + 1;
                    }
                }
            }
            else{
                if (y <= j)
                {
                    tmp=min(tmp,j-y+i-x+1);
                }
                else
                {
                    tmp=min(tmp,y-j+i-x+1);
                }
            }
            m[tmp]++;
        }
    }
    REP(i,n-1){
        cout << m[i+1] << endl;
    }
}

Measured memory_bytes: 384
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=110;
int a[N],b[N],n,m,c;
int main()
{
#ifndef ONLINE_JUDGE
//	freopen("B.in","r",stdin);
#endif
	n=gi();m=gi();c=gi();int ans=0;
	for(int i=1;i<=m;i++)
		b[i]=gi();
	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=1;j<=m;j++)
		{
			a[j]=gi();sum+=a[j]*b[j];
		}
		if(sum+c>0)ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	map<char, int> m1, m2;
	rep(i, 0, S.size()) {
		m1[S[i]]++;
	}

	rep(i, 0, T.size()) {
		m2[T[i]]++;
	}

	vector<int> v1, v2;
	for(map<char, int>::iterator itr = m1.begin(); itr != m1.end(); itr++) {
		v1.push_back(itr->second);
	}
	for(map<char, int>::iterator itr = m2.begin(); itr != m2.end(); itr++) {
		v2.push_back(itr->second);
	}

	vsort(v1);
	vsort(v2);

	rep(i, 0, v1.size()) {
		if(v1[i] != v2[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


}


Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
int main()
{
    string a,b,s,t;
    ll i,j,l,f;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    if(a==b)
    {
        l=b.size()/2;
        j=l+1;
        f=0;
        for(i=0;i<l;i++)
        {
            if(b[i]!=b[j])
            {
                f=1;
                break;
            }
            else j++;
        }
        if(f==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class CStringColoring {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,r,b;
        string s;
        ll ans(0);
        string R,B;
        vector<vector<ll>> dp;
        in>>n>>s;
        fr(i,1<<n){
            r=b=0;
            R.clear(),B.clear();
            fr(_,n){
                if((i>>_)&1) ++r,R+=s[_];
                else ++b,B+=s[_];
            }
            reverse(R.begin(),R.end());
            reverse(B.begin(),B.end());
            dp.assign(n+1,vector<ll>(r+1));
            dp[0][0]=1;
            fr(u,n) fr(v,r+1){
                int w=u-v;
                if(v<r&&s[n+u]==R[v]) dp[u+1][v+1]+=dp[u][v];
                if(w<b&&s[n+u]==B[w]) dp[u+1][v  ]+=dp[u][v];
            }
            ans+=dp[n][r];
        }
        out<<ans<<endl;
    }
};

int main() {
    CStringColoring solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
const double EPS=1e-5;

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    int n;
    cin>>n;
    vector<int> t(n),v(n);
    for(int i=0;i<n;i++) cin>>t[i];
    for(int i=0;i<n;i++) cin>>v[i];
    t.push_back(0);
    v.push_back(0);
    for(int i=1;i<=n;i++) t[i]+=t[i-1];

    double speed=0.0;
    double now=0.0;
    double ans=0.0;
    for(int i=0;i<n;i++){
        for(;now<=t[i]-0.5+EPS;now+=0.5){
            bool flag=true;
            ans+=speed*0.5;
            if(speed+0.5>v[i]+EPS) flag=false;
            for(int j=i;j<n;j++){
                double dt=t[j]-(now+0.5);
                if(speed+0.5-dt>v[j+1]+EPS) flag=false; 
            }
            if(flag){
                ans+=0.125;
                speed+=0.5;
                continue;
            }
            flag=true;
            for(int j=i;j<n;j++){
                double dt=t[j]-(now+0.5);
                if(speed-dt>v[j+1]+EPS) flag=false; 
            }
            if(flag){
                continue;
            }
            ans-=0.125;
            speed-=0.5;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string picture(bool[] xs){ return xs.array.map!(x => x? '#': '.').array; } string picture(bool[][] xf){ return xf.map!(xs => xs.picture).array.join("\n"); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
void solve(){
    int n = scan!int, m = scan!int;
    auto uf = new UnionFind(n);
    foreach(_; 0 .. m){
        int a = scan!int - 1, b = scan!int - 1;
        uf.unite(a, b);
    }
    int count;
    foreach(i; 0 .. n) if(uf.find(i) == i) count += 1;
    (count - 1).print;
}


import std.conv;
class UnionFind{
    int[] rootOf;
    int[][] kidsOf;
    this(int n){
        rootOf = new int[](n);
        kidsOf = new int[][](n);
        foreach(i; 0 .. n) rootOf[i] = i, kidsOf[i] = [i];
    }
    void unite(int a, int b){
        int ra = rootOf[a], rb = rootOf[b];
        if(ra == rb) return;
        if(kidsOf[ra].length < kidsOf[rb].length) unite(b, a);
        else foreach(k; kidsOf[rb]) rootOf[k] = ra, kidsOf[ra] ~= k;
    }
    int find(int a){
        return rootOf[a];
    }
    int getSize(int a){
        return kidsOf[rootOf[a]].length.to!int;
    }
}


Measured memory_bytes: 14236
n = int(input())
ab = []
for i in range(n):
    line = input().split()
    tmp = []
    tmp.append(int(line[0]))
    tmp.append(int(line[1]))
    ab.append(tmp)
    
ab = sorted(ab, key=lambda x: x[1])
t = 0
pos = True
for i in range(n):
    t += ab[i][0]
    if t > ab[i][1]:
        pos = False
        break
if not pos:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 42768
#include<stdio.h>
int main()
{
	char a,b,c,d,e,f,g,h,i;
	scanf("%c %c %c %c %c %c %c %c %c",&a,&b,&c,&d,&e,&f,&g,&h,&i);
	printf("%c%c%c\n",a,e,i);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int n,m;
int v[N],fa[N],fd[N];
int find(int x)
{
	if(x==fa[x])return x;
	return fa[x]=find(fa[x]);
}
int p[N];
bool cmp(int x,int y)
{
	return v[x]<v[y];
}
vector<int>vt[N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>v[i],fa[i]=i;
	int d=0;
	for(int i=1;i<=m;i++)
	{
		int t1,t2;
		cin>>t1>>t2;
		t1++;t2++;
		int a=find(t1),b=find(t2);
		if(a!=b)fa[a]=b,d++;
	} 
	if(d==n-1)return puts("0"),0;
	int nd=(n-1-d)*2;
	if(nd>n)
	{
		puts("Impossible");
	}
	else
	{
		ll ans=0;
		for(int i=1;i<=n;i++)p[i]=i;
		sort(p+1,p+n+1,cmp);
		for(int i=1;i<=n;i++)
		{
			vt[find(i)].push_back(i);
		}
		for(int i=1;i<=n;i++)
		{
			if(i==fa[i])
			{
				int mn=0x3f3f3f3f,id=0;
				for(int j=0;j<vt[i].size();j++)
				{
					if(v[vt[i][j]]<mn)
					{
						mn=v[vt[i][j]];id=vt[i][j];
					}
				}
				ans+=mn;fd[id]=1;nd--;
			}
		}
		for(int i=1;i<=n;i++)
		{
			if(nd&&!fd[p[i]])
			{
				ans+=v[p[i]];
				fd[p[i]]=1;
				nd--;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
 vector<int> num;
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
  int p;
  cin>>p;
  num.push_back(p);
 }
 sort(num.begin(),num.end());
 cout<<num.back()-num.front();
}

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

int main(){
	ll n;cin>>n;n++;
	deque<int>f{1},r{1};
	int p=2;
	bool flag=false;
	for(int i=40;i>=0;i--){
		if(!flag){
			if(n>>i&1)flag=true;
			continue;
		}
		if(n>>i&1){//+1
			f.push_back(p);
			r.push_front(p);
			p++;
		}
		if(i){//*2
			f.push_back(p);
			r.push_back(p);
			p++;
		}
	}
	for(int i:r)f.push_back(i);
	cout<<f.size()<<endl;
	rep(i,f.size()){
		if(i)printf(" ");
		cout<<f[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)


int main(){
    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a);
    cout << abs(a[1],a[0])+abs(a[2],a[1]) << endl;
}








Measured memory_bytes: 256
// https://atcoder.jp/contests/arc064/tasks/arc064_b

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define int long long

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

    string s;
    cin >> s;

    int ans = s.size()%2;

    if(s[0] == s.back()) {
        ans ^= 1;
    }

    if(ans) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define mi(N) int N; cin >> N;
#define ms(s) string s; cin >> s;
#define md(d) double d; cin >> d;
#define mv(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

template<typename T>
T maxi(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())maxi(ret, v[i]);
	return ret;
}

template<typename T>
T mini(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())mini(ret, v[i]);
	return ret;
}

signed main() {
	mi(n);
	ms(s);
	mi(k);
	char c = s[k - 1];
	rep(n) {
		if (s[i] != c)s[i] = '*';
	}
	say(s);
}


Measured memory_bytes: 256
def main
  a, b, c, x, y = gets.split.map(&:to_i)

  max_xy = [x, y].max
  # puts max_xy

  min_price = 1 << 30
  0.step(max_xy * 2, 2) do |ab_num|
    price = ab_num * c

    if ab_num / 2 < x
      price += (x - ab_num / 2) * a
    end
    if ab_num / 2 < y
      price += (y - ab_num / 2) * b
    end

    min_price = price if price < min_price
  end

  puts min_price


end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N;
    cin >> N;

    vector<ll> A(N);
    map<ll, ll>m;
    REP(i, N) {
        cin >> A[i];
        m[A[i]]++;
    }
    debug(A, m)

    ll ans = 0;
    for (auto p: m) {
        ll n = p.se;
        ans += n * (n - 1) / 2;
    }

    REP(i, N) {
        ll a = A[i];
        ll n = m[a];

        ll d = - n * (n - 1) / 2 + (n - 1) * (n - 2) / 2;

        cout << ans + d << endl;
    }
    
}


Measured memory_bytes: 11136