akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int N, T, S, A[3000], B[3000];
int dp[3001];

signed main()
{
    cin >> N >> T >> S;

    rep(i, N) {
        cin >> A[i] >> B[i];
    }

    rep(i, N) {
        rrep(j, T + 1) {
            if (j - B[i] >= 0) {
                if (j > S && j - B[i] < S) continue;
                chmax(dp[j], dp[j - B[i]] + A[i]);
            }
        }
    }

    int ma = 0;

    rep(i, T + 1) chmax(ma, dp[i]);

    cout << ma << endl;
}

Measured memory_bytes: 1196
#include <stdio.h>
int main(void){
    int i, j, k, n;
    int count[4][3][10]={{{0}}};
    scanf("%d", &n);
    for(i=0; i<n; i++){
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3)printf("####################\n");
    }
    return 0;

}



Measured memory_bytes: 2048
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.07.05 21:01:25
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    cout << (n + 999) / 1000 * 1000 - n << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<int>E[100];
vector<ll>recpath(100);
map<pair<int, int>,int>mp;
ll po(ll a,int n){
	ll ret = 1;
	for (int i = 0; i < n; i++)ret *= a;
	return ret;
}

ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void dfs(int now,int go,int pa,ll path,int num){
	if (now == go) {
		recpath[num] = path;
		return;
	}
	fore(x, E[now]) {
		if (x != pa) {
			path += 1LL << mp[{min(now,x),max(now,x)}];
			dfs(x, go, now, path, num);
			path -= 1LL << mp[{min(now,x),max(now,x)}];
		}
	}
	return;
}
ll cnt(ll n) {
	ll ret = 0;
	while (n > 0) {
		ret += n % 2LL;
		n /= 2LL;
	}
	return ret;
}
vector<ll>dp;

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

	int N;
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].pb(b);
		E[b].pb(a);
		mp[{min(a,b),max(a,b)}] = i;
	}


	int M;
	cin >> M;
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		dfs(u, v, -1, 0, i);
	}


	dp.resize(1 << M);
	for (int i = 1; i < (1 << M); i++) {
		int rec;
		for (int j = 0; j < M; j++) {
			if ((i >> j) & 1) {
				rec = j;
				break;
			}
		}
		dp[i] = (dp[i - (1 << rec)]|recpath[rec]);
	}


	ll ans = po(2, N - 1);
	ll sub = 0;
	for (int i = 1; i < (1 << M); i++) {
		int bitcnt = 0;
		for (int j = 0; j < M; j++)bitcnt += ((i >> j) & 1);
		ll mul = (bitcnt % 2 == 0) ? -1 : 1;
		sub += mul * modpow(2,N-1- __builtin_popcountll(dp[i]));
	}
	ans -= sub;
	puts(ans);


	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<string>S(n);
    for(int i=0;i<n;i++){
        cin  >> S.at(i);   
    }

    bool flag = true;
    //末尾と次の語の頭文字を比較
    for(int i=0;i<n-1;i++){
        if(S.at(i).at(S.at(i).size()-1) == S.at(i+1).at(0)){
            flag = true;
        }
        else{
            flag = false;
            break;
        }
    }

    //flag = trueの場合、言葉にダブりがないかを確認
    if(flag){
        sort(S.begin(), S.end());
        for(int i=0;i<n-1;i++){
            if(S.at(i) == S.at(i+1)){
                flag = false;
                break;
            }
        }
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        // Your code here!

       Scanner sc = new Scanner(System.in);
       int i = sc.nextInt();
       List<String> tinko = new ArrayList<>();

       for(int t = 0;t < i;t++){
           tinko.add(sc.next());
       }

       Long kosuu = tinko.stream().distinct().count();

       System.out.println(kosuu);

    }

}

Measured memory_bytes: 72824
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> S(N+5,0);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		if(a>b)swap(a,b);
		S[a+1]++;
		S[b+1]--;
	}
	
	for(int i=1;i<N;i++){
		S[i] += S[i-1];
		if(S[i]%2==1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	cout<<"YES"<<endl;
	
	return 0;
}

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

#define N 11451419

int ans[N+1];
bool is_composite[N+1];
vector<int> primes;

int main() {
  is_composite[1] = true;
  for (int i=2; i<=N; i++) {
    if (!is_composite[i]) {
      primes.push_back(i);
      for (int j=i+i; j<=N; j+=i) {
        is_composite[j] = true;
      }
    }
  }

  int n = primes.size();
  for (int i=0; i<n-1; i++) {
    int a = primes[i];
    int b = primes[i+1];
    for (int j=a+1; j<b; j++) ans[j] = b-a;
  }

  while (1) {
    int k;
    scanf("%d", &k);
    if (k == 0) return 0;
    printf("%d\n", ans[k]);
  }
}

Measured memory_bytes: 61548
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    set<ll> st;
    rep(i,n) {
        ll a; cin>>a;
        st.insert(a);
    }

    if (st.size() == n) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

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

void sep(int n, int& k)
{
	while(n > 0){
		k += n % 10;
		n /= 10;
	}
}
int main()
{
	int n,k = 0;
	cin >> n;

	sep(n,k);
	if(n % k == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
} 



Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    q=INT()
    l=''
    r=''
    ct=0
    for i in range(q):
        fc=LISTS()
        if fc[0]=="1":
            ct+=1
        else:
            if fc[1]=="1":
                if ct%2==0:
                    l=fc[2]+l
                else:
                    r=r+fc[2]
            else:
                if ct%2==1:
                    l=fc[2]+l
                else:
                    r=r+fc[2]
    
    sums=l+s+r
    if ct%2==1:
        ans=""
        for i in range(len(sums)-1,-1,-1):
            ans=ans+sums[i]
    else:
        ans=sums
    
    print(ans)
                
if __name__ == '__main__':
    do()

Measured memory_bytes: 10412
def ok(a,b,c):
    return (a*a+b*b==c*c)

n=input()
for i in range(n):
    a,b,c=map(int,raw_input().split())
    if(ok(a,b,c) or ok(b,c,a) or ok(c,a,b)):
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 5452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b, c;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        solve();
    }

    void solve() {
        if (b - a == c - b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define sp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}



void solve()
{
	int x = 1;
	int n; cin >> n;
	while(x <= n) x *= 2;
	cout << x / 2; 
}

 
int main()
{
	// freopen("crosses.in", "r", stdin);
	// freopen("crosses.out", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3672
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
			int money = scanner.nextInt() % 1000;
			int result = 0;
			if(money != 0)
				result = 1000 - money;
			log.write("" + result);
		log.flush();
	}
}


Measured memory_bytes: 27104
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int> > a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());

    set<int> s;
    s.insert(-1);
    s.insert(n);
    long long ans = 0;
    for(int i=0; i<n; ++i){
        int k = a[i].second;
        int l = *(-- s.lower_bound(k));
        int r = *s.upper_bound(k);
        ans += (long long) (k - l) * (r - k) * a[i].first;
        s.insert(k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main(){
    int N, K;
    long ans = 0;
    long a[100000];
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    long cumsum[100001];
    long possum[100001];
    cumsum[0] = 0;
    possum[0] = 0;
    for(int i = 1; i <= N;i++){
        cumsum[i] = cumsum[i-1]+a[i-1];
        possum[i] = possum[i-1];
        if(a[i-1] > 0) possum[i] += a[i-1]; 
        //cout << cumsum[i] << ' ' << possum[i] << endl;
    }
    for(int i = 0; i+K-1 < N; i++){
        long tmp;
        tmp = possum[i] + possum[N] - possum[i+K];
        //cout << tmp << endl;
        ans = max(ans, tmp);
        ans = max(ans, tmp+cumsum[i+K]-cumsum[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
N, K = map(int, input().split())
A = [0] * N
for i in range(K):
    d = int(input())
    for k in list(map(int, input().split())):
        A[k-1] += 1

ans = 0
for i in A:
    if i == 0:
        ans += 1
print(ans)


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
    Yes();
  else
    No();
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    map<string,ll> mp;
    ll ans=0;
    rep(i,n){
        string s; cin>>s;
        mp[s]++;
    }
    ll m; cin>>m;
    rep(i,m){
        string s; cin>>s;
        mp[s]--;
    }
    for(auto s:mp){
        if(ans<s.second) ans=s.second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			num[i] = scanner.nextInt();
		}
		for (int i = n / 2; i >= 1; i--) {
			maxHeapify(i, num);
		}
		for (int i = 1; i <= n; i++) {
			System.out.print(" " + num[i]);
		}
		System.out.println();
	}

	private void maxHeapify(int i, int[] num) {
		int l = i * 2;
		int r = i * 2 + 1;
		int H = num.length - 1;
		int largest = -1;
		if (l <= H && num[l] > num[i])
			largest = l;
		else
			largest = i;

		if (r <= H && num[r] > num[largest])
			largest = r;

		if (largest != i) {
			swap(i, largest, num);
			maxHeapify(largest, num);
		}
	}

	private void swap(int i, int largest, int[] num) {
		int t = num[i];
		num[i] = num[largest];
		num[largest] = t;
	}
}

Measured memory_bytes: 165892
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(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(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<int> d(N);
	FDS(i,N){
		cin>>d[i];
	}
	int ans=0;
	VSORT(d);
	ans=d[N/2]-d[N/2-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 640
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for (ll i = k; i <= n + 1; i++) {
    ans += ((i * (2 * n - i + 1) - i * (i - 1)) / 2 + 1) % mod;
    // cout << (i * (2 * n - i + 1) - i * (i - 1)) / 2 << endl;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);

	lli n;
	cin>>n;
	string s;
	cin>>s;
	map<string,lli> ani;
	for(lli i=0;i<n-2;i++){
		string temp="";
		temp+=s[i];
		temp+=s[i+1];
		temp+=s[i+2];
		ani[temp]++;
		//cout<<temp;

	}
	cout<<ani["ABC"];


}

Measured memory_bytes: 256
use proconio::input;

const M: u64 = 1000_000_007;

fn main() {
    input! {
        k: u64,
        s: String,
    }
    let slen = s.len() as u64;
    let e = k + slen;

    let mut r = 0;
    let mut ncr = 1;
    for n in slen..(e + 1) {
        r += ncr * (modpow(25, n - slen) * modpow(26, e - n) % M);
        r %= M;
        ncr *= n * modpow(n - slen + 1, M - 2) % M;
        ncr %= M;
    }

    println!("{}", r);
}

fn modpow(x: u64, y: u64) -> u64 {
    let mut result = 1;
    let mut a = x;
    let mut b = y;
    while b > 0 {
        if b % 2 == 1 {
            result = result * a % M;
        }
        a = a * a % M;
        b /= 2;
    }
    result
}

pub fn binom_pascal( n: u64, k: u64 ) -> u64 {
    if k == 0 || k == n {
        return 1;
    }
    let k = k as usize;

    let mut p = vec![ 1 ];

    for _ in 0..n-1 {
        let mut c = vec![ 1 ];

        for x in p.windows(2) {
            c.push( x[0] + x[1] );
        }
        c.push( 1 );

        p = c;
    }

    p[k-1] + p[k]
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double L;
    cin >> L;
    L/=3;
    cout << setprecision(20) << L*L*L << endl; 
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
aLst = list(map(int, input().split()))
aLst.sort()
cdict = {}
for i in range(M):
    B, C = map(int, input().split())
    if C in cdict.keys():
        cdict[C] = cdict[C] + B
    else:
        cdict[C] = B

for i in aLst:
    if i in cdict.keys():
        cdict[i] = cdict[i] + 1
    else:
        cdict[i] = 1

sordC = sorted(cdict.items(), key=lambda x:x[0], reverse=True)
ans = 0
tmp = 0
for i in range(N):
    for j in range(sordC[i][1]):
        if tmp < N:
            ans += sordC[i][0]
            tmp += 1
        else:
            break
    if tmp >= N:
        break
print(ans)

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

using namespace std;

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

    vector<int> moji(50,0);

    for(int i = 0; i< 4;i++){
        moji[ s[i] - 'A' ] ++;
    }
    int syurui=0;
    int flag = 0;

    for(int i = 0;i < 50;i ++){
        if(moji[i]!=0){
            syurui++;
            if(moji[i] == 2)flag++;
        }
    }

    if(syurui ==2 && flag == 2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    string a[3];
    cin >> a[0] >> a[1] >> a[2];
    int next = 0;
    while(1){
        if(a[next].empty()){
            printf("%c\n",next+'A');
            break;
        }
        int c = a[next].front()-'a';
        a[next].erase(a[next].begin());
        next = c;
    }
}   

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

A = []
for _ in range(3):
    a = list(map(int, input().split()))
    A += a

N = int(input())

OPEN = []
for _ in range(N):
    b = int(input())

    if b in A:
        OPEN.append(A.index(b))

#print(OPEN)

ans = 'No'

if 0 in OPEN:
    if 1 in OPEN and 2 in OPEN:
        print('Yes')
        exit()

    if 3 in OPEN and 6 in OPEN:
        print('Yes')
        exit()

    if 4 in OPEN and 8 in OPEN:
        print('Yes')
        exit()

if 1 in OPEN:
    if 4 in OPEN and 7 in OPEN:
        print('Yes')
        exit()

if 2 in OPEN:
    if 5 in OPEN and 8 in OPEN:
        print('Yes')
        exit()

    if 4 in OPEN and 6 in OPEN:
        print('Yes')
        exit()

if 3 in OPEN:
    if 4 in OPEN and 5 in OPEN:
        print('Yes')
        exit()

if 6 in OPEN:
    if 7 in OPEN and 8 in OPEN:
        print('Yes')
        exit()

print('No')
exit()


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

int main() {
  int n;
  cin >> n;
  
  int s1 = n / 100;
  int s2 = n / 10 - 10 * s1;
  int s3 = n - (100 * s1 + 10 * s2);
  
  cout << s1 + s2 + s3 << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c;
	int i;
	int count = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a;i <= b; i++){
		if(c%i==0)count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    double n;
    while(cin>>n)
    {
        double ans=(n/3)*(n/3)*(n/3);
        printf("%.10lf\n",ans);
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  ivec a(n);
  REP(i, n) cin >> a[i];
  int A = 0, B = 0;
  sort(RALL(a));
  REP(i, n) {
    if (i % 2)
      B += a[i];
    else
      A += a[i];
  }
  int ans = abs(A - B);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int[] sosu= {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
		int[][] yakusu=new int[25][101];
		int[] kosu=new int[101];
		List<Integer> unko=new ArrayList<Integer>();
		for(int i=1; i<=100; i++) {
			unko=new ArrayList<Integer>();
			fra(i,unko);
			for(int j=0; j<unko.size(); j++) {
				int a=unko.get(j);
				for(int k=0; k<25; k++) {
					if(a==sosu[k]) {
						yakusu[k][i]++;
					}
				}
			}
		}
		for(int i=0; i<25; i++) {
			for(int j=1; j<=100; j++) {
				yakusu[i][j]=yakusu[i][j]+yakusu[i][j-1];
			}
		}
		kosu[0]=0;
		for(int i=1; i<=100; i++) {
			int yoni=0;
			int nii=0;
			for(int j=0; j<25; j++) {
				if(yakusu[j][i]>=4) {
					yoni++;
				}
				if(yakusu[j][i]>=2) {
					nii++;
				}
			}
			kosu[i]+=((yoni)*(yoni-1)/2)*Math.max((nii-2),0);

			int jyuyon=0;

			for(int j=0; j<25; j++) {
				if(yakusu[j][i]>=14) {
					jyuyon++;
				}
			}
			kosu[i]+=jyuyon*(yoni-1);
			int nijyu4=0;
			for(int j=0; j<25; j++) {
				if(yakusu[j][i]>=24) {
					nijyu4++;
				}
			}
			kosu[i]+=nijyu4*(nii-1);

			int nnjy=0;

			for(int j=0; j<25; j++) {
				if(yakusu[j][i]>=74) {
					nnjy++;
				}
			}
			kosu[i]+=nnjy;
		}

		for(int i=0; i<25; i++) {
			//System.out.println(sosu[i]+" "+yakusu[i][100]);
		}
		for(int i=99; i<=100; i++) {
			//System.out.println(i+"! = "+kosu[i]);
		}
		int unkoo=sc.nextInt();
		System.out.println(kosu[unkoo]);
	}

	public static void fra(int a,List<Integer> p) {//int型用
		for(int i=2; i*i<=a; i++) {
			if(a%i==0) {
				p.add(i);
				fra(a/i,p);
				return;
			}
		}
		p.add(a);
	}


}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

vi GeneratePrimes(int maxVal){
	vector<bool> pri(maxVal+1,true);
	vi ret;
	FOR(i,2,maxVal+1)if(pri[i]){
		ret.PB(i);
		for(int j=i*2;j<=maxVal;j+=i)
			pri[j]=false;
	}
	return ret;
}

signed main(){
	vi primes=GeneratePrimes(100000);
	map<int,int> squares;
	for(auto v:primes)if(v*v<=10000000000LL){
		squares[v*v]=v;
		squares[v]=v*v;
	}
	int n=read();
	map<pii,pii> g;
	const int inf=11451436419LL;
	const auto mult=[](int& x,int y){
		x=min(x*y,inf);
	};
	REP(i,n){
		int a=read(),b=1,tmp=a;
		for(auto v:primes){
			int x=v*v*v;
			if(x>10000000000LL)
				break;
			while(a%x==0){
				a/=x;
				tmp/=x;
			}
			int c=0;
			while(a%v==0){
				c++;
				a/=v;
			}
			int d=1;
			REP(_,(3-c)%3)
				d*=v;
			mult(b,d);
		}
		if(a==1);
		else if(squares.count(a))
			mult(b,squares[a]);
		else
			b=inf;
		a=tmp;
		if(a<b)
			g[MP(a,b)].first++;
		else
			g[MP(b,a)].second++;
	}
	int ans=0;
	for(auto kv:g)
		if(kv.first.first==1)
			ans++;
		else
			ans+=max(kv.second.first,kv.second.second);
	cout<<ans<<endl;
}


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

sum1 = sum(a)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

li = make_divisors(sum1)

ans = 0

for i in li:
    b = sorted(list(map(lambda x: x % i,a)))
    count = 0
    flag = -1
    for j in range(len(b)):
        if b[j] % i != 0:
            count += b[j]
            while b[j] > 0:
                if b[j] + b[flag] < i:
                    b[flag] += b[j]
                    b[j] = 0
                else:
                    b[j] -= i - b[flag]
                    b[flag] = i
                    flag -= 1
    if count <= k:
        ans = max(ans,i)
print(ans)


Measured memory_bytes: 3064
import scipy as sp

def sum_of_digits(n):
    answer = 0
    while True:
        if n == 0:
            break
        else:
            answer += n%10
            n = n // 10
    return answer
     

N = int(input())
answer = N 
for a in sp.arange(1, N//2+1):
  b = N - a
  sum = sum_of_digits(a) + sum_of_digits(b)
  if sum < answer:
    answer = sum
         
     
print(answer)

Measured memory_bytes: 13284
#include<stdio.h>
#include<string.h>

int main(){

	int N = 0;	//問題番号
	int M = 0;	//ドリンクの番号	

	scanf("%d",&N);
	int T[N+1];	//N番目の問題を解くのにかかる時間

	for(int i=1; i<=N; i++){
		scanf("%d",&T[i]);
	}


	scanf("%d",&M);

	int P;	//ドリンクの効果が効く、Xに対応する問題
	int X;	//ドリンクを飲んだ場合に、N番目の問題を解くのにかかる時間
	int result = 0;;	//

	for(int j=1; j<=M; j++){
		result = 0;
		scanf("%d %d",&P,&X);
		for(int k=1; k<=N; k++){
			if( k == P ){
				result += X;
			}else{
				result += T[k];
			}
		}
		printf("%d\n",result);
	}	



	return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	int a, b; cin >> a >> b;
	if(a + b < 10)printf("%d\n", a + b);
	else printf("error\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int INF = 1_000_000_000;
   	public int knapsack(int n, int capacity, int[] weights, int[] values) {
        int totalValue = 0;
        for (int val: values) {
            totalValue += val;
        }
        // System.out.println("total value: " + totalValue);
        int[] dp = new int[totalValue + 1];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            // for (int v = totalValue - values[i]; v >= 0; v--) {
            for (int v = totalValue; v >= 0; v--) {
                int skip = dp[v];
                int take = INF;
                if (values[i] <= v) {
                    take = dp[v - values[i]] + weights[i];
                }
                // System.out.println(String.format("Item %d. Value %d, weight %d. Skip: %d, take: %d", i, v, weights[i], skip, take));
                dp[v] = Math.min(skip, take);
            }
            // System.out.println(Arrays.toString(dp));
        }
        int result = 0;
        for (int i = 0; i < dp.length; i++) {
            if (dp[i] <= capacity) {
                result = Math.max(result, i);
            } 
        }
        return result;
    }
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] split = br.readLine().split(" ");
            int n = Integer.parseInt(split[0]);
            int w = Integer.parseInt(split[1]);
          	int[] weights = new int[n];
          	int[] values = new int[n];
            for (int i = 0; i < n; i++) {
                split = br.readLine().split(" ");
                weights[i] = Integer.parseInt(split[0]);
                values[i] = Integer.parseInt(split[1]);
            }
          	Main app = new Main();
            int result = app.knapsack(n, w, weights, values);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll X,A,B;
  cin>>X>>A>>B;
  X=X-A;
  cout<<X%B<<endl;
}


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


using namespace std;

using ll = long long;


int main(void) {
    ll N;
    cin >> N;
    vector<ll> a(N + 1);
    for (ll i = 1; i <= N; i++) {
        cin >> a[i];
    }

    ll acc = 0;
    for (ll i = 1; i <= N; i++) {
        acc ^= a[i];
    }

    vector<ll> cats(N + 1);
    for (ll i = 1; i <= N; i++) {
        cats[i] = acc ^ a[i];
    }

    for (ll i = 1; i <= N; i++) {
        cout << cats[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 6340
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[1000];
	int k=0,kk=0;
	for(int i=1;i<=int(sqrt(n));i++)
	for(int j=2;j<=10;j++)
	{
		int p=pow(i,j);
		if(p<=n)
		{	
			kk++;
			a[kk]=p;
		}
	}
	sort(a+1,a+1+kk);
	cout<<a[kk]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


string s[5] = { "pre-meiji", "meiji", "taisho", "showa", "heisei" };
int t[4] = { 18680908, 19120730, 19261225, 19890108 };


int main(){
	int a, b, c;
	while (cin >> a >> b >> c){
		int d = a * 10000 + b * 100 + c;
		for (int i = 0; i < 4; i++){
			if (d < t[i]){
				if (i == 0)cout << s[i] << endl;
				else{
					cout << s[i] << " " << a - t[i - 1] / 10000 +  1 << " " << b << " " << c << endl;
				}
				break;
			}
		}
		if (d >= t[3])cout << s[4] << " " << a - t[3] / 10000 + 1 << " " << b << " " << c << endl;
	}
}

Measured memory_bytes: 1204
#include "stdio.h"
#include "string.h"

int main(int argc, char const *argv[]) {
  int N,Q,i;
  scanf("%d%d", &N,&Q);
  char S1[N];
  int l[Q],r[Q];
  scanf("%s", S1);
  char S[N+1];
  for ( i = 1; i <= N; i++) {
    S[i]=S1[i-1];
  }
  for (i = 0; i <Q; i++) {scanf("%d%d",&l[i],&r[i]);}
  int Sum[N+1];
  Sum[0]=0;
  Sum[1]=0;
  for (i = 2; i <= N; i++) {
    if (S[i]=='C'&&S[i-1]=='A') {
      Sum[i]=Sum[i-1]+1;
    }else{
      Sum[i]=Sum[i-1];
    }
  }
  int ans;
  for (i = 0; i < Q; i++) {
    ans=Sum[r[i]]-Sum[l[i]];
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int d[n];
  bool zero = false;
  FOR(i,0,n) {
    cin >> d[i];
    zero |= d[i] == 0;
  }
  if(!zero) {
    cout << 0 << endl;
    return 0;
  }
  set<int> SET;
  // ?????°
  FOR(i,1,10000) {
    // ??????
    FOR(j,0,n) {
      int x = 0;
      if(d[j] == 0) continue;
      FOR(k,0,i) {
        x *= 10;
        x += d[j + k];
      }
      SET.insert(x);
    }
    for(int x = pow(10, i - 1); x < pow(10, i); x++) {
      if(SET.count(x) == 0) {
        cout << x << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
long long fact(long long n) 
{ 
    if (n == 0) 
        return 1; 
    return n * fact(n - 1); 
} 
 
int main()
{
  int n;
  cin >> n;
  long long cnt=0;
  map<string,int> mp;
  for(int i=0;i<n;i++)
  {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
      mp[s]++;
  	
  }
  for(auto&p : mp){
    int s = p.second;
    cnt+=(long long)s*(s-1)/2;
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<iterator>
#include<math.h>
#include<cmath>
#include<sstream>
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include<algorithm>
#include<map>
#include<thread>
#include<stack>
#include<numeric>
#include<functional>
#include<queue>
#include<set>
#include<list>
#include<bitset>
#include <cassert>

typedef long long ll;

using namespace std;

const ll MOD = (ll)1000000007;
const ll inf = (ll)1e18;
const long double eps = 0.0000001;

struct th
{
	ll first = -1, second = -1;
	ll third = -1;
};

vector<vector<pair<ll, ll>>> g;
vector<ll> vert;

void dfs(int v, int par)
{
	for (auto &i : g[v])
	{
		if (i.first != par)
		{
			vert[i.first] += vert[v];
			dfs(i.first, v);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << setprecision(30);

#ifdef _DEBUG
	/*freopen("sorting.in", "r", stdin);
	freopen("sorting.out", "w", stdout);*/

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s, t;
	cin >> s >> t;

	vector<set<int>> alp(30);
	for (int i = 0; i < s.size(); ++i)
	{
		alp[s[i] - 'a'].insert(i);
	}

	bool ok = true;

	for (auto i : t)
	{
		if (alp[i - 'a'].empty())
		{
			ok = false;
			break;
		}
	}

	if (!ok)
	{
		cout << -1;
		return 0;
	}

	ll ans = 0;
	int cur = -1;

	for (auto i : t)
	{
		auto it = alp[i - 'a'].lower_bound(cur + 1);
		if (it == alp[i - 'a'].end())
		{
			cur = *((alp[i - 'a']).begin());
			++ans;
		}
		else
		{
			cur = (*it);
		}
	}

	cout << ans * (ll)s.size() + cur + 1;

	return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string a,b;
	cin>>a;
	cin>>b;
	if(a.size()<b.size())cout<<"LESS"<<endl;
	if(a.size()>b.size())cout<<"GREATER"<<endl;
	if(a.size()==b.size()){
		int x=0,y=0;
		rep(i,a.size()){
			if(a[i]=='1')x=1;
			if(a[i]=='2')x=2;
			if(a[i]=='3')x=3;
			if(a[i]=='4')x=4;
			if(a[i]=='5')x=5;
			if(a[i]=='6')x=6;
			if(a[i]=='7')x=7;
			if(a[i]=='8')x=8;
			if(a[i]=='9')x=9;
			if(b[i]=='1')y=1;
			if(b[i]=='2')y=2;
			if(b[i]=='3')y=3;
			if(b[i]=='4')y=4;
			if(b[i]=='5')y=5;
			if(b[i]=='6')y=6;
			if(b[i]=='7')y=7;
			if(b[i]=='8')y=8;
			if(b[i]=='9')y=9;
			if(x>y){
				cout<<"GREATER"<<endl;
				return 0;
			}
			if(y>x){
				cout<<"LESS"<<endl;
				return 0;
			}
		}
		cout<<"EQUAL"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256