akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    sort(all(v));
    int test=0;
    for(int i=0;i<k;i++)
        test+=v[i];
    cout<<test<<endl;


    return 0;   
}


 
 


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

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

    int n, m, u, v;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        cin >> u >> v;
        u--; v--;
        d.merge(u, v);
    }
    auto groups = d.groups();
    cout << groups.size()-1 << endl;
}

Measured memory_bytes: 8968
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order

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

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int t;
int n;
int arr[2003];

void input(){
    cin>>n;
    rep(i,0,n)
        cin>>arr[i];
}

void solve(){
    sort(arr,arr+n);
    int count=0;
    rel(i,n,1){
        int l=0,r=i-1;
        while(l<r){
            if(arr[l]+arr[r]>arr[i]){
                count+=(r-l);
                r--;
            }
            else
                l++;
        }
    }
    cout<<count<<endl;
}

main(){
    fastio;
    t=1;
    while(t--){
        input();
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a , k;
	cin >> k >> a;
	if(k % a == 0)
		cout << k / a << endl;
	else cout << k / a + 1 << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
//ll f[101010], rf[101010];
//ll inv(ll x) {
//	ll res = 1;
//	ll k = mod - 2;
//	ll y = x;
//	while (k) {
//		if (k & 1) res = (res * y) % mod;
//		y = (y * y) % mod;
//		k /= 2;
//	}
//	return res;
//}
//void init() {
//	f[0] = 1;
//	for (ll i = 1; i < 101010;i++) f[i] = (f[i - 1] * i) % mod;
//	for(ll i = 0; i < 101010; i++) rf[i] = inv(f[i]);
//}
////---------------------------------------------------------------------------------------------------
//ll C(int n, int k) {
//	ll a = f[n]; // = n!
//	ll b = rf[n - k]; // = (n-k)!
//	ll c = rf[k]; // = k!
//
//	ll bc = (b * c) % mod;
//
//	return (a * bc) % mod;
//}

//小文字=大文字+32
int main() {
	int N; cin >> N;
	vector<ll>a(N); rep(i, N) { cin >> a[i];}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ll ans = a[0];
	for (int i = 1; i < N-1;i++) {
		ans += a[(i+1)/2];
	}
	cout << ans;
}

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

using namespace std;

int ctoi(char c){
    switch(c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default : return -1;
        }
}

int main(){
    string S,n;
    int num_old,num_new,num;
    cin >> S;

    vector<int> a(S.size());

    for(int i=0;i<S.size();i++){
         a[i]=ctoi(S[i]);           //参照した時点でchar型になっている
    }

    num_old=0;

    for(int i=0;i<a.size()-2;i++){
        num=100*a[i]+10*a[i+1]+a[i+2];

        if(abs(num-753)<abs(num_old-753)){
            num_new=num;
            num_old=num;
        }
    }
    cout << abs(num_new-753) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  long x;  scanf("%ld", &x);
  long n = 0, i = 0;
  do{
    n += ++i;
  }while(n < x);
  long ans;
  if(n == x)  ans = i;
  else  ans = i;
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
n, m = map(int ,input().split())

adj = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adj[a].append(b)
    adj[b].append(a)

from collections import deque
q = deque()

dist = [-1]*n
ans = [0]*n

q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1:continue
        dist[to] += 1
        q.append(to)
        ans[to] = now 
    
print("Yes")
for i in range(1, n):
    print(ans[i] + 1)


Measured memory_bytes: 34708
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

mod = 10**9+7

class Combination:
    def __init__(self,N):
        self.fac = [1]*(N+1)
        for i in range(1,N+1):
            self.fac[i] = (self.fac[i-1]*i)%mod
        self.invmod = [1]*(N+1)
        self.invmod[N] = pow(self.fac[N],mod-2,mod)
        for i in range(N,0,-1):
            self.invmod[i-1] = (self.invmod[i]*i)%mod

    def calc(self,n,k):#nCk
        return self.fac[n]*self.invmod[k]%mod *self.invmod[n-k] %mod

X,Y = inpl()
X,Y = min(X,Y), max(X,Y)

A = X
B = Y - X

A -= B

if A < 0 or A%3 != 0:
    print(0)
else:
    C = Combination(10**6+10)
    a = A//3
    b = A//3 + B
    print(C.calc(a+b,a))


Measured memory_bytes: 57452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, r;

void solve(){
    cin >> n >> r;
    if(n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
 int l,r,d;
 cin>>l>>r>>d;
 int c=0;
 for(int i=l;i<=r;i++)
 {
 	if(i%d==0)
 	  c++;
 }
 cout<<c;
}


Measured memory_bytes: 3576
#include<stdio.h>

#define MAX 5000

int parent(int);
int left(int);
int right(int);

int main(){
  int H, i, A[MAX];
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);
  
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)
      printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)
      printf("right key = %d, ",A[right(i)]);
    printf("\n");
  
  }
  
  return 0;
  
}

int parent(int p){
  return p/2;
}

int left(int n){
  return n*2;
}

int right(int n){
  return n*2+1;
}



Measured memory_bytes: 2112
#include <iostream>
#include <numeric>

int main(){
    int n, x;
    std::cin >> n >> x;

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x_;
        std::cin >> x_;
        x_ = abs(x - x_);
        ans = std::gcd(ans, x_);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>

char s[55];

int main()
{
    scanf("%s", s);
    int lng = strlen(s);

    bool jdg = true;

    int c = 0;

    if (s[0] == 'K') c = 0;
    else if (s[0] == 'A' && s[1] == 'K') c = 1;
    else jdg = false;

    if (s[c + 1] == 'I' && s[c + 2] == 'H') c += 2;
    else jdg = false;

    if (s[c + 1] == 'B') c += 1;
    else if (s[c + 1] == 'A' && s[c + 2] == 'B') c += 2;
    else jdg = false;

    if (s[c + 1] == 'R') c += 1;
    else if (s[c + 1] == 'A' && s[c + 2] == 'R') c += 2;
    else jdg = false;

    if (lng == c + 1 || (s[c + 1] == 'A' && lng == c + 2)) c++;
    else jdg = false;

    

    if (jdg) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void){
  int i,j;
  char s[101];
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    if(s[i]=='C'){
      for(j=i+1;j<strlen(s);j++){
        if(s[j]=='F'){
          puts("Yes");
          exit(0);
        }
      }
    }
  }
  puts("No");
  return 0;
}

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

using namespace std;

int main(){
    int n, ans = 0, x = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        x ^= a[i];
    }
    for(int i = 30; i >= 0; i--){
        if(x & 1LL << i){
            for(int j = 0; j < n; j++){
                if((a[j] ^ (a[j] - 1)) == (1LL << i + 1) - 1){
                    ans++;
                    x = x ^ a[j] ^ (a[j] - 1);
                    break;
                }
            }
        }
    }
    cout << (x == 0? ans:-1) << endl;
    return 0;
}


Measured memory_bytes: 640
# input
N, K = map(int, input().split())
h = list(map(int, input().split()))

# dp table
INF = float('inf')
dp = [INF]*N
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if i-j>=0:
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

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

using namespace std;
typedef long long  ll;

int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    vector<ll> w(N+1),e(N+1);
    for(int i=1;i<N;i++){
        w[i] = w[i-1];
        if(s[i-1]=='W') w[i] = w[i-1] + 1;
        e[N-i-1] = e[N-i];
        if(s[N-i]=='E') e[N-i-1] = e[N-i] + 1;
    }
    ll res=1e10;
    for(int i=0;i<N;i++)
        res = min(res,w[i]+e[i]);

    cout<<res;
}


Measured memory_bytes: 5380
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A, B, C = new Array[Int](N)
    for (i <- 0 until N) {
      val a, b, c = sc.nextInt()
      A(i) = a
      B(i) = b
      C(i) = c
    }

    val dp = Array.fill(3, N+1)(0)
    dp(0)(0) = 0
    dp(1)(0) = 0
    dp(2)(0) = 0
    for {
      i <- 1 until N + 1
    } {
      dp(0)(i) = (dp(1)(i-1) + B(i-1)) max (dp(2)(i-1) + C(i-1))
      dp(1)(i) = (dp(0)(i-1) + A(i-1)) max (dp(2)(i-1) + C(i-1))
      dp(2)(i) = (dp(0)(i-1) + A(i-1)) max (dp(1)(i-1) + B(i-1))
    }

    println(dp(0)(N) max dp(1)(N) max dp(2)(N))
  }

}


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

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

  int ans = 0;
  rep(i, S.size() / 2) {
    if (S[i] != S[S.size() - i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string stra, strb, strc;
    cin >> stra >> strb >> strc;
    if((stra.back()==strb.front())&&(strb.back()==strc.front())){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  string S;
  cin>>N>>K>>S;
  S[K-1]-='A'-'a';
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
#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>;
const int INF = 1 << 30;
 
int main() {
	string s;
	cin >> s;
	int c0 = 0, c1 = 0;
	rep(i, s.size()) {
		if (s[i] == '0') c0++;
		else c1++;
	}
	cout << 2 * min(c0,c1) << endl;  
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int C = 0;
    bool flag = true;
    if (S[0] != 'A') flag = false;

    for(int i = 1; i < S.size(); i ++){
        if (2 <= i && i <= S.size() - 2 && S[i] == 'C') C++;
        else if ('A' <= S[i] && S[i] <= 'Z') flag = false;
    }

    if (flag && C == 1) cout << "AC";
    else cout << "WA";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793

int main() 
{	ios;
	int t = 1;
	//cin>>t;
	while (t--) {
		int n = 3, k;
		cin>>k;
		unsigned ll dp[k+1];
		dp[0] = 0;
		dp[k] = 1;
		for (int h = k-1; h >= 1; --h) {
			int base = k/h;
			dp[h] = int(pow(base, n) + 0.5);
			//cout<<h<<" "<<ans[h]<<"\n";
			for (int mul = 2; h*mul <= k; mul++) {
				dp[h] -= dp[h*mul];
			}
			//cout<<"after mul "<<ans[h]<<"\n";
		}
		//for (auto x : dp) cout<<x<<" ";
		unsigned ll sum = 0;
		for (int i = 1; i <= k; i++) {
			sum += i*dp[i];
		}
		sum %= hell;
		cout<<sum;
		cout<<"\n";
	}
    return 0; 
} 
/*
look for out of bounds
look for integer overflow, long long vs int
*/


Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
char a[3];
int main(){
	for(int i=0;i<3;i++){
		cin>>a[i];
		if(a[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// find_by_order(k) (k+1)th largest element
// order_of_key(k) no of elements <=k

typedef long long ll;
typedef long double ld;
#define endl '\n'
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define ff first
#define ss second
#define pb push_back
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ld PI = 4*atan((ld)1);
const ll INF = 1e18;
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        map<string,ll> m;
        repA(i,1,n){
            string s;
            cin >> s; m[s]++;
        }
        cout << "AC x " << m["AC"] << endl;
        cout << "WA x " << m["WA"] << endl;
        cout << "TLE x " <<m["TLE"] << endl;
        cout << "RE x " << m["RE"] << endl;
    }
}


Measured memory_bytes: 3672
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=300010;
int n,m;
int k;
map<pii,int> mp;
int col[N],row[N];
int maxr,maxc;
vector<int> a,b;

int main()
{
    cin>>n>>m>>k;
    while(k--)
    {
        int a,b;
        cin>>a>>b;
        mp[{a,b}]=1;
        row[a]++;
        col[b]++;
        maxr=max(maxr,row[a]);
        maxc=max(maxc,col[b]);
    }
    for(int i=1;i<=n;i++) 
        if(row[i]==maxr) a.push_back(i);
    for(int j=1;j<=m;j++)
        if(col[j]==maxc) b.push_back(j);
    
    for(int i=0;i<a.size();i++) 
        for(int j=0;j<b.size();j++)
            if(mp[{a[i],b[j]}]==0) 
            {
                cout<<maxr+maxc<<endl;
                return 0;
            }
    cout<<maxr+maxc-1<<endl;
    return 0;
}

Measured memory_bytes: 28396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);


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

  ll n, a;
  cin >> n >> a;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll sum = SUM(x);

  vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(sum+1, 0)));

  dp[0][0][0] = 1;

  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k <= sum; k++) {
        dp[i][j][k] += dp[i-1][j][k];
        if (j > 0 && k >= x[i-1]) dp[i][j][k] += dp[i-1][j-1][k - x[i-1]];
      }
    }
  }

  ll ans = 0;
  for (int j = 1; j <= n; j++) {
    for (int k = 0; k <= sum; k++) {
      if (a * j == k) ans += dp[n][j][k];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55208
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N),y(M);
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    for(int i=0; i<M; i++){
        cin >> y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    bool flag=false;
    for(int i=X+1; i<=Y; i++){
        if(x[N-1]<i && y[0]>=i) flag=true;
    }
    if(flag) cout << "No War";
    else cout << "War";

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  cout << 48-N << endl;
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll x;
  cin >> x;
  
  if(x<1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(void)
{
 int W,H,x,y,r,a,b,c,d;
 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 a=x-r; b=y-r; c=x+r; d=y+r;
 if(a<0){ puts("No");
 }
 else if(b<0){ puts("No");
 }
 else if(c>W){ puts("No");
 }
 else if(d>H){ puts("No");
 }
 else { puts("Yes");
 }
 return 0;
 } 


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<int> a;
int flag=-1;

void solve(){
    cin >> n;
    a.resize(n,0);
    rep(i,n){
        cin >> a[i];
    }
    int ans=1;
    rep(i,n-1){
        if (flag==-1) {
            if (a[i+1]==a[i]) flag=-1;
            if (a[i+1]>a[i]) flag=0;
            if (a[i+1]<a[i]) flag=1;
        }
        else if (flag==0){
            if (a[i+1]<a[i]) {
                flag=-1;
                ans+=1;
            }
        }
        else if (flag==1){
            if (a[i+1]>a[i]) {
                flag=-1;
                ans+=1;
            }
        }
    }

    cout << ans << endl;
}

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

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  vector< int > d(n);
  for (int i=0; i<n; ++i) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
L = ["".join(sorted(input())) for _ in range(N)]

L = sorted(L)

s = L[0]
c = 0
n = 1
for i in range(1,N):
  if s == L[i]:
    n +=1
  else:
    if n >= 2:
      c += n*(n-1)//2
    s = L[i]
    n = 1
    
if n >=2:
  c +=n*(n-1)//2
print(c)


Measured memory_bytes: 11532
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

struct edge { int u, v, cost; };
edge es[110000];int v,e;
int kruskal() {
  sort(es, es+e, [](const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
  });
  vector<int> tree = init(v);
  int res = 0;
  rep(i,e){
    edge e = es[i];
    if(!same(e.u, e.v, tree)){
      unite(e.u, e.v, tree);
      res += e.cost;
    }
  }
  return res;
}

signed main(){
  string s;cin>>s;
  int a = 0, b = 0, n = s.length();char ca = '0', cb = '1';
  rep(i,n){
    if(ca != s[i])a++;
    if(cb != s[i])b++;
    swap(ca,cb);
  }
  cout << min(a,b) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	
	ll N;
	cin >> N;

	if (N >= 1000) { cout << "ABD"; }
	else { cout << "ABC"; }


	system("PAUSE");
}

Measured memory_bytes: 504
N,K = map(int,input().split())
H=list(map(int,input().split()))
INF=1000000000
dp=[INF]*(N+1)
dp[0]=0
for i in range(1,N):
  for j in range(1,K+1):
    if (i-j)>=0:
      dp[i]=min(dp[i],dp[i-j]+abs(H[i-j]-H[i]))
print(dp[N-1])

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

namespace ColoringColorfully
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int count = 0;
            char[] c = S.ToCharArray();

            for(int i = 0; i < c.Length - 1; i++)
            {
                if(c[i] == c[i + 1])
                {
                    if (c[i + 1] == '1')
                    {
                        c[i + 1] = '0';
                    }
                    else
                    {
                        c[i + 1] = '1';
                    }
                    count++;
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 13536
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

main :: IO ()
main = do
  (x, y) <- readTuple2
  let
    nums a = a : nums (2 * a)
    ans = nums x
  print $ length $ takeWhile (<=y) ans





Measured memory_bytes: 380
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	long long b = 100,x;
	cin>>x;
	int res =0;
	while(b<x){
		res++;
		b += b/100;
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 3192
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);




int main()
{
    fastio;
    ll n,m;bool possible = true;
    cin>>n>>m;
    string s;
    if(n==1)s = "A";
    elif(n==2)s ="AA";
    else s = "AAA";
    

    loop(i,0,m){
        ll x;char y;
        cin>>x>>y;

        if(s[x-1] == 'A')
            s[x-1] = y;
        else{
            if(s[x-1] == y)
                s[x-1] = y;
            else
                possible = false;
        }
    }
    if(!possible){
        cout<<-1;        
    }
    elif(n == 1){
        if(s[0] == 'A')
            s[0] = '0';
        cout<<s;
    }
    elif(n==2){
        if(s[0] == '0')
            cout<<-1;
        else{
            if(s[0] == 'A')
                s[0] = '1';

            if(s[1] == 'A')
                s[1] = '0';
            cout<<s;
        }
    }
    else{
        if(s[0] == '0')
            cout<<-1;
        else{
            if(s[0] == 'A')
                s[0] = '1';

            if(s[1] == 'A')
                s[1] = '0';
            if(s[2] == 'A')
                s[2] = '0';

            cout<<s;
        }
    }
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};

signed main(){
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    REP(i, 3) cnt += (S[i] == T[i]);
    PRINT(cnt);
    return 0;
}

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

const int N = 1e5 + 5;
const double inf = 1e18;
double x[N], y[N];
double dx[N], dy[N];
int n;

double f(double a) {
    double minx = inf, maxx = -inf, miny = inf, maxy = -inf;
    for (int i = 0; i < n; i++) { //n个点
        double nx = x[i] + a * dx[i];
        double ny = y[i] + a * dy[i];
        minx = min(minx, nx);
        maxx = max(maxx, nx);
        miny = min(miny, ny);
        maxy = max(maxy, ny);
    }
    return (maxx - minx) * (maxy - miny);
}

double ternary_search(double l, double r) {
   double ans = inf;
  int times = 300;
    while (times--) {
        double m1 = l + (r - l) / 3;
         double m2 = r - (r - l) / 3;
        //double m1 = (l*2+r) / 3;
        //double m2 = (r*2+l) / 3;
        double f1 = f(m1);
        double f2 = f(m2);
        ans = min(ans, f1);
         ans = min(ans, f2);
        if (f1 < f2) r = m2;
        else l = m1;
    }
    return ans;
}

int main() {
   // while (cin >> n) {
      cin>>n;
        //memset(dx, 0, sizeof(dx));
        //memset(dy, 0, sizeof(dy));

        string s;
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> s;
            if (s == "R") dx[i] = 1;
            if (s == "L") dx[i] = -1;
            if (s == "U") dy[i] = 1;
            if (s == "D") dy[i] = -1;
        }


        //cout << ternary_search(0, 1e9) << endl;
      printf("%lf\n",ternary_search(0, 1e9));
   // }

    return 0;
}

Measured memory_bytes: 3328
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
main = readLn >>= main'
    where
        main' 0 = return ()
        main' n = replicateM n (length <$> getLine) >>= print . solve 1 >> main

solve :: Int -> [Int] -> Int
solve r xxs@(_ : xs) = maybe (solve (r + 1) xs) (const r) $ checkHead xxs >>= checkTail
    where
        checkHead ys = maybeDrop' 5 ys >>= maybeDrop' 7
        checkTail ys = checkHead ys >>= maybeDrop' 7
        maybeDrop' n = innerDrop' 0
            where
                innerDrop' m yys@(y : ys)
                    | m < n = innerDrop' (m + y) ys
                    | m > n = Nothing
                    | otherwise = return yys
                innerDrop' m _
                    | m == n = return []
                    | otherwise = Nothing

Measured memory_bytes: 4056
#include<stdio.h>
long long int gcd(long long int a, long long int b){
    long long int tmp = a % b;
    if(tmp == 0)
        return b;
    else
        return gcd(b, tmp);
}
int main(){
    long long int a, b;
    while (scanf("%lld %lld", &a, &b) != EOF){
        long long int g, l;
        if (a < b){
            long long int tmp = a;
            a = b;
            b = tmp;
        }
        g = gcd(a, b);
        l = a * b / g;
        printf("%lld %lld\n", g, l);
    }
    return 0;
}

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

ll xor_sum(ll num) {
  ll ans = ((num + 1)/2) % 2;
  if (num % 2 == 0) ans ^= num;
  return ans;
}

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

  ll a, b;
  cin >> a >> b;
  ll ans = xor_sum(b) ^ xor_sum(a-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#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) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
 
#define str string
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  LCIN(n,k);
  int bmin=k+1;
  ll sum=0;
  FOR(i,bmin,n+1){
    ll num=0;
    num += n/i  * (i-k);
    num += max(0LL,(n%i-k+1));
    num=min(num,n);
    /*
    dump(num);
    dump(i);
    */
    sum+=num;
  }
  COUT(sum);


  return 0;
}


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

using namespace std;

int N;
struct data{
    string s; int num, pos;
    bool operator<(const data&r)const{
        return s < r.s || (s == r.s && num > r.num);
    }
}arr[104];

int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i) cin >> arr[i].s >> arr[i].num, arr[i].pos = i;
    sort(arr + 1, arr + N + 1);
    for(int i = 1; i <= N; ++i){
        printf("%d\n", arr[i].pos);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = LONG_LONG_MAX;
    rep(bit, 1 << n) {
        ll cnt = __builtin_popcountll(bit);
        if (cnt != k) continue;
        ll tmp = 0, next = -1;
        rep(i, n) {
            if (i == 0) {
                next = a[i] + 1;
            }
            else if ((bit & (1 << i)) == 0) {
                next = max(next, a[i] + 1);
            }
            else {
                if (next <= a[i]) {
                    next = a[i] + 1;
                }
                else {
                    tmp += next - a[i];
                    next++;
                }
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N;
    i64 ans = 0;
    cin >> N;
    vector<i64> A(N + 1);
    for(auto& x : A) cin >> x;
    for(int i = 0; i < N; i++) {
        i64 b;
        cin >> b;
        if(b > A[i]) {
            ans += A[i];
            b -= A[i];
            A[i] = 0;
            if(b > A[i + 1]) {
                ans += A[i + 1];
                A[i + 1] = 0;
            } else {
                ans += b;
                A[i + 1] -= b;
            }
        } else {
            ans += b;
            A[i] -= b;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	
	int ans = 0;
	char cur = 'A';
	REP(i, S.size()) {
		if (S[i] <= cur) ++ans;
		cur = S[i];
	}
	
	cout << ans << endl;
	
	return 0;
}



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

vector< pair<int,int> > g[123450];
bool vis[123450];
int dist[123450];
int ok=1;

void dfs(int node)
{
    //cout<<"node is "<<node<<endl;
    if(vis[node]) return;
    vis[node]=true;

    for(auto i:g[node]){
        if(!vis[i.first]){
            dist[i.first]=dist[node]+i.second;
            dfs(i.first);
        }
        else if(dist[i.first]!=dist[node]+i.second){
            ok=0;
        }
    }
}
int main()
{

    //freopen("input.txt","r",stdin);
    memset(vis,false,sizeof vis);
    int n,m;
    cin>>n>>m;
    int l,r,d;
    while(m--)
    {
        cin>>l>>r>>d;

        g[l].push_back(make_pair(r,d));
        g[r].push_back(make_pair(l,-1*d));
    }

    for(int i=1;i<=n;i++){
        int ok=1;
        if(!vis[i]){
            dfs(i);
            //cout<<"dist is "<<dist<<endl
        }
    }
    if(!ok) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h> 
using namespace std; 
  
string longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
   
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; 
    int res_length  = 0; 
   
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) { 
            if (str[i-1] == str[j-1] && LCSRe[i-1][j-1] < (j - i)){ 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res; 
} 
  
int main() 
{	
	long int n;
	cin>>n;
	
    string str;
    cin>>str; 
    cout << longestRepeatedSubstring(str).size(); 
    return 0; 
}

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int A,B;
    cin>>A>>B;
    int ans=A-2*B;
    if(ans<0){
        ans=0;
    }
   cout<<ans<<endl;
}




Measured memory_bytes: 3612
# E - Cell Distance

n, m, k = map(int, input().split())
mod = 10**9 + 7

difx = 0
dify = 0

for i in range(m):
    difx += (i * (m-i) * pow(n, 2, mod))%mod

for j in range(n):
    dify += (j * (n-j) * pow(m, 2, mod))%mod

def comb_mod(n, r, p):
    num = 1
    den = 1
    r = min(r, n-r)
    for i in range(r):
        num = (num * (n-i))%p
        den = (den * (i+1))%p
    return num * pow(den, p-2, p)  

pat = comb_mod(n*m-2, k-2, mod)

ans = ((difx + dify) * pat)%mod

print(ans)


Measured memory_bytes: 3064