akhauriyash/Code-Regression huggingface dataset:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    l, r, d = mi()
    cnt = 0
    tmp = d
    while tmp <= r:
        if tmp <= r and tmp >= l:
            cnt += 1
        tmp += d
    print(cnt)


main()


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

namespace AOJ0045
{
    class Program
    {
        static void Main()
        {
            var data = ReadInputs().ToArray();

            var sum = data.Sum(values => values[0]*values[1]);
            var ave = (int)(data.Average(values => values[1]) + 0.5);

            Console.WriteLine(sum);
            Console.WriteLine(ave);
        }

        public static IEnumerable<int[]> ReadInputs()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                yield return line.Split(',').Select(int.Parse).ToArray();
            }
        }
    }
}

Measured memory_bytes: 6032
import bisect
N, M = map(int, input().split())
l_1 = [[] for i in range(N+1)]
l_2 = []
for i in range(M):
  p, y = map(int, input().split())
  l_1[p].append(y)
  l_2.append([p, y])
  
for i in range(N+1):
  l_1[i].sort()
    
for i in range(M):
  c = l_2[i]
  n = bisect.bisect_left(l_1[c[0]], c[1]) + 1
  ans = str(c[0]).zfill(6) + str(n).zfill(6)
  print(ans)


Measured memory_bytes: 99576
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    int n, x, t;
    cin >> n >> x >> t;

    int a = n / x;
    if(a * x < n) {
        a++;
    }

    cout << a * t << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string A,B,C;cin>>A>>B>>C;
    if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3580
N=int(input())
list=[]
new_list=[]
for i in range(0,N):
    item=input()
    list.append(item)
list.sort()
for i in range(0,N):
    if i==N-1:
        new_list.append(list[i])
    elif list[i]==list[i+1]:
        pass
    else:
        new_list.append(list[i])
print(len(new_list))

Measured memory_bytes: 25236
X, Y, A, B, C = map(int, input().split())

r = sorted(list(map(int, input().split())), reverse = True)
g = sorted(list(map(int, input().split())), reverse = True)
a = sorted(list(map(int, input().split())), reverse = True)

r = r[0:X]
g = g[0:Y]

ans = r+g+a
ans = sorted(ans, reverse = True)

print(sum(ans[0:(X+Y)]))

Measured memory_bytes: 110956
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  int X1 = 0;
  int Y1 = 0;
  int X2 = w;
  int Y2 = h;
  int x, y, a;
  REP(i,n){
    cin >> x >> y >> a;
    if(a == 1){
      X1 = max(x, X1);
    }else if(a == 2){
      X2 = min(x, X2);
    }else if(a == 3){
      Y1 = max(y, Y1);
    }else{
      Y2 = min(y, Y2);
    }
  }
  // cout << X1 <<" " << X2 << " " << Y1 << " " << Y2 << endl;
  cout <<  max(X2 - X1,0)*max(Y2 - Y1,0) << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long a,b,i,j,max,k,l,r;
	scanf("%lld%lld",&a,&b);
	if(a<=b) max=a,a=b,b=max; k=a,l=b;
	while(b!=0)
	{
		r=a%b;
		a=b;
		b=r;
	}

			printf("%lld",k*l/a);
	
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>

using namespace std;

using Mat = vector<vector<char>>;

constexpr char col[] = {'R', 'G', 'B'};
constexpr int MAX = 10;

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

int W, H;
Mat M;

bool visited[MAX][MAX];

bool in_field(int x, int y)
{
    return (0 <= x && x < W && 0 <= y && y < H);
}

void paint(Mat& m, int x, int y, char nc, char c)
{
    if (visited[y][x]) return;
    visited[y][x] = 1;

    m[y][x] = nc;
    
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (in_field(nx, ny) && m[ny][nx] == c) {
            paint(m, nx, ny, nc, c);
        }
    }
}

Mat get_next(const Mat& m, char c)
{
    Mat res = m;
    memset(visited, 0, sizeof(visited));
    paint(res, 0, 0, c, m[0][0]);
    return res;
}

bool reach(Mat& m)
{
    char c = m[0][0];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (m[i][j] != c) {
                return 0;
            }
        }
    }
    return 1;
}

int bfs()
{
    queue<Mat> Q;
    Q.push(M);

    map<Mat, int> d;
    d[M] = 0;
    
    while (!Q.empty()) {
        Mat m = Q.front(); Q.pop();

        if (reach(m)) return d[m];
        
        for (int i = 0; i < 3; i++) {
            if (m[0][0] == col[i]) continue;
            Mat next = get_next(m, col[i]);
            if (d.count(next) == 0) {
                d[next] = d[m] + 1;
                Q.push(next);
            }
        }
    }
    return -1;
}

int main()
{
    while (cin >> W >> H, W > 0) {
        M.resize(H);
        for (int i = 0; i < H; i++) {
            M[i].resize(W);
            for (int j = 0; j < W; j++) {
                cin >> M[i][j];
            }
        }
        cout << bfs() << endl;
    }        
    return 0;
}

Measured memory_bytes: 7916
import java.util.*;
import java.io.*;
import java.util.function.*;

public class Main {
	public final int MOD = (int)1e9 + 7;
	
	public void solve(BufferedReader br) throws IOException {
		int[] nk = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int n = nk[0];
		int k = nk[1];
		int[] ar = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int[] dp = new int[n];
		Arrays.fill(dp, 1000000000 + 7);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			int[] array = new int[k];
			for (int j = 0; j < k; j++) array[j] = i + j + 1;
			for (int j: array) {
				if (j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(ar[i] - ar[j]));
				}
			}
		}
		System.out.println(dp[n - 1]);
		//System.out.println(Arrays.toString(ar));	
	}
	
	public long mathPow(long base, long exp, long mod) {
		long res = 1;
		base = base % mod;
		while (exp > 0) {
			if ((exp & 1) == 1) res = (res * base ) % mod;
			exp = exp >> 1;
			base = (base * base) % mod;
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		new Main().solve(br);
	}
}



Measured memory_bytes: 47560
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int A, B;

	cin >> A >> B;

	if (A > 12) {
		cout << B << endl;
	}
	else if (A > 5) {
		cout << B/2 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

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

map<long long, long long> prime_factor(long long n) {
	map<long long, long long> ret;
	for(long long i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n] = 1;
	return ret;
}

map<ll, ll> prime;
ll n;

template<typename iterator>
ll solve(iterator it, ll num)
{
	if (it == prime.end())
	{
		return (num == 1);
	}

	ll res{0};
	for (ll i = 1; i <= it->second+1; ++i)
	{
		if (num % i != 0) continue;
		res += solve(next(it), num/i);
	}
	return res;
}

int main(int argc, char **argv)
{
	cin >> n;
	for (ll i = 1; i <= n; ++i)
	{
		auto tmp = prime_factor(i);
		for (auto &p : tmp)
		{
			prime[p.first] += p.second;
		}
	}

	std::cout << solve(prime.begin(), 75) << std::endl;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()
ans=0
for b in range(N):
    a=bisect.bisect_left(A,B[b])
    c=N-bisect.bisect_right(C,B[b])
    ans+=a*c
print(ans)

Measured memory_bytes: 105204
#include <stdio.h>

int main(){

  int a, b, c;

  int tmp;

  scanf("%d %d %d", &a, &b, &c);

  if(a > b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(a > c){
    tmp = a;
    a = c;
    c = b;
    b = tmp;
  }
  if(b > c){
    tmp = b;
    b = c;
    c = tmp;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;

}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a;
void solve(){
	cin >> n >> a;
	
	cout << (n >= 10 ? a : a+100*(10-n)) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;



bool f(int num){
	if(!(num%7 == 1 || num%7 == 6)) return false;
	for(int i=2;i<num;i++){
		if(num % i == 0){
			if(i%7 == 1 || i%7 == 6) return false;
		}
	}
	return true;
}

bool solve(){
	int n;
	cin>> n;
	if(n == 1) return false;
	
	cout<< n<< ":";
	for(int i=2;i<=n;i++){
		if((n % i == 0) && f(i)){
			cout<< " "<< i;
		}
	}
	cout<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1160
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from itertools import accumulate

n,w = li()
wi,vi = li()
w0 = wi
v_list = [[] for _ in range(4)]
v_list[0].append(vi)

for _ in range(n-1):
    wi,vi = li()
    v_list[wi-w0].append(vi)
    
for i in range(4):
    v_list[i].sort(reverse=True)
    v_list[i] = list(accumulate([0] + v_list[i]))
    
ans = 0
res = w
for w1 in range(len(v_list[0])):
    
    if w - w0*(w1) < 0:
        pass
    else:
        res1 = w - w0*(w1)
        ans1 = v_list[0][w1]
        ans = max(ans, ans1)
    

    for w2 in range(len(v_list[1])):

        if res1 - (w0+1)*(w2) < 0:
            pass
        
        else:
            res2 = res1 - (w0+1)*(w2)
            ans2 = ans1 + v_list[1][w2]
            ans = max(ans, ans2)

        
        
        for w3 in range(len(v_list[2])):
            
            if res2 - (w0+2)*(w3) < 0:
                pass
            
            else:
                res3 = res2 - (w0+2)*(w3)
                ans3 = ans2 + v_list[2][w3]
                ans = max(ans, ans3)
                
            
            for w4 in range(len(v_list[3])):

                if res3 - (w0+3)*(w4) < 0:
                    pass
                
                else:
                    res4 = res3 - (w0+3)*(w4)
                    ans4 = ans3 + v_list[3][w4]
                    ans = max(ans, ans4)

                
print(ans)

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

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

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18;
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	string s;
    	cin>>s;
    	for(int i=0;i<s.length();i++)
    	{
    		if(s[i]=='?')
    		{
    			s[i]='D';
			}
		}
		cout<<s;

    }

}

Measured memory_bytes: 3776
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n>>m;
    cout<<(n+m-1)/m<<endl;

}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd,pi
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
R = int(input())

ans = 2*R*3.14159265359

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> arr(n+1);
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    vector<ll> vis(n+1);
    ll cur=1;
    ll cnt =1;
    while(vis[cur]==0){
        vis[cur] = cnt++;
        cur = arr[cur];
    }
    ll cur2=cur;
    vector<ll> loop;
    do{
    loop.push_back(cur2);
    cur2 = arr[cur2];
    }while(cur2!=cur);
    ll dist = vis[cur]-1;
    if(k<dist){
    cur=1;
      while(k--)
      cur = arr[cur];
    cout<<cur<<endl;
    return 0;
    }
    cout<<loop[(k-dist)%loop.size()]<<endl;
    
    return 0;
}



Measured memory_bytes: 8388
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)

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

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){
    
    int a, b, c, k;

    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k<=a) ans = k;
    else {
        if(k<=a+b) ans = a;
        else {
            int numc = k-a-b;
            ans = a-(k-a-b);
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

struct UnionFind {
	vector<long> par;//親を返す

	UnionFind(long N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;//全て根である状態
	}

	long root(long i) {//根を返す
		if (par[i] == i) return i;
		return par[i] = root(par[i]); //根に直接繋ぎなおす
	}

	void unite(long x, long y) {//二つの木の統合(rxをryに繋ぐ)
		long rx = root(x);
		long ry = root(y);

		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(long x, long y) { return root(x) == root(y); }//根が等しいか
};

int main() {

	long N, M; cin >> N >> M;
	long res = 0;
	vector<long> p;

	for (int i = 0; i < N; i++) {
		long pin; cin >> pin;
		pin--;
		p.push_back(pin);
	}

	UnionFind tree(N);

	for (int i = 0; i < M; i++) {
		long x, y; cin >> x >> y;
		x--; y--;
		tree.unite(x, y);
	}

	for (int i = 0; i < N; i++) {
		if (tree.same(i, p[i])) res++;
	}

	cout << res << endl;
}

Measured memory_bytes: 1908
def rank(pm, pe, pj):
    ave_me = (pm + pe) // 2
    ave_all = (pm + pe + pj) // 3

    if 100 == pm or 100 == pe or 100 == pj or 90 <= ave_me or 80 <= ave_all:
        return 'A'
    
    if 70 <= ave_all or 50 <= ave_all and (80 <= pm or 80 <= pe):
        return 'B'
    return 'C'

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    for _ in range(n):
        pm, pe, pj = map(int, f.readline().split())
        print(rank(pm, pe, pj))

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
long long int L, A[202020], ls[202020], rs[202020];
long long int dp1[202020], dp2[202020], dp3[202020], dp4[202020];
long long int opt1(int i){
	if(dp1[i] != -1)return dp1[i];
	if(i == 0)return dp1[i] = 0;
	return dp1[i] = min(ls[i], opt1(i - 1) + (A[i] == 0 ? 2 : (A[i] % 2)));
}
long long int opt2(int i){
	if(dp2[i] != -1)return dp2[i];
	if(i == 0)return dp2[i] = 0;
	return dp2[i] = min(ls[i], min(opt2(i - 1), opt1(i - 1)) + 1  - (A[i] % 2));
}
long long int opt3(int i){
	if(dp3[i] != -1)return dp3[i];
	if(i == L)return dp3[i] = 0;
	return dp3[i] = min(rs[i + 1], opt3(i + 1) + (A[i + 1] == 0 ? 2 : (A[i + 1] % 2)));
}
long long int opt4(int i){
	if(dp4[i] != -1)return dp4[i];
	if(i == L)return dp4[i] = 0;
	return dp4[i] = min(rs[i + 1], min(opt4(i + 1), opt3(i + 1)) + 1  - (A[i + 1] % 2));
}
long long int opt(int i){
	return min(opt1(i) + opt4(i), opt2(i) + opt3(i));
}
int main(){
	//freopen("test.in", "r+", stdin);
	
	memset(dp1, -1, sizeof dp1);
	memset(dp2, -1, sizeof dp2);
	memset(dp3, -1, sizeof dp3);
	memset(dp4, -1, sizeof dp4);
	
	cin >> L;
	for(int i = 1; i <= L; i++)cin >> A[i];
	ls[1] = A[1];
	for(int i = 2; i <= L; i++)ls[i] = ls[i - 1] + A[i];

	rs[L] = A[L];
	for(int i = L - 1; i >= 1; i--)rs[i] = rs[i + 1] + A[i];
	/*
	for(int i = 1; i <= L; i++){
		cout << opt1(i) + opt4(i) << " or " << opt2(i) + opt3(i) << endl;
	}
	*/
	long long int final_result = 1e9;
	for(int i = 1; i <= L; i++)
		final_result = min(final_result, opt(i));
	cout << final_result << endl; 
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
using Graph = vector<vector<P>>;
Graph G;
vector<int> color;
void dfs(int u, int p, int c) {
    color[u] = c;
    for (auto v : G[u]) {
      if (v.first == p) continue;
      dfs(v.first, u, (v.second %2 == 0 ? c : 1-c));
    }
  }

int main(){
  int n;
  cin >> n;
  G.resize(n);
  rep(i,n-1) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    G[u].push_back({v,c});
    G[v].push_back({u,c});
  }  
  color.resize(n);
  dfs(0,-1,1);
  for (auto ans : color) cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 8960
#include <iostream>

int main(){
  int r = 0;
  int x_2000 = 0;
  int D = 0;
  int x[20];
  std::cin>> r >> D >> x_2000;
  x[0] = x_2000;
  // printf("%d\n",x[0]);

  for(int i = 0; i < 10; i++)
  {
    x[i+1] = ( r * x[i] ) - D;
    printf("%d\n",x[i+1]);
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

void insertion_sort(vector<int> &A, int g, int &cnt){
  // insertion sort
  int N = A.size();
  for (int i=0;i<N;i++){
    int v = A[i];
    int j = i - g;
    while (j>=0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    } 
    A[j+g] = v;
  }
  return;
}

void shell_sort(vector<int> &A, vector<int> G, int &cnt){
  cnt = 0;
  for (auto g : G){
    insertion_sort(A,g,cnt);
  }
  return;
}


int main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  int cnt = 0;
  vector<int> G, Ginv;
  int g0 = 1;
  while (g0<=N){
    Ginv.push_back(g0);
    g0 = 3*g0 + 1;
  }
  for(int i=Ginv.size()-1;i>=0;i--) {
    G.push_back(Ginv[i]);
  }


  shell_sort(A,G,cnt);

  // Gのサイズと値を出力
  cout << G.size() << endl;
  rep(i,G.size()){
    cout << G[i];
    if (i<G.size()-1) cout << " ";
  }
  cout << endl;

  // insertの回数を出力
  cout << cnt << endl;
  
  // ソートされた配列を出力
  rep(i,N) cout << A[i] << endl;  

  return 0;
}


Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;

// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T & a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T & a, T b) { a = std::min(a, b); }

int main() {

    int a, b;
    cin >> a >> b;

    if (abs(a - b) <= 1) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
  ll n;
  cin >> n;
  ll a,b;
  cin >> a >> b;
  bool yes= false;
  if((n>a)&&(n>b)){
    cout << "NG" ;
  }
  else{
    for(ll i=a; i<=b;i++){
      if(i%n==0){
        yes = true;
      }
    }
    if(yes){
      cout << "OK";
    }
    else{
      cout << "NG";
    }

  } 
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int s,memo[1000000];

main() {
    cin >> s;
    memo[s]++;
    for(int i=2;;i++) {
        if (s%2) s=s*3+1;
        else s/=2;
        if (memo[s]) {ct(i)return 0;}
        memo[s]++;
    }
}


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

int main(){
	int adj[100][100] = {};
	int n;
	cin >> n;
	int a,b,c;
	for (int i=0; i<n;i++){
	cin >> a >> b;
	//adj[num1-1]?????\??????
	
	for (int j=0;j<b;j++){
	cin >> c;
	adj[a-1][c-1] = 1;
	}

	}
	
	for (int i=0;i<n;i++){
	for (int j=0;j<n;j++){
	if (j) cout << " ";
	cout << adj[i][j];
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, Q = il()
    S = [-MAX, MAX]
    for _ in range(A):
        S.append(ii())
    S.sort()
    T = [-MAX, MAX]
    for _ in range(B):
        T.append(ii())
    T.sort()

    for _ in range(Q):
        q = ii()
        Srange = bisect.bisect_left(S, q)
        Trange = bisect.bisect_left(T, q)
        print(min(abs(q - S[Srange - 1]) + abs(S[Srange - 1] - T[Trange]),
                  abs(q - S[Srange - 1]) + abs(S[Srange - 1] - T[Trange - 1]),
                  abs(q - S[Srange]) + abs(S[Srange] - T[Trange - 1]),
                  abs(q - S[Srange]) + abs(S[Srange] - T[Trange]),
                  abs(q - T[Trange - 1]) + abs(T[Trange - 1] - S[Srange]),
                  abs(q - T[Trange - 1]) + abs(T[Trange - 1] - S[Srange - 1]),
                  abs(q - T[Trange]) + abs(T[Trange] - S[Srange - 1]),
                  abs(q - T[Trange]) + abs(T[Trange] - S[Srange])))


if __name__ == '__main__':
    main()


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

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

	// freopen("input.txt","r",stdin);
	
	long long n;
	cin >> n;
	vector<int> answer;

	if (n == 0) cout << 0;
	else {
		while (n)
		{
			if (n >= 0 || n%-2 == 0)
			{
				answer.push_back(n%-2);
				n = n/-2;
			}
			else
			{
				answer.push_back(1);
				n = n/-2 + 1;

			}
		}

		for (int i = answer.size() - 1; i >= 0; --i)
		{
			cout << answer[i];
		}
	}


	return 0;
}

Measured memory_bytes: 256
#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(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N>>M>>K;

}
//=============================
void func(){}
//=============================
void solve()
{
    int A=N;
    int B=M;

    map<int,int> mp;
    rep(i,A,A+K-1){
        if (i <= B)
        mp[i]++;
    }
    rep(i,B-K+1,B){
        if (i>=A){
            mp[i]++;
        }
    }
    for(auto x : mp){
        cout<<x.first<<endl;
    }

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
//abc127_e.cpp
//Mon Sep 23 17:29:07 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
const int MAX = 200000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll n,m,k;
	cin >> n >> m >> k;

	COMinit();

	ll otherscom = COM(n*m-2,k-2);
	ll tateall = 0;
	for (int i=1;i<n;i++){
		ll tate = (n-i)*i%MOD;
		tate = ((tate * m)%MOD) * m % MOD;
		tate = tate * otherscom % MOD;
		tateall = (tateall + tate) % MOD;
	}

	ll yokoall = 0;
	for (int i=1;i<m;i++){
		ll yoko = (m-i)*i%MOD;
		yoko = (yoko * n)%MOD * n % MOD;
		yoko = yoko * otherscom % MOD;
		yokoall = (yokoall + yoko) % MOD;
	}

	ll ans = (tateall + yokoall) % MOD;
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String pattern = input.nextLine().toUpperCase();
        String word = input.nextLine().toUpperCase();
        String new_word = null;
        while(input.hasNextLine()){
            new_word = input.nextLine().toUpperCase();
            if(word.compareTo("END_OF_TEXT") == 0)
                break;
            word += (" " + new_word);
        }
        String[] words = word.split("\\s");
        int cnt = 0;
        for (int i = 0; i < words.length; i ++){
            if(words[i].compareTo(pattern) == 0)
                cnt ++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26232
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip> 
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(j, a, b) for (int j = a; j >= b; j--)
using namespace std;
const int MAX = 100001; 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin >> k;
    vector <int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[k-1] << endl;
}


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

template<typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    typename vector<T>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "}";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
    os << "[";
    typename set<T>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template<typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
    os << "[";
    typename map<F, S>::const_iterator it;
    for (it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) os << ", ";
        os << it->first << " = " << it->second;
    }
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long int ll;
typedef long double ld;

#define endl "\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c),x) != (c).end())
#define F first
#define S second

const ll mod = 1000000007;
const ll inf = (ll) 1e15;

ll power(ll a, ll b, ll m = mod) {if (b == 0) return 1; if (b == 1) return (a % m); ll x = power(a, b / 2, m); x = (x * x) % m; if (b % 2) x = (x * a) % m;return x;}
ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }

const int N=405,M=405;
int a[N][N];
int vis[N][N];
ll n,m,b=0,w=0;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int num=1;

bool valid(int r,int c)
{
    return r>=1&&r<=n&&c>=1&&c<=m&&(vis[r][c]!=num);
}

void dfs(int r,int c)
{
    if(a[r][c]==1)
        w++;
    else
        b++;
    vis[r][c]=num;
    for(int i=0;i<4;i++)
    {
        int newx=r+dx[i],newy=c+dy[i];
        if(valid(newx,newy) && (a[r][c]+a[newx][newy]==1))
        {
            dfs(newx,newy);
        }
    }
}

void solve() {

    cin >> n >> m;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin >> s;
        for(int j=1;j<=m;j++)
        {
            if(s[j-1]=='#')
            {
                a[i][j]=0;
            } else
            {
                a[i][j]=1;
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]==0 && vis[i][j]==0)
            {
                dfs(i,j);
                ans+=b*w;
                b=0,w=0;
                num++;
            }
        }
    }
    cout << ans << endl;
}

int main() {
    IOS;
    int t = 1, num = 1;   ///// change this t for number of testcase globally
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;

int main(){
	cin >> n >> k;
	
	if(k <= (n+1)/2){cout << "YES" << endl;}
	else{cout << "NO" << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int n,tmp,count = 0,limit;
	scanf("%d",&n);

	for(int i = 0; i < n; i++)
	{
		scanf("%d",&tmp);
		limit = sqrt(tmp);
		for(int j = 2; j <= limit; j++){
			if(tmp%j==0){
				count++;
				break;
			}
		}
	}
	printf("%d\n",n-count);
}






  

 



Measured memory_bytes: 2768
import sys
import math
from decimal import *

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def LF(): return list(map(float,sys.stdin.readline().rstrip().split()))

A,B = LS()


# A = int(A)
# B = int(B*100)
# ab = A*B

print(math.floor(Decimal(A)*Decimal(B)))

Measured memory_bytes: 71496
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		long ans = (long) (a + Math.pow(a, 2) + Math.pow(a, 3));
		System.out.println(ans);

	}

}


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

string S;

int main(){
	cin >> S;
	int first = atoi(S.substr(0,2).c_str());
	int second = atoi(S.substr(2,4).c_str());

	if((first > 12 || first == 0) && (second > 12 || second == 0)){
		cout << "NA" << endl;
		return 0;
	}

	if(first > 12 || first == 0){
		cout << "YYMM" << endl;
	} else if (second > 12 || second == 0){
		cout << "MMYY" << endl;
	} else {
		cout << "AMBIGUOUS" << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	x := make([][]float64, n)
	for i := 0; i < n; i++ {
		x[i] = make([]float64, d)
		for j := 0; j < d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			var sum, tmp float64
			for k := 0; k < d; k++ {
				tmp = math.Abs(x[i][k] - x[j][k])
				tmp *= tmp
				sum += tmp
			}
			sum = math.Sqrt(sum)
			if sum == float64(int64(sum)) {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;


int main() {
    int a, b,c;
    cin >> a >> b>>c;
    if (b - a == c - b)cout << "YES" << endl;
    else cout << "NO" << endl;
 
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n, m; 
    // cin>>n>>m;
    // int a[n], b[m];
    // For(i, 0, n){
    //     cin>>a[i];
    // }
    // For(i, 0, m){
    //     cin>>b[i];
    // }
    string a, b; cin>>a>>b;
    n = sz(a); m=sz(b);
    int ans = m;
    For(i, 0, n-m+1){
        int ct = 0;
        For(j, 0, m){
            if(a[i+j]!=b[j])
                ct++;
        }
        ans = min(ans, ct);
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



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

using namespace std;
set <int> s;
int main()
{
    /*string s;
    cin>>s;
    s[3]='8';
    cout<<s;*/
    int n,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        int k;
        cin>>k;
        s.insert(k);
    }
    int p=s.size();
    cout<<p;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
X_L = [list(map(int, input().split())) for i in range(N)]

s_t = []
for i in range(N):
    s = X_L[i][0] - X_L[i][1]
    t = X_L[i][0] + X_L[i][1]
    s_t.append([t, s])

s_t.sort()

cnt = 0
t = s_t[0][1]
for i in range(N):
    if t <= s_t[i][1]:
        cnt += 1
        t = s_t[i][0]
print(cnt)

Measured memory_bytes: 41440
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

//ACL

#include <atcoder/all>
using namespace atcoder;

//ACL END

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n,q;
    cin>>n>>q;
    fenwick_tree<int> fw(n);
    rep(i,n){
        int in;
        cin>>in;
        fw.add(i,in);
    }
    rep(i,q){
        int t;
        cin>>t;
        if(t){
            int l,r;
            cin>>l>>r;
            cout<<fw.sum(l,r)<<endl;
        }
        else{
            int p,x;
            cin>>p>>x;
            fw.add(p,x);
        }
    }
}


Measured memory_bytes: 8236
var n;
var t = [];
var m;
var s = [];
var dp = [];

function main(){
	while(n = scan()){
		rep(n, function(i){
			t[i] = scan();
		});

		m = scan();
		rep(100, function(i){
			s[i] = Infinity;
		});
		rep(m, function(i){
			var d = scan() - 1;
			s[d] = Math.min(scan(), s[d]);
		});

		rep(100, function(i){
			dp[i] = [];
		});
		dp[0][0] = 0;
		rep(1, n, function(i){
			dp[0][i] = Infinity;
		});
		rep(1, 100, function(i){
			rep(n, function(j){
				if(s[i] < t[j]){
					dp[i][j] = Infinity;
				}
				else{
					dp[i][j] = dp[i - 1][(j + n - 1) % n];
				}
			});
			dp[i][0] = Math.min(Math.min.apply(null, dp[i - 1]) + 1, dp[i][0]);
		});

		print(Math.min.apply(null, dp[99]));
	}
}

function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});

Measured memory_bytes: 18120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    
    int a=0,b=0;
    vi ans(N,0);
    
    rep(i,N){
        if(S[i]=='a' && a+b < A+B) ans[i] = 1,a++;
        else if(S[i] == 'b' && a+b < A+B && b < B) ans[i] = 1,b++;
    }
    
    rep(i,N) ans[i] ? cyes : cno;
    
    
    
    

    return 0;
}


Measured memory_bytes: 3816
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=200100,p=1000000007;
int n;
int c[200];
char s[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for (int i=0;i<n;i++) c[s[i]-'a']++;
	int ans=1;
	for (int i=0;i<26;i++) ans=1LL*ans*(c[i]+1)%p;
	ans--;
	if (ans==-1) ans+=p;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int array[100], n, i, tmp;
	scanf("%d", &n);

	for(i = 0;i < n; i++){
		scanf("%d", array + i);
	}

	for(i = 0; i < (n / 2); i++){
		tmp = array[i];
		array[i] = array[n - i -1];
		array[n - i - 1] = tmp;
	}

	for(i = 0; i < n; i++){
		printf("%d", array[i]);
		if(i < n - 1) printf(" ");
	}
	printf("\n");
	return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, k;
  vector<double> p;
  Solver2(LL n, LL k) : n(n), k(k), p(max(n, 2 * k) + 1){};

  void solve() {
    for (int i = max(n, 2 * k); i >= 0; --i) {
      if (i >= k) {
        p[i] = 1.0;
      } else {
        p[i] = p[2 * i] / 2.0;
      }
    }
    double ans = 0.0;
    for (int i = 1; i <= n; ++i) {
      ans += p[i] / n;
    }
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);
  long long n = 0, k;
  std::cin >> n >> k;

  Problem::Solver2 sol(n, k);
  sol.solve();
  return 0;
}


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

int main(void)
{
  int n = 0;
  long long int ans = 0;
  scanf("%d", &n);

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

  printf("%lld\n", ans);
  return 0;
  }


Measured memory_bytes: 1700