akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  long a, b, c, d, e;

  cin >> a >> b >> c>> d>>e;

  vector<long> v = {a, b, c, d, e};

  long m = INF; 

  do {
    long time = 0;

    for (auto x:v) {
      while(time % 10) {
        time++;
      }
      time += x;
    }

    m = min(m, time);
         
  } while( next_permutation(v.begin(), v.end()) ); 

  cout << m << endl;


  return 0;
}


Measured memory_bytes: 888
import numpy

H, W= list(map(int,input().split()))
S = numpy.array(["."]*(H+2)*(W+2),dtype=str).reshape(H+2,W+2)
for i in range(1,H+1):
	S[i,:]= list("."+input()+".")

X = numpy.array([0]*(H+2)*(W+2),dtype=int).reshape(H+2,W+2)
X[S=="#"]=1

rH=range(1,H+1)
rW=range(1,W+1)
for h in rH:
	for w in rW:
		if S[h,w]==".":
			S[h,w]=numpy.sum(X[h-1:h+2, w-1:w+2])
	print(*S[h,1:-1],sep="")

Measured memory_bytes: 12856
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)

class UnionFind(n: Int) {
    data class Node(var parent: Int, var size: Int)
    val nodes = Array<Node>(n) { Node(parent = it, size = 1) }
    fun findRoot(x: Int): Int {
        if (x == nodes[x].parent) return x
        nodes[x].parent = findRoot(nodes[x].parent)
        return nodes[x].parent
    }
    fun unite(x: Int, y: Int) {
        var xRoot = findRoot(x)
        var yRoot = findRoot(y)
        if (xRoot == yRoot) return
        if (getSize(xRoot) < getSize(yRoot)) {
            nodes[xRoot].parent = yRoot
            nodes[yRoot].size += nodes[xRoot].size
        } else {
            nodes[yRoot].parent = xRoot
            nodes[xRoot].size += nodes[yRoot].size
        }
    }
    fun getSize(x: Int) = nodes[findRoot(x)].size
    fun isSame(x: Int, y: Int) = findRoot(x) == findRoot(y)
}

fun solve(N: Int, M: Int, A: IntArray, B: IntArray) {
    val uf = UnionFind(N)
    val dp = LongArray(M)
    val n = N.toLong()
    dp[M - 1] = (n * (n - 1) / 2).toLong()
    for (i in M - 2 downTo 0) {
        var node1 = A[i + 1] - 1
        var node2 = B[i + 1] - 1
        if (uf.isSame(node1, node2)){
            dp[i] = dp[i+1]
        }
        else{
            var N1 = uf.getSize(node1).toLong()
            var N2 = uf.getSize(node2).toLong()
            dp[i] = dp[i+1] - N1 * N2
            uf.unite(node1, node2)
        }
    }
    dp.forEach{ pw.println(it) }
    pw.flush()
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    val A = IntArray(M)
    val B = IntArray(M)
    for (i in 0 until M) {
        A[i] = sc.next().toInt()
        B[i] = sc.next().toInt()
    }
    solve(N, M, A, B)
}


Measured memory_bytes: 49228
MOD = 10**9+7
n = int(input())
s = input()
dp = [[0] * (n + 1) for _ in range(n + 1)]
# dp[i][j] - the number of ways to put numbers in prefix of size 'i' such that the last number is 'j'
dp[1][1] = 1
for length in range(2, n + 1):
    pref = [0] * (length + 1)
    for i in range(1, length):
        pref[i] = (pref[i - 1] + dp[length - 1][i]) % MOD
    for b in range(1, length + 1):
        l = r = 0
        if s[length - 2] == '<':
            l, r = 1, b - 1
        else:
            l, r = b, length - 1
        if l <= r:
            dp[length][b] = (dp[length][b] + (pref[r] - pref[l - 1] + MOD) % MOD) % MOD
res = sum(dp[n]) % MOD
print(res)

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

int main() {
    string N;
    string ans;
    
    //標準入力
    cin >> N;

    //7が含まれてるかを確認
    if(N[0] == '7' || N[1] == '7' || N[2] == '7') {
        ans = "Yes";
    }
    else{
        ans = "No";
    }
    
    //表準出力
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, T;
  cin >> A >> B >> T;

  int ret = 0;
  int x = 0;
  while(true){
    x += A;
    if(T < x) break;
    ret += B;
  }

  cout << ret << endl;
  return 0;
}



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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    set<string> s;
    int n;
    cin >> n;
    while(n--)
    {
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << "\n";
    return 0;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

struct cake {
    ll x, y, z;
};

ll calc(vector<cake>& C, int M, std::function<bool(const cake&, const cake&)> comp) {
    sort(C.begin(), C.end(), comp);
    ll X = 0, Y = 0, Z = 0;
    for (int i = 0; i < M; i++) {
        X += C[i].x;
        Y += C[i].y;
        Z += C[i].z;
    }
    return abs(X) + abs(Y) + abs(Z);
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<cake> C(N);
    for (int i = 0; i < N; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        C[i] = cake({x, y, z});
    }

    ll ans = 0;
    for (int n = 0; n < (1 << 3); n++) {
        int c[3];
        int temp = n;
        for (int i = 0; i < 3; i++) {
            if (temp % 2 == 1) {
                c[i] = 1;
            } else {
                c[i] = -1;
            }
            temp /= 2;
        }
        ans = max(ans, calc(C, M, [&](const cake& a, const cake& b) { return c[0] * a.x + c[1] * a.y + c[2] * a.z > c[0] * b.x + c[1] * b.y + c[2] * b.z; }));
    }
    cout << ans << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int h, w;
  cin >> h >> w;
  vector< vector<int> > a( h, vector<int>(w) );
  for(int i = 0; i < h; ++i)
  {
    for(int j = 0; j < w; ++j)
    {
      cin >> a[i][j];
    }
  }

  vector<tuple<int, int, int, int>> ans;
  for(int i = 0; i < h; ++i)
  {
    for(int j = 0; j < w; ++j)
    {
      if(a[i][j] & 1)
      {
        if (j < w - 1)
        {
          a[i][j + 1]++;
          ans.emplace_back(make_tuple(i, j, i, j + 1));
        }
        else if (i < h - 1)
        {
          a[i + 1][j]++;
          ans.emplace_back(make_tuple(i, j, i + 1, j));
        }
      }
    }
  }

  cout << ans.size() << endl;
  for(const auto& t : ans)
  {
    int x, y, ax, ay;
    tie(x, y, ax, ay) = t;
    cout << x + 1 << " " << y + 1 << " " << ax + 1 << " " << ay + 1 << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//素因数分解
vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    ll N,D; cin >> N >> D;
    ll ans=0;
    REP(i,N){
        ll X,Y; cin >> X >> Y;
        if(X*X + Y*Y <= D*D) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,m=MI()
    ac=[False]*n
    wa=[0]*n
    for _ in range(m):
        p,s=input().split()
        p=int(p)-1
        if s=="AC":
            ac[p]=True
        else:
            if not ac[p]:
                wa[p]+=1
    s=sum(wa[i] for i in range(n) if ac[i])
    print(sum(ac),s)

main()

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

#define int long long

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

int H, W;
string r[500], b[500];

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> r[i];
        b[i] = r[i];
    }
    for (int i = 0; i < W; i++) {
        r[0][i] = '#';
        b[H - 1][i] = '#';
    }
    for (int i = 0; i < H - 1; i++) {
        for (int j = 0; j < W; j += 2) {
            r[i][j] = '#';
        }
    }
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j += 2) {
            b[i][j] = '#';
        }
    }
    for (int i = 0; i < H; i++) {
        cout << r[i] << endl;
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << b[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    if (N/10 == 9 or N%10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int BubbleSort(int [],int);

int main(void){

  int i,len;
  int chenge;
  int A[MAX];


  scanf("%d",&len);

  for(i=0;i<len;i++)
    scanf("%d",&A[i]);

  chenge = BubbleSort(A,len);

  for(i=1;i<len;i++)
    printf("%d ",A[i-1]);
  printf("%d\n",A[i-1]);

  printf("%d\n",chenge);
  return 0;
}


int BubbleSort(int A[],int len){
  
  int i,j;
  int chenge=0;
  int tmp;
  
  for(i=0;i<len;i++){
    for(j=len-1;j>=i+1;j--){
      if(A[j] < A[j-1]){
	tmp = A[j-1];
	A[j-1] = A[j];
	A[j] = tmp;
	chenge++;
      }
    }
  }

  return chenge;
}

Measured memory_bytes: 600
def solve(n, x, y):
    S = set()
    for i in range(n):
        for j in range(n):
            if i != j:
                p, q = x[i]-x[j], y[i]-y[j]
                S.add((p, q))
    P = set([(x[i], y[i])for i in range(n)])
    best = n
    for p, q in S:
        total = n
        for i in range(n):
            u, v = x[i] + p, y[i] + q
            if (u, v) in P:
                total -= 1
        best = min(best, total)
    return best

n = int(input())
x = [-1] * n
y = [-1] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, x, y))

Measured memory_bytes: 3444
#include<iostream>
int main()
{
	int N, A, B, C, D;
	std::cin >> N >> A >> B >> C >> D;
	int ans1, ans2;
	if (N%A != 0) {
		ans1 = (N / A + 1)*B;
	}
	else if(N%A==0){
		ans1 = N / A * B;
	}
	if (N%C != 0) {
		ans2 = (N / C + 1)*D;
	}
	else if(N%C==0){
		ans2 = N / C * D;
	}
	if (ans1 > ans2) {
		std::cout << ans2 << std::endl;
	}
	else if (ans2 > ans1) {
		std::cout << ans1 << std::endl;
	}
	else {
		std::cout << ans1 << std::endl;
	}
	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int main() {
    string s;
    cin >> s;
    vector<char> vc;

    rep (i, s.size()) {
        if (s[i] == 'B') {
            if (vc.size() != 0) {
                vc.pop_back();
            }
        } else {
            vc.eb(s[i]);
        }
    }

    rep (i, vc.size()) {
        cout << vc[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int l1 = s1.length();
  int l2 = s2.length();
  int dp[l1+1][l2+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=l1;i++)
  {
    for(int j=1;j<=l2;j++)
    {
      	if(s1[i-1]!=s2[j-1])
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        else
          dp[i][j] = 1+dp[i-1][j-1];
        }
    }
   /* for(int i=0;i<=l1;i++)
    {
        for(int j=0;j<=l2;j++)
        cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
     int i = l1, j=l2;
     string s = "";
     while(i>0&&j>0)
     {

     if( s1[i-1]==s2[j-1])
	 {
       s += s1[i-1];
       i--,j--;
     }
	 else if(dp[i-1][j]>dp[i][j-1])
     i--;
       else
         j--;
     }
     reverse(s.begin(),s.end());
      cout<<s<<endl;
           return 0;
           
  
}

Measured memory_bytes: 38800
#include<iostream>

using namespace std;


int main(void) {
    int N;
    int A[200];
    int flag=1, count = 0;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    while (flag) {
        for (int i=0; i<N; i++) {
            if (A[i] % 2 == 0) {
                A[i] = A[i]/2;
            }
            else {
                flag = 0;
            }

            if (i==N-1 && flag==1) {
                count += 1;
            }
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
	int k, s, cnt = 0;
	scanf("%d %d", &k, &s);
	for(int i = 0; i <= k; i++) {
		for(int j = 0; j <= k; j++) {
			int t = s - i - j;
			if(t >= 0 && t <= k)
				cnt++; 
		}
	}
		
	printf("%d\n", cnt);
	return 0;
} 

Measured memory_bytes: 128
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
acdic={}

for i in range(m):
    #p,s=map(str,input().split())
    li = input().split()
    p=int(li[0])
    s=li[1]
    #p=int(p)
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:#もしACなら
        #acdic[p]=True
        if acdic.get(p,False)==False:
            ac+=1
            acdic[p]=True
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))



Measured memory_bytes: 15100
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int64_t A,B,C,K;
    cin >> A >> B >> C >> K;
    if(abs(A-B)>10e18) 
    {
        cout << "Unfair" << endl;
    return 0;
    }
    if(K%2==0) cout << A-B << endl;
    else
    {
        cout << B-A << endl;
    }
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro m = new Magatro();
        m.Scan();
        m.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;

    private const char Separator=' ';

    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[]LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }

    public bool ScanToEnd(ref string s)
    {
        if (Sr.EndOfStream)
        {
            return false;
        }
        else
        {
            s = Sr.ReadLine();
            return true;
        }
    }
}

public class Magatro
{
    private int N;
    private string S;

    public void Scan()
    {
        Scanner sc = new Scanner();
        N = sc.NextInt();
        S = sc.Next();
    }

    public void Solve()
    {
        int x = 0;
        int ans = 0 ;
        for(int i = 0; i < N; i++)
        {
            switch (S[i])
            {
                case 'I':
                    x++;
                    break;
                case 'D':
                    x--;
                    break;
                default:
                    throw new Exception();
            }
            ans = Math.Max(ans, x);
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 2648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	ll n=s.size();
	ll out=n*(n-1)/2;
	vi co(26);
	rep(i,n)co[s[i]-'a']++;
	rep(i,26)out-=(ll)co[i]*(co[i]-1)/2;
	cout<<out+1<<endl;
}








Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n;
int main()
{
    cin>>n;
    cout<<(ll)n*(n-1)/2;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int k, x;
  cin>>k>>x;
  cout<<(500*k>=x ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

// Binary indexed Tree(BIT)
template <typename T>
struct BIT{
    private:
    vector<T> array;
    const int n;

    public:
    // 初期化
    BIT(int _n) : array(_n+1,0),n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            // LSB減算
            i -= i & -i;
        }
        return s;
    }
    
    // [i,j]の要素の総和
    T sum(int i,int j){
        // 1番目からi-1番目までの総和
        T ret_i = sum(i-1);
        // 1番目からj番目までの総和
        T ret_j = sum(j);
        // i番目からj番目までの総和
        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i,T x){
        while(i <= n){
            array[i] += x;
            // LSB加算
            i += i & -i;
        }
    }
};

int main() {
    long long N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
    int low = 0, high = 1<<30;
    const int geta = N+1;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        long long num = 0;
        BIT<long long> bit(N*2+10);
        int sum = 0;
        bit.add(sum+geta, 1);
        for (int i = 0; i < N; ++i) {
            int val;
            if (a[i] <= mid) val = 1; else val = -1;
            sum += val;
            num += bit.sum(1, sum+geta-1);
            bit.add(sum+geta, 1);
        }
        if (num > (N+1)*N/2/2) high = mid;
        else low = mid;
    }
    cout << high << endl;
}

Measured memory_bytes: 2176
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n;
int main()
{
    fast;
    cin>>n;
    cout<<48-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, max = -1;
	string s;
	map<string, int> res;
	
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> s;
		res[s]++;
		max = (res[s] > max) ? res[s] : max;
	}
	
	for (auto r: res) {
		if (r.second == max) cout << (r.first) << endl;
	}
	
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, l;
    cin >> n >> l;
    vs s(n);
    rep(i, n) cin >> s[i];
    VSORT(s);
    string ans;
    rep(i, n) ans += s[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	tmp = factorize(N)
	ans = 0

	for i,val in enumerate(tmp):
		sosuu,kai = val

		tmtmtm = 1
		con = 2
		while True:
			if kai < tmtmtm:
				break
			ans += 1
			tmtmtm += con
			con += 1

	print(ans)

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

if __name__ == "__main__":
	main()


Measured memory_bytes: 72616
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W;
  cin >> H >> W;

  vector<string> s(H);
  REP(i, H) cin >> s[i];


  vector<vector<int>> A(H, vector<int>(W, 0));
  vector<vector<int>> B(H, vector<int>(W, 0));

  REP(i, H) REP(j, W){
    if(s[i][j] == '#') continue;
    A[i][j] = 1;
    if(i != 0) A[i][j] += A[i-1][j];
  }
  RREP(i, H-1) REP(j, W){
    if(s[i][j] == '#') continue;
    chmax(A[i][j], A[i+1][j]);
  }

  REP(i, H) REP(j, W){
    if(s[i][j] == '#') continue;
    B[i][j] = 1;
    if(j != 0) B[i][j] += B[i][j-1];
  }
  REP(i, H) RREP(j, W-1){
    if(s[i][j] == '#') continue;
    chmax(B[i][j], B[i][j+1]);
  }

  int ans = 0;
  REP(i, H) REP(j, W){
    if(s[i][j] == '#') continue;
    chmax(ans, A[i][j]+B[i][j]-1);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 67200
/*

*/
#include <bits/stdc++.h>

using namespace std;

#define ll           long long int
#define vi 			 vector<int>
#define pb           push_back
#define fi           first
#define si           second
#define pii 		 pair<int,int>
#define vii 		 vector<pair<int,int>>
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define mem(a,b)     memset(a, b, sizeof a)
#define matrix(x) 	 vector<vector<x>>
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;

void func(){
	ll a[2], b[2];
	F(a, 2);
	F(b, 2);
	ll ans=-1e18;
	for(int i=0; i<2; i++){
		for(int j=0; j<2; j++){
			ans = max(ans, a[i]*b[j]);
		}
	}
	cout<<ans;
}

int main(){
	fastIO
	int t=1;//cin>>t;
	while(t--){
		func();
	}
}

Measured memory_bytes: 3648
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
#include<chrono>
#include <fstream>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}*/
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x);

		y = y >> 1;
		x = (x * x);
	}
	return res;
}


/*ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}*/

ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}
ll sum_digit(ll n)
{
	ll ans = 0;
	while (n)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll n;
	cin>>n;
	ll curr=0;
	string ans="No";
	f(i,0,n)
	{
		ll a,b;
		cin>>a>>b;
		if(a==b)
		{
			curr+=1;
		}
		else
		{
			if(curr>=3)
			{
				ans="Yes";
			}
			curr=0;
		}
	}
	if(curr>=3)
		ans="Yes";
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	ll X, ans = 0;
	cin >> X;
	ans += (X/500) * 1000;
	X %= 500;
	ans += (X/5) * 5;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3548
// Author: droftware
#include <bits/stdc++.h>

#define forn(i,a,n) for(int i=a;i<(int)n;i++)
#define DRT()  int t; cin>>t; while(t--)

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
using namespace std;

const int N = 3e3+5;

int nums[N];
long long dp[N][N];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	forn(i,0,n){
		cin>>nums[i];
	}
	for(int i = n-1; i >= 0; --i){
		for(int j = i; j < n; ++j){
			if(i == j){
				dp[i][j] = nums[i];
			} else {
				dp[i][j] = max(nums[i] - dp[i+1][j], nums[j] - dp[i][j-1]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
}
	
	



Measured memory_bytes: 70016
s=input()
s_len=len(s)
n=2019
sp=[0]*n
sp[0]=1
p=1
d=0
for i in reversed(s):
    d+=int(i)*p
    m=d%n
    sp[m]+=1
    p*=10
    p%=2019
result=sum(i*(i-1)//2 for i in sp)
print(result)

Measured memory_bytes: 9216
#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 X, Y; cin >> X >> Y;
    ll ans = 1;
    while(X <= Y){
        X *= 2;
        if(X <= Y){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;
stack<int> s;
int main() {
	char inp[100010];
	int a[100010];
	int cnt0 = 0;
	int cnt1 = 0;
	scanf("%s", inp);
	int len = strlen(inp);
	for (int i = 0; i < len; i++) {
		a[i] = inp[i] - '0';
		if (a[i] == 0)
			cnt0++;
		else
			cnt1++;
	}
	printf("%d\n", min(cnt0, cnt1) * 2);
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] input = sc.next().toCharArray();
    int n = input.length;
    boolean bl = true;
    for(int i = 0; i < (n - 1) / 2; i++){
      bl &= (input[i] == input[n - 1 - i]);
    }
    for(int i = 0; i < (n - 1) / 4; i++){
      bl &= (input[i] == input[(n - 1) / 2 - 1 -i]);
      
    }
    if(bl){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
} 

Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007LL;
struct SegTree {
	vector<LL> dat[(1 << 19) - 1];
	void init(int k, int l, int r, LL A[], int N) {
		if (r - l == 1) {
			dat[k].push_back(A[l]);
		}
		else {
			int lch = k * 2 + 1, rch = k * 2 + 2;
			init(lch, l, (l + r) / 2, A, N);
			init(rch, (l + r) / 2, r, A, N);
			dat[k].resize(r - l);
			merge(dat[lch].begin(), dat[lch].end(), dat[rch].begin(), dat[rch].end(), dat[k].begin());
		}
	}
	int query(int i, int j, LL x, int k, int l, int r) {
		if (j <= l || r <= i) return 0;
		if (i <= l && r <= j) {
			return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
		}
		int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
		int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
		return lc + rc;
	}
};
LL A[200000];
SegTree s;
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i], A[i] -= K;
	for (int i = 1; i < N; i++) A[i] += A[i - 1];
	s.init(0, 0, N, A, N);
	LL ans = 0;
	for (int i = 0; i < N; i++) if (A[i] >= 0) ans++;
	for (int i = 1; i < N; i++) {
		ans += s.query(0, i, A[i], 0, 0, N);
	}
	cout << ans << endl;
}

Measured memory_bytes: 50560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    string s;
    //int flat=1;
    //for(int i=0; i<s.size(); i++)
    cin>>s;
    cout<<s.rfind('Z')-s.find('A')+1<<endl;
return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    vector<bool> dp(a[n - 1] + 1, true);
    int tmp = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == tmp) dp[a[i]] = false;
        for (int j = 2; a[i] * j <= a[n - 1]; j++) {
            dp[a[i] * j] = false;
        }
        tmp = a[i];
    }
    int cnt = 0;
    for (int itr : a) {
        if (dp[itr] == true) cnt++;
    }
    cout << cnt << endl;
}

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

int main(void){
    vector<int> vec(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    sort(vec.begin(), vec.end());
    cout << vec[0] << " " << vec[1] << " " << vec[2] << endl;
    return 0;
}


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

int main(){
  while(1){
  int n,m;
  cin>>n>>m;
  if(n+m==0) break;
  int an,p[1001]={},a[1001];
  for(int i=0;i<n;i++)
    for(int j=1;j<=m;j++)cin>>an,p[j]+=an;
  for(int i=1;i<=m;i++){
    int  ma=-1;
    for(int j=1;j<=m;j++)if(ma<p[j])a[i]=j,ma=p[j];
    p[a[i]]=-1;
  }
  for(int i=1;i<m;i++)cout<<a[i]<<" ";
  cout<<a[m]<<endl;
  }
  return 0;
}

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

namespace AtCoder.Contests.AGC044
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var ps = ReadIntArray();
            var nn = new bool[n + 2, n + 2];

            var mm = new int[n + 2, n + 2];

            for (int i = 2; i < n; i++)
            {
                for (int j = 2; j < n; j++)
                {
                    mm[i, j] = Math.Min(Math.Min(i - 1, n - i), Math.Min(j - 1, n - j));
                }
            }

            long sum = 0;
            var q = new Queue<P>();
            for (int i = 0; i < n * n; i++)
            {
                var pp = ps[i];
                var p = new P((pp-1) / n + 1,(pp-1) % n + 1);

                sum += mm[p.x, p.y];
                nn[p.x, p.y] = true;

                q.Enqueue(p);

                while (q.Count > 0)
                {
                    var c = q.Dequeue();
                    var x = c.x;
                    var y = c.y;
                    var cc = mm[x, y] + (nn[x, y] ? 0 : 1);
                    
                    if (x > 1 && mm[x - 1, y] > cc)
                    {
                        mm[x - 1, y] = cc;
                        q.Enqueue(new P(x - 1, y));
                    }
                    if (x < n && mm[x + 1, y] > cc)
                    {
                        mm[x + 1, y] = cc;
                        q.Enqueue(new P(x + 1, y));
                    }
                    if (y > 1 && mm[x, y - 1] > cc)
                    {
                        mm[x, y - 1] = cc;
                        q.Enqueue(new P(x, y - 1));
                    }
                    if (y < n && mm[x, y + 1] > cc)
                    {
                        mm[x, y + 1] = cc;
                        q.Enqueue(new P(x, y + 1));
                    }
                }
            }

            Console.WriteLine(sum);
        }
        class P
        {
            public int x;
            public int y;

            public P(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        #endregion
    }
}


Measured memory_bytes: 64688
#include "stdio.h"

int main()
{
	char c[5];
	scanf("%s", &c);
	if ((c[0] == c[1] && c[2] == c[3]&&c[0]!=c[2]) || (c[0] == c[2] && c[1] == c[3] && c[0] != c[1]) || (c[0] == c[3] && c[1] == c[2] && c[0] != c[1]))printf("Yes");
	else printf("No");
	
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int, int>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<int> P(N), Q(N), tmp(N);
  REP(i, N) cin >> P[i];
  REP(i, N) cin >> Q[i];
  REP(i, N) tmp[i] = i + 1;
  int a, b, res;
  do {
    res++;
    for(int i = 0; i < N; ++i) {
      if(P[i] != tmp[i]) break;
      if(i == N - 1) a = res;
    }
    for(int i = 0; i < N; ++i) {
      if(Q[i] != tmp[i]) break;
      if(i == N - 1) b = res;
    }
  } while (next_permutation(tmp.begin(), tmp.end()));
  cout << abs(a - b) << endl;
}

Measured memory_bytes: 3600
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := make([]string, n)
	var flag int
	mid := n / 2

	if n%2 == 0 {
		flag = -1
	} else {
		flag = 1
	}

	for i := 0; i < n; i++ {
		var tmp string
		fmt.Scanf("%s", &tmp)
		if i%2 == 0 {
			ans[mid-flag*(i/2)] = tmp
		} else {
			ans[mid+flag*(i/2+1)] = tmp
		}
	}
	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 17920
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
 
R += sorted(P)[-X:]
R += sorted(Q)[-Y:]
ans = sum(sorted(R)[-(X+Y):])
print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=100005;
int n,ans;
int pre[N],suf[N];
pii a[N];
int main(){
	scanf("%d",&n);
	int mn=1<<30,mx=0,l=0;
	For(i,1,n){	
		scanf("%d%d",&a[i].fi,&a[i].se);
		mn=min(mn,++a[i].se);
		mx=max(mx,a[i].fi);
		l=max(l,a[i].se-a[i].fi);
	}
	ans=max(mn-mx,0)+l;
	sort(a+1,a+n+1);
	suf[n+1]=1<<30;
	Rep(i,n,1) suf[i]=min(suf[i+1],a[i].se);
	For(i,1,n) pre[i]=max(pre[i-1],a[i].fi);
	For(i,1,n-1) ans=max(ans,max(mn-pre[i],0)+max(suf[i+1]-mx,0));
	printf("%d\n",ans);
}

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

int main() {
  string A;
  cin >> A;
  if(A == "RRR") {
    cout << "3" << endl;
  }
  else if (A == "RRS" || A == "SRR"){
    cout << "2" << endl;
  }
  else if(A == "SSS") {
    cout << "0" << endl;
  }
  else {
    cout << "1" << endl;
  }
}


Measured memory_bytes: 3620