akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main() {
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    n--;
    ll k=b-a;
    rep(i,n+1){
        int j=n-i;
        ll from=c*j-d*i,to=d*j-c*i;
        if(from<=k&&k<=to){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

#define MAX_N 100

#define pb push_back

using namespace std;

int n;

vector <int> g[MAX_N + 1];

void add(int a, int b)
{
    g[a].pb(b);
}

struct elem
{
    int x, y;
};

elem red[MAX_N + 1];
elem blue[MAX_N + 1];

int cst[MAX_N + 1];
int cdr[MAX_N + 1];
int cp[MAX_N + 1];

int rez = 0;

bool cuplat(int n)
{
    if(cp[n] == 1)
        return 0;

    cp[n] = 1;

    for(auto u : g[n])
    {
        if(cst[u] == 0)
        {
            cst[u] = n;
            cdr[n] = u;

            return 1;
        }
    }

    for(auto u : g[n])
    {
        if(cuplat(cst[u]))
        {
            cst[u] = n;
            cdr[n] = u;

            return 1;
        }
    }

    return 0;
}

void match()
{
    int i;
    int change = 1;
    while(change != 0)
    {
        change = 0;
        memset(cp, 0, sizeof(cp));
        for(i = 1; i <= n; i ++)
        {
            if(cdr[i] == 0)
            {
                int x = cuplat(i);
                change = change || x;
            }
        }
    }

    for(i = 1; i <= n; i ++)
    {
      //  cout << cdr[i] << " " << cst[i] << "\n";
        rez += (cdr[i] != 0);
    }
}

int main()
{
    cin >> n;

    int i;
    for(i = 1; i <= n; i ++)
        cin >> red[i].x >> red[i].y;

    for(i = 1; i <= n; i ++)
        cin >> blue[i].x >> blue[i].y;

    int j;
    for(i = 1; i <= n; i ++)
    {
        for(j = 1; j <= n; j ++)
        {
            if(red[i].x < blue[j].x && red[i].y < blue[j].y)
                add(i, j);
        }
    }

    match();

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
a = map(int,raw_input().split())

ans = 0

while True:
  flag = 0
  for x in range( len(a) ):
    if a[x] % 2 == 0:
      a[x] = a[x]/2
      ans += 1
      flag = 1
  if flag == 0:
    break

print ans


Measured memory_bytes: 3460
#include<iostream>
using namespace std;
int list[1000000];

int main(){
	int n;
	cin>>n;
	for(int i=1;i*i<=n;i++){
		for(int j=1;j*j<=n;j++){
			for(int k=1;k*k<=n;k++){
				int ans = i*i + j*j + k*k + i*j + j*k + i*k;
				list[ans]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",list[i]);
	}
	return 0;
}

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

void solve() {
    string s;
    cin >> s;

    if (s[s.length()-1] == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Item{
public:
	long v;
	long w;
	std::string t;
	long long d;
	std::string s;

	Item() : v(0), w(0), d(0){
		return;
	}

	~Item(){
		return;
	}

	bool operator < (const Item &r){
		if(this->v != r.v){
			return this->v < r.v;
		}
		else if(this->w != r.w){
			return this->w < r.w;
		}
		else if(this->t != r.t){
			return this->t < r.t;
		}
		else if(this->d != r.d){
			return this->d < r.d;
		}
		else{
			return this->s < r.s;
		}
	}

};

int main(int argc, char **argv){
	int n;
	std::vector<Item> a;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	n = std::stoi(buf);

	a.resize(n);
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		std::istringstream stream(buf);

		stream >> a[i].v >> a[i].w >> a[i].t >> a[i].d >> a[i].s;
	}

	std::sort(a.begin(), a.end());

	for(int i = 0; i < a.size(); i++){
		std::cout << a[i].v << " " << a[i].w << " " << a[i].t << " " << a[i].d << " " << a[i].s << std::endl;
	}

	return 0;
}


Measured memory_bytes: 16676
s = list(input())
len_s= len(s)
#print(s)
if len_s%2==0:
    ans_0=['0','1']*int(len_s/2)
    ans_1=['1', '0']*int(len_s/2)
else:
    ans_0=['0'] + ['1', '0']*int((len_s-1)/2)
    ans_1=['1'] + ['0','1']*int((len_s-1)/2)
    
#print(ans_0)
#print(ans_1)

count_0 =0
for i in range(len_s):
    if ans_0[i] is not s[i]:
        count_0+=1

count_1 =0
for i in range(len_s):
    if ans_1[i] is not s[i]:
        count_1 += 1
print(min(count_0, count_1))

Measured memory_bytes: 11892
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim d As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim ans As Long = 0
    For i As Integer = 0 To n - 2
      Dim b As Integer = d(i)
      For j As Integer = i + 1 To n - 1
        ans += (b * d(j))
      Next
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class

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

using namespace std;

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

struct Card {
    char suit;
    int value;
};

void bubble(struct Card A[], int N) {
    REP(i, N - 1) {
        for (auto j = N - 1; j > i; j--) {
            if (A[j - 1].value > A[j].value) {
                swap(A[j], A[j - 1]);
            }
        }
    }
}

void selection(struct Card A[], int N) {
    REP(i, N - 1) {
        auto mini = i;
        for (auto j = i + 1; j < N; j++) {
            if (A[mini].value > A[j].value) {
                mini = j;
            }
        }
        if (mini != i) swap(A[i], A[mini]);
    }
}

void print(struct Card A[], int N) {
    REP(i, N) {
        if (i != 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card A[], struct Card B[], int N) {
    REP(i, N) {
        if (A[i].suit != B[i].suit) return false;
    }
    return true;
}

int main() {
    string str;
    Card C1[36], C2[36];;
    int N;
    cin >> N;
    REP(i, N) cin >> C1[i].suit >> C1[i].value;
    REP(i, N) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;

    print(C2, N);
    cout << ((isStable(C1, C2, N)) ? "Stable" : "Not stable") << endl;
    return 0;
}

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

ll inf =1e9+7;

#define pi 3.14159265358979323846L
bool isprime(ll a)
{
	
	ll cnt=0;	
	for(ll i=1;i*i<a;i++)
	{
		
	 	if(a%i==0)
	 	{
	 		cnt+=2;
		 }
		
		
	}
	
		if(cnt==2)
		return true;
		else
		return false;
		
}
ll mod(ll a)
{
	if(a<inf)return a;
	else
	return a%inf;
}
void solve()
{
	ll n;
	cin>>n;
	set<string>s;
while(n--)
{
	string x;
	cin>>x;
	s.insert(x);
	
}

cout<<s.size();
}

int main()
{


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

		solve();
	
return 0;

		
	}
	
	
	


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

using namespace std;

const int MaxN = 300005;

int n;
int x, y, a, b, c;
pair<int, int> apple[MaxN];
int cnt[3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> x >> y >> a >> b >> c;
    n = a + b + c;
    for (int i = 1; i <= a; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 1;
    }
    for (int i = a + 1; i <= a + b; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 2;
    }
    for (int i = a + b + 1; i <= n; ++i)
    {
        cin >> apple[i].first;
        apple[i].second = 0;
    }
    sort(apple + 1, apple + n + 1, greater<pair<int, int>>());
    for (int i = 1; i <= x + y; ++i)
    {
        cnt[apple[i].second]++;
    }
    if (cnt[1] <= x && cnt[2] <= y)
    {
        long long ans = 0;
        for (int i = 1; i <= x + y; ++i)
        {
            ans += 1LL * apple[i].first;
        }
        cout << ans;
    }
    else
    {
        long long ans = 0LL;
        if (cnt[1] > x)
        {
            for (int i = 1; i <= n && x; ++i)
            {
                if (apple[i].second == 1)
                {
                    ans += 1LL * apple[i].first, --x;
                }
            }
            for (int i = 1; i <= n && y; ++i)
            {
                if (apple[i].second != 1)
                {
                    ans += 1LL * apple[i].first, --y;
                }
            }
            cout << ans;
        }
        else
        {
            for (int i = 1; i <= n && y; ++i)
            {
                if (apple[i].second == 2)
                {
                    ans += 1LL * apple[i].first, --y;
                }
            }
            for (int i = 1; i <= n && x; ++i)
            {
                if (apple[i].second != 2)
                {
                    ans += 1LL * apple[i].first, --x;
                }
            }
            cout << ans;
        }
    }
    return 0;
}




Measured memory_bytes: 2688
class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)] # par[i]=iとして初期化  ex) par[3]=2 :3の親は2
        self.rank = [0] * (n+1)

    def find(self,x):
        if self.par[x] == x:
            return x

        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y

        else:
            self.par[y] = x

            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m = map(int,input().split())
 
edges = [list(map(int,input().split())) for i in range(m)]
 
ans = 0
 
for i in range(m):
	uf = UnionFind(n)
	for j in range(m):
		if i != j:
			uf.union(edges[j][0]-1,edges[j][1]-1)
 
	c = 0
	for j in range(n):
		if j == uf.find(j):
			c += 1
 
	if c > 1 :
		ans += 1 
print(ans)

Measured memory_bytes: 3064
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/topic.jsp?cid=ITP1#problems/ITP1_7
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(" ").map(_.toInt))
      .map { case Array(m, f, r) => (m, f, r) }
      .takeWhile(_ != (-1, -1, -1))
      .map {
        case (m, f, _) if m == -1 || f == -1 => "F"
        case (m, f, _) if 80 <= (m + f) => "A"
        case (m, f, _) if 65 until 80 contains (m + f) => "B"
        case (m, f, _) if 50 until 65 contains (m + f) => "C"
        case (m, f, r) if 30 until 50 contains (m + f) => if (r >= 50) "C" else "D"
        case (m, f, _) if (m + f) < 30 => "F"
      }
      .foreach(println)
  }
}

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

int main() {
	int n, m = 0;
	cin >> n;
	int a[n+1], st[n+1] = {};
	for(int i = 1; i < n+1; i++) cin >> a[i];
	
	for(int i = n; i > 0; i--)
	{
		int c = 0;
		for(int j = 2*i; j < n+1; j = j+i)
		if(st[j] == 1) c++;
		
		if(c%2 != a[i]) {st[i] = 1; m++;}
	}
	cout << m << endl;
	for(int i = 1; i < n+1; i++) if(st[i] == 1) cout << i << " ";
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

signed main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vi va, vb, vc;
    rep(i, x) {
        capi(a);
        va.push_back(a);
    }

    rep(i, y) {
        capi(b);
        vb.push_back(b);
    }

    rep(i, z) {
        capi(c);
        vc.push_back(c);
    }

    sort(all(va), greater());
    sort(all(vb), greater());
    sort(all(vc), greater());

    vi v;

    rep(i, x) {
        rep (j, y) {
            if ((i + 1) * (j + 1) > k) break;
            rep(l, z) {
                if ((i + 1) * (j + 1) * (l + 1) > k) break;
                v.push_back(va[i] + vb[j] + vc[l]);
            }
        }
    }

    sort(all(v), greater());
    rep(i, k) {
        cout << v[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 3948
N, A = map(int, input().split())  # N枚のカード, 平均をAにしたい

X = tuple(map(int, input().split()))  # カードリスト

# [カードの総枚数][選んだカードの枚数][今の総和]
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]

# 0枚の中から0枚選んで総和が0になるパターンは1つ
dp[0][0][0] = 1

for i in range(N):
    for j in range(N+1):
        for k in range(N*50+1):
            if dp[i][j][k]:  # 今の状態を未来へ遷移させる処理
                dp[i+1][j][k] += dp[i][j][k]  # 何も加えず未来へ
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]  # 今見ているカードを加えて未来に遷移

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]

print(ans)


Measured memory_bytes: 62952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main
{

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		// TODO Auto-generated method stub
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int p = Integer.parseInt(in.readLine());
		System.out.println(factorial(p));

	}
	public static Long factorial(int p)
	{
		Long result;
		if (p==0) result = (long) 1;
		else if (p==1) result = (long) 1;
		else result = p*factorial(p-1);
		
		return result;
	}

}

Measured memory_bytes: 24244
N = int(input())
S = input()
Q = int(input())
K = [int(_) for _ in input().split()]

D = [0] * (N+10)
M = [0] * (N+10)
C = []
DM = [0] * (N+10)
DMC = [0] * (N+10)

for i in range(N):
    if S[i] == 'D':
        D[i] += 1
    elif S[i] == 'M':
        M[i] += 1
        DM[i] += D[i-1]
    elif S[i] == 'C':
        C += [i]
    D[i+1] = D[i]
    M[i+1] = M[i]
    DM[i+1] = DM[i]

for k in K:
    ans = 0
    for c in C:
        ans += DM[c-1]
        if c-k+1 > 0:
            ans -= D[c-k]*(M[c-1]-M[c-k])+DM[c-k]
    print(ans)


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

using namespace std;

int N;
int a[105];
int dp=0;
int ans=0;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(dp == a[i]){
            ans++;
            dp = -1;
        }else{
            dp = a[i];
        }

    }
    cout << ans << endl;

    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14 
 
signed main(){
    string s;
    cin >> s;
    int cnt = 0;
    if((s[0] == s[1] && s[1] == s[2]) ||
        (s[1] == s[2] && s[2] == s[3]) ||
        (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl; 
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x, t;
    cin >> n >> x >> t;

    if (n % x != 0)
        cout << (n / x + 1) * t << '\n';
    else
        cout << n / x * t << '\n';

    return 0;
}


Measured memory_bytes: 3644
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, x;
    cin >> n >> x;
    vector<int> L(n + 1);
    vector<int> D(n + 1);
    D[0] = 0;
    int rem = 0;
    rep(i, n){
        cin >> L[i];
        D[i + 1] = D[i] + L[i];
    }
    for(int i = 0; i <= n; i++){
        if(D[i] <= x) rem++;
    }

    cout << rem << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int sum = 0;
    for (int i=0;i<m;i++) sum+=sc.nextInt();
    int result = (n-sum>=0)?n-sum:-1;
    System.out.println(result);
  }
}

Measured memory_bytes: 46420
#include<stdio.h>

int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A+B>=A-B&&A+B>=A*B)
    printf("%d",A+B);
    else if(A-B>=A+B&&A-B>=A*B)
        printf("%d",A-B);
    else if(A*B>=A+B&&A*B>=A-B)
        printf("%d",A*B);
    return 0;

}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	string t ;
	cin >> s >> t;

	//substrを全部試す
	int m = -1 ;
	for(int i = 0 ; i + t.size() <= s.size() ; i++){
		string sub = s.substr(i,t.size());
		//subと、tを比較する
		bool flag = true; 
		for(int j = 0 ; j < t.size() ; j++){
			//１文字ずつ一致しているかどうか
			if(t[j] ==sub[j] || sub[j] =='?'){
				//ok
			}else{
				//dame
				flag = false;
				break;
			}
		}
		if(flag){
			m = i ; 
		}
	}
	string ans = s;
	int kill = 0 ;
	rep(i,s.size()){
		if( i >= m  && i < m + t.size()){
			ans[i] = t[kill];
			kill ++ ;
		}else{
			if(s[i] =='?'){
				ans[i] = 'a';
			}
			else{
				ans[i] =s[i];
			}
		}
	}
	if(m==-1){
		cout<<"UNRESTORABLE"<<endl;
	}else{
		cout << ans << endl;
	}
}



Measured memory_bytes: 256
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 SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    ans=0
    for i in range(1,n+1):
        if i%3 and i%5:ans+=i
    print(ans)

main()

Measured memory_bytes: 9140
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int pcnt(int x) {
  return __builtin_popcount(x);
}

int f(int x) {
  if (x == 0) return 0;
  return f(x % pcnt(x)) + 1;
}

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

  vector<int> x(n);
  rep(i, n) x[i] = s[i] - '0';  // 0~9には0の48から1ずつ増えながら数値が振られているので素の差を見ればintへ一桁ずつ落とし込める

  int pc = 0;
  rep(i, n) pc += x[i];
  vector<int> ans(n);

  // 元の文字列が0の場合と1の場合で処理をする
  rep(b, 2) {
    int npc = pc;
    if (b == 0)
      npc++;
    else
      npc--;
    if (npc <= 0) continue;
    // 2進数 -> 10進数
    int r0 = 0;
    rep(i, n) {
      r0 = (r0 * 2) % npc;
      r0 += x[i];
    }
    // もとの数のあまりに0なら桁分足す、1なら桁分引く
    int k = 1;
    for (int i = n - 1; i >= 0; --i) {
      if (x[i] == b) {
        int r = r0;
        if (b == 0)
          r = (r + k) % npc;
        else
          r = (r - k + npc) % npc;
        ans[i] = f(r) + 1;
      }
      k = (k * 2) % npc;
    }
  }

  rep(i, n) cout << ans[i] << endl;

  return 0;
}

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

#define MAX 100
int A[MAX];

int selectionSort(int n){
  int cnt, i, j, swap, minj;
  for (i = 0; i < n; i++){
    minj = i;
    for (j = i; j < n; j++){
      if (A[j] < A[minj])  minj = j;
    }
    swap = A[i];
    A[i] = A[minj];
    A[minj] = swap;
    if (minj != i) cnt++;
  }
  return cnt;
}

int main(){
  int i, j, cnt, n, x;
  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];
  x = selectionSort(n);
  cout << A[0];
  for (i = 1; i < n; i++) cout << " " << A[i];
  cout << "\n";
  cout << x << "\n";
  return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>b(n);
    rep(i,n) {
        b[i] = a[i]-(i+1);
    }
    sort(b.begin(),b.end());
    int med = b[n/2];
    ll ans = 0;
    rep(i,n) {
        ans += abs(a[i] - (med+i+1));
    }
    cout << ans << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int a, b, c, d;
   cin >> a >>b >> c >> d;
   if (abs(a-c) <= d || (abs(a-b)<=d && abs(b-c)<=d)) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      double r = Double.parseDouble(sc.next());
      
      System.out.println(calCircumference(r));
      
    }
  public static double calCircumference(double r) {
        return 2 * Math.PI * r;
    }
}

Measured memory_bytes: 27080
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// ****  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fl(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define fi(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> dmap;
typedef set<int> dset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
/********** solver function **********/
int solve(int i, vector<int> &v, vector<int> & dp){
    if( i==v.size()-1) return 0;
    if( i>=v.size()) return INT_MAX -1000;
    if( dp[i]!=-1) return dp[i];
    int a=INT_MAX, b=INT_MAX;
    if( i+1<v.size())
     a= abs(v[i+1]-v[i]) + solve( i+1, v, dp);
    if( i+2<v.size())
     b= abs( v[i+2]-v[i]) + solve( i+2, v, dp);
    return dp[i] =min( a,b);
	
}
/********** Main()  function **********/
int main()
{std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> dp(n, -1);
    vector<int> v(n);
    for( int i=0; i<n; i++){
        cin>>v[i];
    }
    cout<<solve( 0,v,dp)<<endl;

}

Measured memory_bytes: 9892
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const int q=1000000007;
int n,m,f[3010][3010],a[3010],b[3010],l[3010],r[3010];
char s[3010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d%s",&n,&m,&s[0]+1);
	for(i=1;i<=m;i++)
	  scanf("%d%d",&l[i],&r[i]);
	for(i=1,j=0,k=0;i<=n;i++)
	  {
	   a[i]=a[i-1];
	   b[i]=b[i-1];
	   for(;j<=m && i==l[j+1];j++)
	     for(;k+1<=r[j+1];k++)
	       if(s[k+1]=='0')
	         a[i]++;
	       else
	         b[i]++;
	   if(k<i)
	     {
		  k++;
		  if(s[i]=='0')
		    a[i]++;
		  else
		    b[i]++;
		 }
	  }
	f[0][0]=1;
	for(i=1;i<=n;i++)
	  {
	   f[i][0]=f[i-1][0];
	   for(j=1;j<=i;j++)
	     f[i][j]=(f[i-1][j-1]+f[i-1][j])%q;
	   for(j=a[i]+1;j<=i;j++)
	     f[i][j]=0;
	   for(j=0;j<i-b[i];j++)
	     f[i][j]=0;
	  }
	printf("%d\n",f[n][a[n]]);
	return 0;
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  vector<vector<int>> dist(h, vector<int>(w, -1));
  
  queue<P> q;
  rep(i, h) rep(j, w)
  {
    cin >> grid[i][j];
    if(grid[i][j] == '#')
    {
      q.push(P(i, j));
      dist[i][j] = 0;
    }
  }
  
  vector<int> dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
  
  while(q.size())
  {
    P p = q.front();
    q.pop();
    
    rep(i, 4)
    {
      int ny = p.first + dy[i], nx = p.second + dx[i];
      if(ny >= 0 && ny < h && nx >= 0 && nx < w && dist[ny][nx] == -1)
      {
        q.push(P(ny, nx));
        dist[ny][nx] = dist[p.first][p.second] + 1;
      }
    }
  }
  
  int res = 0;
  rep(i, h) rep(j, w) res = max(res, dist[i][j]);
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 13456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
		AC = new int[N + 1];
		WA = new int[N + 1];
	}

	int M;

	public boolean hasNext() {
		// return cnt < N;
		return cnt < M;
	}

	int[] AC;
	int[] WA;

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split("\\s+");
		int p = Integer.parseInt(strArr[0]);
		if (AC[p] == 0) {
			if ("AC".equals(strArr[1]))
				AC[p] = 1;
			else {
				WA[p]++;
			}
		}
		cnt++;
	}

	public void solve() {
		int a = 0;
		int w = 0;
		for (int i = 1; i <= N; i++) {
			if (AC[i] > 0) {
				a++;
				w += WA[i];
			}
		}
		System.out.println(a + " " + w);
	}
}


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

int main() {
	string S;
	cin >> S;
	int n = 0;
	long long int sum = 0;
	n = S.length();
	for (int bit = 0; bit < (1 << (n - 1)); bit++) {
		string str = S;
		long long int s[10] = { 0 };
		for (int i = 0; i < n; i++) {
			s[i] = S[n - 1 - i] - '0';
		}
		int res = 0;
		for (int i = 0; i < n - 1; i++) {
			if (bit&(1 << i)) {
				sum += s[i];
				res = 0;
			}
			else {
				res++;
				s[i+1] = pow(10,res) * s[i + 1] + s[i];
			}
		}
		sum += s[n - 1];
	}
	cout << sum;
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	char c; vector<int>v(5);
	while (cin >> v[0] >> c >> v[1] >> c >> v[2] >> c >> v[3] >> c >> v[4]) {
		vector<int>trump(15, 0); int m(0); int p = 1;
		rep(i, 0, 5) {
			trump[v[i]]++;
			if (v[i] == 1)trump[14]++;
			m = max(m, trump[v[i]]);
		}
		if (m == 4)p = max(p, 7);
		if (m == 3) {
			rep(i, 1, 14) {
				if (trump[i] == 2) {
					p = max(p, 6);
					break;
				}
			}
			p = max(p, 4);
		}
		rep(i, 1, 11) {
			bool f(true);
			rep(j, i, i + 5) {
				if (trump[j] != 1)f = false;
			}
			if (f)p = max(p, 5);
		}
		if (m == 2) {
			int cnt(0);
			rep(i, 1, 14) {
				if (trump[i] == 2) {
					cnt++;
				}
			}
			if (cnt == 2)p = max(p, 3);
			else p = max(p, 2);
		}

		switch (p) {
		case 1:cout << "null" << endl; break;
		case 2:cout << "one pair" << endl; break;
		case 3:cout << "two pair" << endl; break;
		case 4:cout << "three card" << endl; break;
		case 5:cout << "straight" << endl; break;
		case 6:cout << "full house" << endl; break;
		case 7:cout << "four card" << endl; break;
		}

	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

#if 0
template <class T> void _print(T v) { cerr << v; } void _err(istream_iterator<string> it) { (void)it; }
template <class A, class B> void _print(pair<A,B> v) { cerr << "("; _print(v.ff); cerr << ","; _print(v.ss); cerr << ")"; }
template <class T, class... Args> void _err(istream_iterator<string> it, T a, Args... args) { cerr << '\t' << *it << " = "; _print(a); _err(++it, args...); }
#define trace(...)  { cerr << "Line " << __LINE__ << ":"; string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' ');       \
  stringstream _ss(_s); _err(istream_iterator<string>(_ss), __VA_ARGS__); cerr << nl; }
#define debug if(1)
#else
#define trace(...)	{}
#define debug if(0)
#endif

// sorted small to big
VL neg, pos;
ll z = 0;

// # -vals <= x
ll neg_count(ll x) {
  if (x >= 0) {
    return (ll) neg.size() * (ll) pos.size();
  }
  ll ans = 0;
  for (ll p : pos) {
    int lo = -1;
    int hi = neg.size();
    while (lo+1 < hi) {
      int mid = lo+(hi-lo)/2;
      if (p * neg[mid] <= x) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    ans += hi;
  }
  return ans;
}

// # +vals <= x
ll pos_count(ll x) {
  ll ans = 0;
  for (int i = 0; i < pos.size(); ++i) {
    int lo = i;
    int hi = pos.size();
    while (lo+1 < hi) {
      int mid = lo + (hi-lo)/2;
      if (pos[i] * pos[mid] <= x) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    ans += lo-i;
  }
  for (int i = neg.size(); i--;) {
    int lo = -1;
    int hi = i;
    while (lo+1<hi) {
      int mid = lo + (hi-lo)/2;
      if (neg[i] * neg[mid] <= x) {
        hi = mid;
      } else {
        lo = mid;
      }
    }
    ans += i-hi;
  }
  return ans;
}

// # vals <= x
ll count(ll x) {
  ll cnt = neg_count(x) + pos_count(x);
  if (x >= 0) cnt += z;
  return cnt;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n;
  ll k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a < 0) {
      neg.emplace_back(a);
    } else if (a > 0) {
      pos.emplace_back(a);
    } else {
      z++;
    }
  }
  z = (z-1)*z/2 + z*(ll)(neg.size() + pos.size());
  trace(z);
  sort(neg.begin(), neg.end());
  sort(pos.begin(), pos.end());
  ll lo = -LINF;
  ll hi = LINF;
  while (lo+1 < hi) {
    ll mid = lo+(hi-lo)/2;
    trace(mid, count(mid));
    if (count(mid) >= k) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << hi << nl;
  return 0;
}



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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (998244353)
#define umap unordered_map

int main()
{
    long t = 1;

    while (t--) {
        long x, n;
        cin >> x >> n;

        vector<long> p(n);
        for (auto &x : p) cin >> x;

        long k = x;
        long j = -1;
        while (true) {
            bool ok = true;
            for (long i = 0; i < n; i++) {
                if (p[i] == k) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                printf("%lld\n", k);
                break;
            }
            k += j;
            j = (j + j/abs(j)) * (-1);
        }
    }
}


Measured memory_bytes: 3724
#include <stdio.h>

int main(){
  long long int M=1000000007LL;
  long long int A[300000];
  int N;
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
    scanf("%lld",A+i);
  long long int S=0LL,T=0;
  for(int j=N;j>=2;j--){
    T+=A[j];
    T%=M;
    S+=T*A[j-1];
    S%=M;
  }
  
  printf("%lld\n",S);
  return 0;
}

Measured memory_bytes: 3300
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            long[] input = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var A = input[0];
            var B = input[1];
            Console.WriteLine(A*B/Gcd(A,B));
        }

        static long Gcd(long m,long n){
            long temp;
            while(m%n!=0){
                temp =n;
                n = m%n;
                m = temp;
            }
            return n;
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Linq;

namespace AGC013
{
    class A
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count = 1;
            int flag = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (flag == 1 && A[i] > A[i + 1]) { count++; flag = 0; continue; }
                if (flag == -1 && A[i] < A[i + 1]) { count++; flag = 0; continue; }

                if (A[i] < A[i + 1]) { flag = 1; }
                if (A[i] > A[i + 1]) { flag = -1; }

            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 19680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    while (input.ready())
    {
      System.out.println(decoder(input.readLine()));
    }
  }

  private static String decoder(String str)
  {
    return decoder(str.toCharArray());
  }

  private static String decoder(char[] charArray)
  {
    String ret = "";
    for (int i = 0; i < charArray.length; i++)
    {
      if (charArray[i] == '@')
      {
        final int COUNT = Integer.valueOf(String.valueOf(charArray[i + 1]));
        for (int j = 0; j < COUNT; j++)
        {
          ret += charArray[i + 2];
        }
        i += 2;
        continue;
      }
      ret += charArray[i];
    }
    return ret;
  }
}

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

using namespace std;

int const INF = 1e9;
int const NMAX = 1e5;
int n;
int arr[1 + NMAX];
int dp[1 + NMAX];

int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
    dp[i] = INF;
  }
  dp[1] = 0;
  dp[2] = abs(arr[2] - arr[1]);
  for(int i = 3; i <= n; i++) {
    dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
  }
  cout << dp[n];
}


Measured memory_bytes: 1024
import math
import itertools
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
color = [0]*3
ans = 1
for i in range(N):
  if A[i] not in color:
    ans = 0
    break
  ind = color.index(A[i])
  ans *= len([c for c in color if c == A[i]])
  ans %= mod
  color[ind] += 1

#ans = rec(color,0)
print(ans)

Measured memory_bytes: 16080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
using namespace std;
typedef long long ll;

void Main()
{
	int N; cin >> N;
	string S; cin >> S;
	map<pair<string, string>, ll> mp;
	for (int bit = 0; bit < (1<<N); ++bit) {
        string a = "";
        string b = "";
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
				a += S[i];
			} else {
				b += S[i];
			}
		}
		mp[make_pair(a, b)] += 1;
		// cout << a << " " << b << endl;
	}
	ll res = 0;
	for (int bit = 0; bit < (1<<N); ++bit) {
        string a = "";
        string b = "";
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
				a += S[N + i];
			} else {
				b += S[N + i];
			}
		}
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		res += mp[make_pair(a, b)];
	}
	cout << res << endl;
}

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


Measured memory_bytes: 87040
#include<stdio.h>
int primeNumber(int);

int main(){
  int n, i, x, sum=0;
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&x);
    if( primeNumber(x) ) sum++;
  }
  printf("%d\n", sum);
  return 0;
}

int primeNumber(int x){
  int i;
  if( x < 2 ) return 0;
  else if( x == 2 ) return 1;
  if( x % 2 == 0 ) return 0;
  for( i = 3 ; i*i <= x ; i+=2 ){
    if( x % i == 0 ) return 0;
  }
  return 1;
}



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

bool isprime(int x);

int main(){
	int n; cin>>n;
	int temp,count = 0;
	for(int i=0;i<n;i++){
		cin>>temp;
		if(isprime(temp))
			count++;
	}

	cout<<count<<endl;

}

bool isprime(int x){
	if(x==2) return true;
	if(x<2 || x%2==0) return false;

	int i = 3;
	while(i<=sqrt((double)x)){
		if(x%i==0) return false;
		i += 2;
	}
	return true;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = 0;
        for(int i=1; i<=n; i++) {
            int cnt = 0;
            if(i % 2 != 0) {
                for(int j=1; j*j<=i; j++) {
                    if(i % j == 0) {
                        cnt++;
                        if(i / j != j) {
                            cnt++;
                        }
                    }
                }
                if(cnt == 8) ans++;
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	long long int sum = a + b + c;
	if(d % 2) {
	    cout << -a + b;
	}
	else 
	    cout << a -b ;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for (int x = 0; x <= k; x++)
    {
        for (int y = 0; y <= k; y++)
        {
            int z = s - (x + y);
            if (z <= k && z >= 0)
            {
                cnt++;
            }
            // cout << x << "," << y << "," << s - (x + y) << endl;
        }
    }

    cout << cnt << endl;
    return 0;
}


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

typedef vector <bool> VB;
typedef vector <VB> VVB;

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n && m )
	{
		VVB G( n+1, VB( n+1, false ) );
		for ( int i = 0; i < m; i++ )
		{
			int a, b; // a-bツづ債友ツ達
			cin >> a >> b;
			G[a][b] = G[b][a] = true;
		}

		VB F( n+1, false );
		for ( int i = 0; i <= n; i++ )
		{
			if ( G[1][i] )
			{
				F[i] = true;
			}
		}

		VB R( n+1, false );
		for ( int i = 0; i <= n; i++ )
		{
			if ( F[i] == false ) continue;
			for ( int j = 0; j <= n; j++ )
			{
				if ( j == 1 ) continue;
				if ( G[i][j] )
				{
					R[j] = true;
				}
			}
		}

		int answer = 0;
		for ( int i = 0; i <= n; i++ )
		{
			if ( F[i] || R[i] )
			{
				answer++;
			}
		}

		cout << answer << endl;

	}
	return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(all(a));
    for(int i=1;i<n;i++)
    {
        if(a[i] == a[i-1])
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";

    return 0;
}



Measured memory_bytes: 1792
# coding: utf-8

def main():
    n = int(input())
    l = ["".join(sorted(input())) for i in range(n)]

    c = {}
    ans = 0
    for s in l:
        if s in c:
            c[s] = c[s] + 1
        else:
            c[s] = 0
        ans += c[s]

    print(ans)

main()


Measured memory_bytes: 19404
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
#define mod 1000000007
int main(){
	fast;
	int n,m;
	ll ans=1;
	cin>>n>>m;
	if(abs(n-m)>1)
	{
		cout<<"0";
		return 0;
	}
	if(n==m)
		ans=2;
	while(n+m>2)
	{
		ans=ans*n%mod;
		ans=ans*m%mod;
		n=(n)?n-1:n;
		m=(m)?m-1:m;
		if(ans==0)
		    break;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl t(n);
  rep(i,n)cin>>t[i];
  ll a=1,b=1;
  rep(i,n){
    if(t[i]%2==0){
      a*=3;
      b*=2;
    }
    else {
      a*=3;
    }
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())

    sosuu_mask = sosuu()

    r = [0 for i in range(int(1e5+1))]
    l = [0 for i in range(int(1e5+1))]
    for i in range(len(r)-2,0,-1):
        r[i] += r[i+1] + sosuu_mask[i+1]
    for i in range(1,len(l)):
        l[i] += l[i-1] + sosuu_mask[i-1]
    _all = len([s for s in sosuu_mask if s==1])
    
    # print(_all)
    # print(r[:10])
    # print(l[:10])

    for i in range(n):
        a,b = list(map(int,input().split(' ')))
        # print(list(map(int,input().split(' '))))
        print(_all-l[a]-r[b])
    return 

def sosuu():
    ret = [1 for i in range(int(1e5+1))]
    ret[0]=0
    ret[1]=0
    for i in range(2,len(ret)):
        if ret[i]==0:
            continue
        else:
            for j in range(2*i,len(ret),i):
                ret[j] = 0
    # print(ret[:54])
    ret2 = [s for s in ret]
    for i in range(len(ret)):
        if i%2==1 and ret[(i+1)//2]!=1 or i%2==0:
            ret2[i]=0
    # print(ret2[:54])
    return ret2


if __name__ == "__main__":
    main()

Measured memory_bytes: 55368
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		double x[] = new double[N];
		String u[] = new String[N];
		double ans = 0;
		for(int i = 0; i < N; i++) {
			x[i] = Double.parseDouble(sc.next());
			u[i] = sc.next();
			if(u[i].equals("JPY")) {
				ans += x[i];
			} else {
				ans = ans + (x[i] * 380000);
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716