akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader(Console.In);
            var N = consoleReader.Int;

            var items = consoleReader.Repeat(N).String
            .Select(x => new string(x.OrderBy(c => c).ToArray()))
            .GroupBy(x => x)
            .Select(g => (long)g.Count());
            long count = 0;

            foreach (var i in items)
            {
                if (i > 1)
                {
                    count += i * (i - 1) / 2;
                }
            }


            Console.WriteLine(count);
        }
    }

    class ConsoleReader
    {
        private StringBuilder sb = new StringBuilder(4096);
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                return textReader.ReadLine();
            }
        }


        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : (x))
#define all(x) x.begin(), x.end() // sort(all(x))
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair((x), (y))

typedef long long ll;

typedef double T;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<T> vt;
typedef vector<vt> vvt;
typedef vector<pii> vpi;
typedef vector<pii> vpl;
typedef vector<vpi> graph;
typedef complex<T> Pt;
typedef pair<Pt, Pt> Line;

const ll MOD = 1000; // 998244353;
const T EPS = 1e-10;
const int INF = 1e9 + 1;

/* Mod Library */

struct Mod {
    ll x;
    Mod (ll x = 0) : x(x) {}
    Mod operator+(Mod b) { return Mod((x + b.x)%MOD); }
    Mod operator-(Mod b) { return Mod((x - b.x + MOD)%MOD); }
    Mod operator*(Mod b) { return Mod((x * b.x)%MOD); }
    Mod operator/(Mod b) { return *this * inverse(b); }
    Mod operator%(Mod b) { return Mod(x % b.x); }

    ll euclid(ll a, ll b, ll &x, ll &y) {
        if (b) {
            ll d = euclid(b, a%b, y, x);
            y -= a/b*x;
            return d;
        }
        x = 1; 
        y = 0;
        return a;
    }
    
    Mod inverse(Mod a) {
        ll x, y, g = euclid(a.x, MOD, x, y);
        assert(g == 1);
        return Mod((x + MOD)%MOD);
    }

    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this^(e/2);
        r = r*r;
        return e&1 ? *this*r : r;
    }
};

/* Input Library */
template <typename A, typename B>
istream& operator>>(istream &in, pair<A, B> &p) {
    in >> p.first >> p.second;
    return in;
}

template <typename A, typename B>
ostream& operator<<(ostream &out, pair<A, B> &p) {
    out << p.first << " " << p.second;
    return out;
}

template <typename I>
istream& operator>>(istream &in, vector<I> &a) {
    trav(i, a) in >> i;
    return in;
}

template <typename I>
ostream& operator<<(ostream &out, vector<I> &a) {
    rep(i, 0, sz(a)) {
        if (i) out << " ";
        out << a[i];
    }
    return out;
}

void fast_io() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //cout.tie(0);
    cin.exceptions(cin.failbit);
}

/* Solution */

void solve_test() {
    int a, b;
    cin >> a >> b;

    int ans = 0, s = 1;
    while (s < b) {
        ans++;
        s += a-1;
    }
    cout << ans << endl;
}

void setup() {

}

int main() {
    setup();
    srand(time(0));
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) {
        solve_test();
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import itertools
import sys
import math

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n > 36:
        print(0)
        continue
    cnt = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - (a + b + c)
                if 0 <= d and d <= 9:
                    cnt += 1
    print(cnt)

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


int main(){
    int n; cin >> n;
    vector<int> b(n-1);
    vector<int> a(n);
    rep(i,n-1) cin >> b[i];
    a[0] = b[0];
    for(int i=1;i<=n-2;i++){
        a[i] = min(b[i], b[i-1]);
    }
    a[n-1] = b[n-2];
    int ans=0;
    rep(i,n) ans += a[i];
    cout << ans;
}

Measured memory_bytes: 256
H=int(input())

N=100
p=[1]*(N+1)
for i in range(N):
    p[i+1]=p[i]*2
    
index=0
for i in range(N):
    if H==p[1]:
        index=i
    if H<p[i]:
        index=i-1
        break
        
print(p[index+1]-1)

Measured memory_bytes: 38384
import java.util.*;

class Main {
        private static int N, K;
        private static List<Integer>[] vec;
        private static int ans;
        public static void main(String args[]) {
                new Thread(null, () -> {
                        Scanner sc = new Scanner(System.in);
                        N = sc.nextInt();
                        K = sc.nextInt();
                        ans = 0;
                        vec = new ArrayList[N];
                        for (int i = 0; i < N; i++) {
                                vec[i] = new ArrayList<>(0);
                        }
                        for (int i = 0; i < N; i++) {
                                int a = sc.nextInt() - 1;
                                if (i != 0) {
                                        vec[a].add(i);
                                } else {
                                        if (a != 0) {
                                                ans++;
                                        }
                                }
                        }
                        dfs(0, 0);


                        System.out.println(ans);
                }, "", 1<<24).start();
        }
        private static int dfs(int v, int pre){
                int hight = 0;
                for (int j = 0; j < vec[v].size(); j++) {
                        hight = Math.max(hight, dfs(vec[v].get(j), v));
                }
                if (pre != 0 && hight == K - 1) {
                        hight = 0;
                        ans++;
                } else {
                        hight++;
                }
                return hight;
        }
}

Measured memory_bytes: 40932
#include <bits/stdc++.h>
#define N 101
using namespace std;
int v[N],w[N],m[N];

int Max(int &a,int b){return a=max(a,b);}

int main(){
  int n,W;
  cin>>n>>W;

  for(int i=0;i<n;i++)cin>>v[i]>>w[i]>>m[i];

  vector<int> dp(W+1,0);
  for(int i=0;i<n;i++){
    int num = m[i];
    for(int j=1;num>0;num-=j,j=min(j*2,num))
      for(int k=W;k>=j*w[i];k--) Max(dp[k],dp[k-j*w[i]]+j*v[i]);
  }

  int ans = 0;
  for(int i=0;i<=W;i++)  Max(ans,dp[i]);
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3108
import fractions
a,b,c,d=map(int,input().split())
b_n=b//c+b//d-b//(c*d//fractions.gcd(c,d))
a_n=(a-1)//c+(a-1)//d-(a-1)//(c*d//fractions.gcd(c,d))
print((b-a+1)-(b_n-a_n))

Measured memory_bytes: 5048
# -*- coding: utf-8 -*-

a = int(input())#500
b = int(input())#100
c = int(input())#50
x = int(input())

counter = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            s = 500*i + 100*j + 50*k
            if s == x:
                counter += 1
print(counter)


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

int main(){
    int n, b, f, r, v;
    cin >> n;
    int rooms[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                rooms[i][j][k] = 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        rooms[b-1][f-1][r-1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << rooms[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int dp[100100][3];


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

	int N; cin >> N;
	vector<Vi> happy(N, Vi(3));

	for (int i = 0; i < N; ++i) {
		cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
	}

	memset(dp, 0, sizeof(dp));
	
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + happy[i - 1][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		ans = max(ans, dp[N][i]);
	}

	cout << ans << endl;

	return 0;
}

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

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

	string ans = "AB";	
	ans += (n < 1000) ? "C" : "D";

	/*
	if (n >= 1000) {
		n = n - 1000 + 1;
	}

	if (n < 10) {
		ans += "00";
	}
	else if (n < 100) {
		ans += "0";
	}

	ans += to_string(n);
	*/
	
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list()
B = list()
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort(reverse=True)
if N%2 == 1:
    print(B[(N+1)//2 - 1] - A[(N+1)//2 - 1] + 1)
else:
    print((B[(N+1)//2 - 1] - A[(N+1)//2 - 1]) + (B[(N+1)//2] - A[(N+1)//2]) + 1)


Measured memory_bytes: 25544
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int area[2][102];
	for(int i=0; i<2; i++){
		for(int j=0; j<n; j++){
			cin >> area[i][j];
		}
	}
	for(int i=1; i<n; i++){
		area[0][i]+=area[0][i-1];
	}
	area[1][0]+=area[0][0];
	for(int i=1; i<n; i++){
		area[1][i]+=max(area[0][i],area[1][i-1]);
	}
	cout << area[1][n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define forn(i, n) for(lli i=0; i<n; i++)
#define forn1(i, n) for(lli i=1; i<n; i++)
#define elif else if
#define lli long long int
#define _USE_MATH_DEFINES
#define _x first
#define _y second

#define _CRT_SECURE_NO_WARNINGS



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

#include <stdlib.h>
#include <limits.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <numeric>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <list>
#include <sstream>

#include <random>
#include <typeinfo>

using namespace std;

//Constant vars

const lli MOD = 1000000007, LIM = 4294967295;

//Vars

lli n, m, a, b, c, d, q, k, tr, summ, ans, minx, maxx, l, r, mid, l1, r1, mid1, res, mass1[1000000], mass2[1000000], mass3[100000], mass[200001];

string s, trs, str;

//Structures

set<lli> g, bb, all;
set<lli> myset;
vector<lli> myvec, toWrite;
vector<vector<lli>> mvv;
queue<lli> myq;
map<lli, lli> mymap, mymap1, mymap2;
map<lli, vector<lli>> mymapvec;
multiset<lli> mmset;
unordered_map<string, lli> smap;





int compare(const void * a, const void * b) {

	return -((*(lli*)a) - (*(lli*)b));

};

lli gcd(lli a, lli b) {

	while (b != 0) {

		lli t = b;
		b = a % b;
		a = t;

	}

	return a;

}

lli gcdex(lli a, lli b, lli & x, lli & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	lli x1, y1;
	lli d = gcdex(b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}

lli NOK(lli n1, lli n2) {

	return n1 * n2 / gcd(n1, n2);

}

lli bin_pow(lli base, lli p) {
	if (p == 1) {
		return base % MOD;
	}
	if (p == 0) {
		return 1;
	}

	if (p % 2 == 0) {
		lli t = bin_pow(base, p / 2) % MOD;
		return t * t % MOD;
	}
	else {
		return bin_pow(base, p - 1) * base % MOD;
	}
}

lli inverse_element(lli x) {
	return bin_pow(x, MOD - 2);
}


lli divide(lli a, lli b) {
	return a * inverse_element(b) % MOD;
}


double rec(lli a, lli b) {

	return rec(a, b);

}

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("testlist.txt", "w", stdout);

	ios::sync_with_stdio(0);
	cin.tie();

	for (lli i = 2; i < 1e6 + 1; i++) {

		if (mass1[i] == 0) {

			for (lli j = i * i; j < 1e6 + 1; j += i) {

				mass1[j] = 1;

			}

			mymap2[i] = 1;

		}

	}

	cin >> n;

	forn(i, n) {

		cin >> mass[i];

		mass2[mass[i]]++;

	}

	summ = n;

	forn(i, n) {

		mymap1.clear();

		a = min((lli)sqrt(mass[i]) + 3, mass[i] - 1);


		if (mass[i] == 1) {

			if (mass2[mass[i]] > 1) {

				summ--;
				continue;

			}
			else {

				continue;

			}

		}

		if (mass2[mass[i]] >= 2 || mass2[1] >= 1) {

			summ--;
			continue;

		}

		if (mymap2[mass[i]] == 1) {

			continue;

		}

		for (lli j = 2; j <= a; j++) {

			if (mass[i] % j == 0) {

				if (mass2[j] >= 1 || mass2[mass[i] / j] >= 1) {

					summ--;
					break;

				}

			}

		}

	}

	cout << summ;

	return 0;
}
//


Measured memory_bytes: 35168
open System


[<EntryPoint>]
let main argv =
    let N = stdin.ReadLine()|>int64
    [for i in [1..(N|>double|>sqrt|>floor|>int)] do yield (if N%(i|>int64)<>0L then 10000000000000L else (N/(i|>int64))+(i|>int64)-(2L))]
    |>List.min
    |>stdout.WriteLine
    0

Measured memory_bytes: 81440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  string r = "Yes";
  
  for (int i = 0; i < N; i++)
    cin >> h.at(i);
  
  for (int i = 0; i < N - 1; i++) {
    
      if (h.at(i) > h.at(i+1) + 1) {
        r = "No";
        break;
      }
    
      else if (h.at(i) == h.at(i+1)+1) 
        h.at(i+1) += 1;
    
    
    if (r == "No")
      break;
  }  
  cout << r << endl;
}

Measured memory_bytes: 640
/**
 * Grading.cpp
 * Create:20180425
 * Description:大文字と小文字を入れ替える。
 */
#include <iostream>
#include <stdio.h>
#include <ctype.h>

int main(int argc, char* argv[]){
  std::string input;
  std::getline(std::cin, input);

  for (char c:input){
    if (std::islower(c)) {
      printf("%c", toupper(c));
    } else if (std::isupper(c)) {
      printf("%c", tolower(c));
    } else {
      printf("%c", c);
    }
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3156
n = int(input())
dp = ["3"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp[i]+c)>n:
            brk = True
            break
        dp.append(dp[i]+c)
        
dp2 = ["5"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp2[i]+c)>n:
            brk = True
            break
        dp2.append(dp2[i]+c)

dp3 = ["7"]
brk = False
for i in range(n):
    if brk == True:
        break
    for c in "357":
        if int(dp3[i]+c)>n:
            brk = True
            break
        dp3.append(dp3[i]+c)

dp = dp+dp2+dp3
count = 0
for i in range(len(dp)):
    if all(dp[i].count(c) for c in "753"):
        count += 1
print(count)

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

using namespace std;

int main() {

	int n,h;
	cin >> n >> h;

	vector<pair<int,int>> a(n, pair<int,int> ());
	vector<int> b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
		b[i] = a[i].second;

	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int abeqcount = 0;
	for (int i = 0; i < n; i++) {
		if (a[n - 1].second == b[i]) {
			abeqcount++;
		}
	}
	int counter = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (b[i] < a[n - 1].first) { break; }
		else {
			h -=b[i];
			counter++;
			if (h <= 0) { cout << counter << endl; return 0; }
		}
	}


	counter += h / a[n - 1].first+ (h % a[n - 1].first!=0? 1 : 0);

	cout << counter << endl;

}

Measured memory_bytes: 1408
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>


int main(){
	int A1,A2,A3;
	scanf("%d%d%d",&A1,&A2,&A3);
	int min = 1001;
	int max = 0;
	if(A1<min)min=A1;
	if(A1>max)max=A1;
	if(A2<min)min=A2;
	if(A2>max)max=A2;
	if(A3<min)min=A3;
	if(A3>max)max=A3;
	
	int a = max-min;
	
	printf("%d",a);	
	return 0;
}

Measured memory_bytes: 128
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
    int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>a>>b>>c;
     if(b-a==c-b){
        cout<<"YES"<<endl;
     }
     else{
        cout<<"NO"<<endl;
     }
     return EXIT_SUCCESS;
}


Measured memory_bytes: 256
n, m = gets.split().map(&:to_i)
c = []
d = []
f = false
m.times do |i|
  a, b = gets.split().map(&:to_i)
  if a == 1
    c.push(b)
  end
  if a == n
    d.push(b)
  end
  if b == 1
    c.push(a)
  end
  if b == n
    d.push(a)
  end
end
e = c & d
if e.length > 0
  puts "POSSIBLE"
else
  puts "IMPOSSIBLE"
end

Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
vector<int>adj[100];
int visited[100];
void bfs(int s,int n)
{
    for(int i=0; i<n; i++)
    {
        visited[i]=0;
        queue<int>Q;
        Q.push(s);
        visited[s]=1;
        while(!Q.empty())
        {
            int u=Q.front();
            Q.pop();
            for(int i=0; i<adj[u].size(); i++)
            {
                if(visited[adj[u][i]]==0)
                {
                    int v=adj[u][i];
                    visited[v]=1;
                    Q.push(v);
                }
            }
        }
    }
}
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}

bool prime(int n)
{
    if(n<=1)
    {
        return 0;
    }
    for(int i=2; i*i<sqrt(n); i++)
    {
        if(n%i==0)
        {
            return 0;
        }
        return 1;
    }
}
long convert(int n)
{
    long binary = 0;
    int i = 1;
    //converting decimal to binary
    while (n!=0)
    {
        int rem = n%2;
        n /= 2;
        binary += rem*i;
        i *= 10;
    }
    return binary;
}
int binarySearch(int arr[], int lo, int hi, int x)
{
    if (hi >= lo)
    {
        int mid = lo + (hi - lo) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, lo, mid - 1, x);
        return binarySearch(arr, mid + 1, hi, x);
    }
    return -1;
}


int main()

{
        string s,t;
        cin>>s>>t;
        t+=s;
        cout<<t<<endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
ary = [list(map(str, list(input().split()))) for i in range(H)]
ary_d = []
for i in range(H):
    ary_d.append(ary[i])
    ary_d.append(ary[i])


print('\n'.join(''.join([str(j) for j in i]) for i in ary_d))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

//#define DEBUG

int main() {
    ll h;
    cin >> h;
    int n = 0;
    while(h >= 1) {
        h = h >> 1;
        n++;
    }
    cout << (ll)powl(2, n) - 1 << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		int n = Integer.parseInt(br.readLine());
		List<Integer> S = new ArrayList<Integer>();
		String[] line_S = br.readLine().split(" ");
		for (String str : line_S)
			S.add(Integer.parseInt(str));
		int q = Integer.parseInt(br.readLine());
		List<Integer> T = new ArrayList<Integer>();
		String[] line_T = br.readLine().split(" ");
		for (String str : line_T)
			T.add(Integer.parseInt(str));
		
		int C = 0;
		for (int t : T)
			for (int s : S)
				if (s == t) {
					C++;
					break;
				}
		
		System.out.println(C);
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

/*
0-index
functionの中を書いて使う
宣言の時に単位元を書く
*/
template<typename T>
class segtree{
	int n;vector<T> dat;T ZERO;
public:
	segtree(int n_,T zero):ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}
	void update(int k, int a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = function(dat[k*2+1],dat[k*2+2]);
	  }
	}
	
	T function(T a,T b){
		return a + b;
	}
	
	T get(int k){return dat[k+n-1];}
	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = function(L,dat[A++]);
            if((B & 1) == 0)R = function(R,dat[--B]);
            A = A >> 1;
            B = B >> 1;
		}
		return function(L,R);
	}
};

int main(){
	
	int n;cin >> n;
	vector<pair<int,int>> v(n);
	REP(i,n){
		cin >> v[i].FI;
		v[i].SE = i;
	}
	sort(ALL(v),greater<pair<int,int>>());
	
	ll ans = 0;
	segtree<int> seg(n,0);
	
	int num = 0;
	while(num < n){
		vector<pair<int,int>> now;
		now.PB(v[num]);
		while(num < n && v[num].FI == v[num+1].FI){
			now.PB(v[num + 1]);
			num++;
		}
		REP(i,now.size()){
			ans += min(seg.que(0,now[i].SE), seg.que(now[i].SE, n));
		}
		REP(i,now.size()){
			seg.update(now[i].SE, 1);
		}
		num++;
	}
	
	cout << ans << endl;
		
	
	return 0;
}



Measured memory_bytes: 5544
#include "bits/stdc++.h"
#include <random>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll D=365;
vi c(26);
vi last(26,-1);
vvi dat(D, vi(26));  // N * M の2次元配列
vvi AAlist(D, vi(D));  // N * M の2次元配列




ll calcscore(vi &Alist)
{
  for(ll i=0;i<26;i++){
    last[i]=-1;
  }
  

  ll sc=0;
  ll sct=0;
  ll l;
  ll id;
  ll factscore=0;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    for(ll j=0;j<26;j++){
      if (Alist[i]==j)continue;
      l=i-last[j];
      sct=l*c[j];
      factscore-=sct;
    }

    id=Alist[i];
    factscore+=dat[i][id];
    last[id]=i;
  }

  return factscore;
}



void makeseed(int xid,int startoffset)
{

  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  ll factscore=0;
  
  for(ll i=0;i<26;i++){
    last[i]=startoffset-1;
  }

  for(ll i=startoffset;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    
    for(ll j=0;j<26;j++){
      ll l=i-last[j];
      
      l*=(l-1-l/2);
      sct=l*c[j];
      factscore-=sct;
      sct=dat[i][j]+sct;
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    factscore+=sc;
    last[maxid]=i;
    AAlist[startoffset][i]=maxid;
    //cout<<(maxid+1)<<endl;
  }


}





int main(){
  ll ans=0;
  ll debug=0;//本番では0に
  cin>>ans;
  ll factscore=0;


  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>dat[i][j];
    }
  }


  for(ll i=0;i<D;i++){
    makeseed(0,i);
  }
  



  for(ll i=1;i<D;i++){
    for(ll j=0;j<i;j++){
      AAlist[i][j]=AAlist[i-1][j];
    }
  }
  
  ll score=-922337203685477580LL;
  ll ansid=0;
  for(ll i=0;i<D;i++){
    if (score<calcscore(AAlist[i])){
      score=calcscore(AAlist[i]);
      ansid=i;
    }

    if (debug==1){
      cout<<calcscore(AAlist[i])<<endl;
    }

  }



  if (debug==0)
  {
    for(ll i=0;i<D;i++){
      cout<<(AAlist[ansid][i]+1)<<endl;
    }
  }else{
    cout<<calcscore(AAlist[ansid])<<endl;
  }
    

  return 0;
}

/*
1万
36万
92万
*/

Measured memory_bytes: 4768
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    
    int cnt = 0;
    
    for(int i = 0;i < A+1;i++) {
      for(int j=0;j<B+1;j++) {
        for(int k=0;k<C+1;k++) { 
          if(500*i + 100*j + 50*k == X) cnt += 1;
        }
      }
    }
    
    System.out.println(cnt);
  }
         
}

Measured memory_bytes: 25812
using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string s=Console.ReadLine();
		bool b=false;
		for(int i=1;i<s.Length;i++)
		{
			if(s[i]==s[i-1])b=true;
		}
		if(b)
		{
			Console.WriteLine("Bad");
		}
		else
		Console.WriteLine("Good");
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n;
string s;
int main(){
	cin>>s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
		printf("Bad\n");
	}
	else printf("Good\n");
	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <fstream>

using namespace std;

typedef long long ll;
int H,W;

int dp[110][5][110];
const int mod=1000000;

int dfs(int cy,int cx,int cdepth){
  if(dp[cy][cx][cdepth]>=0)return dp[cy][cx][cdepth];
  ll res=0;
  if(cy==H&&cx==W)return 1;
  // 右に移動する場合と左に移動する場合で場合分け
  if(cx==1){
    if(cy==H)return 1;
    else{
      res=(res+dfs(cy,cx+1,cdepth))%mod;
      res=(res+dfs(cy,cx-1,cdepth))%mod;
      res=(res+dfs(cy+1,cx,cy+2))%mod;
    }
  }
  // 左にいる場合、そのまましたにいくか
  // 右にいって↓にいくか
  // 右にいって上にいって右にいって下にいくか(どこで右に曲がるかで場合分け)
  else if(cx==0){
    // 下
    if(cy+1<=H)res=(res+dfs(cy+1,cx,cdepth))%mod;
    // 右にいって下
    if(cy+1<=H&&cdepth<=cy)res=(res+dfs(cy+1,cx+1,cy+2))%mod;
    // 右に行ってどれだけ上に行って右に行って下にいくかで場合分け
    res=(res+(ll)(cy-cdepth+1)*dfs(min(H,cy+1),cx+2,cy+1))%mod;
  }
  else if(cx==2){
    // 下
    if(cy+1<=H)res=(res+dfs(cy+1,cx,cdepth))%mod;
    // 左にいって下
    if(cy+1<=H&&cdepth<=cy)res=(res+dfs(cy+1,cx-1,cy+2))%mod;
    // 左に行ってどれだけ上に行って左に行って下にいくかで場合分け
    res=(res+(ll)(cy-cdepth+1)*dfs(min(H,cy+1),cx-2,cy+1))%mod;
  }
  return dp[cy][cx][cdepth]=res;
}

int dp2[3][110][3];

int dfs2(int px,int cy,int cx){
  if(dp2[px][cy][cx]>=0)return dp2[px][cy][cx];
  if(cy==H&&cx==W)return 1;
  ll res=0;
  if(cy+1<=H)res=res+dfs2(cx,cy+1,cx);
  if(cx+1<=W&&cx+1!=px)res=(res+dfs2(cx,cy,cx+1))%mod;
  if(cx-1>=0&&cx-1!=px)res=(res+dfs2(cx,cy,cx-1))%mod;
  return dp2[px][cy][cx]=res;
}

int main(){
  cin>>H>>W;
  memset(dp,-1,sizeof(dp));
  memset(dp2,-1,sizeof(dp2));
  if(W==2)cout<<dfs(0,0,0)<<endl;
  else cout<<dfs2(2,0,0)<<endl;
  
  return 0;
}

Measured memory_bytes: 1416
n,x=map(int, input().split())
l=sorted(list(map(int, input().split())))
ans=0
if x==sum(l):
  print(n)
elif x>sum(l):
  print(n-1)
else:
  for i in range(n):
    if x>=l[i]:
      ans+=1
      x=x-l[i]
    else:
      print(ans)
      exit()

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#006
import numpy as np

def main():
	n,m,q=MI()
	li=np.zeros((n+1,n+1),dtype=np.int64)
	for _ in range(m):
		l,r=MI()
		li[l][r]+=1
	#print(li)

	li=np.cumsum(li,axis=0)
	li=np.cumsum(li,axis=1)
	#print(li)

	for _ in range(q):
		p,q=MI()
		print(li[q,q]-li[p-1,q]-li[q,p-1]+li[p-1,p-1])

if __name__ == "__main__":
	main()

Measured memory_bytes: 30872
#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>
#include <functional>
#include <random>
#include <ctime>

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 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int64 s[N];

int64 gcd(int64 a, int64 b) {
  while (b) {
    int64 c = a;
    a = b;
    b = c % b;
  }
  return a;
}

vector<int64> L[N], R[N];

int64 solve(int64 A, int64 B, int64 n) {
  int64 step = (n - A) / (A - B);
  if (n % (A - B) == 0 && n / (A - B) <= 2 * step) return -1;
  // int64 C = gcd(A, A - B);
  // int64 mins = A / C;
  // // trace(A, B, n, mins, step);
  // if (mins <= step) return -1;
  // trace(A, B, step, L[A - B][step], R[A - B][step]);
  int64 ret = L[A - B][step] + R[A - B][step];
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  --n;
  for (int i = 0; i <= n; ++i) {
    scanf("%lld", &s[i]);
  }
  for (int k = 1; k < n; ++k) {
    int64 cur = 0;
    for (int i = 0; i <= n; i += k) {
      cur += s[i];
      L[k].push_back(cur);
    }
  }
  for (int k = 1; k < n; ++k) {
    int64 cur = 0;
    for (int i = 0; i <= n; i += k) {
      cur += s[n - i];
      R[k].push_back(cur);
    }
  }
  // for (int k = 1; k < n; ++k) {
  //   trace(k, sum[k].size());
  //   for (auto& it : sum[k]) {
  //     cout << it << " ";
  //   }
  //   cout << endl;
  // }
  int64 ret = 0;
  for (int A = 2; A < n; ++A) {
    int m = n - A;
    for (int C = 1; C * C <= m; ++C) {
      if (m % C) continue;
      int B = A - C;
      if (B > 0 && B < A) ret = max(ret, solve(A, B, n));
      B = A - m / C;
      if (B > 0 && B < A) ret = max(ret, solve(A, B, n));
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 33396
#include <iostream>
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
int N;
string s,t;
stack<char> sta;
int main(){
  cin >> N;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='('){
      sta.push(s[i]);
      t+='(';
    }
    else{
      if(sta.empty()){
	t+=')';
	t='('+t;
      }
      else{
	sta.pop();
	t+=')';
      }
    }
  }
  while(!sta.empty()){
    t+=')';
    sta.pop();
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int a,b,n;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(a+b-n,0ll)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;

ll fn(ll n, ll a, ll r, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll mul(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

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

ll compgcd(ll n, vector<ll> const &primes) 
{ 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

vector<bool> sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
    return prime;
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    ll f[8]={0};
    ll a, b, c;
    cin>>a>>b>>c;
    f[a]++;
    f[b]++;
    f[c]++;
    if(f[5]== 2 && f[7]==1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0; 
} 

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, M, L[101010], R[101010];
ll i, j, k,l;
int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,M){
        ll l, r;
        scanf("%lld%lld", &l, &r);
        L[l]++;
        R[r + 1]++;
    }
    j = 0;
    k = 0;
    fornum(i,0,N){
        j += L[i + 1];
        j -= R[i + 1];
        if(j==M){
            k++;
        }
    }
    printf("%lld", k);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> M;
}
void solve() {
  cout << (500 * N >= M ? "Yes" : "No");
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<ll> ans(n,1e9+7);
    for(i = n-1;i >= 0;--i){
        auto it = upper_bound(all(ans), a.at(i));
        *it = a.at(i);
    }
    auto it = lower_bound(all(ans), 1e9 + 7) - ans.begin();
    cout << it << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b,t,i;
main(N){
    long long c;
    for(scanf("%d",&N);N--;c+=t,i++){
        scanf("%d",&t);
        a=i&&a<t?a:t;
        b=i&&b>t?b:t;
    }
    printf("%d %d %lld\n",a,b,c);
}

Measured memory_bytes: 1776
#include <stdio.h>

int main (){
	char s[100];
	int k;
	int length=0;
	scanf("%d\n", &k);
	scanf("%[^\n]", &s);
	for (int i=0; s[i] != '\0'; i++){
		length++;
	}
	if (length <= k){
		printf("%s", s);
	}
	else if (length > k){
		for (int i=0; i<k; i++){
		printf("%c", s[i]);
		}
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 1700
package main
import ("fmt"
        "strings"
        "bufio"
        "os"
        "strconv"
       )
func main (){
  n,m,an:=0,0,0
  fmt.Scanf("%d %d", &n,&m)
  sc:=bufio.NewScanner(os.Stdin)
  sc.Scan()
  ins:=strings.Split(sc.Text(), " ")
  //in:=[]int
  for _, i := range ins{
    j,_:=strconv.Atoi(i)
    //in=append(in,j)
    an+=j
  }
  if 0>n-an{
    fmt.Println(-1)
    return
  }
  fmt.Println(n-an)
}

Measured memory_bytes: 2184
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i : [] for i in range(n)}
INF = 10 ** 18
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

# memo_ls[i][j] 状態iでjにいる時の通り数
memo_ls = [[-1 for j in range(n)] for i in range(1 << n)]
# 状態sでvにいる通り数
def bit_dp(s, v):
    if memo_ls[s][v] >= 0:
        return memo_ls[s][v]
    if s == (1 << n) - 1:
        return 1
    res = 0
    for i in graph[v]:
        already = s >> i
        if not (already & 1):
            res += bit_dp((s | (1 << i)), i)
    memo_ls[s][v] = res
    return res

res = bit_dp(1, 0)
print(res)

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

const int stop[31] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0};
int main()
{
	int n;
	cin >> n;
	for(int x=0;x<n;x++){
		int a,b;
		cin >> a >> b;
		bool flag = false;
			for(int i=0;i<31;i++){
				if(stop[i] == a){
					for(int k=i;k<31;k++){
						if(stop[k] == b)
							break;
						else if(stop[k] == a)
							i = k;
					}
					for(int j=i;j<31;j++){
						if(stop[j] != b)
							cout << stop[j] << " ";
						else{
							cout << stop[j] << endl;
							flag = true;
							break;
						}
					}
				}
				if(flag)
					break;
			}
	}
	return 0;
}

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

using namespace std;

int main()
{ 
  while(1)
  {
    int m,n;
    cin>>m;
    if(m == 0){
      break;
    }
    cin>>n;

    int ans = 0;

    for(int i = m;i <= n;++i){
      int temp = i;

      for(int j = temp;j > 1;){
        if(temp % 5 == 0){
          temp = temp / 5;
        }
        else if(temp % 3 == 0){
          temp = temp / 3;
        }
        else if(temp % 2 == 0){
          temp = temp / 2;
        }
        else{
          break;
        }
      }
      
      if(temp == 1){
        ++ans;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
struct node {
   string  s;
};
bool cmp(node x,node y)
{
          return x.s<y.s;
}
int main()
{
     int n;
     cin>>n;
     node q[n];
     for(int i=0;i<n;i++)
          cin>>q[i].s;
     sort(q,q+n,cmp);
     int cnt=1;
     for(int i=0;i<n-1;i++)
      {
          if(q[i].s!=q[i+1].s)
              cnt++;
      }
      cout<<cnt<<endl;
}


Measured memory_bytes: 9856
#include<stdio.h>
#include<math.h>
int main(){
int i,r,g,b,y[9],sum,ans;
int a[9][4]={{0,0,0},{0,0,255},{0,255,0},
              {0,255,255},{255,0,0},{255,0,255},
              {255,255,0},{255,255,255}};              
char z[8];
double min=1000000,dk,dka;
while(1){
scanf("%c",&z[0]);
if(z[0]=='0'){
break;
}
for(i=1;i<7;i++){
scanf("%c",&z[i]);
}
scanf("\n");
for(i=1;i<7;i++){
if(z[i]=='a'){
y[i]=10;
}
else if(z[i]=='b'){
y[i]=11;
}
else if(z[i]=='c'){
y[i]=12;
}
else if(z[i]=='d'){
y[i]=13;
}
else if(z[i]=='e'){
y[i]=14;
}
else if(z[i]=='f'){
y[i]=15;
}
else{
y[i]=z[i]-'0';
}
}
r=16*y[1]+y[2];
g=16*y[3]+y[4];
b=16*y[5]+y[6];
for(i=0;i<8;i++){
sum=(r-a[i][0])*(r-a[i][0])+(g-a[i][1])*(g-a[i][1])+(b-a[i][2])*(b-a[i][2]);
dka=sum;
dk=sqrt(dka);
if(dk<min){
min=dk;
ans=i;
}
}
min=1000000;
if(ans==0){
printf("black\n");
}
else if(ans==1){
printf("blue\n");
}
else if(ans==2){
printf("lime\n");
}
else if(ans==3){
printf("aqua\n");
}
else if(ans==4){
printf("red\n");
}
else if(ans==5){
printf("fuchsia\n");
}
else if(ans==6){
printf("yellow\n");
}
else if(ans==7){
printf("white\n");
}
}
return 0;
}


Measured memory_bytes: 2128
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var H = one[0];
  var N = one[1];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    list[i] = {
      "damage" : tmp[0],
      "maryoku" : tmp[1]
    };
  }
  var maxHP = 100000;
  var dp = new Array(maxHP);
  dp[0] = 0;
  for(var i = 0; i < N; i++){
    for(var j = 0; j < H; j++){
      if(dp[j] != null){
        if(!dp[j + list[i]["damage"]]){
          dp[j + list[i]["damage"]] = dp[j] + list[i]["maryoku"];
        }else{
          dp[j + list[i]["damage"]] = Math.min(dp[j + list[i]["damage"]], dp[j] + list[i]["maryoku"]);
        }
      }
    }
  }
  var last = 1000000007;
  if(!dp[maxHP]){
    dp[maxHP] = last;
  }
  
  //myerr(dp);
  for(var i = maxHP - 1; i >= 0; i--){
    if(dp[i]){
      dp[i] = Math.min(dp[i], dp[i + 1]);
    }else{
      dp[i] = dp[i + 1];
    }
  }
  myout(dp[H]);
}

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

//#define USE_FILES 1

#ifdef USE_FILES
ifstream fin("tmp.in");
ofstream fout("tmp.out");
#define cin fin
#define cout fout
#endif // USE_FILES

int n, x, max1, second1, max2, second2, val1, val2;
map <int, int> freqeven, frequneven;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        if (i % 2) {
            ++frequneven[x];
        } else {
            ++freqeven[x];
        }
    }

    for (auto x : freqeven) {
        if (x.second > max1) {
            second1 = max1;
            max1 = x.second;
            val1 = x.first;
            }
        else if (x.second > second1) {
            second1 = x.second;
        }
    }
    for (auto x : frequneven) {
        if (x.second > max2) {
            second2 = max2;
            max2 = x.second;
            val2 = x.first;
        }
        else if (x.second > second2) {
            second2 = x.second;
        }
    }
    int sol = 0;
    if (val1 != val2) {
        sol = n - max1 - max2;
    } else {
        sol = n - max(max1 + second2, max2 + second1);
    }
//    for (auto x : freqeven) {
//        cout << "f[" << x.first << "]= " << x.second <<'\n';
//    }
//    cout << '\n';
//    for (auto x : frequneven) {
//        cout << "f[" << x.first << "]= " << x.second <<'\n';
//    }
    cout << sol;// << '\n' << max1 << ' ' << second1 <<'\n' << max2 << ' ' << second2;
    return 0;
}


Measured memory_bytes: 4992
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N = int(self.input_data())
        a = list(map(int, self.input_data().split()))

        a2_sum = [0]*N

        for i in range(0, N, 2):
            a2_sum[i] = a[i] ^ a[i+1]

        source = 0
        for i in range(0, N, 2):
            source = source ^ a2_sum[i]

        for i in range(N):
            print(str(a[i]^source), end=' ')


solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 31948
#include <bits/stdc++.h>
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;

bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.first == b.first){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}
int main(){
  int N;
  cin>>N;
  vector<pair<string, int> > pairs(N);
  vector<pair<string, int> > copy(N);
  for(int i=0;i<N;i++){
        string a;
        int b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
        copy[i] = make_pair(a,b);
    }
  sort(pairs.begin(),pairs.end(), compare_by_b);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(pairs[i]==copy[j]){
        cout<<j+1<<endl;
        break;
      }
    }
  }
}



Measured memory_bytes: 256