akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
const int maxn = 100;
int n,a[maxn+1],x;
int res;
main()
{
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> x;
    for (int i=1; i<=n; i++)
        cin >> a[i];
    sort(a+1,a+1+n);
    res=0;
    for (int i=1; i<=n; i++)
    {
        x-=a[i];
        if (x>=0) res++;
    }
    if (x>0) res--;
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9;
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int l, n;
  cin >> l >> n;
  int a[n];
  for(int i = 0; i < n; i++)
  	cin >> a[i];
  sort(a, a+n);
  int mi=(a[n-1]-a[0]);
  for(int i = 1; i < n; i++)
  {
  	mi=min(l-(a[i]-a[i-1]), mi);
  }
  cout << mi << '\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	typedef double d;
	//#define for(i,a,b) for(int i=a;i<b;i++)
	//#define f(i,a,b) for(int i=a;i<=b;i++)
    int main()
    {
        int n;
        string s,r;
        int cnt1=0,cnt2=0;
        cin>>n;
        cin>>s;
        r=s;
        for(int i=0,j=n-1;j>=0 && i<=n-1;j--)
        {
            if (s[j]=='R')
            {
                while (s[i]!='W')
                {
                    i++;
                    if(i==n) break;
                }
                if(i>=j) break;
                swap(s[i],s[j]);
                cnt1++;
            }
        }
        s=r;
        for(int i=0,j=n-1;j>=0 && i<=n-1;i++)
        {
            if (s[i]=='W')
            {
                while (s[j]!='R')
                {
                    j--;
                    if(j==-1) break;
                }
                if(i>=j) break;
                swap(s[i],s[j]);
                cnt2++;
            }
        }
        cout<<min(cnt1,cnt2)<<endl;

    }

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

int main() {
  int h, w;
  std::string temp;
  
  std::cin >> h >> w;
  
  std::vector<std::string> a(h + 2);
  
  a.at(0).assign(w + 2, '#');
  a.at(h + 1).assign(w + 2, '#');
  
  for (int i = 1; i < h + 1; i++) {
    std::cin >> temp;
    a.at(i).assign(w + 2, '#').replace(1, w, temp);
  }
  
  for(int i = 0; i < a.size(); i++) {
    std::cout << a.at(i) << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int gcd (int a, int b) {
        return b == 0 ? a : gcd (b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long total = 0;
        int k = sc.nextInt();

        for (int x = 1; x < k + 1; x++) {
            total += x;
            for (int y = x+1; y < k + 1; y++) {
                int first = gcd(x, y);
                total += 2 * 3 * first;
                for (int z = y+1; z < k + 1; z++) {
                    total += 6 * gcd(first, z);
                }
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 35620
# coding: utf-8
import numpy
n, d = map(int, input().split())
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    a = numpy.array([0, 0])
    b = numpy.array([x, y])
    u = b - a
    kyori = numpy.linalg.norm(u)
    if d >= kyori:
        ans = ans + 1

print(ans)


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

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

int main() {
  char n;
  cin >> n;
  cout << char(n+1) << endl;
  return 0;
}


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

template <typename T>
class fenwick_tree{
	const int n;
	vector<T> dat;
public:
	fenwick_tree(int n_) : n(n_), dat(n, 0) {}
	void add(int i, T val){
		for(;i < n;i |= i + 1){
			dat[i] += val;
		}
	}
	T sum(int i) const {
		T res = 0;
		for(;i >= 0;i = (i & (i + 1)) - 1){
			res += dat[i];
		}
		return res;
	}
	T sum(int l, int r) const {
		return sum(r - 1) - sum(l - 1);
	}
};

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<pair<int, int>> ai;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		ai.emplace_back(a[i], i);
	}
	sort(ai.begin(), ai.end());
	fenwick_tree<int> ft(n);
	for(int i = 0;i < n;i++){
		ft.add(i, 1);
	}
	ll res = 0;
	for(int i = 0;i < n;){
		int val = ai[i].first;
		vector<int> ids;
		while(i < n && ai[i].first == val){
			ft.add(ai[i].second, -1);
			ids.push_back(ai[i++].second);
		}
		for(int id : ids){
			res += min(ft.sum(0, id), ft.sum(id, n));
		}
	}
	cout << res << endl;
	return 0;
}




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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    if(s == "ABC")
    {
        cout << "ARC";
    }
    else
    {
        cout << "ABC";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



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

    ll N, D;
    cin >> N >> D;
    int cnt = 0;
    rep(i, N){
        ll X, Y;
        cin >> X >> Y;
        ll ans = pow(X, 2)+pow(Y, 2);
        if(ans<=pow(D, 2)) cnt++;
    }
    cout << cnt << endl;
	return 0 ;
}

Measured memory_bytes: 3640
S_lst = list(input())

S_len = len(S_lst)

count = 0

count_max = 0

for s in range(0, S_len):

    if S_lst[s] == "A" or S_lst[s] == "C" or S_lst[s] == "G" or S_lst[s] == "T":
        count += 1
        if count > count_max:
            count_max = count

    else:
        count = 0

print(count_max)



Measured memory_bytes: 2940
N = int(input())
rireki = []
rireki.append(input())
flag = 1
for i in range(N-1):
  rireki.append(input())
  if rireki[-2][-1] != rireki[-1][0]:
    flag = 0
  if rireki[-1] in rireki[:-1]:
    flag = 0
print("Yes" if flag else "No")
  
  

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 1010;

int main(int argc, char const *argv[]) {
  int q;
  cin >> q;
  for (auto k = 0; k < q; k++) {
    vector<vector<int>> dp(MAXN, vector<int>(MAXN, 0));
    string s1, s2;
    cin >> s1 >> s2;
    auto n = s1.size();
    auto m = s2.size();
    for (size_t i = 0; i < n; i++) {
      for (size_t j = 0; j < m; j++) {
        if (s1[i] == s2[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    cout << dp[n][m] << endl;
  }

  return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,ans=0,a,b,c;
  a = b = c = 0;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  rep(i,n){
    if(s[i][0]!='B' && s[i][s[i].size()-1]=='A') a++;
    if(s[i][0]=='B' && s[i][s[i].size()-1]!='A') b++;
    if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') c++;
    rep(j,s[i].size()-1){
      if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
    }
  }
  if(c==0){
    ans += min(a,b);
  }else if(a+b>0){
    ans += c+min(a,b);
  }else if(a+b==0){
    ans += c-1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 768
n = gets.to_i
ac = wa = tle = re = 0

n.times do
  case gets.strip
    when 'AC' then ac += 1
    when 'WA' then wa += 1
    when 'TLE' then tle += 1
    when 'RE' then re += 1
  end
end
      
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


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

using namespace std;

int d,n;
int ans;
int t[203],h[203][3];
int dp[203][203];
int main(){
	cin >> d >> n;
	for(int i = 1;i <= d;i++){
		cin >> t[i];
	}
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 3;j++){
			cin >> h[i][j];
		}
	}

	for(int i = 2;i <= d;i++){
		for(int j = 1;j <= n;j++){
			if(h[j][0] > t[i] || h[j][1] < t[i])continue;
			for(int k = 1;k <= n;k++){
				if(h[k][0] > t[i-1] || h[k][1] < t[i-1])continue;
				dp[i][j] = max(dp[i][j],dp[i-1][k]+abs(h[k][2]-h[j][2]));
			}
			ans = max(ans,dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1328
import java.util.Scanner;

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

        num = scan.nextInt();

        String num_s = String.valueOf(num);

        boolean bool = false;
        for(int i = 0; i < 3; i++) {
            String s = num_s.substring(i, i+1);
            if(s.equals("7")) {
                bool = true;
                break;
            }
        }

        if(bool) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 27092
#include <stdio.h>
int main(){
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	x=x+y,y=x-y,x=x-y;
	x=x+z,z=x-z,x=x-z;
	printf("%d %d %d\n",x,y,z);
}

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

string s;

int main()
{
    cin >> s;

    for( int i = 0 ; i < s.size() ; i ++ )
    {
        if((s[i] == 'L' && i % 2 == 0))
        {
            cout << "No" << endl;
            return 0;
        }
        if((s[i] == 'R' && i % 2 != 0))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import numpy as np

dic={}
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'

A = input()
for a in ascii_lowercase:
    dic[a]=[0]*len(A)

i=0
for l in A:
    dic[l][i]=1
    i+=1

for d in dic:
    dic[d]=np.cumsum(dic[d])



dp=[0]*len(A)
dp[0]=1
for i in range(1,len(A)):
    tmp = (i+1-dic[A[i]][i])
    #print(tmp)
    dp[i]=dp[i-1]+tmp

print(dp[-1])


Measured memory_bytes: 60996
#include <stdio.h>
#include <stdlib.h>

int MOD(int a, int p){
	if(a >= 0){
		return a % p;
	}
	else{
		return (p + a % p) % p;
	}
}

int main(){
	int H, W, d, i, j;
	scanf("%d%d%d", &H, &W, &d);
	char **A = (char **)malloc(sizeof(char *) * H);
	for(i = 0; i < H; i++){
		A[i] = (char *)malloc(sizeof(char) * W);
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(MOD(i + j, 2 * d) < d){
				if(MOD(i - j, 2 * d) < d){
					A[i][j] = 'R';
				}
				else{
					A[i][j] = 'Y';
				}
			}
			else{
				if(MOD(i - j, 2 * d) < d){
					A[i][j] = 'G';
				}
				else{
					A[i][j] = 'B';
				}
			}
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			printf("%c", A[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 640
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n); double absolute(double n);
void input(vector<int>& vec);
void print(vector<int> vec); void print(vector<double> vec);
int sum(vector<int> vec); double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int a,b;
    cin >> a>>b;
    int ans=0;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }else{
        for(int num=1;num<b-1+a;++ans){
            if(num<b){
                num=num-1+a;
            }else{
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int sum=0;
  for(int i=0;i<1200;i++){
    double x=floor(i*0.08);
    double y=floor(i*0.1);
    if(a==x&&b==y){
      break;
    }
   sum++;
  }
  if(sum>=1200){
    cout<<-1<<endl;
  }
  else cout<<sum<<endl;
}


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

int main() {
  int N, T; std::cin >> N >> T;
  constexpr int kCostInvalid = 1000000;
  int cost = kCostInvalid;
  int index = -1;

  for (int i = 0; i < N; i++) {
    int c, t; std::cin >> c >> t;
    if (t > T) continue;
    if (c < cost) {
      cost = c;
      index = i + 1;
    }
    cost = std::min(c, cost);
  }

  if (index < 0) std::cout << "TLE" << std::endl;
  else std::cout << cost << std::endl;
}


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

int main(){
  while(1){
    int H,W;
    cin>>H>>W;
    if(H==0 && W==0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if((i+j)%2==0) cout<<"#";
	else cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#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() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
          if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j])
            ans++;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
n=int(input())
k=int(input())

ans=[]

while n>0:
    ans.append(n%10)
    n=n//10
    
ans.reverse()

c = 0

for i in range(len(ans)):
    if ans[i]==1:
        c+=1
    else:
        a=ans[i]
        break

if c>=k:
    print(1)
else:
    print(a)

Measured memory_bytes: 3064
N = int(input())
ans = 0
ary = [0]*100
for n in range(1, N+1):
    s = str(n)
    ary[int(s[0])*10+int(s[-1])] += 1
for i in range(10, 100):
    s = str(i)
    j = int(s[-1])*10+int(s[0])
    ans += ary[i]*ary[j]
print(ans)


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

struct dice {
    int men1, men2, men3, men4, men5, men6;
    // コンストラクタ：構造体をオブジェクト化する時に引数をとった場合される処理
    dice(int men1_, int men2_, int men3_, int men4_, int men5_, int men6_){
        men1 = men1_; men2 = men2_; men3 = men3_;
        men4 = men4_; men5 = men5_; men6 = men6_;
    }

    void roll(char di){
        int ori_men1 = men1; int ori_men2 = men2;
        int ori_men3 = men3; int ori_men4 = men4;
        int ori_men5 = men5; int ori_men6 = men6;
        if(di == 'N'){
            men1 = ori_men2; men5 = ori_men1;
            men6 = ori_men5; men2 = ori_men6;
        }else if(di == 'E'){
            men1 = ori_men4; men3 = ori_men1;
            men6 = ori_men3; men4 = ori_men6;
        }else if(di == 'S'){
            men1 = ori_men5; men5 = ori_men6;
            men6 = ori_men2; men2 = ori_men1;
        }else if(di == 'W'){
            men1 = ori_men3; men3 = ori_men6;
            men6 = ori_men4; men4 = ori_men1;
        }
    }

    int display_up(){ return men1; }
    int display_front(){ return men2; }
    int display_right(){ return men3; }
};

int main()
{
    int n1, n2, n3, n4, n5, n6;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    dice dice1(n1, n2, n3, n4, n5, n6);
    string s1 = "NNNNENNNN";
    string s2 = "WWWW";
    int q; cin >> q;
    for(int j=0; j<q; j++){
        int q1, q2; cin >> q1 >> q2;
        bool isq2 = false;
        for(int i=0; i<s1.size(); i++){
            char com = s1[i];
            dice1.roll(com);
            if(q2 == dice1.display_front()){
                for(int k=0; k<s2.size(); k++){
                    com = s2[k];
                    dice1.roll(com);
                    if(q1 == dice1.display_up()){
                        cout << dice1.display_right() << endl;
                        isq2 = true;
                        break;
                    }
                }
            }
            if(isq2) break;
        }
    }
}


Measured memory_bytes: 3196
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	char S;
	cin >> S;

	cout << (char)(S + 1) << endl;

	return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    int n;
    cin>>n;
    int ans = 0;
    map<pair<int,int>,int> mp;
    string s;
    for(int i = 1; i<=n; i++){
        s = to_string(i);
        mp[{s.front() - '0',s.back() - '0'}]++;
    }
    for(int i = 1; i<=n; i++){
        s = to_string(i);
        ans += mp[{s.back() - '0',s.front() - '0'}];
    }
    cout<<ans;

}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    out(n*(n-1)/2);
    re0;
}

Measured memory_bytes: 256
#include<stdio.h>
    int main(void){
    int a,b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(a<b){
       if(b<c){
       printf("Yes\n");
       }
       else{
       printf("No\n");
       }
    }
    else{
    printf("No\n");
    }
    
    return 0;
    }


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;



// ABC129C - Typical Stairs
// https://atcoder.jp/contests/abc129/tasks/abc129_c
void ABC129C() {

	int N, M;
	cin >> N >> M;

	vector<int> oks(N + 1, true); //踏める段・踏めない段を示す
	for (int i = 0; i < M; i++)
	{
		int a;
		cin >> a;
		oks[a] = false; //踏めない段
	}

	vector<ll> dp(N+1);
	dp[0] = 1;
	for (int now = 0; now < N; now++)
	{
		//f(x) = f(x-1) + f(x-2)の計算
		for (int next = now + 1; next <= min(N, now + 2); next++) {
			if (oks[next]) {
				dp[next] += dp[now];
				dp[next] %= MOD;
			}
		}

	}

	cout << dp[N] << endl;






}

int main() {
	ABC129C();

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        m.insert(make_pair(s, i));
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 19252
import sys
inp = lambda: sys.stdin.readline()
mi = lambda: map(int, inp().split())
li = lambda: list(map(int, inp().split()))
mf = lambda: map(float,inp().split())
lf = lambda: list(map(float,inp().split()))

def nCk(n,k):
    u,s = 1,1
    for i in range(n - k + 1,n + 1):u *= i
    for i in range(1,k + 1):s *= i
    return u // s
N,A,B = mi()
vec = lf()
vec.sort()
vec = vec[::-1]
avr = 0.0
for i in range(A):
    avr += vec[i]
avr /= A
print("{:.08f}".format(avr))
kosu = vec.count(vec[A - 1])
#print(kosu)
if kosu == 1:
    print(1)
    sys.exit()
if vec[0] == vec[A - 1]:
    ans = 0
    for i in range(A,B + 1):
        if vec[i - 1] != vec[0]:
            break
        ans += nCk(kosu,i)
    print(ans)
else:
    K = vec[:A].count(vec[A - 1])
    print(nCk(kosu,K))

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    int num = 0;
    num = a*100 + b*10 + c;
    if(num%4==0) cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

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

int main(){
    long N,x = 1;
    double num = 10.0, index = 9, plus = 7.0;
    cin >> N;

    rep(i, N){
        double div = pow(num, index);
        x = x * long(i + 1) % long(div + plus);
    }
    cout << x << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
    int x,i,j,z;
    scanf("%d", &x);
    for(j=x; j<x+100; j++){
        z=0;
        for(i=2; i<=j/2; i++){
            if(j%i==0){z=1;
                       break;}
    }
    if(z==0){break;}
    }
    printf("%d", j);

}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans[51] = {},i,j,k,l,x;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            for(k=0;k<10;k++){
                for(l=0;l<10;l++) ans[i+j+k+l]++;
            }
        }
    }
    while(cin >> x) cout << ans[x] << "\n";
}


Measured memory_bytes: 3084
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double d;
ll M=998244353;
ll fact[300100]={0};

ll powmod(ll a,ll b)
{
    a=a%M;
    if(b==0)
    {
        return 1;
    }

    else if(b==1)
    {
        return a;
    }
    ll ans=1;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b=b>>1;
        a=(a*a)%M;
    }
    return ans;
}
ll C(ll a,ll b)
{
    if(b==0||b==a)
    {
        return 1;
    }
    else if(b==1||(b==(a-1)))
    {
        return a;
    }
    ll ans=fact[a]%M;
    ans=((ans%M)*(powmod(fact[a-b],M-2)%M))%M;
    ans=((ans%M)*(powmod(fact[b],M-2)%M))%M;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    fact[0]=1;
    for(ll i=1;i<=300099;i++)
    {
        fact[i]=((fact[i-1]%M)*(i))%M;
    }
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    ll ans=0;
    //cout<<C(4,1)<<endl;
    //cout<<(C(5,3))<<endl;
    for(ll i=0;i<=n;i++)
    {
        //cout<<i<<endl;
        ll j=k-(i*a);
        if(j%b==0 && j>=0)
        {
            j=j/b;
            //cout<<i<<" "<<j<<endl;

            if((j)<=n)
            {
               // cout<<n<<" "<<i<<"--"<<n<<" "<<j<<endl;
               //cout<<((C(n,i)%M)*(C(n,j)))%M<<endl;
                ans=(ans+((C(n,i)%M)*(C(n,j)%M)))%M;
                //cout<<ans<<endl;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T>
bool chmax(T& a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;

int main(){
    int n,w;
    cin>>n>>w;
    vector<int64_t>weight(n);
    vector<int64_t>value(n);
    vector<vector<int64_t>>dp(110,vector<int64_t>(100001));
    for(int i=0;i<n;i++)cin>>weight.at(i)>>value.at(i);
    for(int j=0;j<w+1;j++) if(j-weight.at(0) >= 0) dp.at(0).at(j)=value.at(0);

    for(int i=1;i<n;i++){
        for(int j=0;j<w+1;j++){
            if(j-weight.at(i) >= 0) chmax(dp.at(i).at(j) , dp.at(i-1).at(j-weight.at(i)) + value.at(i));
            chmax(dp.at(i).at(j) , dp.at(i-1).at(j));
        }
    }
    /*for(int i=0;i<n;i++){
        for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" ";
        cout<<endl;
    }*/

    cout<<dp.at(n-1).at(w)<<endl;
}

Measured memory_bytes: 87296
#include <iostream>
#include <algorithm>
#define mod 1000000007
using namespace std;
int a[20], f[20][1 << 16 | 5], fac[1 << 16 | 5], inv[1 << 16 | 5], pow2[1 << 16];
int C(int x, int y){
    if (x < y)
        return 0;
    return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int poww(int x, int y){
    int ans = 1;
    for (int i = 1; i <= y; i <<= 1, x = 1LL * x * x % mod)
        if (y & i)
            ans = 1LL * ans * x % mod;
    return ans;
}
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i)
        cin >> a[i];
    pow2[0] = 1;
    for (int i = 1; i <= n; ++ i)
        pow2[i] = pow2[i - 1] * 2 % mod;
    fac[0] = 1;
    for (int i = 1; i <= pow2[n]; ++ i)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[pow2[n]] = poww(fac[pow2[n]], mod - 2);
    for (int i = pow2[n] - 1; i; -- i)
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
	inv[0] = 1;
    sort(a + 1, a + 1 + m);
    f[m + 1][0] = 1;
    for (int i = m; i; -- i){
        for (int s = 0; s < 1 << n; ++ s)
            f[i][s] = f[i + 1][s];
        for (int s = 0; s < 1 << n; ++ s){
            int cnt = 0;
            for (int j = 1; j <= n; ++ j)
                if (s >> (j - 1) & 1)
                    cnt += pow2[j - 1];
            int rst = pow2[n] - a[i] - cnt;
            for (int j = 1; j <= n; ++ j)
                if (! (s >> (j - 1) & 1))
                    (f[i][s | (1 << j - 1)] += 1LL * f[i + 1][s] * C(rst, pow2[j - 1] - 1) % mod * fac[pow2[j - 1]] % mod) %= mod;
        }
    }
    int ans = 0;
    for (int i = 0; i < 1 << n; ++ i){
        int cur = f[1][i], cnt = 0, tot = 0;
        for (int j = 1; j <= n; ++ j)
            if (i >> (j - 1) & 1)
                cnt += pow2[j - 1], ++ tot;
        cur = 1LL * cur * fac[pow2[n] - cnt - 1] % mod;
        if (tot & 1)
            ans = (ans - cur + mod) % mod;
        else
            ans = (ans + cur) % mod;
    }
    ans = 1LL * ans * pow2[n] % mod;
    cout << ans << endl;
}


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

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int n, k;
int l[11],r[11];
mint dp[200005];//マスNに行く方法
mint sum[200005];

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

  rep(i, k){
    cin >> l[i] >> r[i];
  }
  dp[1]=1;sum[1]=1;
  for(int i=2;i<=n;i++){
    mint cnt=0;
    rep(j, k){
      if(i-r[j]-1>0){
        cnt+=sum[i-l[j]]-sum[i-r[j]-1];
      }
      else if(i-l[j]>0){
        cnt += sum[i-l[j]];
      }
    }
    dp[i]=cnt;
    sum[i]=sum[i-1]+cnt;
  }
  
  cout << dp[n] << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int d[100];
	int f[100]={0};
	for(int i=0;i<k;i++){
		cin>>d[i];
		f[d[i]]=1;
	}
	int N=n;
	for (;;N++) {
    	stringstream ss;
    	string str;
    	ss<<N;
    	ss>>str;
      bool ok = true;
      for (int i = 0 ; i < str.size() ; i++) {
        for (int j = 0 ; j < k ; j++) {
          if ((int)(str[i] - '0') == d[j]) 
		  	ok = false;
        }
      }
      if (ok) 
	  	break;
  }
  cout << N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int A[N + 1], B[N];
  REP(i, N + 1) cin >> A[i];
  REP(i, N) cin >> B[i];

  ll cnt = 0;
  REP(i, N) {
    if(A[i] <= B[i]) {
      cnt += A[i];
      int rest = B[i] - A[i];
      cnt += min(A[i + 1], rest);
      A[i + 1] -= min(A[i + 1], rest);
    } else {
      cnt += B[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if( r <= x && x <= W-r && r <= y && y <= H-r ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{    rtn
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
     int a, b, n;
     cin  >> a >> b >> n;
     // n = 100;
     // b = 42;
     // lop(i, 0, n)
     // {
     //      int a1 = (a * i) / b , a2 =  a * (i / b);
     //      bug(i, a1 - a2);
     // }
     int s = 0, e = min(b - 1, n);
     int a1 = (a * e) / b , a2 =  a * (e / b);
     cout << a1 - a2 << endl;



}

int32_t main()
{
     ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

     int test = 1;
     // cin >> test;
     while (test--)solve();


}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
 	int z1, z2;
 	cin >> z1 >> z2;
 	int hcf = __gcd(z1, z2);
 	cout << (z1*z2)/hcf << '\n';
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h, n = na()
a = na()
s = sum(a)
if h > s:
    print("No")
else:
    print("Yes")


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll a, b; cin >> a >> b;

    cout << max(max(a+b, a-b), a*b) << endl;

    return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c,d,e;
  while(cin >> a >> b >> c>> d>> e){
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    v.push_back(d);
    v.push_back(e);
    sort(v.begin(), v.end(), greater<int>());
    cout << v[0] <<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 100100100100;
const int MOD = 1000000007;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<MOD>;


const int MAX = 1e5 + 10;
long long 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;
    }
}

// 二項係数計算
long long 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(){
  COMinit();

  int N, K; cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(ALL(A));

  mint ans = 0;
  rep(i, N){
    ans += mint(A[i]) * mint(COM(i, K-1) - COM(N-i-1, K-1));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> cont(n);
  
  for(int i = 0 ; i < n ; i++){ 
    cin >> cont.at(i);
  }
  
  sort(cont.begin() , cont.end());
  
  int a = 0;
  int b = 0;
  int ans = 1000000009;
  //n = 4 k = 2 
  for(int i = 0 ; i < n-k+1; i++){
    a = cont.at(i);
    b = cont.at(i+k-1);
    ans = min(ans , b-a);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int RA,RB;
	int MA,MB;
	int *A=&MA,*B=&MB,*C;
	int G,L;
	while(scanf("%d %d",&RA,&RB)!=EOF){
		MA=RA;
		MB=RB;
		if(*A<*B){
			C=A;
			A=B;
			B=C;
		}
		while(*A=(*A)%(*B)){
			C=A;
			A=B;
			B=C;
		}
		G=*B;
		L=RA/G*RB;
		printf("%d %d\n",G,L);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#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() {
  long double l;
  cin >> l;

  long double hen = l/3.0;

  cout << fixed << setprecision(12) << hen*hen*hen << endl;

  return 0;
}


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

goukei=[]

for i in range(N):
  A,B=map(int,input().split())
  goukei.append((A+B,A,B))

goukei.sort(key=lambda x:x[0],reverse=True)

Asum=0
Bsum=0
for i in range(N):
  if i%2==0:
    Asum+=goukei[i][1]
  else:
    Bsum+=goukei[i][2]
    
print(Asum-Bsum)

Measured memory_bytes: 22136
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5],B[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	f1(i,n)sc(A[i]);
	fd(i,n,1){
		c=0;
		for(ll j=i+i;j<=n;j+=i)c^=B[j];
		if(c^A[i])B[i]=1,ans++;
	}	
	pr(ans);
	f1(i,n)if(B[i])cout<<i<<" ";
	

	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 6528
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();
        if (N == 1) {
            System.out.println("1");
        } else {
            int X = 1;
            while (X <= N) {
            X*=2;
            }
            System.out.println(X/2);
        }
    }

}


Measured memory_bytes: 21844
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
S_=[[] for i in range(H)]
for i in range(H):
  for j in range(W):
    S_[i].append(S[i][j])
def chkS(i,j,H,W):
  if 0<=i<H and 0<=j<W:
    return True
  else:
    return False
import copy
  
def tansaku(i,j,__):
  global H,W,S
  X=[]
  #ue
  ni=i
  nj=j-1
  if chkS(ni,nj,H,W):
    if S[ni][nj]=='.':
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    elif S[ni][nj]=='#':
      pass
    elif S[ni][nj]>S[i][j]+1:
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    else:
      pass
    
  #sita
  ni=i
  nj=j+1
  if chkS(ni,nj,H,W):
    if S[ni][nj]=='.':
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    elif S[ni][nj]=='#':
      pass
    elif S[ni][nj]>S[i][j]+1:
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    else:
      pass
    
  #migi
  ni=i+1
  nj=j
  if chkS(ni,nj,H,W):
    if S[ni][nj]=='.':
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    elif S[ni][nj]=='#':
      pass
    elif S[ni][nj]>S[i][j]+1:
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    else:
      pass
    
    
  #hidari
  ni=i-1
  nj=j
  if chkS(ni,nj,H,W):
    if S[ni][nj]=='.':
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    elif S[ni][nj]=='#':
      pass
    elif S[ni][nj]>S[i][j]+1:
      S[ni][nj]=S[i][j]+1
      X.append([ni,nj])
    else:
      pass

  if len(X)==0:
    return X,S[i][j]
  else:
    return X,__+1

  
ans=0
for i in range(H):
  for j in range(W):
    if S_[i][j] =='.':
      _=[[i,j]]
      S=copy.deepcopy(S_)
      S[i][j]=0
      __=0
      while len(_)>0:
        _X=[]
        for NEXT in _:
          X,__=tansaku(NEXT[0],NEXT[1],__)
          _X.extend(X)
        _=_X
      if __>ans:
        ans=__
print(ans)

Measured memory_bytes: 3532