akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;

//0-origin
template <typename T>
struct FenwickTree {
	vector<T> data;
	FenwickTree(int n) : data(n, 0) {}
        //v[i] += x
	void add(int i, T x) { for (int p = i; p < (int)data.size(); p |= p + 1) data[p] += x; }
        //[0, i)
	T sum(int i) {
		T s = 0;
                for (int p = i - 1; p >= 0; p = (p & (p + 1)) - 1) s += data[p];
		return s;
	}
        //[l, r)
	T sum(int l, int r) { return sum(r) - sum(l); }
};

int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	vector<FenwickTree<int>> vf(n + 5, FenwickTree<int> (n + 5));
	rep(i, m) {
		int l, r;
		scanf("%d%d", &l, &r);
		l --, r --;
		vf[l].add(r - l, 1);
	}
	rep(i, q) {
		int p, q;
		scanf("%d%d", &p, &q);
		p --, q --;
		int ans = 0;
		for (int pp = p; pp <= q; pp ++) {
			ans += vf[pp].sum(q - pp + 1);
		}
		printf("%d\n", ans);
	}
        return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define outl2(x,y) cout<< (x) << ' ' << (y) << '\n'
using pii = pair<int,int>;
using ll = long long;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
static constexpr int INF = 0x3f3f3f3f;


int main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    int n, T;
    cin >> n >> T;
    int minv = INF;

    bool f = false;

    rep(i, n) {
        int c, t;
        cin >> c >> t;
        if (t <= T && c < minv) {
            minv = c;
            f = true;
        }
    }

    if (!f) {
        outl("TLE");
    }
    else {
        outl(minv);
    }

    return 0;
}



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

typedef long long ll;

ll count (ll b, int c) { // [1,b) で c の倍数
  return (b-1)/c;
}

ll count(ll b, ll a, int c) { // [a,b) で c の倍数の数
  return count(b, c) - count(a, c);
}

ll K[20]; // K[i] = [10^i, 10^(i+1)) のFB文字列の長さ

void Kinit() {
  for (int i=0; i<20; i++) {
    ll ub = pow(10, i+1);
    ll lb = pow(10, i);
    K[i] = 0;
    K[i] += (ub - lb - count(ub, lb, 3) 
	     - count(ub, lb, 5) + count(ub, lb, 15) ) * (i+1);
    K[i] += count(ub, lb, 3)*4 + count(ub, lb, 5)*4;
  }
}

ll L[20]; // L[i] = [1, 10^i) のFB文字列の長さ

void Linit() {
  L[0] = 0;
  for (int i=1; i<20; i++) {
    L[i] = K[i-1] + L[i-1];
  }
}

ll count(ll s) { // [1,s)
  int k = to_string(s).size();
  ll ans = L[k-1];
  ll ub = s;
  ll lb = pow(10,k-1);
  ans += (ub - lb - count(ub, lb, 3) 
	  - count(ub, lb, 5) + count(ub, lb, 15) ) * k;
  ans += count(ub, lb, 3)*4 + count(ub, lb, 5)*4;
  return ans;
}

string fb(ll s) {
  string ans = "";
  for (int i=0; i<20; i++) {
    ll t = s+i;
    if (t%15 == 0) {
      ans += "FizzBuzz";
    } else if (t%3 == 0) {
      ans += "Fizz";
    } else if (t%5 == 0) {
      ans += "Buzz";
    } else {
      ans += to_string(t);
    }
  }
  return ans;
}

int main() {
  Kinit();
  Linit();
  /*for (int i=0; i<100; i++) {
    cerr << "count(" << i << ") = " << count(i) << endl;
    }*/
  ll s;
  cin >> s;
  ll lb = 0;
  ll ub = pow(10, 18) + 10;
  while (lb + 1 != ub) {
    ll t = (lb+ub)/2;
    if (count(t) < s) {
      lb = t;
      //cerr << "lb = " << t << endl;
    } else {
      ub = t;
      //cerr << "ub = " << t << endl;  
    }
  }
  ll u = count(lb);
  string S = fb(lb);
  cout << S.substr(s-u-1, 20) << endl;
}

Measured memory_bytes: 1280
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(40, -1, -1):
    j = 2 ** i
    count = len([1 for temp in a if temp&j > 0])
    if count < n - count and j <= k:
        k -= j
        count = n - count
    ans += j * count
print(ans)

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


int main(){

    int N,W;
    cin >> N >> W;
    long long int w[N],v[N];
    for(int i = 0 ; i < N ; i++){
        cin >> w[i] >> v[i];
    }
    vector<vector<long long int>> Knapsack(N,vector< long long int>(W+1));

    for(int i = 0; i <= W; i++){
        if(i >= w[0]){
            Knapsack[0][i] = v[0];
        }else{
            Knapsack[0][i] = 0;
        }
    }

    for(int i = 1; i < N ; i++){
        for(int j = 0; j <= W; j++){
            if(j >= w[i]){
                Knapsack[i][j] = max(Knapsack[i-1][j], Knapsack[i-1][j-w[i]] + v[i]);
            }else{
                Knapsack[i][j] = Knapsack[i-1][j];
            }
        }
    }

    cout << Knapsack[N-1][W] << endl;
}

Measured memory_bytes: 79488
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 3e5;
const ll bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll p = 29;

int main(){

    FASTIO;
    PRECISION; 
    
    int a,b;
    cin>>a>>b;

    if(a<=5){
        cout<<0<<"\n";
    }else if(a<=12){
        cout<<b/2<<"\n";
    }else{
        cout<<b<<"\n";
    } 
    
}


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

#define ll long long

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n;
	cin>>n;
	string s="";
	while(n>0){
		n-=1;
		s+=(char)('a'+(n%26));
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 3652
#k回消化コストを-1できる

n,k=map(int,input().split())
#消化コスト
a=list(map(int,input().split()))
a.sort()
#食べにくさ
f=list(map(int,input().split()))
f.sort(reverse=True)

#食べやすいものを消化コストが高い人
#食べにくいものを消化コストが低い人にしたほうがいい
#kをどこで減らすかは2部探索
#a-ans//f の和がk以下で、最小のans

ll=-1
rr=10**18

result=10**18
while ll+1<rr:
    ans=(rr+ll)//2
    
    cnt=0
    for i in range(n):
        cnt+=max(0,a[i]-ans//f[i])
    if cnt<=k:
        rr=ans
    else:
        ll=ans
#ansが小さくなると、cntが大きくなる



print(rr)


    





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

int main()
{
    int n, m;
    int i;
    scanf("%d %d",&n,&m);
    int nn;
    for(nn=m/n; m%nn!=0; nn--);
    printf("%d",nn);
    return 0;
}

Measured memory_bytes: 128
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

const int MAX = 310;
int a[MAX][MAX], n;

void clear() {
}

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

void solve() {
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (a[i][k] + a[k][j] < a[i][j])
					return void(printf("-1\n"));
	lli res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			bool isEdge = true;
			for (int k = 0; k < n; k++) {
				if (k == i || k == j) continue;
				if (a[i][j] == a[i][k] + a[k][j])
					isEdge = false;
			}
			if (isEdge) 
				res += a[i][j];
		}
	printf("%lld\n", res / 2);
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d", &n) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

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

typedef struct {
	char toshi[256];
	int hyouka;
	int x;
}house;

void scan(house* data);
int cmp_str(const void* p, const void* q) {
	return strcmp(((house*)p)->toshi,((house*)q)->toshi);
}
int cmp_num(const void* p, const void* q) {
	return((house*)q)->hyouka - ((house*)p)->hyouka;
}
int print(house* data);
/*int testprint(house* data);*/

int main(void) {
	int i;
	int N;

	scanf("%d", &N);

	house data[N];

	for (i = 0;i < N;i++) {

		scan(&data[i]);
		data[i].x = i + 1;

	}

	qsort(data, N, sizeof(house), cmp_num);
	qsort(data, N, sizeof(house), cmp_str);

	for (i = 0;i < N;i++) {
		print(&data[i]);
	}

	/*for (i = 0;i < N;i++) {
		testprint(&data[i]);
	}*/

	return 0;

}


void scan(house * data) {

		scanf("%s%d", data->toshi, &data->hyouka);

		return;
}

int print(house * data) {
		printf("%d\n", data->x);

		return 0;
}

/*int testprint(house* data) {
	printf("%s %d\n", data->toshi, data->hyouka);

	return 0;
}*/

Measured memory_bytes: 252
#include <stdio.h>

int
main(){
	int i;
	int N;
    int A[100000] = {0};
    int t[100000] = {0};
    scanf("%d", &N);
    for (i = 0; i < N; i ++){
    	scanf("%d", &A[i]);
    }


    for (i = 0; i < N; i ++){
        t[A[i] - 1] = i + 1;
        }

    for(i = 0; i < N; i ++){
        printf("%d ", t[i]);
        }
    
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	int ans = 100000;
	int tmp;
	for (int i=0; i<n; i++) {
		ans *= 1.05;
		tmp = ans / 1000 * 1000;
		if (tmp != ans) ans = tmp + 1000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#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>;

int main()
{
    string s;
    cin >> s;
    int ans = 0, cnt = 0;
    rep(i, s.size())
    {
        if (s[i] == 'R')
            cnt++;
        else
            cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            cout << i << "x" << j << "=" << i*j<< endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1116
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    //Round One
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a != 1 && b != 1) System.out.println("1");
        else if (a != 2 && b != 2) System.out.println("2");
        else if (a != 3 && b != 3) System.out.println("3");
        sc.close();
    }
}


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

int main(){
    string s, t;
    int cnt = 0;

    cin >> s >> t;

    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]) cnt++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int N,M;
	vector<string> A,B;
	string s;
	cin >> N >> M;
	for(int i=0;i<N;++i){
		cin >> s;
		A.push_back(s);
	}
	for(int i=0;i<M;++i){
		cin >> s;
		B.push_back(s);
	}
	for(int i=0;i<=N-M;++i){
		int pos = A[i].find(B[0]);
		if(pos == string::npos) continue;
		bool match = true;
		for(int j=1;j<M;++j){
			if(A[i+j].substr(pos,M) != B[j]) {
				match = false;
				break;
			}
		}
		if(match == true) {cout << "Yes" << endl;return 0;}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
/* Author : tushar3105 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<long long int,long long int> ii;					// Pair of integers
typedef vector<long long int> vi;                   				// Vector of integers
typedef vector<vector<long long int>> vvi;                 			// Vector of vi
typedef vector<pair<long long int, long long int>> vii;				// Vector of ii

#define pb push_back								// Push back to vectors
#define mp make_pair								// For pairs
#define ff first								// For pairs
#define ss second								// For pairs
#define all(c) (c).begin(),(c).end()						// Use in sorting
#define sz(a) ((long long int)(a).size())
#define lli long long int
#define ull unsigned long long int
#define ld long double
#define ref(i,x,y) for(long long int i=(x);i<=(y);++i)				// Loop to go forward
#define reb(i,x,y) for(long long int i=(x);i>=(y);--i)				// Loop to go backward
#define trf(c,it) for(auto it = (c).begin(); it != (c).end(); it++)		// Remember it is an iterator
#define trb(c,it) for(auto it = (c).end()-1; it != (c).begin()-1; it--)		// Remember it is an iterator
#define tc(t) long long int (t); cin>>(t);while((t)--)				// Test cases
//fill (dist,dist+110000,pinf);							// For setting default

const long long int mod = 1e9+7;
const long long int pinf = 9223372036854775807;
const long long int ninf = -9223372036854775807;

/*-----------------------------Code begins----------------------------------*/

int main (void)
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif

	lli n,k,arr[210000];

	cin>>k>>n;

	ref(i,0,n-1)
		cin>>arr[i];

	lli diff=k+arr[0]-arr[n-1];

	ref(i,1,n-1)
		diff=max(diff,arr[i]-arr[i-1]);
	

	cout<<k-diff<<endl;

	return 0;
}

Measured memory_bytes: 1792
mod=10**9+7
n=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
Tres=[0]*n
Ares=[0]*n
Tres[0]=(0,T[0])
Ares[n-1]=(0,A[n-1])
for i in range(1,n):
  if T[i]>Tres[i-1][1]:
    Tres[i]=(0,T[i])
  else:
    Tres[i]=(1,T[i])
  if A[n-i-1]>Ares[n-i][1]:
    Ares[n-i-1]=(0,A[n-i-1])
  else:
    Ares[n-i-1]=(1,A[n-i-1])
if Tres[0]<=Ares[0]:
  ans=1
else:
  ans=0
for i in range(1,n):
  ta,tb=Tres[i]
  aa,ab=Ares[i]  
  if ta==aa==1:
    ans=ans*min(tb,ab)%mod
  elif ta==0 and aa==1 and tb>ab:
    ans=0
  elif ta==1 and aa==0 and tb<ab:
    ans=0
  elif ta==0 and aa==0 and tb!=ab:
    ans=0
print(ans%mod)

Measured memory_bytes: 25412
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()

gcd_cnt = [0]*(K+1)
ans = 0
for i in range(K, 0, -1):
	cnt = pow(K//i, N, mod)
	for j in range(2, K//i+1):
		cnt -= gcd_cnt[j*i]
		cnt %= mod
	gcd_cnt[i] = cnt
	ans += i*cnt
	ans %= mod

print(ans)


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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int
main()
{
    IO;
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        // cout<<"Case #"<<c<<": ";
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i = 0; i < n; i++){
            cin >> arr[i];
        }
        int ans = 0;
        int pre = arr[0];
        for(int i = 1; i < n; i++){
            (ans += (pre * (arr[i]%MOD)))%=MOD;
            (pre += arr[i])%=MOD;
        }
        cout << ans << nl;
    }
    return 0;
}

Measured memory_bytes: 4776
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        int[] sum = new int[n + 1];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
            sum[i + 1] = sum[i] + p[i];
        }
        int max = 0;
        for (int i = 0 ; i < n - k + 1 ; i++) {
            max = Math.max(max, sum[i + k] - sum[i]);
        }

        System.out.println((double) (max + k) / 2);
    }

}

Measured memory_bytes: 83196
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    std::cout << std::fixed << std::setprecision(10);
    ll n;
    cin >> n;
    vector<ll> zyunretu(n), x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    iota(zyunretu.begin(), zyunretu.end(), 0);
    double dist = 0;
    do
    {
        for (int i = 1; i < n; i++)
        {
            dist += sqrt(pow(x[zyunretu[i]] - x[zyunretu[i - 1]], 2) + pow(y[zyunretu[i]] - y[zyunretu[i - 1]], 2));
        }
    } while (next_permutation(zyunretu.begin(), zyunretu.end()));
    double avr = dist / kaizyou(n);
    cout << avr << endl;
}


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

int main(void){
    int A, B, X;
    cin >> A >> B >> X;
    int sum;
    int count = 0;

    for(int i = 0; i <= B; i++){
        sum = A + i;
        if(sum == X)
            count++;
    }

    if(count == 1)
        cout << "YES" << endl;
    else if(count == 0)
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	REPO(i, 9) {
		REPO(j, 9) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m;
char p[101000], q[101000];
int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
	int i;
	scanf("%d%d", &n, &m);
	scanf("%s%s", p, q);
	int g = gcd(n, m);
	for (i = 0; i < n; i++) {
		if (i % (n / g) == 0) {
			if (p[i] != q[i / (n / g) * (m / g)]) {
				puts("-1");
				return 0;
			}
		}
	}
	printf("%lld\n", 1ll * n*m / g);
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

ans = 1
flg = True

if 0 in A: print(0)
else:
    for i in range(N):
        ans *= A[i]
        if ans > 1e18:
            flg = False
            break

    if flg: print(ans)
    else:print(-1)

Measured memory_bytes: 21640
fun main(args: Array<String>) {
  val (N, M) = readLine()!!.split(" ").map{ it.toInt() }
  var (min, max) = readLine()!!.split(" ").map{ it.toInt() }
  var result = 0
  val start_index = 2
  val last_index  = M
  for (i in start_index..last_index) {
    val (L, R) = readLine()!!.split(" ").map{ it.toInt() }
    when {
      max < L -> {
        println(0)
        return
      }
      min <= L && L <= max -> min = L
    }
    when {
      R < min -> {
        println(0)
        return
      }
      min <= R && R <= max -> max = R
    }
  }
  
  result = max - min + 1
  println(result)
  
}
    


Measured memory_bytes: 55656
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	for(int i=1;i<1262;i++) {
		double s1=i*1.0*0.08;
		double s2=i*1.0*0.1;
		if((int)s1==a && (int)s2==b) {
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

K = list(range(1,int(input())+1))
c = list(itertools.combinations(K, 2))
count = 0

for i in c:
  
  #print(i[0]%,i[1])
  if i[0]%2==0 and i[1]%2==1 or i[0]%2==1 and i[1]%2==0:
    count+=1
    

print(count)    

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

namespace AtCoderBeginnerContest149
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = int.Parse(Console.ReadLine());
			if (input == 2)
			{
				Console.WriteLine(2);
				return;
			}

			if (input % 2 == 0)
			{
				// 偶数の場合はどうせ素数じゃないからインクリメント
				input++;
			}

			while (true)
			{
				var isContinue = false;
				for (var i = 3; i <= Math.Ceiling(Math.Sqrt(input)); i += 2)
				{
					if(input % i == 0)
					{
						input += 2;
						isContinue = true;
						break;
					}
				}
				if (isContinue)
				{
					continue;
				}
				Console.WriteLine(input);
				return;
			}
		}
	}
}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int main() {
    int A, X, B, Y, T;
    
    cin >> A >> X >> B >> Y >> T;
    if (Y > X) {
        printf("NO\n");
        return 0;
    }
    int dv = X - Y;
    printf(abs(B - A) <= (long long)T * dv ? "YES\n" : "NO\n");
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1,j=m+1;i<j;i++,j--)
		printf("%d %d\n",i,j);
	for(int i=m+2,j=2*m+1;i<j;i++,j--)
		printf("%d %d\n",i,j);
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,a[1005];cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a,1+n+a);
  int ans=0;
  for(int i=1;i<=k;i++){
    ans+=a[i];
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp63 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(A.Max() - A.Min());


        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
using namespace std;
int a[100010];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int dap = 0;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == i) {
			if (a[i + 1] == i + 1)
				i++;
			dap++;
		}
	}
	printf("%d", dap);
}

Measured memory_bytes: 512
from heapq import *

INF = 10**15

def djikstra(G,s,d):
    #d = [0]*V
    que = []
    d[s] = 0
    visited = [False] * V
    heappush(que,(0,s))
    while(len(que)!=0):
        c,v = heappop(que)
        if visited[v]:
            continue
        visited[v] = True
        for i in range(len(G[v])):
            e = G[v][i]
            if visited[e[0]]:
                continue
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heappush(que,(d[e[0]],e[0]))


n,m,s,t = map(int,input().split())
V = n
Ga = [[] for i in range(n)]
Gb = [[] for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    Ga[u-1].append((v-1,a))
    Ga[v-1].append((u-1,a))
    Gb[u-1].append((v-1,b))
    Gb[v-1].append((u-1,b))

S = [INF]*V
T = [INF]*V
djikstra(Ga,s-1,S)
djikstra(Gb,t-1,T)
M = [0]*n
for i in range(n):
    M[i] = INF-S[i]-T[i]
ans = [0]*n
ans[n-1] = M[n-1]
for i in range(n-2,-1,-1):
    ans[i] = max(ans[i+1],M[i])

for i in range(n):
    print(ans[i])

Measured memory_bytes: 87500
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    
    int maxX = -1000;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        maxX = max(maxX, x);
    }
    
    int minY = 1000;
    for(int i = 0; i < M; i++) {
        int y;
        cin >> y;
        minY = min(minY, y);
    }
    
    cout << ((max(X, maxX) >= min(Y, minY)) ? "War" : "No War") << endl;
}


Measured memory_bytes: 256
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

sum=0
for n in range(1,N+1):
    if n<K:
        sum+=1/N*((1/2)**math.ceil(math.log2(K/n)))
    else:
        sum+=1/N
print(sum)

Measured memory_bytes: 13448
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;
double V[100];
priority_queue<double, vector<double>, greater<double>> q;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		double v;
		cin >> v;
		q.push(v);
	}

	double sum = 0.0;

	for (int i = 0; i < N - 1; i++)
	{
		double a = q.top();
		q.pop();
		double b = q.top();
		q.pop();
		double n = (a + b) / 2.0;
		q.push(n);
	}

	cout << fixed << setprecision(10) << q.top() << endl;
}




Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#define mod 1000000007
#define maxn 200100
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
ll tree[maxn*4];
int minn[maxn],maxx[maxn];
void pu(int rt) {
	tree[rt]=(tree[rt*2]+tree[rt*2+1])%mod;
}
ll query(int rt,int l,int r,int al,int ar) {
	if(al<=l&&ar>=r) {
		return tree[rt];
	}
	int mid=(l+r)>>1;
	ll sum=0;
	if(al<=mid) {
		sum+=query(rt*2,l,mid,al,ar);
		sum%=mod;
	}
	if(ar>mid) {
		sum+=query(rt*2+1,mid+1,r,al,ar);
		sum%=mod;
	}
	pu(rt);
	return sum;
}
void add(int rt,int l,int r,int pos,ll val) {
	if(l==r) {
		tree[rt]+=val;
		tree[rt]%=mod;
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) add(rt*2,l,mid,pos,val);
	else add(rt*2+1,mid+1,r,pos,val);
	pu(rt);
	return;
}
struct node {
	ll x,v;
	int pos;
} a[maxn];
struct line {
	int l,r;
} seg[maxn];
int lll[maxn],rrr[maxn];
bool cmpv(node a,node b) {
	return a.v<b.v;
}
bool cmpx(node a,node b) {
	return a.x<b.x;
}
bool cmpseg(line a,line b) {
	if(a.r==b.r) return a.l<b.l;
	return a.r<b.r;
}
int main() {
	ll N;
	cin >> N;
	for(int i=1; i<=N; i++) {
		scanf("%lld%lld",&a[i].x,&a[i].v);
	}
	memset(lll,0,sizeof(lll));
	memset(rrr,0,sizeof(rrr));
	sort(a+1,a+1+N,cmpv);
	for(int i=1; i<=N; i++) {
		a[i].pos=i;
	}
	sort(a+1,a+1+N,cmpx);
	for(int i=1;i<=N;i++) {
		minn[i]=INF;
		maxx[i]=-1;
	}
	minn[N]=a[N].pos;
	for(int i=N-1;i>0;i--) {
		minn[i]=min(minn[i+1],a[i].pos);
	}
	for(int i=1;i<=N;i++) {
		lll[a[i].pos]=minn[i];
	}
	maxx[1]=a[1].pos;
	for(int i=2;i<=N;i++) {
		maxx[i]=max(maxx[i-1],a[i].pos);
	}
	for(int i=1;i<=N;i++) {
		rrr[a[i].pos]=maxx[i];
	}
	for(int i=1;i<=N;i++) {
		seg[i].l=lll[i],seg[i].r=rrr[i];
	}
	sort(seg+1,seg+1+N,cmpseg);
	memset(tree,0,sizeof(tree));
	ll ans=0;
	for(int i=1;i<=N;i++) {
		ll tmp=0;
		if (seg[i].l==1) tmp++;
		tmp+=query(1,1,N,seg[i].l-1,seg[i].r);
		tmp%=mod;
		add(1,1,N,seg[i].r,tmp);
		if(seg[i].r>=N) {
			ans+=tmp;
			ans%=mod;
		}
	}
	cout << ans << endl;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> t(n);
    ll sum = 0;
    for (ll i = 0; i < n; i++){
        cin >> t[i];
        sum += t[i];
    }
    ll m;
    cin >> m;
    vector<pair<ll,ll>> px(m);
    for (ll i = 0; i < m; i++){
        cin >> px[i].first >> px[i].second;
    }
    
    ll a,b;
    for (ll i = 0; i < m; i++){
        a = px[i].first-1;
        b = px[i].second;
        cout << sum - t[a] + b << endl;
    }
    
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

//r本再利用されない時、N本から再利用して売れる本数
int rec(int m,int n,int N,int r){
  if(N == 0) return 0;

  int k = N/m * n;//新たに作り出す本数
  r = N%m;//再利用されない本数
  int res = N + k;//売った本数
  
  while(1){
    k = k/m * n;//k本からk/m本再利用
    res += k;
    r += k%m;
    if(k < m){//k本で再利用できなくなったら
      k += r;
      res += rec(m,n,k,r);
    }
  }
}

int main(){
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if(M1 != M2) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
const int Q=50;
int a[Q],b[Q],c[Q],d[Q];
int ans=0;
int A[10];
void dfs(int x,int before){
    if(x==n){
        int score=0;
        for(int i=0;i<q;i++)if(A[b[i]]-A[a[i]]==c[i])score+=d[i];
        ans=max(ans,score);
    }
    else{
        for(int i=before;i<=m;i++){
            A[x]=i;
            dfs(x+1,i);
        }
    }
    return;
}
int main(){
    cin>>n>>m>>q;
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    dfs(0,1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int ap=-1,an,b,c;
    vector<bool> renzoku(n-1);
    int ans=0;

    for(int i=0;i<n;i++){
        cin>>an;
        if(ap+1==an){
            renzoku[ap]=true;
        }
        ap=an;
    }
    for(int i=0;i<n;i++){
        cin>>b;
        ans+=b;
    }
    for(int i=0;i<n-1;i++){
        cin>>c;
        if(renzoku[i+1]==true){
            ans+=c;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, t;
	cin>>a>>b>>t;
	int cnt = 0;
	int time = 0;
	while(time + a <= t)
	{
		cnt += b;
		time += a;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {

	int input, flag = 0;

	cin >> input;

	for (int i = 1; i <= 9; i++) {
		if (input%i == 0 && input / i <= 9) {
			cout << "Yes" << endl;
			flag = 1;
			break;
		}
	}

	if (flag == 0)
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
def solve(A, b):
    for i in xrange(3):
        if A[i][i] == 0.0:
            for j in xrange(i+1, 3):
                if A[j][i]!=0.0:
                    A[i], A[j] = A[j], A[i]
                    b[i], b[j] = b[j], b[i]
                    break
        for j in xrange(3):
            if i==j:
                continue
            a = A[j][i] / A[i][i]
            for k in xrange(3):
                A[j][k] -= a * A[i][k]
            b[j] -= a * b[i]
    for i in xrange(3):
        b[i] /= A[i][i]
        A[i][i] = 1.0

u = map(float, raw_input().split())
e = map(float, raw_input().split())
o = map(float, raw_input().split())
p = map(float, raw_input().split())
q = map(float, raw_input().split())

n = [(p[i-2]-o[i-2])*(q[i-1]-o[i-1])-(p[i-1]-o[i-1])*(q[i-2]-o[i-2]) for i in xrange(3)]
v = [e[i]-u[i] for i in xrange(3)]
if sum(n[i]*v[i] for i in xrange(3))==0.0:
    print "HIT"
    exit(0)

A = [[p[i]-o[i], q[i]-o[i], e[i]-u[i]] for i in xrange(3)]
b = [e[i] - o[i] for i in xrange(3)]
solve(A, b)
s, t, x = b
j = lambda x: -0.0000001 < x < 1.0000001
if j(s) and j(t) and j(s+t) and j(x):
    print "MISS"
else:
    print "HIT"

Measured memory_bytes: 4388
N, L = [int(elem) for elem in input().split()]

sum_taste = N * L + (N - 1) * N // 2
# print(sum_taste)
# print(sum_taste - L)
taste_chosen_applepie = None
cur_diff = float('inf')

for i in range(1, N + 1):
    taste_apple = L + i - 1
    taste_applepie = sum_taste - taste_apple
    diff = abs(taste_applepie - sum_taste)
    # print(taste_apple, taste_applepie, diff)
    if diff < cur_diff:
        # print("hoge")
        cur_diff = diff
        taste_chosen_applepie = taste_applepie
print(taste_chosen_applepie)


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

using ll = long long;

int main() {

    ll A, B, K;

    cin >> A >> B >> K;

    ll a = max(A - K, (ll)0);
    ll b;

    K = max(K - A, (ll)0);
    b = max(B - K, (ll)0);

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    string s, t;
    cin >> s >> t;
    
    auto check = [&](string s, string t) {
        int c = 0;
        rep(i, 3) if (s[i] != t[i]) c++;
        return c;
    };
    
    cout << 3 - check(s, t) << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, K;
    cin >> N;
    vector<int> P(N);
    cin >> K;
    REP (i, N) {
        cin >> P[i];
    }
    SORT(P);
    REP(i,K) ans += P[i];
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc171/abc171_b && sh shellscripts/submit_cpp.sh
*/


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> snuke(n,1);
  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int a;
      cin >> a;
      snuke[a-1] = 0;
    }
  }
  int ans = 0;
  for(int c : snuke) ans += c;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string ans;
void solve()
{
 long long N;
  cin>>N;
  ans.clear();
  string ref="zabcdefghijklmnopqrstuvwxy";
  while(N)
  { 
    int k=N%26;
    ans+=ref[k];
    if(k==0)
      N=(N/26)-1;
    else
      N=N/26;
    
  }
    reverse(ans.begin(), ans.end());
    cout<<ans;
 
  
  
}

int main()
{
solve();
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String t = scan.next();
		String p = scan.next();
		for (int i = 0; i <= t.length() - p.length(); i++) {
			if (t.substring(i, i + p.length()).equals(p))
				System.out.println(i);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 26544
#include <iostream>
#include <iomanip>
using namespace std;
 
int main()
{
    long long a,n,b;
    cin>>n;
    cin>>a;
    cin>>b;
    if((b-a)%2==0){
            cout<< ((b-a)/2);
        }
        else if((b-a)%2!=0){
            if((a-1)<=(n-b))
                cout<<std::setprecision(0)<<(a-1)+1+((b-a-1)/2);
            else
                cout<<std::setprecision(0)<<(n-b)+1+((b-a-1)/2);
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main()
{
  int r, D, xt;
  cin >> r >> D >> xt;
  vector<int> x(10);
  generate(x.begin(), x.end(), [&]() {
      xt = r * xt - D;
      return xt;
  });
  copy(x.begin(), x.end(), ostream_iterator<int>(cout, "\n"));
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
pS = []
for i in range(M):
    pS.append(tuple(map(str, input().split())))

# AC数を数える
countAC = 0
# 複数ACしている問題を1つにまとめる
pS_set = set(pS)
# AC数をfor文で計算
for i in pS_set:
    if i[1] == 'AC':
        countAC += 1

# WA数を保存する辞書を作る
countWA_dict = {}
# 始めてACするまでのWA数を保存する辞書を作る
countWA_final = {}
# WA数を数える
countWA = 0

for i in pS:
    # WAだったら
    if i[1] == 'WA':
        # ある問題で始めてWAを見つけた時
        if i[0] not in countWA_dict.keys():
            countWA_dict[i[0]] = 1
        # ある問題で2回目以上WAを見つけた時
        else:
            countWA_dict[i[0]] += 1
    # ACだったら
    else:
        # countWA_finalにまだ保存されていない(=始めてAC)かつcountWA_dictに保存されている(=ACする前にWAした)時
        if i[0] not in countWA_final.keys():
            countWA_final[i[0]] = 0
            if i[0] in countWA_dict.keys():
                # countWA_finalに保存
                countWA_final[i[0]] = countWA_dict[i[0]]
                # countWAにその数を足す
                countWA += countWA_dict[i[0]]

print(str(countAC) + ' ' + str(countWA))

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	string S;
	int Q;

	cin >> S >> Q;

	set<pair<int, char>> s;

	for (int i = 0; i < sz(S); ++i)
		s.insert(mp(i, S[i]));

	int L = 0, R = sz(s) - 1;

	int flip = 0;
	for (int i = 1; i <= Q; ++i) {
		int t;
		cin >> t;
		db(flip);
		if (t == 1)
			flip ^= 1;
		else {
			int F;
			char C;
			cin >> F >> C;
			if (flip)
				F = 3 - F;
			if (F == 1)
				s.insert(mp(--L, C));
			else
				s.insert(mp(++R, C));
		}
	}

	V<char> ans;

	for (auto& pr : s) {
		ans.pb(pr.sc);
	}

	if (flip)
		reverse(ans.begin(), ans.end());

	for (auto& c : ans) {
		cout << c;
	}
	ndl;

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 15176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(j, m) for (int j = 0; i < (int)(n); j++)
using ll = long long;
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll s = 0;
    rep(i, n + 1)
    {
        if ((i % 3 != 0 && i % 5 == 0) || (i % 3 == 0 && i % 5 != 0) || (i % 3 == 0 && i % 5 == 0))
        {
            continue;
        }
        s += i;
    }
    cout << s << endl;
}

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

int main(){
	int n;
	int coin[6]={500,100,50,10,5,1};
	while(cin>>n,n){
		int ans=0;
		n = 1000-n;
		for(int i=0;i<6;i++){
			ans += n/coin[i];
			n %= coin[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long x;
    cin>>x;
    int ans=0;
    long long y=100;
    while(y<x){
        ans++;
        y=y*(1.01);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3688