akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7);

int main(void) {
	int b[3] = { 0 };
	char a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	b[0] = a[0] - '0';
	b[1] = a[1] - '0';
	b[2] = a[2] - '0';
	cout << b[2] * 10 + b[1] + b[0] << endl;
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a[10],b[10];
int i,max1=0,max2=0,max3=0,min1=0,min2=0,min3=0,w,k;
for(i=0;i<10;i++){
scanf("%d",&a[i]);
}
for(i=0;i<10;i++){
scanf("%d",&b[i]);
}
for(i=0;i<10;i++){
if(max2>max1 && max1<a[i]){
max1=a[i];
continue;
}
if(max3>max2 && max2<a[i]){
max2=a[i];
continue;
}
if(max3<a[i]){
max3=a[i];
continue;
}
}
for(i=0;i<10;i++){
if(min2>min1 && min1<b[i]){
min1=b[i];
continue;
}
if(min3>min2 && min2<b[i]){
min2=b[i];
continue;
}
if(min3<b[i]){
min3=b[i];
continue;
}
}
w=max1+max2+max3;
k=min1+min2+min3;
printf("%d %d\n",w,k);


return 0;
}

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


#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int dp[110][100010];
int w[110];
int v[110];

int main()
{
    int n;
    ll limit;
    cin >> n >> limit;
    ll sum_v = 0;

    rep(i,n)
    {
        cin >> w[i] >> v[i];
        sum_v += v[i];
    }

    rep(i,n+1)
    {
        rep(j,sum_v+1)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    rep(i, n)
    {
        rep(j, sum_v + 1)
        {
            chmin(dp[i+1][j], dp[i][j]);
            if (j-v[i]>=0)
            {
                chmin(dp[i+1][j], dp[i][j-v[i]]+w[i]);
            }
        }
    }
    
    ll ans = 0;
    rep(j,sum_v+1)
    {
        if (dp[n][j]<=limit)
        {
            ans = j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 41216
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

K = INT()
A, B = MAP()
for i in range(A, B+1):
    if i%K == 0:
        print('OK')
        sys.exit()
print('NG')

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();

    #ifdef LOCAL_ENV
    assert(cin.rdstate() & ios_base::eofbit);
    #endif
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define X 15
vector<pair<int,int> > v[30];
int cnt;
void make(int a,int b,int len){
    v[a].push_back(make_pair(b,len));
    cnt++;
}
int f(){
    int s=1;
    lol(i,X-1)s*=3;
    return s;
}
int main(){
    cnt=0;
    int n;cin>>n;
    int sum=0;
    int k=f();
    lol(i,X){
	for(int j=1;j<=n/k;j++){
	    make(1,i+2,sum);
	    sum+=k;
	}
	//cout<<"#"<<i<<" "<<k<<" "<<sum<<" "<<n<<endl;
	n%=k;
	k/=3;
    }
    k=f()/3;
    lol(i,X-1){
	lol(j,3)make(i+2,i+3,j*k);
	k/=3;
    }
    lol(i,30)for(auto x:v[i])if(x.second>1000000)cnt--;
    cout<<X+1<<" "<<cnt<<endl;
    lol(i,30){
	for(auto x:v[i]){
	    if(x.second>1000000)continue;
	    int a=i,b=x.first;
	    if(a>b)swap(a,b);
	    cout<<a<<" "<<b<<" "<<x.second<<endl;
	}
    }
    return 0;
}


Measured memory_bytes: 256
H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
   a,b=map(int,input().split())
   A.append(a)
   B.append(b)

DP=[[0]*(H+max(A)) for i in range(N)]
DP.insert(0,[10**8+1]*(H+max(A)))
DP[0][0]=0

for i in range(1,N+1):
   for j in range(1,H+1):
      if j-A[i-1]>0:
         DP[i][j]=min(DP[i-1][j],DP[i][j-A[i-1]]+B[i-1])
      else:
         DP[i][j]=min(DP[i-1][j],B[i-1])

print(DP[N][H])

Measured memory_bytes: 127216
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int n;
    int total=0;

    cin>>n;
    vector<int> d(n+1);

    FOR(i,1,n){
        cin>>d[i];
    }
    FOR(i,1,n-1){
        FOR(k,i+1,n){
            total+=d[i]*d[k];
        }
    }
    cout<<total<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int frog(int v[],int i,int a[])
{


    if(a[i]!=-1)
    {

        return a[i];
    }
    else
    {
        a[i]=min(frog(v,i+1,a)+abs(v[i]-v[i+1]),frog(v,i+2,a)+abs(v[i]-v[i+2]));
        return a[i];
    }


}
int main()
{




    cin>>n;

    int v[n];
    int a[n];

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

        cin>>v[i];
        a[i]=-1;
    }
    a[n-2]=abs(v[n-1]-v[n-2]);
    a[n-1]=0;
    a[n-3]=abs(v[n-3]-v[n-1]);
    int res=frog(v,0,a);
    cout<<res;

}


Measured memory_bytes: 4864
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int F[N][10];
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin >> F[i][j];
    }
  }
  int P[N][11];
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin >> P[i][j];
    }
  }

  //全探索
  int ans = -1000000000;
  for(int i=1 ; i<(1 << 10) ; i++){
    int use[10];
    int itmp = i;
    for(int j=0;j<10;j++){
      if(itmp%2==1) use[j] = 1;
      else use[j] = 0;
      itmp /= 2;
    }

    int anstmp = 0;
    for(int j=0;j<N;j++){
      int cnt = 0;
      for(int k=0;k<10;k++){
        if(F[j][k]==1 && use[k]==1) cnt++;
      }
      anstmp += P[j][cnt];
    }

    //cout << "aaa" << endl;
    ans = max(ans, anstmp);
  }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>      
using namespace std;
const int N = 2e5 + 100;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ull unsigned long long
#define ll long long
#define pii pair <int,int>
#define forn(l,i,n) for(int i = l;i <= n;++i)   
#define FOR(l,i,n) for(int i = l;i < n;++i)
#define all(v) v.begin(), v.end()
#define pll pair <ll,ll>
const ll inf = 1e9 + 7;
const ll ll_inf = 1e17 + 100;   
const double pi = 3.14159265358979323;
inline void fr(){
    freopen("gcd.in", "r", stdin);
    freopen("gcd.out", "w", stdout);
}
void boost()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
 
ll binpow (ll a, ll n)
{
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }
        a *= a;
        n >>= 1;
        a %= inf;
    }
    return res;
}
        
int n;
int h[N];
int dp[N];
int k;
 
main()	
{                                                                        
	cin >> n >> k;
	dp[0] = inf;
	for (int i = 1;i <= n;++i)
	{
	  	cin >> h[i];
	}
	for (int i = 2;i <= n;++i)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);                                                                      
		for (int j = i - 2;j >= max(i - k,1);--j)
		{
			dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n];

}	 


Measured memory_bytes: 1024
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
dh = [-1, 0, 0, 1]
dw = [0, -1, 1, 0]
cnt = 0

for h in range(H):
  for w in range(W):
    # Check only black cell
    if s[h][w] == '.':
      continue
    for k in range(4):
      nh = h + dh[k]
      nw = w + dw[k]
      if nh < 0 or nw < 0 or H <= nh or W <= nw:
        continue
      # ok
      if s[nh][nw] == '#':
        break
    # failed
    else:
      cnt += 1

if cnt == 0:
  print('Yes')
else:
  print('No')

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

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, x, y;
  int n, ans = 0;
  cin >> n >> s;
  
  rep(i, 1, n) {
    x = s.substr(0, i);
    y = s.substr(i, n-i);
    
    int cnt = 0;
    rep(k, 0, 26) {
      bool xx = false;
      bool yy = false;
      rep(j, 0, i) if(x[j] == k+'a') xx = true;
      rep(j, 0, n-i) if(y[j] == k+'a') yy = true;
      if(xx and yy) cnt++;
    }
    ans = max(ans, cnt);
  }      
  cout << ans << "\n";
}


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

int main() {
    int n, a, b;
    std::string s;

    std::cin >> n >> a >> b >> s;
    
    int a_count = 0, b_count = 0;
    for (auto c : s) {
        switch (c) {
            case 'a':
                if (a_count + b_count < a + b) {
                    std::cout << "Yes" << std::endl;
                    a_count++;
                } else {
                    std::cout << "No" << std::endl;
                }
                break;
            case 'b':
                if (a_count + b_count < a + b && b_count < b) {
                    std::cout << "Yes" << std::endl;
                    b_count++;
                } else {
                    std::cout << "No" << std::endl;
                }
                break;
            default:
                std::cout << "No" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(void){
    int n, i;
    int L[110];
    int max = 0, sum = 0;


    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &L[i]);

    //for(i = 0; i < n; i++) printf("%d\n", L[i]);

    for(i = 0; i < n; i++){
        sum += L[i];
        if(max < L[i]){
            max = L[i];
        }
    }

    if(sum - max > max){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;
const ll mod = 1e18;

int main()
{
    ll a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 1){
        if(abs(b-a) > mod) cout << "Unfair" << endl;
        else cout << b-a << endl;
    }else{
        if(abs(a-b) > mod) cout << "Unfair" << endl;
        else cout << a-b << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> ans(n);
  rep(i,n) ans[a[i]-1] = i+1;
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
from itertools import permutations

def main():
    N, M = map(int, input().split())
    G = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        G[a - 1].add(b - 1)
        G[b - 1].add(a - 1)
    r = 0
    for p in permutations(range(1, N)):
        f = 0
        for i in p:
            if i not in G[f]:
                break
            f = i
        else:
            r += 1
    return r

print(main())


Measured memory_bytes: 9132
n = int(input())
d = [0 for i in range(n)]
for i in range(n):
    a = 0
    for j in input():
        a += 10**(ord(j)-97)
    d[i] = a
d = sorted(d)
ans = 0
co = 1
for i in range(1, n):
    if d[i-1] == d[i]:
        co += 1
    else:
        ans += co*(co-1) // 2
        co = 1
ans += co*(co-1) // 2
print(ans)


Measured memory_bytes: 9068
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int main(){
    int a;
    char s[11];
    scanf("%d",&a);
    scanf("%s",s);
    if(a<3200){
        printf("red\n");
    }
    else{
        printf("%s\n",s);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,i;
  char s1[21];
  scanf("%s",s1);
  int len=strlen(s1);
  len--;
  for(i=len;i>=0;i--){
    printf("%c",s1[i]);
  }
  printf("\n");
  return(0);
}

Measured memory_bytes: 932
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Stack<String> s = new Stack<>();
			while (sc.hasNext()) {	
				String l = sc.nextLine();
				if ("0".equals(l)) {
					System.out.println(s.pop());
				} else {
					s.push(l);
				}
			}
			while(!s.isEmpty()) {
				System.out.println(s.pop());
			}
		}
	}
}

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

//namespace _3_C
//{
class Program
{
    static void Main(string[] args)
    {
        int i = 1;
        while (true)
        {

            //?????????????????????
            string readData = Console.ReadLine();

            // ???????????£????????????????????????????????¨??§????????????
            string[] readDataValue = readData.Split(' ');
            int x = int.Parse(readDataValue[0]);
            int y = int.Parse(readDataValue[1]);

            //x???0?????¨???????????????
            if (x == 0 && y == 0) break;

            //x???y??\????????¨???
            if (x <= y)
            {
                Console.WriteLine(x + " " + y );
            }
            else
            {
                Console.WriteLine(y + " " + x);
            }
            
            ++i;
        }
    }
}
//}

Measured memory_bytes: 9344
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,S;
ll K;
ll ans=0;
ll A[10000];
ll B [200001];




int main(){
    cin >> N>>S;
    
    if(S == 2 || S==5){
        for(int i=0;i<N;i++){
            char a;
            cin >> a;
            int d = a-'0';
            if(d%S==0){
                ans += i+1;
            }
        }
    }else{
        for(int i=0;i<N;i++){
            char a;
            cin >> a;
            int d =a-'0';
            B[i] = d;
        }
        ll b = 1;
        ll c = 0;
        for(int i=0;i<N;i++){
            c = (c + b*B[N-i-1])%S;
            A[c]+=1;;
            b *= 10;
            b %= S;
        }
        A[0] += 1;
        for(int i= 0;i<S;i++){
            ans += A[i]*(A[i]-1)/2;
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int h,w;
int ch,cw,dh,dw;
string s[1001];
int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0},ddx[24]={-1,-1,-1,0,1,1,1,0,-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1,0,-1},ddy[24]={-1,0,1,1,1,0,-1,-1,-2,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2};
bool in(int x,int y){
	re (x>=0&&x<h&&y>=0&&y<w);
}
bool f[1001][1001];
int cnt;
vii v[1000001]; 
int e[1001][1001];
void dfs(int x,int y){
	e[x][y]=cnt;
	f[x][y]=true;
	v[cnt].pb(m_p(x,y));
	rep(i,4){
		int xx=x+dx[i],yy=y+dy[i];
		if(!in(xx,yy)||s[xx][yy]=='#'||f[xx][yy])
		continue;
		dfs(xx,yy);
	}
}
vi a[1000001];
bool g[1000001];
ll dist[1000001];
int main(){
	//ios::sync_with_stdio(0);
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--;
	cw--;
	dh--;
	dw--;
	rep(i,1000001)
	dist[i]=1e9;
	rep(i,h)
	cin>>s[i];
	rep(i,h)
	rep(j,w){
		if(s[i][j]=='#')
		continue;
		if(f[i][j])
		continue;
		dfs(i,j);
		cnt++;
	}
	g[e[ch][cw]]=true;
	queue<int> q;
	q.push(e[ch][cw]);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		rep(i,(int)(v[x].size())){
			rep(k,24){
				int xx=v[x][i].fr+(ddx[k]),yy=v[x][i].se+(ddy[k]);
				if(!in(xx,yy)||(s[xx][yy]=='#')||g[e[xx][yy]])
				continue;
				q.push(e[xx][yy]);
				g[e[xx][yy]]=true;
				a[x].pb(e[xx][yy]);
				a[e[xx][yy]].pb(x);
			}
		}
	}
	if(!g[e[dh][dw]]){
		cout<<-1;
		re 0;
	}
	dist[e[ch][cw]]=0;
	q.push(e[ch][cw]);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		rep(i,(int)(a[x].size())){
			int xx=a[x][i];
			if(dist[xx]<=dist[x]+1)
			continue;
			dist[xx]=dist[x]+1;
			q.push(xx);
		}
	}
	cout<<dist[e[dh][dw]];
	re 0;
}

Measured memory_bytes: 75028
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main(){
	int a,b;
  	cin >> a >> b;

  	if(a > b){
    	for(int i = 0; i < a; i++){
        	cout << b ;
        }
    }else{
    	for(int i = 0; i < b; i++){
        	cout << a ;
        }
    }
  	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n;
char s[5000010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	FOR(i,1,n) if (s[i]=='P') putchar('P'); else putchar('D');
	return 0;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, M;
    cin >> N >> M;
    Yes(N == M);
}


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

int main(){
  int N;
  cin >> N;
  vector<long> a(N);
  for(int i = 0; i < N; i++) cin >> a.at(i);
  vector<int> total(30, 0);
  long q, r;
  for(int i = 0; i < N; i++){
    q = 1;
    for(int j = 0; j < 30; j++){
      q *= 2;
      r = a.at(i) % q;
      if(r == 0) continue;
      else{
        total.at(j) += 1;
        a.at(i) -= r;
      }
    }//j
  }//i
  bool isOK = true;
  for(int i = 0; i < total.size(); i++){
    if(total.at(i) % 2 != 0){
      isOK = false;
      break;
    }
  }
  if(isOK) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
d[1001],c;main(w,n,i,C,W,b){for(;scanf("%d",&w),w;printf("Case %d:\n%d\n%d\n",++c,d[w],b),bzero(d,4004))for(scanf("%d",&n);n--;)for(i=w,scanf("%d,%d",&C,&W);i>=W;i--)d[i]=fmax(d[i],d[i-W]+C),b=d[i]-d[w]?b:i;}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    int ans;
    cin >> N;
    ans = N / 1.08;
    if((int)(ans * 1.08) == N) cout << ans << endl;
    else if((int)((ans + 1) * 1.08) == N) cout << ans + 1 << endl;
    else cout << ":(" << endl;
    return 0;
}

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

using namespace std;

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[1005][4][2]; // dp[i][j][k]:= i桁目まで見て0以外がj個あって
// k=0:N以下がまだ確定していない k=1:N以下が確定
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.size();
    dp[0][0][0] = 1;
    rep(i,N)rep(j,4)rep(k,2){
        int x = S[i]-'0';
        rep(d,10){//新たに追加する数
            int ni = i + 1, nj = j, nk = k;
            if(d!=0)nj++;
            if(nj>3)continue;
            if(k==0 && d>x)continue;
            if(d<x)nk=1;
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    cout << dp[N][K][0] + dp[N][K][1] << endl;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if x >= k * d:
    print(x - k * d)
elif -x >= k * d:
    print(abs(x + k * d))
else:
    a = x // d
    b = x % d
    if b <= abs(b-d):
        if a % 2 == k % 2:
            print(b)
        else:
            print(abs(b-d))
    else:
        if (a+1) % 2 == k % 2:
            print(abs(b-d))
        else:
            print(b)


Measured memory_bytes: 9080
#include <iostream>
#include <algorithm>
#include<string>
using namespace std;
struct f{
int a;
int b;
char c;
long long d;
string e;
}g[100001];
int compare(f x,f y)
{
    if(x.a<y.a)
        return 1;
    if(x.a>y.a)
        return 0;
    if(x.b<y.b)
        return 1;
    if(x.b>y.b)
        return 0;
    if(x.c<y.c)
        return 1;
    if(x.c>y.c)
        return 0;
    if(x.d<y.d)
        return 1;
    if(x.d>y.d)
        return 0;
    if(x.e<y.e)
        return 1;
    if(x.e>=y.e)
        return 0;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>g[i].a>>g[i].b>>g[i].c>>g[i].d>>g[i].e;
    }
    sort(g,g+n,compare);
    for(int i=0;i<n;i++)
    {
        cout<<g[i].a<<" "<<g[i].b<<" "<<g[i].c<<" "<<g[i].d<<" "<<g[i].e<<endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n, d;

int main() {
  cin >> n >> d;
  int x[n + 10][d + 10];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < d; ++j) cin >> x[i][j];

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int subtot = 0;
      for (int k = 0; k < d; ++k) {
        subtot += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      double subtotsq = sqrt(subtot);
      if (floor(subtotsq) == subtotsq) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N) = readLine()!!.split(' ').map(String::toInt)
    val S = readLine()!!

    var ans = 0
    for (i in 0..9) {
        for (j in 0..9) {
            for (k in 0..9) {
                var d = 0
                for ((p, c) in S.toCharArray().withIndex()) {
                    if (d == 0 && i == c - '0') d += 1
                    else if (d == 1 && j == c - '0') d += 1
                    else if (d == 2 && k == c - '0') d += 1
                }
                if (d == 3) {
                    ans += 1
                    //println("$i$j$k")
                }

            }
        }
    }
    println(ans)


//    val dp = Array(50000) { Array(4) {Array (10) {0}  } }
//    for ((i, c) in S.toCharArray().withIndex()) {
//        val digit = c - '0'
//        dp[i+1] = dp[i].copyOf()
//        for (l in 1..2) {
//            for (d in 0..9) {
//                dp[i+1][l+1][digit] += dp[i][l][d]
//            }
//        }
//        dp[i+1][1][digit] = 1
//
//        println("from")
//        dp[i].forEach { l -> l.forEach { d -> print("$d ") }; println() }
//
//        println("to")
//        dp[i+1].forEach { l -> l.forEach { d -> print("$d ") }; println() }
//        println()
//    }
//    println(dp[N][3].sum())
}

Measured memory_bytes: 53208
package main

import "fmt"

func main() {
	var a, b int
	_, err := fmt.Scan(&a, &b)
	if err != nil {
		panic(err)
	}
	product := a * b
	if product%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}


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

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;

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

    int n;
    cin >> n;
    vi h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int hl = 0;
    for (int i = 0; i < n; ++i) {
        if (h[i] > hl) {
            hl = h[i] - 1;
        }
        else if (hl > h[i]) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';

    return 0;
}

Measured memory_bytes: 640
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;

    int ans = 0;

    vector<int> d(n + 1, 0);

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j += i) {
            d[j]++;
        }
    }

    for (int k = 1; k <= n; k++) {
        ans += k * d[k];
    }

    cout << ans << endl;
}


Measured memory_bytes: 81320
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0) cout<<a-b<<endl;
    else cout<<-a+b<<endl;
    return 0;
}

Measured memory_bytes: 256
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
graph = [[float('INF')]*(N+1) for i in range(N+1)]
for i in range(1, N):
    graph[i][i+1] = 1
graph[X][Y] = 1
kyori = [0]*N

# dp
for i in range(1, N):
    for j in range(i+1, N+1):
        if j<=X:
            graph[i][j] = min(graph[i][j], abs(j - i))
        else:
            graph[i][j] = min(graph[i][j], abs(j - i), abs(X - i)+1+abs(j - Y))

# kyori count
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if not graph[i][j]==float('INF'):
            kyori[graph[i][j]] += 1

# output
for i in range(1, N):
    print(kyori[i])


Measured memory_bytes: 164616
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#include<fstream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;

int main()
{
    char s[10];
    while(scanf("%s",s)!=EOF)
    {
        if(s[0]!=s[2]) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


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

const int MAX_N = 100000;
const int MAX_Q = 100000;

//&#36755;入
int N, Q;

int par[MAX_N + 1];				//父&#32467;点
bool marked[MAX_N + 1];			//&#26631;&#35760;&#32467;点

void init(){
	//初始化
	par[1] = 1;
	memset(marked, 0, sizeof(marked));
	marked[1] = true;
	for(int i = 2; i <= N; i ++)
		scanf("%d", &par[i]);
}

int find(int x){
	//找到最近被&#26631;&#35760;的父&#32467;点
	if(marked[x])return x;
	else return find(par[x]);
}

void solve(){
	long long ans = 0;
	for(int i = 0; i < Q; i ++){
		getchar();
		char c;
		int v;
		scanf("%c %d", &c, &v);
		if(c == 'M'){
			marked[v] = true;
		}
		else{
			ans += find(v);
		}
	}
	printf("%lld\n", ans);
}

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

	while(scanf("%d %d", &N, &Q)){
		if(N == 0 && Q == 0)break;

		init();
		solve();
	}

	return 0;
}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(100010,INT64_MAX>>2));
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        int p,q;
        cin >> p >> q;
        for (int j = 0;j < 100010;++j) dp[i+1][j] = dp[i][j];
        for (int j = 0;j < 100010-q;++j) {
            if (dp[i+1][j+q] > dp[i][j]+p) dp[i+1][j+q] = dp[i][j]+p;
        }
    }
    int ans = 0;
    for (int i = 0;i < 100010;++i) if (dp[n][i] <= w) ans = max(ans,i);
    cout << ans << endl;
    return 0;
}

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


vector<ll> divisors(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (n / i != i) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        if (divisors(i).size() == 8) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0; i<n; i++)
int main(){
    string s; cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14, 5) << endl;
}

Measured memory_bytes: 256
import Debug.Trace
import Data.List
import Data.Maybe
import qualified Data.IntSet as S
import qualified Data.ByteString.Char8 as B

type Index = Int
type Memo = S.IntSet

-- data Props = Props { total :: Int, memo :: Memo } deriving Show

step :: (Int, Memo) -> (Int, Index) -> (Int, Memo)
step (total, memo) (x, i) = -- traceShow (props, x, i)
  (total', memo')
  where
    h = fromJust (S.lookupGT i memo) - i
    w = i - fromJust (S.lookupLT i memo)
    total' = total + x * h * w
    memo' = S.insert i memo

solve :: [Int] -> Int
solve l = total
  where
    n = length l
    l' = sort $ zip l [1..]
    init = (0, (S.fromList [0, n + 1]))
    (total, memo) = foldl' step init l'

readInt = fst . fromJust . B.readInt
main = B.getContents >>= print .  solve . map readInt . B.words . last . B.lines


Measured memory_bytes: 81276
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const ll MAX_N = 1e5+5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------


int main(){
    fastio;
    ld n;
  	cin>>n;
  	ld aux=n/3;
  	cout<<fixed <<setprecision(12)<<aux*aux*aux<<endl;


}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
    long long a[100000],b,n;
    int p=0,q=0;
    cin>>n;
    for (int i=0;i<n;i++) cin>>a[i];
    b=a[0];
    for(int i=0;i<n;i++){
        if(a[i]==0) {
            b=0;
            p=1;
            break;
            }
    }
    long long x=1000000000000000000;
    if(p==0) for (int i=0;i<n;i++){
        x=x/a[i];
        if(x<1) {
            q=1;
            break;
            }
    }
    if(p==0&&q==0) for(int i=1;i<n;i++){
        b=b*a[i];
    }
    if(p==1&&q==0)cout<<0;
    else if(p==0&&q==1) cout<<-1;
    else cout<<b;
    return 0;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	while(n--){
		cin>>x;
		if(z>x)return cout<<"No",0;
		z=max(z,x-1);
	}
	cout<<"Yes";

}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;
  if (x <= 999) {
  	cout << "ABC" << '\n';
  } else {
  	cout << "ABD" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi A(N); rpz(i, N) cin>>A[i];
	sort(all(A));
	int n = A[N-1], r = 0;
	int mindiff = INT_MAX;
	rpz(i, N-1){
		int ai = A[i];
		int diff = abs((n+2-1)/2 - A[i]);// |⌈n/2⌉ - ai|
		if(mindiff > diff){
			mindiff = diff;
			r = A[i];
		}
	}
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX_N = 4020;
const int INF = 1145141919;

struct BIT{
    // [1, n]
    vector<int>bit;
    int N;
    void init(int n){
        N = n;
        bit.resize(n, 0);
    }
    BIT(int n=0){
        init(n);
    }
    int sum(int i){
        int s = 0;
        while(i>0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i, int x){
        if(i==0)return;
        while(i <= N){
            bit[i] += x;
            i += i & -i;
        }
    }
};

int dp[MAX_N][MAX_N];

int main(){
    
    rep(i,MAX_N)rep(j,MAX_N)dp[i][j] = INF;
    dp[0][0]=0;

    int N;
    cin >> N;
    BIT bit(MAX_N);
    vector<int>bpos(N+2, 0), wpos(N+2, 0);
    for(int i = 1; i <= 2*N; i++){
        char c;
        int a;
        cin >> c >> a;
        if(c=='B')bpos[a] = i;
        else wpos[a] = i;
        bit.add(i, 1);
    }

    for(int b=0; b<=N; b++){
        BIT tmpBit = bit;
        for(int w=0; w<=N; w++){
            chmin(dp[b+1][w], dp[b][w] + tmpBit.sum(bpos[b+1]-1));
            chmin(dp[b][w+1], dp[b][w] + tmpBit.sum(wpos[w+1]-1));
            tmpBit.add(wpos[w+1], -1);
        }
        bit.add(bpos[b+1], -1);
    }
    cout << dp[N][N] << endl;

    return 0;
}

Measured memory_bytes: 63360
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, m, q, l, r, cnt[505][505];
signed main() {
	cin >> n >> m >> q;
	rep(i, m) {
		cin >> l >> r;
		cnt[l][r]++;
	}
	for (int i = n; i >= 1; i--) {
		for (int j = 0; j <= n; j++) {
			cnt[i - 1][j] += cnt[i][j];
			cnt[i][j] += cnt[i][j - 1];
		}
	}
	rep(i, q) {
		cin >> l >> r;
		cout << cnt[l][r] << endl;
	}
	endre;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;


     signed main(){
         int n;
         cin>>n;
         int l[n];
         for(int i=0;i<n;i++)cin>>l[i];
         sort(l,l+n);
         int ans=0;
         for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
             if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]&&l[k]<l[j]+l[i])ans++;
         }
         cout<<ans<<endl;
       


     }


 


 






    





      

        


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,K;
    cin >> N >> M >> K;
    rep(i,0,N+1){
        rep(j,0,M+1){
            ll v = i * M + j * N - 2 * i * j;
            if(v == K){
                print("Yes");
                return 0;
            } 
        }
    }
    print("No");

}

Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var input = test.ConvertIntArray(test.ReadInput());
            var n = input[0];
            var k = input[1];
            var array = test.ConvertIntArray(test.ReadInput());
            long count = 0;
            Array.Sort(array);
            
            for(var i = 0; i<array.Length - k; i++)
            {
                count += array[i];
            }

            Console.WriteLine(count);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

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

int main()
{
	string S;
	int m;

	cin >>m>> S;

	int s = S.size(), a[10000] = {0},ans = 0,sum = 0;

	for (int i = 0; i < s-1; i++,sum = 0) {
		for (int j = i + 1; j < s; j++) {
			for (int k = 0; k <= i; k++) {
				if (S[k] == S[j]&& a[S[k] - '0'] == 0) {
					a[S[k] - '0'] = 1;
					sum++;
				}
			}
		}

		if (ans < sum)ans = sum;
		for (int n = 0; n < 10000; n++) {
			a[n] = 0;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*
  AOJ 2582
  Title:Step Aerobics
  @kankichi573
*/
#include <stdio.h>

main()
{
  int n,i,cnt,rl;
  char buf[2];

  while(scanf("%d",&n) && n)
    {
      cnt=rl=0;
      for(i=0;i<n;i++)
	{
	  scanf("%s",buf);
	  if(buf[0]=='r')
	    rl ^= 1;
	  if(buf[0]=='l')
	    rl ^= 2;
	  if(rl==3)
	    {
	      rl=0;
	      cnt++;
	    }
	}
      printf("%d\n",cnt);
    }
  return(0);
}

Measured memory_bytes: 604