akhauriyash/Code-Regression huggingface dataset:
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


//typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

int main(){
    string s;
    cin>>s;
    int c = 0;
    FREP(i,0,s.size()-1){
        if(s[i]=='1')c++;
    }
    cout<<c<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void insertionsort(int [], int,int);
void shellsort(int [], int);

int count = 0;

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

}

void insertionsort(int temp[],int n, int g){

  for(int i=g; i<n; i++){
    int v = temp[i];
    int j = i - g;
    while((j>=0)&&(temp[j]>v)){
      temp[j+g]=temp[j];
      j=j-g;
      count++;

    }
    temp[j+g]=v;
  }


}

void shellsort(int temp[], int n){

  int cnt = 0;

  int m = n/2;
  int x = n/2;
  if(n==1){
    m = 1;
    x = 1;
  }

  


  int G[m];

  for(int i=0;;i++){
    if(x<1){
      break;
    }
    G[i]=x;

    x/=2;
    cnt++;

  }

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



  for(int i=0; i<cnt; i++){
    insertionsort(temp,n,G[i]);
  }

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


}



Measured memory_bytes: 5628
import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
a.sort()
pz = a[a > 0]
ng = a[a < 0]
z = np.count_nonzero(a == 0)


def count(x):
    res = 0
    if x >= 0:
        res += z * n
    res += np.searchsorted(a, x // pz, side="right").sum()
    res += n * len(ng) - np.searchsorted(a, -(-x // ng), side="left").sum()
    res -= np.count_nonzero(a * a <= x)
    return res // 2


l, r = -10 ** 19, 10 ** 19
while r - l > 1:
    m = (l + r) // 2
    if count(m) >= k:
        r = m
    else:
        l = m
print(r)


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

#define A   0
#define B   1
#define C   2

char solve(std::vector<std::string> cards)
{
    int t = A;
    while (cards[t].length())
    {
        char c = cards[t][0];
        cards[t] = cards[t].substr(1, cards[t].length() - 1);
        t = c - 'a';
    }
    return static_cast<char>('A' + t);
}
signed main(void)
{
    std::vector<std::string> cards(3);
    std::cin >> cards[A] >> cards[B] >> cards[C];
    std::cout << solve(cards) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  char ch[250]={0};
  char a[250] ={0};
  int h;
  int i,j,k,l,n,m;
 
 
  while(1){
    i=0;
    while(1){
       
      scanf("%c",&ch[i]);
      if(ch[i] == '\n') {    
    break;
      }
       
      i++;
    }
    
    if ( i == 1 && ch[0] == '-' ) break;
 
    //  printf("%d",i);
     
    scanf("%d",&m);
     
    for(j=0;j<m;j++){
      scanf("%d", &h );
       
      for(k=0;k<i-h;k++) {
    a[k] = ch[h+k];
    //    printf("a[%d] = ch[%d]の%c\n",k ,h+k,ch[h+k]);
      }
      for(k=0;k<h;k++){
    a[i-h+k] = ch[k];
    //   printf("a[%d] = ch[%d]の%c\n",i-h+k,k,ch[k]);
      }
      for(k=0; k<i; k++){
    ch[k] = a[k];
    // printf("ch[%d] = a[%d]の%c\n",k,k,a[k]);
      }
    }
    for(k=0;k<i;k++) {
      printf("%c",ch[k]);
    }
    printf("\n");
      scanf("%c",&ch[0]);
  }
   
   
  return 0;
   
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

bool prime[MAX];
bool like_2017[MAX];
int ary[MAX];

// エラトステネスの篩（素数は配列primeがfalseになる添え字）
void eratosthenes(int N) {
  prime[0] = prime[1] = true;
  for (int i = 2; i < sqrt(MAX); i++) {
    for (int j = i; i * j < MAX; j++) {
      prime[i*j] = true;
    }
  }
}

int main() {
  // エラトステネスの篩で素数表を作る
  eratosthenes(MAX);
  // like_2017配列を作る
  for (int i = 1; i < MAX; i++) {
    if (!prime[i]) {
      int n = (i + 1) / 2;
      if (!prime[n]) like_2017[i] = true;
    }
  }
  // like_2017の個数を定数時間で答えられるように配列aryを作る
  for (int i = 1; i < MAX; i++) {
    ary[i] = ary[i-1];
    if (like_2017[i]) ary[i]++;
  }

  // 入力と解答
  int Q;
  cin >> Q;
  int l, r;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    cout << ary[r] - ary[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
vll h(200010);
ll hh(ll n){
  if(h[n]!=0){
    return h[n];
  }
  return n*hh(n-1);
}
int main(){
  h[0]=0;
  for(int i=1;i<sz(h);i++){
    h[i]=h[i-1]+i;
  }
  cout << fixed << setprecision(10);
  ll n,k;
  cin>>n>>k;
  vector<double> p(n);
  rep(i,n){
    cin>>p[i];
  }
  vll a(n+1);
  a[0]=0;
  for(int i=1;i<=n;i++){
    a[i]=p[i-1]+a[i-1];
  }
  ll cu=0;
  ll ans=0;
  for(int i=0;i<=n-k;i++){
    if(ans<a[i+k]-a[i]){
      ans=max(ans,a[i+k]-a[i]);
      cu=i;
    }
  }
  double r=0;
  for(int i=cu;i<cu+k;i++){
    r+=hh(p[i])/p[i];
  }

  COUT(r);
}

Measured memory_bytes: 4992
R,G,B,n = map(int, input().split())
ans = 0
for r in range(n//R+1):
    if R*r > n: break
    for g in range(n//G+1):
        ball = R*r + G*g
        if ball > n: break
        if (n-ball)%B==0: ans += 1
print(ans)

Measured memory_bytes: 9180
#151
N, M = map(int,input().split())
AC = [0]*N
WA = [0]*N
for i in range(M):
    p, s = input().split()
    p = int(p)
    if(s=='WA' and AC[p-1]==0):
        WA[p-1] += 1
        continue
    if(s=='AC' and AC[p-1]==0):
        AC[p-1] += 1
        continue
WA_num = sum([WA[i] for i in range(len(AC)) if AC[i] == 1])
print(sum(AC), WA_num)

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


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt=0;
    int ans;
    rep(i,n){
        if(s[i] == '0') cnt++;
    }
    ans = 2 * min(cnt, n-cnt);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int fibonacci(int);
int F[45];
int main(){

  int n,i;
 
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    F[i]=-1;
  }
  fibonacci(n);
  printf("%d\n",F[n]);


  return 0;
}

int fibonacci(int n){
  if(n==0 || n==1){
    F[n]=1;
    return F[n];
  }
    if(F[n]!=-1) return F[n];

    F[n]=fibonacci(n-2)+fibonacci(n-1);
    return F[n];
  }

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>

int main(void) {

	int n;
	double x[100], y[100], s[100];		//s????????¶???????????????.
	double p;
	double tmp;
	double d[4];

	scanf("%d", &n);

	int i;

	for (i = 0; i < n; i++)
		scanf("%lf", &x[i]);

	for (i = 0; i < n; i++) {
		scanf("%lf", &y[i]);
		s[i] = x[i] - y[i] > 0 ? x[i] - y[i] : y[i] - x[i];
	}

	for (p = 1; p <= 3; p++) {
		tmp = 0;

		for (i = 0; i < n; i++) {
			tmp += pow(s[i], p);
		}

		d[(int)(p - 1)] = pow(tmp, 1 / p);
	}

	double max = s[0];

	for (i = 0; i < n; i++) {
		if (max < s[i])
			max = s[i];
	}

	d[3] = max;

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

	return 0;
}

Measured memory_bytes: 716
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  ll ans = 1ll * n * (n - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i = 1;
		
		int n;
		do {
			n = sc.nextInt();
			if (n == 0){
				break;
			} else {
				System.out.println("Case " + i + ": " + n);
				i++;
			}
		} while(!(n == 0));
	}
}

Measured memory_bytes: 31356
#include <stdio.h>
int main(void){
   int S;
   int h,m,s;
   scanf("%d",&S);
   h=S/3600;
   S%=3600;
   m=S/60;
   S%=60;
   s=S;
   printf("%d:%d:%d\n",h,m,s);
   return 0;
   
}


Measured memory_bytes: 2684
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    while (1) {

        string str;
        getline(cin, str);
        if (str == "0") break;
        else{
        int num = 0;
        for (int i = 0; i < str.size();++i) {
            num += str[i] - '0';
        }
        cout << num << endl;
        }
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

int a, b;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << a*b;
	return 0;
}
//10-09-2020 18:00:06

Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;

char a[100], b[100], c[100];

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

	a[0] += 'A' - 'a';
	b[0] += 'A' - 'a';
	c[0] += 'A' - 'a';

	cout << a[0] << b[0] << c[0] << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
max_1 = 0
max_2 = 0
al = []
for _ in range(n):
    a = int(input())
    al.append(a)

max_1 = sorted(al)[-1]
max_2 = sorted(al)[-2]

for a in al:
    if a == max_1:
        print(max_2)
    else:
        print(max_1)
    


Measured memory_bytes: 68896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	c := Scanner()
	d := Scanner()
	if c[0] == d[2] && c[1] == d[1] && c[2] == d[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1776
#include "bits/stdc++.h"
// #include <boost/multi_array.hpp>
// #include <boost/optional.hpp>
// #include <boost/range/irange.hpp>
// #include <boost/range/algorithm.hpp>
// #include <boost/range/adaptors.hpp>

// namespace adaptor = boost::adaptors;

using ll = long long;
using i64 = int64_t;

void Main()
{
   int R, G, B, N;
   int r, g, b;
   int ans = 0;
   std::cin >> R >> G >> B >> N;
   for (r = 0; R * r <= N; r++)
   {
      for (g = 0; R * r + G * g <= N; g++)
      {
         if ((N - R * r - G * g) % B == 0)
         {
            ans++;
         }
      }
   }
   std::cout << ans << std::endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	ll A, B, C, D;
	ll ans;

	cin >> A >> B >> C >> D;

	ans = B - A + 1;

	ll cnum = B / C - (A-1) / C;
	ll dnum = B / D - (A-1) / D;

	ll val = lcm(C, D);
	ll cdnum = B / val - (A-1) / val;

	ans = ans - cnum - dnum + cdnum;

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


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Trim();

        var t = new string(s.Select(x => (char)((x - 'A' + n) % ('Z' - 'A' + 1) + 'A')).ToArray());
        Console.WriteLine(t);
    }
}


Measured memory_bytes: 11348
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


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

    def f(s):
        if int(s) > N:
            return 0
        p = 0
        if len(set(list(s))) == 3:
            p = 1
        return f(s + "3") + f(s + "5") + f(s + "7") + p

    answer = f("3") + f("5") + f("7")
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
while True:
    st = list(input().split("/"))
    if st == ["#"]:
        break
    a, b, c, d = map(int, input().split())

    s=[]
    for i in range(len(st)):
        str=[]
        for ele in st[i]:
            if ele=="b":
                str.append("b")
            else:
                for _ in range(int(ele)):
                    str.append(".")
        s.append(str)

    s[a-1][b-1] = "."
    s[c-1][d-1] = "b"

    '''
    print(s)
    ans=""
    for i in range(len(s)):
        count = 0
        for ele in s[i]:
            if ele=="b":
                sr="{}".format(count)
                ans=ans+sr
                ans+="b"
            else:
                count+=1
        ans+="/"
    print(ans)
    '''


    ans = []
    for i in range(len(s)):
        sr = ""
        c = 0
        for j in range(len(s[i])):
            if s[i][j] == 'b':
                if c != 0:
                    sr += "{}".format(c)
                sr += "b"
                c=0
            elif s[i][j] == '.':
                c += 1
            '''
            if j==len(s[i])-1:
                if s[i][j] == '.' and c != 0:
                    sr += "{}".format(c)
            '''
        if c!=0:
            sr+="{}".format(c)
        ans.append(sr)
    ass = "/".join(ans)
    print(ass[:])



Measured memory_bytes: 5624
#include<stdio.h>
int a[1000010]={0};
int main(void){
    int n,i,j,ans;
    for(i=2;i<1000000;i++){
        if(a[i]==0){
            for(j=2;i*j<1000000;j++){
                a[i*j]=1;
            }
        }
    }
    
    while(scanf("%d",&n)!=EOF){
        ans=0;
        for(i=2;i<=n;i++){
            if(a[i]==0)ans++;
        }
    printf("%d\n",ans);
    }
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    vector<int> L(N + 1);  // i番目まででWを向いている人数。
    vector<int> R(N + 1);  // i番目〜N-1番目まででEを向いている人数。

    L[0] = 0;
    R[N] = 0;

    rep(i, N) {
        if (S[i] == 'W') L[i+1] = L[i] + 1;
        else L[i+1] = L[i];
    }
    // R[N+1] = R[N];

    for (int i = N-1; i >= 0; i--) {
        if (S[i] == 'E') R[i] = R[i + 1] + 1;
        else R[i] = R[i + 1];
    }

    // cout << "L: ";
    // rep(i, N+1) {
    //     cout << L[i] << " ";
    // }
    // cout << endl;
    // cout << "R: ";
    // rep(i, N+1) {
    //     cout << R[i] << " ";
    // }
    // cout << endl;

    int res = N;
    rep(i, N) {
        res = min(res, L[i] + R[i+1]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6132
a,b,c,d,e,f = gets.split(" ").map(&:to_i)

water = []
(0..f).each do |i|
  (0..f).each do |j|
    total = (100 * a * i)  + (100 * b * j)
    if total <= f
      water << total
    end
  end
end
water.uniq!

sugar = []
(0..f).each do |i|
  (0..f).each do |j|
    total = c * i + d * j
    if total <= f
      sugar << total
    end
  end
end
sugar.uniq!

max_w = 0
max_s = 0
max_p = 0
water.each do |w|
  sugar.each do |s|
    next if w + s > f
    if w != 0 && (w / 100) * e >= s
      p = (100.0 * s) / (w + s)
      if p > max_p
        max_w = w
        max_s = s
        max_p = p
      end
    end
  end
end

if max_w == 0
  puts "#{100*a} 0"
else
  puts "#{max_w+max_s} #{max_s}"
end

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

ll digits(ll x){
	ll d = 1, cnt = 0;
	if (x == 0) return 1;
	while (x >= d){
		d *= 10;
		cnt++;
	}
	return cnt;
}
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll N, least = LL_INF;
	cin >> N;
	for (ll A = 1; A*A <= N; A++){
		if (N%A == 0){
			least = min(least, max(digits(A), digits(N/A)));
		}
	}
	cout << least << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int m=in();
	vector<int> a(n);
	for(auto &i:a)
	{
		i=in();
		i/=2;
	}
	
	int l=1;
	for(int i=0;i<n;i++)
	{
		l=l/__gcd(l,a[i]);
		l*=a[i];
	}
	
	for(int i=0;i<n;i++)
	{
		if((l/a[i])%2==0)
		{
			puts("0");return 0;
		}
	}
	//cout<<m/(2*l) +(m%(2*l))/l<< endl;
	cout<<(m/(2*l))+((m%(2*l))/l);
	
}

Measured memory_bytes: 4044
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    K = II()
    S = input()
    N = len(S)
    if N <= K:
        print(S)
    else:
        print(S[:K]+'...')

main()

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

using namespace std;

int A,B,score;

int main(void){

  while( cin >> score ){

    A = B = 0;
    A += score;
    for( int i = 0 ; i < 3 ; i++ ){
      cin >> score;
      A += score;
    }
    for( int i = 0 ; i < 4 ; i++ ){
      cin >> score;
      B += score;
    }
    cout << max( A , B ) << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var A = Scanner.ScanEnumerable<int>().ToArray();
            Array.Sort(A, (x, y) => Comparer<int>.Default.Compare(y, x));
            var max = A[0];
            var sieve = new int[max + 1];
            for (var i = 0; i < N; i++)
            {
                for (var x = A[i]; x <= max; x += A[i])
                {
                    sieve[x]++;
                }
            }
            var answer = 0;
            for (var i = 0; i < N; i++)
            {
                if (sieve[A[i]] == 1) answer++;
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

using namespace std;

const int N = 200000;

int dsu[N];

int find(int i) {
	return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (dsu[i] > dsu[j])
		swap(i, j);
	dsu[i] += dsu[j];
	dsu[j] = i;
}

int main() {
	int n, m; cin >> n >> m;
	fill(dsu, dsu + n, -1);
	while (m--) {
		int i, j; cin >> i >> j, i--, j--;
		join(i, j);
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (dsu[i] < 0)
			ans = max(ans, -dsu[i]);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)
#define INF 100000000000 // long only

int main(){
	char s[100], t[100];
    scanf("%s%s",s,t);
    if(strncmp(s,t,strlen(s))==0)printf("Yes\n");
    else printf("No\n");
    return 0;

}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

long long N, K;

int main(){
  ios_base::sync_with_stdio(false); 
  cin >> N >> K;
  vector<pair<int, int> > v(N);
  for(int i=0; i<N; ++i){
    cin >> v[i].first >> v[i].second;
  }
  sort(all(v), [&](const pair<int, int> a, const pair<int, int> b){
        return a.first < b.first;
      });
  long long p = 0, i;
  for(i=0; p+v[i].second < K && i<N; ++i){
    p += v[i].second;
  }
  cout << v[i].first << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e14+4;
const int Nmax=2e5+1;
const int Nd=61;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint kaijo(int m){
  mint sum=1;
  for(int i=1;i<=m;i++){
    sum *=i;
  }
  return sum;
}

int main(){
  int n,m;cin>>n>>m;
  if( n-m>1 || m-n>1){
    cout<<0<<endl;
    return 0;
  }
  mint nkaijo=kaijo(n);
  mint mkaijo=kaijo(m);
  mint ans;
  if(n==m){
    ans=mint(2)*nkaijo*mkaijo;
    cout<<ans<<endl;
    return 0;
  }else{
    ans=nkaijo*mkaijo;
    cout<<ans<<endl;
    return 0;
  }


  return 0;
}


Measured memory_bytes: 3520
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
vector<int> calc(const vector<int> &a) {
  int n = a.size();
  vector<int> res;
  FOR(i, 1, n - 1) {
    vector<int> tmp{a[i - 1], a[i], a[i + 1]};
    sort(ALL(tmp));
    res.emplace_back(tmp[1]);
  }
  return res;
}

void swap1(vector<int> &a, int idx) {
  swap(a[idx], a[idx + 1]);
  swap(a[idx - 1], a[idx]);
}

void swap2(vector<int> &a, int idx) {
  swap(a[idx - 1], a[idx]);
  swap(a[idx], a[idx + 1]);
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, x; cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  vector<int> ans(2 * n - 1);
  iota(ALL(ans), 1);
  if (x < n) {
    FOR(i, x - 1, n - 1) swap1(ans, i);
  } else if (n < x) {
    for (int i = x - 1; i > n - 1; --i) swap2(ans, i);
  }
  REP(i, 2 * n - 1) cout << ans[i] << '\n';

  // int n = 5;
  // vector<int> a(2 * n - 1);
  // iota(ALL(a), 1);
  // do {
  //   vector<int> ans(a);
  //   while (ans.size() > 1) ans = calc(ans);
  //   if (ans[0] == 4) {
  //     REP(i, 2 * n - 1) cout << a[i] << ' ';
  //     break;
  //   }
  // } while (next_permutation(ALL(a)));
}


Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

struct Node {
  int pre, nxt;
  int64 w, c;
  int x, y;
};

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

ostream& operator <<(ostream& os, const Node& a) {
  os << a.x << " " << a.y << " " << a.w << " " << a.c << " "
     << a.pre << " " << a.nxt;
  return os;
}

struct cmp {
  bool operator ()(int u, int v) {
    return a[u].c < a[v].c;
  }
};

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i].w);
    a[i].x = i, a[i].y = i + 1;
    a[i].pre = (i - 1 >= 0 ? i - 1 : -1);
    a[i].nxt = (i + 1 < n ? i + 1 : -1);
  }
  set<int, cmp> A;
  for (int i = 0; i < n - 1; ++i) {
    a[i].c = a[i].w + a[i + 1].w;
    A.insert(i);
  }
  vector<int> ret;
  while (!A.empty()) {
    // for (auto& it : A) {
    //   cout << a[it] << " | ";
    // } cout << endl;
    int cur = *prev(A.end());
    int pre = a[cur].pre, nxt = a[cur].nxt, nnxt = a[nxt].nxt;
    // cout << pre << " " << cur << " " << nxt << " " << nnxt << endl;
    if (a[cur].c < m) break;
    ret.push_back(a[cur].y);
    A.erase(cur);
    A.erase(nxt);
    a[cur].w += a[nxt].w;
    a[cur].y = a[nxt].y;
    a[cur].nxt = nnxt;
    if (nnxt >= 0) {
      a[nnxt].pre = cur;
      a[cur].c = a[cur].w + a[nxt].w;
      A.insert(cur);
    }
    if (pre >= 0) {
      A.erase(pre);
      a[pre].c = a[pre].w + a[cur].w;
      A.insert(pre);
    }
  }
  if (ret.size() == n - 1) {
    puts("Possible");
    reverse(ret.begin(), ret.end());
    for (auto& it : ret) {
      printf("%d\n", it);
    }
  } else {
    puts("Impossible");
  }
  return 0;
}


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




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

    if (k % 2 == 0)
        cout << a - b << endl;
    else
        cout << b - a << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    vector<int> time(3, 0);
    cin >> time[0] >> time[1] >> time[2];

    int ans = time[0] + time[1] + time[2];
    for (int i = 0; i < 3; i++) {
        int temp = time[i%3] + time[(i+1)%3];
        if (temp < ans) ans = temp;
    }

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


Measured memory_bytes: 256
using System;

class TEST
{
    public static void Main()
    {
        long num =long.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        long[] people = new long[num];
        long[] sabun = new long[num];

        for (int i = 0; i < num; i++)
        {
            people[i] = long.Parse(str[i]);
            sabun[i] = 0;
        }
  //      while (true)
//        {
     //   YAHOO:
            for (int i = 1; i < num; i++)
            {
                long value = (people[i] + sabun[i]) - (people[i - 1] + sabun[i - 1]);
                if (value < 0)
                {
                    sabun[i] -= value;
                 //   sabun[i]++;
                  //  goto YAHOO;
                }
   //         }
     //       break;
        }

        long ans = 0;
        foreach (long value in sabun)
        {
            ans += value;
        }
        Console.WriteLine(ans);
         //   Console.ReadKey();
    }

}

Measured memory_bytes: 50368
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {

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

        while (scanner.hasNext()) {
            final int n = scanner.nextInt();

            System.out.println(PrimeNumbers.countPrimeNumber(n));
        }
    }

    public static class PrimeNumbers {

        public static int countPrimeNumber(int endValue) {
            if (endValue <= maxCheckedValue) {
                int count = 0;
                final int size = list.size();
                for (; count < size; count++) {
                    if (list.get(count) > endValue) {
                        break;
                    }
                }
                return count;
            }

            for (int n = maxCheckedValue + 1; n <= endValue; n++) {
                if (isPrimeNumber(n)) {
                    list.add(n);
                }
            }
            maxCheckedValue = endValue;

            return list.size();
        }

        public static boolean isPrimeNumber(int value) {
            for (final int primeNumber : list) {
                if (primeNumber > Math.sqrt(value)) {
                    break;
                }
                if (value % primeNumber == 0) {
                    return false;
                }
            }

            return true;
        }

        private static List<Integer>    list = new ArrayList<Integer>();
        private static int              maxCheckedValue = 1;

    }

}

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

int p_num[1000000] = {} ;
int d[1000000] = {} ;

void cal(){
	for( int i=2 ; i<1000000 ; i++ ){
		if( p_num[i] == 0 ){
			for( int j=2 ; j<1000000 ; j++ ){
				if( i*j > 1000000 ) break ;
				p_num[i*j] = 1 ;
			}
		}
	}
	
	for( int i=2 ; i<1000000 ; i++ ){
		if( p_num[i] == 0 ) d[i] = d[i-1] +1 ;
		else d[i] = d[i-1] ;
	}
}

int main(){
	
	cal() ;
	
	int n ;
	while(1){
		cin >> n ;
		if( cin.eof() ) break ;
		
		cout << d[n] << endl ;
	}
	
return 0 ;
}

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

void swap(int *,int *);

int main()
{
  int i,j,n,flag=0,count=0,mimj=0;
  int *num;

  scanf("%d",&n);
  num=(int *)malloc(n*sizeof(int));

  for(i=0; i<n; i++)
    {
      scanf("%d",&num[i]);
    }

  //ここから並び換え作業//

  for(i=0; i<=n-2; i++)
    {
      mimj=i;
      for(j=i+1; j<=n-1; j++)
	{
	  if(num[j]<num[mimj])
	    {
	      mimj=j;
	    }
	}
      swap(&num[i],&num[mimj]);
      if(i!=mimj)
	{
	  count++;
	}
    }
  

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

  return 0;
}

void swap(int *j,int *j_1)
{
  int temp;
  temp=*j;
  *j=*j_1;
  *j_1=temp;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,l;cin>>n>>l;
  int mn=1000*1000*1000;
  int sum=0;
  for(int i=0;i<n;i++){
    int t = l+i;
    sum += t;
    if(abs(t)<abs(mn)){
      mn=t;
    }
  }
  cout<<sum-mn<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int K, even, odd, answer;
	scanf("%d", &K);
	even = K / 2;
	if (K % 2 == 0)
	{
		odd = even;
	}
	else
	{
		odd = even + 1;
	}
	answer = even * odd;
	printf("%d\n", answer);
	return 0;
}

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

def solve(N: int, A: "List[int]"):
    dictionary = collections.defaultdict(int)
    for a in A:
        dictionary[a] += 1

    counted = collections.defaultdict(int)
    for k, v in dictionary.items():
        counted[k] = v*(v-1)//2
    summarized = sum(counted.values())

    #print(counted)
    for a in A:
        v = dictionary[a]
        #print(summarized, v, v*(v-1)//2,  (v-1)*(v-2)//2)
        result = summarized - v*(v-1)//2 + (v-1)*(v-2)//2
        print(result)
    return


# Generated by 1.1.6 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()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main(){
    long long N;
    scanf("%lld",&N);

    ll ans = 0;

    for (int i = 0; i <= N; i++)
    {
        if (i%3 && i%5) ans+=i;
    }

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



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int n;string s;
    cin >> n >> s;
    ll res = 0;
    rep(i,1000){
        int i3 = i%10;
        int i2 = (i/10)%10;
        int i1 = (i/100);
        //cout << i1 << i2 << i3 << endl;
        bool b1 = false;
        bool b2 = false;
        bool b3 = false;
        rep(j,n){
            if(!b1){
                if((i1 + '0') == (s[j]))b1 = true;
            }
            else if(!b2){
                if((i2 + '0') == (s[j]))b2 = true;
            }
            else if(!b3){
                if((i3 + '0') == (s[j]))b3 = true;
            }
            if(b1 && b2 && b3){
                 res++;
                 break;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		int[] points = new int[3];
		
		for(;;)
		{
			String[] pointsStr = input.readLine().split(" ");
			
			for(int insert = 0; insert <points.length; insert++)
			{
				points[insert] = Integer.parseInt(pointsStr[insert]);
			}
			
			if((points[0] == -1)&&(points[1] == -1)&&(points[2] == -1))
			{
				break;
			}
			
			else if((points[0] == -1)||(points[1] == -1))
			{
				System.out.println("F");
			}
			
			else if(points[0] + points[1] >= 80)
			{
				System.out.println("A");
			}
			
			else if((65 <= points[0] + points[1])&&(points[0] + points[1] <80))
			{
				System.out.println("B");
			}
			
			else if(((50 <= points[0] + points[1])&&(points[0] + points[1] <65)||((30 <= points[0] + points[1])&&(points[0] + points[1] <50)&&(points[2] >=50))))
			{
				System.out.println("C");
			}
			
			else if(((30 <= points[0] + points[1])&&(points[0] + points[1] <50))&&(points[2] <50))
			{
				System.out.println("D");
			}
			
			else
			{
				System.out.println("F");
			}
		}
	}

}



Measured memory_bytes: 24116
using System;

class ABC121_A
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int H = int.Parse(input[0]);
        int W = int.Parse(input[1]);

        string[] input2 = Console.ReadLine().Split(' ');
        int h = int.Parse(input2[0]);
        int w = int.Parse(input2[1]);

        int ans = (H-h) * (W-w);

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 1000010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll A[MAXN];
int sieve[MAXN], cnt[MAXN];

ll powmod(ll a, ll b){
	if (!b) return 1;
	if (b&1) return a*powmod(a*a%mod, b>>1)%mod;
	return powmod(a*a%mod, b>>1);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	for (int i=2; i<MAXN; i++) if (!sieve[i]) for (int j=i; j<MAXN; j+=i) if (!sieve[j]) sieve[j]=i;
	
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>A[i];
		ans+=powmod(A[i], mod-2);
		for (int x=A[i]; x>1; ){
			int p=sieve[x], t=0;
			while (x%p==0) x/=p, t++;
			cnt[p]=max(cnt[p], t);
		}
	}
	ans%=mod;
	for (int i=1; i<MAXN; i++) ans=ans*powmod(i, cnt[i])%mod;
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 8192
#!/usr/bin/env python2
"""
This file is part of https://github.com/cheran-senthil/PyRival
Copyright 2019 Cheran Senthilkumar <hello@cheran.io>

"""
from __future__ import division, print_function

import itertools
import os
import sys
from atexit import register
from io import BytesIO


class dict(dict):
    """dict() -> new empty dictionary"""

    def items(self):
        """D.items() -> a set-like object providing a view on D's items"""
        return dict.iteritems(self)

    def keys(self):
        """D.keys() -> a set-like object providing a view on D's keys"""
        return dict.iterkeys(self)

    def values(self):
        """D.values() -> an object providing a view on D's values"""
        return dict.itervalues(self)


def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x


range = xrange

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')


def main():
     s = input()

     y, m, d = map(int, s.split('/'))

     if (y <= 2019) and (m <= 4) and (d <= 30):
         print('Heisei')
     else:
         print('TBD')


if __name__ == '__main__':
    main()


Measured memory_bytes: 28652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
 
 
    public static void main(String[] args) throws IOException {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] str2 = str.split(" ");
        int[] n = new int[str2.length];
        for (int i = 0; i < str2.length; i++) {
            n[i] = Integer.parseInt(str2[i]);
        }
        if(n.length == 2){
            System.out.print(n[0] * n[1] + " ");
            System.out.println((n[0] + n[1]) * 2);
 
        }
    }
}

Measured memory_bytes: 24156
#include<stdio.h>
int main()
{
  int  x, n, sa, ans;
  int min = 200000, i = 0;
  scanf("%d", &n);
  scanf("%d", &x);
  min = x;
  ans = -10000000000;
  for ( i = 1 ; i < n ; i++ ){
  	
    scanf("%d", &x);
    
      sa = x - min;
      if (min > x){
        min = x;
      }
      
      if (ans < sa ){
        ans = sa;
      }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 1840
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
left,right=0,10**12+1
a.sort()
f.sort()
# print(a)
while right-left>0:
    mid=(right+left)//2
    tmp=0
    for i in range(n):
        tmp+=max(0,a[i]-mid//f[-1-i])
    
    if tmp<=k:
        right=mid-(mid==right)
    else:
        left=mid+(mid==left)
print(right)

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

using namespace std;

constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;

int n, m, q, x, y;
array<int, MAXN> arr, brr;
string s;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> s;
    if (s.back() != 's') s.push_back('s');
    else s.push_back('e'), s.push_back('s');
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
ls = [''.join(sorted(input())) for j in range(n)]
ls = sorted(ls)

s = ls[0]
i = 1
count = 1
ans = 0
while i < n:
  if ls[i] == s:
    count += 1
    i += 1
    if i == n:
      ans += count*(count-1)//2
  else:
    ans += count*(count-1)//2
    count = 1
    s = ls[i]
    i += 1
  

print(ans)




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

int main(){
  int N,M;
  cin >>N>>M;
  
  bool can=false;
  for(int i=1;i<=10099;i++){
    if(i*8/100==N && i*10/100==M ){
      can=true;
      cout << i <<endl;
      break;
    }
  }
  if(!can){
    cout << -1 <<endl;
  }
}


Measured memory_bytes: 3628