akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main() {
	int i,j;
	int N, K, Q;
	int A[100000];
	int point[100000];

	scanf("%d %d %d", &N, &K, &Q);
	
	for (i = 0; i < N; i++) {
		point[i] = K - Q;
	}

	for (i = 0; i < Q; i++) {
		scanf("%d", &A[i]);
		point[A[i]-1]++;
	}

	for (i = 0; i < N; i++) {
		if (point[i] > 0) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,m;
int k;
string s,t;
const ll mod=1e9+7;
ll pw(ll x,ll y){
	if(y==0) return 1;
	if(y%2) return x*pw(x,y-1)%mod;
	ll res=pw(x,y/2);
	return res*res%mod;
}
int main(){
	ios::sync_with_stdio(false);
	string s;cin >> s;
	for(auto &c:s) if(c=='?') c='D';
	cout << s << endl;
}

Measured memory_bytes: 3772
/*
 * Matheus Oliveira
 * 09:22:26 26/04/2020
 * d.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 200002
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

const int mod = 2019;

int szn;
char n[MAXN];
int remo[mod+10];

int main() {
	ll ans = 0;
	int idx, m;

	scanf("%s", n);
	szn = strlen(n);

	idx = szn - 1;
	m = n[idx] - '0';
	
	remo[m] = 1;
	remo[0] = 1;

	idx--;
	int p = 10;
	while(idx >= 0) {
		m = (m + (n[idx] - '0')*p ) % mod;
		
		//printf("m: %d, idx: %d\n", m, idx);
		
		ans += ((ll) remo[m]);
		remo[m]++;

		p = (p*10) % mod;
		idx--;
	}

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

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>
#include <numeric>

int main()
{
	int N, M;
	std::multimap<long, int> AB; /* Ai -> Bi */
	long result = 0;

	std::cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		long a;
		int b;
		std::cin >> a >> b;
		AB.insert({a, b});
	}

	for (const auto& ab : AB) {
		if (M <= ab.second) {
			result += ab.first * M;
			break;
		}
		result += ab.second * ab.first;
		M -= ab.second;
	}

	std::cout << result << "\n";
}


Measured memory_bytes: 6528
# AGC014A - Cookie Exchanges
def main():
    a, b, c = list(map(int, input().rstrip().split()))
    if a == b == c:
        if 1 in (a % 2, b % 2, c % 2):
            print(0)
        else:
            print(-1)
        return
    ans = 0
    while True:
        if 1 in (a % 2, b % 2, c % 2):
            break
        a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <math.h>
using namespace std;
struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define ff first
#define ss second 
#define pp pair
#define ULRED 1000000007
#define MS(x,y) (x-y>0?x-y:y-x) 
#define MX(x,y) x>y?x:y
#define MN(x,y) x>y?y:x
#define MXPTR2(a,b,x,y) (x>y?a:b)
#define MXPTR3(a,b,c,x,y,z) (x>y?(x>z?a:c):(y>z?b:c))
#define MX3(a,b,c) (a>b?(a>c?a:c):(b>c?b:c))
#define AEQ(a,b,c) (a==b?1:(a==c?3:(c==b?2:-1)))
/*------------------------------------------------------------------*/

int main()
{
	FAST_IO
		ll n;
	cin >> n;
	vector<vector<ll>> v(n + 1, vector<ll>(4, 0));
	for (ll i = 1; i < n + 1; i++)
		cin >> v[i][1] >> v[i][2] >> v[i][3];

	ll vis = 0;
	vector<vector<ll>> dp(n + 1,vector<ll>(4,0));
	dp[1][1] = v[1][1];
	dp[1][2] = v[1][2];
	dp[1][3] = v[1][3];

	for (ll i = 2; i < n + 1; i++)
	{
		dp[i][1] =  v[i][1]+ max(dp[i - 1][2], dp[i - 1][3]);
		dp[i][2] = v[i][2] + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = v[i][3] + max(dp[i - 1][2], dp[i - 1][1]);
	}

	cout << MX3(dp[n][1], dp[n][2],dp[n][3])<<endl;
	return 0;
}

Measured memory_bytes: 14336
A, B = map(int,input().split())
S = input()
v = 0
if len(S) != A + B + 1:
    v = 1
for i in range(len(S)):
    if i!= A and S[i] not in [str(j) for j in range(10)]:
        v = 1
    if i == A and S[i] != '-':
        v = 1
if v == 1:
    print("No")
else:
    print("Yes")


            


Measured memory_bytes: 3060
from operator import itemgetter

n,m = map(int,input().split())
py = []
pyy = []

npy = []

for i in range(m):

    pyy=list(map(int,input().split()))
    pyy.append(i)
    py.append(pyy)

py.sort(key=itemgetter(0,1))


num = 1

npy.append([str(10**12+py[0][0]*(10**6)+num)[1:13],py[0][2]])


for i in range(m-1):
    if py[i+1][0] == py[i][0]:
        num = num + 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])
    else:
        num = 1
        npy.append([str(10**12+py[i+1][0]*(10**6)+num)[1:13],py[i+1][2]])

npy.sort(key=itemgetter(1))

for j in range(m):
    print(npy[j][0])


Measured memory_bytes: 47392
import java.util.Comparator;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
  private static void solve(int n, int m, long[] a) {
    PriorityQueue<Long> pq = new PriorityQueue<>(n, new Comparator<Long>() {
      @Override
      public int compare(Long o1, Long o2) {
        return o2.compareTo(o1);
      }
    });
    for (long val : a) pq.add(val);
    for (int i = 0; i < m; i++) {
      long price = pq.poll();
      pq.add(price / 2L);
    }
    long sum = 0L;
    Iterator<Long> it = pq.iterator();
    while (it.hasNext()) sum += it.next();
    System.out.println(sum);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] nums = sc.nextLine().split(" ");
    int n = Integer.parseInt(nums[0]);
    int m = Integer.parseInt(nums[1]);
    long[] a = new long[n];
    String[] as = sc.nextLine().split(" ");
    for (int i = 0; i < n; i++) a[i] = Integer.parseInt(as[i]);
    sc.close();
    solve(n, m, a);
  }
}


Measured memory_bytes: 49244
N = int(input())
li = ['']
so = 0
for _ in range(9):
  l = len(li)
  for i in range(so, l):
    li.append(li[i] + '3')
    li.append(li[i] + '5')
    li.append(li[i] + '7')
  so = l
cnt = 0
for x in li:
  if '3' in x and '5' in x and '7' in x and int(x) <= N:
    cnt += 1
print(cnt)

Measured memory_bytes: 5236
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rm()
print(max(0, c+b-a))

















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

int main(){
    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i < N + 1; i++)
    {
        if (!(i % 3 == 0) && !(i % 5 == 0))
        {
            ans += i;
        }
        
    }
    cout << ans << endl;
      
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSeaech(Node,int);
Node treeSuccessor(Node);
Node treeDelete(Node);*/
void insert(int);
void inorder(Node);
void preorder(Node);




int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      /*Node t = treeSearch(root, x);*/
      /*if ( t != NIL ) printf("yes\n");
	else printf("no\n");*/
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      /* treeDelete(treeSearch(root, x));*/
    }
  }

  return 0;
}

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;
 




}

void inorder(Node u){
  if(u->left==NIL&&u->right==NIL){
    printf(" %d",u->key);
    return;
  }
   if(u->left!=NIL)
  inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
  inorder(u->right);

}
void preorder(Node u){
  if(u->left==NIL&&u->right==NIL){
    printf(" %d",u->key);
      return;
  }
  printf(" %d",u->key);
  if(u->left!=NIL)
  preorder(u->left);
  if(u->right!=NIL)
  preorder(u->right);

}



Measured memory_bytes: 25224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 

// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

# define ll long long int
#define M 1000000007
#define pb push_back
#define ss second
#define ff first
#define inf 1000000000000000


 

													//nestedcode



int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,i,ans = 0;
    cin>>n;
    ll a[n+5], dp[n+5];
    for(i=0;i<n;i++){
    	cin>>a[i];
    	if(i == 0)
    	dp[i] = a[i];
    	else
    	dp[i] = dp[i-1] + a[i];
	}
	for(i=1;i<n;i++){
		ans += (dp[i-1]%M * a[i]%M)%M;
		ans %= M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int,int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}

int main () {
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
ll x,k,d;
cin>>x>>k>>d;
ll q= abs(x)/d;
ll r1 = abs(x)%d;
ll r2=d-r1;
if (q<k) {
  ll reach = k-q;
  if (reach&1) cout<<r2;
  else cout<<r1;
//cout<<min(r1,r2);
}
else if (q==k) cout<<r1;
else {
  cout<<abs(x)-(d*k);
}
return 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const ll INF = 0x3f3f3f3f;
const int maxn = 3e5 + 7;
const int mod = 998244353;
#define start int wuyt()
#define end return 0
#define pi 3.14159265358979323846
ll gcd(ll a,ll b)
{
    ll t;
    while(b!=0)
    {
        t=a%b;
        a=b;
        b=t;
    }
    return a;
}
ll qPow(ll x, ll k)
{
    ll res = 1;
    while(k) {
        if(k&1)
            res=(res*x);
        k>>=1;
        x=(x*x);
    }
    return res;
}
ll maxx=-1;
ll minn=inf;
ll num[maxn];
///ll a[maxn];
ll num2[maxn];
ll res,ans;
priority_queue <int ,vector<int> ,greater<int> > xiaogen;
deque<int> q;
ll posx[2000],posy[2000];
map<string ,ll> mp;
int main()
{
    string s,t;
    cin>>s>>t;
    int flag=1;
    int len=s.length();
    for(int i=0;i<len;i++){
        if(s[i]!=t[i]) flag=0;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3656
n=int(input())
s=input()
s=s+s[0]
for a,b in [(0,0),(0,1),(1,0),(1,1)]:
    ans=[a,b]+[1]*n
    for i in range(2,n+2):
        ans[i]^=ans[i-2]^ans[i-1]^(s[i-1]=='o')
    if ans[:2]==ans[-2:]:
        for i in range(n):
            print('SW'[ans[i]],end='')
        break
else:
    print(-1)

Measured memory_bytes: 6740
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a * n <= b)	printf("%d\n", a * n);
	else printf("%d\n", b);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */


void solve()
{
    ll i, j, count = 0;

    string a, b;

    cin >> a >> b;

    int n = a.length();

    int m = b.length();




    for (int i = 0; i < n; ++i)
    {

        if (a[i] != b[i])
            count++;

    }

    cout << count << endl;

}


int32_t main()
{

    IOS;
    cin.tie(NULL);

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

    int T = 1;



    wh(T)
    {

        solve();

    }
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int ans = 0;
	int n; cin >> n;
	for(int i = 1; i <= n; ++i) {
		string a = to_string(i);
		if (a.length() % 2 == 1) ++ans;
	}
	cout << ans;
}

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

using namespace std;
#define ll long long
#define mod 1000000007

vector<int> v;
int dp[100001], k;

int f(int i) {
    if (i == v.size() - 1) return 0;

    if (dp[i] != -1) return dp[i];

    int ans = INT_MAX;
    for (int j = 1; j <= k; j++) {
        if (i + j < v.size()) {
            ans = min(ans, abs(v[i] - v[i + j]) + f(i + j));
        }
    }
    dp[i] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n >> k;

    v.resize(n);

    for (int &i : v) {
        cin >> i;
    }

    cout << f(0) << "\n";
}


Measured memory_bytes: 11884
#CODEFESTIVAL2016qualA
alpha='abcdefghijklmnopqrstuvwxyz'
S=input()
K=int(input())
ans=''
for s in S:
    idx=alpha.index(s)
    if idx==0 or 26-idx>K:
        ans+=s
        continue
    else:
        K-=26-idx
        ans+='a'
if K>0:
    tar=ans[-1]
    idx=alpha.index(tar)
    ans=ans[:-1]+alpha[(idx+K)%26]
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
 
 
int main() {
    int N;
    string S;
    cin>>N>>S;
    map<char, long long> mp;
    for(int i=0; i<N; i++) mp[S[i]]++;
 
    long long count=mp['R']*mp['G']*mp['B'];
    for(int i=0; i<N-2; i++) {
        for(int j=1; i+2*j<N; j++) {
                if(S[i]!=S[i+j] && S[i]!=S[i+2*j] && S[i+j]!=S[i+2*j])
                    --count;
        }
    }
    cout<<count<<endl;
 
    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 repd(i,n) for(int i=n-1;i>=0;i--)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S;
    cin>>S;
    int siz=S.size();
    const int p = 2019;
    vector<pair<int,int>> r;
    rep(i,2019){
        r.push_back({i,0});
    }
    vector<int> tr;
    tr.push_back(1);

    rep2(i,1,siz){
        tr.push_back((tr.at(i-1)*10)%p);
    }
    
    int tmp=0;
    char c='0';
    int d=0;
    rep(i,siz){
        c=S.at(siz-i-1);
        d=c-'0';
        d=(tr.at(i)*d)%p;
        tmp=(tmp+d)%p;
        // cout << tmp << endl;
        r.at(tmp).second++;
    }
    long long ans=0;
    rep(i,p){
        // cout << "i:"<<r.at(i).first<<" j:"<<r.at(i).second<<endl;
    }
    rep(i,2019){
        if(i==0){
            ans=ans+r.at(i).second;
        }
        if(r.at(i).second<=1){
            continue;
        }
        ans+=(r.at(i).second*(r.at(i).second-1))/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4368
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func intAbs(x int) int {
	return int(math.Abs(float64(x)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}

	S := 0
	for _, a := range A {
		S += a
	}

	for i := 1; i < N; i++ {
		A[i] += A[i-1]
	}

	ans := intAbs(S - 2*A[0])
	for i := 1; i < N-1; i++ {
		ans = intMin(ans, intAbs(S-2*A[i]))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4792
// by tmt514
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#define SZ(x) ((int)(x).size())
#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
using namespace std;
typedef long long LL;

int main(void) {
  int x;
  int b[5]={};
  for(int i=0;i<6;i++) {
    scanf("%d", &x);
    b[x]++;
  }
  sort(b+1, b+5);
  if(b[1]==1 && b[2]==1 && b[3]==2 && b[4]==2) {
    puts("YES");
  } else puts("NO");
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	int t[n];
	int sum=0;
	rep(i,n){
		cin>>t[i];
		sum+=t[i];
	}
	int m;
	cin>>m;
	int p[m],x[m];
	rep(i,m){
		cin>>p[i]>>x[i];
		int diff=t[p[i]-1]-x[i];
		puts(sum-diff);
	}
	
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        Console.WriteLine("ABC"+input);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

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

#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef double ld;

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

int cnt[4];
int main() {
  __;

  int n;
  cin >> n;

  string s[] = {"AC", "WA", "TLE", "RE"};
  for(int i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    for(int j = 0; j < 4; j++) { if(temp == s[j]) cnt[j]++; }
  }

  for(int i = 0; i < 4; i++) {
    cout << s[i] << " x " << cnt[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 3652
n = int(input())
#A = [int(input()) for i in range(n)]
L = [int(i) for i in input().split()]

def InsertionSort(A,N):
	for i in range(1,N):
		key = A[i]
		j = i - 1
		while j>=0 and A[j] > key:
			A[j+1] = A[j]
			j -= 1
		A[j+1]  = key

		for item in range(len(A)):
			if item == len(A)-1:
				print(A[item])
			else:
				print(A[item],end=" ")

for item in range(len(L)):
	if item == len(L)-1:
		print(L[item])
	else:
		print(L[item],end=" ")

InsertionSort(L,n)






"""
for i in range(len(A)):
	if i == len(A)-1:
		print(A[i])
	else:
		print(A[i],end=" ")
"""



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

int coin[] = {10,50,100,500};

int main(){
  bool flag = false;
  while(1){

    int w[4];
    int pay;
    cin >> pay;
    if (!pay) break;

    if (flag){
      cout << endl;
    }

    int sum = 0;
    for (int i = 0; i < 4; i++){
      cin >> w[i];
      sum += w[i] * coin[i];
    }

    sum -= pay;
    for (int i = 3; i >= 0; i--){
      while(sum>=coin[i]){
	w[i]--;
	sum-=coin[i];
      }
    }

    for (int i = 0; i < 4; i++){
      if (w[i] > 0){
	cout << coin[i] << ' ' << w[i] << endl;
      }
    }
    flag = true;
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
c = input()
lr_dict = dict()
lr_dict["W"] = {"R": 0,
                "W": 0
                }
lr_dict["R"] = {"R": 0,
                "W": 0
                }
n_r = 0
n_w = 0
for i in range(N):
    if c[i] == "W":
        n_w += 1
    else:
        n_r += 1
l_w = 0
r_r = 0
for i in range(n_r):
    if c[i] == "W":
        l_w += 1
for i in range(n_r, N):
    if c[i] == "R":
        r_r += 1
print(max(l_w, r_r))



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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  rep(i, n) x += (d-1) / a[i] + 1;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
struct Step {
    int y, x, y1, x1;
};
bool a[501][501];
Step step[251001];
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    int H, W;
    cin >> H >> W;
    int cnt = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            int t;
            cin >> t;
            a[i][j] = t & 1;
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j < W; j++) {
            if (a[i][j]) {
                step[cnt].y = i;
                step[cnt].x = j;
                step[cnt].y1 = i;
                step[cnt].x1 = j + 1;
                cnt++;
                a[i][j + 1] = !a[i][j + 1];
            }
        }
    }
    for (int i = 1; i < H; i++) {
        if (a[i][W]) {
            step[cnt].y = i;
            step[cnt].x = W;
            step[cnt].y1 = i + 1;
            step[cnt].x1 = W;
            cnt++;
            a[i + 1][W] = !a[i + 1][W];
        }
    }
    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) {
        cout << step[i].y << ' ' << step[i].x << ' ' << step[i].y1 << ' ' << step[i].x1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define all(x) x.begin(),x.end()
#define CS ios_base::sync_with_stdio(false);
#define show(x) cerr << #x << " is " << x <<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi; 
const ll MOD=1e9+7;
int32_t main()
{
	ll n; cin>>n;	
	ll ans=1;
	for(int i=1;i<=n;i++) ans = (ans * (ll)(i))%MOD;
	return cout<<ans<<endl,0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

void solve(ll N, ll H, ll W, vector<ll> A, vector<ll> B) {
  int cnt = 0;
  rep(i, N) if (A.at(i) >= H && B.at(i) >= W) cnt++;
  cout << cnt << endl;
}

int main() {
  ll N;
  ignore_ret(scanf("%lld",&N));
  ll H;
  ignore_ret(scanf("%lld",&H));
  ll W;
  ignore_ret(scanf("%lld",&W));
  vector<ll> A(N);
  vector<ll> B(N);
  for(int i = 0 ; i < N ; i++){
    ignore_ret(scanf("%lld",&A[i]));
    ignore_ret(scanf("%lld",&B[i]));
  }
  solve(N, H, W, move(A), move(B));
  return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn=1e6+10;

int a[maxn],b[maxn];
ll sum1[maxn],sum2[maxn];

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for( int i=1;i<=n;i++ ) cin>>a[i],sum1[i]=sum1[i-1]+a[i];
	for( int i=1;i<=m;i++ ) cin>>b[i],sum2[i]=sum2[i-1]+b[i];
	int ans=0;
	for( int i=0;i<=m;i++ )
	{
		if( k-sum2[i]<0 ) break;
		int idx=lower_bound(sum1+1,sum1+n+1,k-sum2[i])-sum1;
		if( sum1[idx]!=k-sum2[i] ) idx--;
		ans=max(ans,i+idx);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8284
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

struct Cake{
    ll i, j, k;
    ll delicious;

    Cake(ll _d, ll _i, ll _j, ll _k){
        delicious = _d;
        i = _i;
        j = _j;
        k = _k;
    }
    bool operator<(const Cake &another) const
    {
        return delicious < another.delicious;
    }
};

ll X, Y, Z, K;
vector<ll> A(X);
vector<ll> B(Y);
vector<ll> C(Z);

bool done[1000][1000][1000];

Cake make_cake(ll i, ll j, ll k){
    if(i>=X) return Cake(0, 0, 0, 0);
    if(j>=Y) return Cake(0, 0, 0, 0);
    if(k>=Z) return Cake(0, 0, 0, 0);
    if(done[i][j][k]) return Cake(0, 0, 0, 0);

    done[i][j][k] = true;
    ll delicious = A[i] + B[j] + C[k];
    return Cake(delicious, i, j, k);
}

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

    // input
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    B.resize(Y);
    C.resize(Z);
    
    FOR(i, 0, X){
        cin >> A[i];
    }
    FOR(i, 0, Y){
        cin >> B[i];
    }
    FOR(i, 0, Z){
        cin >> C[i];
    }
    sort(ALL(A), greater<ll>());
    sort(ALL(B), greater<ll>());
    sort(ALL(C), greater<ll>());

    priority_queue<Cake> que;
    que.push(Cake(A[0]+B[0]+C[0], 0, 0, 0));

    while(K>0){
        if(que.empty()) break;

        auto cake = que.top();
        que.pop();
        p(cake.delicious);

        K--;
        
        ll i = cake.i;
        ll j = cake.j;
        ll k = cake.k;
        
        // // 1番美味しいケーキを入れる
        auto cake0 = make_cake(i+1, j, k);
        auto cake1 = make_cake(i, j+1, k);
        auto cake2 = make_cake(i, j, k+1);

        if(cake0.delicious>0) que.push(cake0);
        if(cake1.delicious>0) que.push(cake1);
        if(cake2.delicious>0) que.push(cake2);
    }

    return 0;
}

Measured memory_bytes: 973440
import numpy as np
n,m,x = map(int, input().split())
li = []
for i in range(n):
    c_A = list(map(int, input().split()))
    li.append(c_A)

li = np.array(li)
cost = 10**7
for i in range(2**n):
    c_s = np.array([0]*(m+1))
    for j in range(n):
        if ((i>>j)&1):
            c_s += li[j]
    if np.all(c_s[1:]>=x):
        cost = min(cost,c_s[0])
if cost==10**7:
    print(-1)
else:
    print(cost)

Measured memory_bytes: 27328
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int popcnt32(uint32_t x) noexcept {
#ifdef __GNUC__
    return __builtin_popcount(x);
#else
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0F0F0F0F) + ((x & 0xF0F0F0F0) >> 4);
    x = (x & 0x00FF00FF) + ((x & 0xFF00FF00) >> 8);
    return (x & 0x0000FFFF) + ((x & 0xFFFF0000) >> 16);
#endif
}

int main() {
    int N;
    cin >> N;
    vi F(N);
    rep(i, N) {
        rep(j, 10) {
            int f;
            cin >> f;
            F[i] |= f << j;
        }
    }
    vv<int> P = vvec(N, 11, 0);
    rep(i, N) rep(j, 11) cin >> P[i][j];

    ll ans = -LINF;
    for (int bit = 1; bit < 1 << 10; ++bit) {
        ll pena = 0;
        rep(i, N) {
            int ol = popcnt32(F[i] & bit);
            pena += P[i][ol];
        }
        ans = max(ans, pena);
    }
    write(ans);
}

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

using namespace std;

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

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  ll N, M;
  cin >> N >> M;

  ll ans = 0;

  if( M - N * 2 >= 0 ) {
    // S を使い切れる
    ans += N;
    M -= N * 2;
    N = 0;

    // C だけで Scc を作る。
    ans += M / 4;

  } else  {
    // c が足りない
    ans += M / 2;
  }

  cout << ans << "\n";

  return 0;
}


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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long S){
	string str = to_string(S);
  int n = str.length();
  ll ans = 0;

  FOR(mask,0,(1<<(n-1))){
    string buf = "";buf += str[0];

    FOR(k,1,n){
      if(mask & (1 << (k-1))){
        ans += stol(buf.c_str());
        buf = "";
      }
      
      buf += str[k];
    }

    ans += stol(buf.c_str());
  }

  cout << ans << endl; 
}



int main(){
	ios::sync_with_stdio(false);
	long long S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 205;
char s[MAXN][MAXN];
int sum[MAXN][MAXN];
int f[MAXN][MAXN][MAXN][10];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= m; ++j) {
      while (s[i][j] != '.' && s[i][j] != '#')
        s[i][j] = gc();
      sum[i][j] = sum[i][j - 1] + (s[i][j] == '.');
    }
  for (RI i = n; i; --i)
    for (RI j1 = 1; j1 <= m; ++j1)
      for (RI j2 = j1; j2 <= m; ++j2)
        if (sum[i][j2] - sum[i][j1 - 1] == j2 - j1 + 1)
          if (s[i][j1] == s[i + 1][j1]) f[i][j1][j2][0] = f[i + 1][j1][j2][0];
          else f[i][j1][j2][0] = i;
        else if (sum[i][j2] - sum[i][j1 - 1] == 0)
          if (s[i][j1] == s[i + 1][j1]) f[i][j1][j2][0] = f[i + 1][j1][j2][0];
          else f[i][j1][j2][0] = i;
        else f[i][j1][j2][0] = i - 1;
  int k;
  for (k = 1; f[1][1][m][k - 1] < n; ++k) {
    for (RI i = 1; i <= n; ++i) {
      for (RI j1 = 1; j1 <= m; ++j1)
        for (RI j2 = j1; j2 <= m; ++j2) {
          if (f[i][j1][j2][k - 1] == n) { f[i][j1][j2][k] = n; continue; }
          f[i][j1][j2][k] = f[f[i][j1][j2][k - 1] + 1][j1][j2][k - 1]; // heng
          int l = j1, r = j2 - 1, mid, ans = 0;
          while (l <= r) {
            mid = (l + r) >> 1;
            int L = f[i][j1][mid][k - 1], R = f[i][mid + 1][j2][k - 1];
            ans = max(ans, min(L, R));
            if (L < R) r = mid - 1;
            else l = mid + 1;
          }
          f[i][j1][j2][k] = max(f[i][j1][j2][k], ans);
        }
    }
  }
  printf("%d\n", k - 1);
        
  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 306048
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){

  ll A, B, C, tmp1, tmp2, tmp3;
  cin >> A >> B >> C;

  vector<ll> a, b;
  ll amin = 1e8, bmin = 1e8;
  for(ll i = 0; i < A; i++){
    cin >> tmp1;
    a.push_back(tmp1);
    amin = min(amin, tmp1);
  }
  for(ll i = 0; i < B; i++){
    cin >> tmp1;
    b.push_back(tmp1);
    bmin = min(bmin, tmp1);
  }

  cerr << "a:" << endl;
  for(ll i = 0; i < A; i++){
    cerr << a[i] << " ";
  }cerr <<endl;

  cerr << "b:" << endl;
  for(ll i = 0; i < B; i++){
    cerr << b[i] << " ";
  }cerr <<endl;

  // calculate answer
  ll ans = amin + bmin;
  for(ll i = 0; i < C; i++){
    cin >> tmp1 >> tmp2 >> tmp3;
    ans = min(ans, a[tmp1-1] + b[tmp2-1] - tmp3);
  }

  cerr << "Answer:" << endl;
  cout << ans << endl;

  return 0;

  
}


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

namespace AtCoder.DP
{
    public class SegmentTree<T>
    {
        private readonly T ex;

        private readonly int n;

        private readonly int offset;

        private readonly T[] node;

        private readonly Func<T, T, T> func;

        public T this[int index] => node[offset + index];

        public SegmentTree(int m, Func<T, T, T> func, T ex)
        {
            this.func = func;
            this.ex = ex;

            n = 1;
            while (n < m)
                n *= 2;
            offset = n - 1;
            node = new T[n * 2 - 1];
            for (int i = 0; i < node.Length; i++)
                node[i] = ex;
        }

        public SegmentTree(int n, Func<T, T, T> operation, T init, T ex) : this(n, operation, ex)
        {
            for (int i = offset; i < offset + n; i++)
                node[i] = init;
        }

        public SegmentTree(T[] values, Func<T, T, T> operation, T ex) : this(values.Length, operation, ex)
        {
            Array.Copy(values, 0, node, offset, values.Length);
            UpdateTree();
        }

        public void Assign(int i, T value)
            => node[offset + i] = value;

        public void AssignAndUpdate(int i, T value)
        {
            i += offset;
            node[i] = value;

            while (i > 0)
            {
                i = (i - 1) / 2;
                node[i] = func(node[2 * i + 1], node[2 * i + 2]);
            }
        }

        public void UpdateTree()
        {
            for (int i = offset - 1; i >= 0; i--)
                node[i] = func(node[2 * i + 1], node[2 * i + 2]);
        }

        public T Query(int head, int foot)
            => Query(head, foot, 0, 0, n);

        private T Query(int head, int foot, int k, int left, int right)
        {

            if (foot <= left || right <= head)
                return ex;
            if (head <= left && right <= foot)
                return node[k];
            else
            {
                var m = (left + right) / 2;
                T leftValue = Query(head, foot, k * 2 + 1, left, m);
                T rightValue = Query(head, foot, k * 2 + 2, m, right);
                return func(leftValue, rightValue);
            }
        }
    }

    class EDPC_Q
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            // i本目までの最大高さがjである場合についてdpを行う
            var dp = new long[n + 1];
            var segmentTree = new SegmentTree<long>(n, (long x, long y) => Math.Max(x, y), 0, 0);

            for (int i = 0; i < n; i++)
            {
                var max = segmentTree.Query(0, h[i] - 1);
                segmentTree.AssignAndUpdate(h[i] - 1, max + a[i]);
            }
            Console.WriteLine(segmentTree.Query(0, n));
        }
    }
}


Measured memory_bytes: 49800
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,c,i=0,e,d[100000];
  string b;
  while(b!="?"){
    cin>>a>>b>>c;
    if(b=="+"){
      d[i]=a+c;
    }
    if(b=="-"){
      d[i]=a-c;
    }
    if(b=="*"){
      d[i]=a*c;
    }
    if(b=="/"){
      d[i]=a/c;
    }
    i++;
  }
  e=i;
  for(int i=0;i<e-1;i++){
    cout<<d[i]<<"\n";
  }
  return(0);
}



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

#define i64 long long int
#define ran 101101

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
	int rev(int x) {return pw(x, mod-2);}
};
modular_arithmetic ma;

int n, k;
int a[ran];

int main() {
	scanf("%d%d", &n, &k);
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		a[i] += 1e9;
	}
	sort(a+1, a+n+1);
	
	if(k==1) {
		puts("0");
		return 0;
	}
	
	int ans = 0;
	int s = 0;
	int c = 0;// c(len-2, k-2)
	for(int len = 2; len <= n; len++) {
		//s += a[n] - a[len-1];
		//s -= a[n] - a[n-(len-1)+1];
		s = ma.add(s, (a[n]-a[len-1])%ma.mod);
		s = ma.sub(s, (a[n]-a[n-(len-1)+1])%ma.mod);
		
		if(len<k) continue;
		if(len==k) c = 1;
		else {
			c = ma.mul(c, len-2);
			c = ma.mul(c, ma.rev(len - k));
		}
		
		ans = ma.add(ans, ma.mul(s, c));
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
ll d[501][501];
int main(){
    int n,m,h,w;
    cin >> n >> m >> h >> w;
    rep(i,n){
        rep(j,m){
            d[i][j] = 1000;
        }
    }
    for(int i=h-1;i<n;i+=h){
        for(int j=w-1;j<m;j+=w){
            d[i][j] = -1000*h*w+999;
        }
    }
    ll sm = 0;
    rep(i,n){
        rep(j,m){
            sm += d[i][j];
        }
    }
    if(sm<=0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        rep(i,n){
            rep(j,m){
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ld a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  ld distance=abs(a-b);
  if(v<=w){
    cout<<"NO"<<endl;
    return 0;
  }
 else{
   ld u=v-w;
   if(ceil(distance/u)<=t) cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 }
return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {


       ll N;
       cin>>N;
       set<string> st;
       forn(i,N){
        string s;
        cin>>s;
        st.insert(s);
       }
       cout<<st.size()<<endl;







    }



    return 0;
}

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

int main(){

int n;
cin>>n;
if(n>=400 && n<=599)
 cout<<8<<endl;
 else if(n>=600 && n<=799)
  cout<<7<<endl;
  else if(n>=800 && n<=999)
  cout<<6<<endl;
  else if(n>=1000 && n<=1199)
  cout<<5<<endl;
  else if(n>=1200 && n<=1399)
  cout<<4<<endl;
  else if(n>=1400 && n<=1599)
  cout<<3<<endl;
  else if(n>=1600 && n<=1799)
  cout<<2<<endl;
  else if(n>=1800 && n<=1999)
  cout<<1<<endl;

}

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

int main() {
	int l[6] = { 0,0,0,0,0,0 };
	double f;
	int length;
	cin >> length;
	for (int i = 0; i < length; i++) {
		cin >> f;
		if (f < 165.0) {
			l[0] += 1;
		}
		else if (f < 170.0) {
			l[1] += 1;
		}
		else if (f < 175.0) {
			l[2] += 1;
		}
		else if (f < 180.0) {
			l[3] += 1;
		}
		else if (f < 185.0) {
			l[4] += 1;
		}
		else l[5] += 1;
	}
	for (int i = 0; i < 6; i++){
		cout << i+1 << ":";
		for (int j = 0; j < l[i]; j++){
			cout << "*";
		}
		cout << endl;
	}
	
}

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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;

  long ans;

  if(A == 0) {
    ans = 0;
  } else
  if(B == 0) {
    ans = N;
  } else {
    ans = N / (A+B);
    ans = ans * A;
    ans += min(N % (A+B), A);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,M,i,total,pop;
  total=0;//全体投票数                                   
  pop=0;//人気商品の数                                 
  scanf("%d %d",&N,&M);
  int vote[N];
  for(i=0;i<N;i++){
    scanf("%d",&vote[i]);
    total+=vote[i];
  }
  for(i=0;i<N;i++){
    if(vote[i]>=1.0*total/4.0/M){
      pop++;
    }
  }
  if(pop>=M){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007
#define l_ength size
using ll = long long;
#define INF (1ll<<60)
using namespace std;

int main(){
	
	int n; cin >> n;
	vector<ll> a(n);
	// S(n) = Σ[0, n);
	vector<ll> sum(n+1);
	sum[0] = 0;
	for( int i = 0; i < n; ++i ){
		ll k; cin >> k;
		a[i] = k;
		sum[i+1] = sum[i] + k;
	}

	ll ans = INF;
	// 空ではない部分列なので最初の二分割（Q と R の間）の位置は 2 <= x <= n-2
	for( int x = 2; x <= n-2; ++x ){
		auto pitr = lower_bound( sum.begin(), (sum.begin()+=x), sum[x]/2 );
		// 二分探索したあとにその 1 つ前の要素も見てどちらのほうが sum[x]/2 近いか見る
		// f <= sum[x]/2 <= g
		ll g = *pitr, f = *(--pitr);
		ll presum1 = sum[x]/2;
		ll p = ( abs(presum1-f) >= abs(presum1-g) ) ? g : f;
		ll q = sum[x] - p;
		
		// (sum[n]-sum[x])/2 + sum[x] = (sum[n]+sum[x])/2 
		auto ritr = lower_bound( (sum.begin()+=x), sum.end(), (sum[n]+sum[x])/2 );
		// f <= (sum[n]+sum[x])/2 <= g
		ll i = *ritr, h = *(--ritr);
		ll presum2 = (sum[n]+sum[x])/2;
		ll r = ( abs(presum2-h) >= abs(presum2-i) ) ? i : h;
		ll s = sum[n] - r;
		r -= ( p + q );
		
		// cout << p << " " << q << " " << r << " " << s << endl;
		ans = min( ans, abs(max({p, q, r, s})-min({p, q, r, s})) );
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456