akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int MAX = 1000000007;

int dp[103][200007];

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, ww, i, j, sum_val=0;
    cin>>n>>ww;
    int w[n+1], v[n+1];
    for(i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        sum_val+=v[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= 200003; ++j) {
            dp[i][j] = MAX;
        }
    }
    dp[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=0;j<=1000*n;j++){
            if(j-v[i]>=0)
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    for(i=sum_val;i>=0;i--){
        if(dp[n][i]<=ww)
            break;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 160000
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define unittest_name_helper(counter) unittest_ ## counter
#define unittest_name(counter) unittest_name_helper(counter)
#define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) ()
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    while (true) {
        int n, t, l, b; scanf("%d%d%d%d", &n, &t, &l, &b);
        if (n == 0 and t == 0 and l == 0 and b == 0) break;
        vector<char> f(n + 1);
        repeat (i, l) { int x; scanf("%d", &x); f[x] = 'L'; }
        repeat (i, b) { int x; scanf("%d", &x); f[x] = 'B'; }
        auto dp = vectors(t + 1, n + 1, double());
        dp[0][0] = 1;
        double result = 0;
        repeat (y, t + 1) {
            result += dp[y][n];
            dp[y][n] = 0;
            repeat (x, n + 1) {
                int ny = y + (f[x] == 'L' ? 2 : 1);
                if (ny >= t + 1) continue;
                repeat_from (dice, 1, 6 + 1) {
                    int nx = x + dice;
                    if (nx > n) nx = n - (nx - n);
                    if (f[nx] == 'B') nx = 0;
                    dp[ny][nx] += dp[y][x] / 6;
                }
            }
        }
        printf("%.8lf\n", result);
    }
    return 0;
}

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

using namespace std;

int main() {
  int n;
  int l, r;
  int num = 0;
  cin >> n;
  
  for (int i=0; i < n; i++) {
    cin >> l >> r;
    num += r - l + 1;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;

		for(int i=0 ; i<=s.length()-3 ; i++) {
			if(s.charAt(i)=='A' && s.charAt(i+1)=='B' && s.charAt(i+2)=='C') {
				count++;
			}
		}

		System.out.println(count);

		sc.close();

	}

}


Measured memory_bytes: 35864
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,i,j,ans=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=1;i<n;i++)
    {
        if(arr[i-1] > arr[i])
        {
            ans += arr[i-1] - arr[i];
            arr[i]=arr[i-1];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 998244353
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){
  if(*(LL*)a>*(LL*)b)return 1;
  if(*(LL*)a<*(LL*)b)return -1;
  return 0;
}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  LL N,M,i,a=0,b=1,n=1,ans=0;
  scanf("%lld",&N);
  LL D[N];
  FOR(i,0,N)scanf("%lld",&D[i]);
  if(D[0]!=0){
    printf("0\n");
    return 0;
  }
  qsort(D,N,sizeof(LL),lcmp);
  if(D[1]!=0){
    ans=1;
    FOR(i,1,N){
      if(D[i]==n)a++,ans=(ans*b)%MOD;
      else{
        if(D[i]!=n+1)ans=0;
        else b=a,ans=(ans*b)%MOD,n++,a=1;
      }
    }
  }

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


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
//#include <search.h>
#include <algorithm>
//#include <vector>
using namespace std;
int main()
{
    /*
    long long int n,f=1,sum=0;
    cin>>n;
    for(long long int i=1;i<=n;i++){
        f=f*i;
    }
    cout<<f;
    for(long long int i=1;i<=f;i++){
        if(f%i==0) sum++;
    }
    cout<<sum;
*/
long long int n,a,b,arr[100000],sum=0;
cin>>n>>a>>b;
for(int i=0;i<n;i++){
    cin>>arr[i];
}
for(int i=0;i<n-1;i++){
    if(((arr[i+1]-arr[i])*a)>b){
        sum+=b;
    }
    else{
        sum+=((arr[i+1]-arr[i])*a);
    }
}
cout<<sum;
return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;


int main()
{
    char str[1001];

    while(1) {
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for (int i = 0; i < strlen(str); i++) {
            sum += (str[i] - '0');
        }

        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 3180
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  ll a, b;
  cin >> n >> a >> b;
  vector<ll> x;
  for(int i = 0; i < n; i++){
    ll y;
    cin >> y;
    x.pb(y);
  }
  ll res = 0;
  for(int i = 1; i < n; i++){
    ll cost = min(a * (x[i] - x[i - 1]), b);
    res += cost;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <climits>
#include <algorithm>

using namespace std;

struct flow_graph{
    static const int MAX_V = 20005;
    static const int MAX_E = 80000;

    int E,s,t,head,tail;
    int cap[2 * MAX_E],to[2 * MAX_E],next[2 * MAX_E],last[MAX_V],dist[MAX_V],q[MAX_V],now[MAX_V];

    flow_graph(){
        E = 0;
        memset(last,-1,sizeof last);
    }

    void clear(){
        E = 0;
        memset(last,-1,sizeof last);
    }

    void add_edge(int u, int v, int uv){
        to[E] = v, cap[E] = uv, next[E] = last[u]; last[u] = E++;
        to[E] = u, cap[E] = 0, next[E] = last[v]; last[v] = E++;
    }

    bool bfs(){
        memset(dist,-1,sizeof dist);
        head = tail = 0;

        q[tail] = t; ++tail;
        dist[t] = 0;

        while(head < tail){
            int v = q[head]; ++head;

            for(int e = last[v];e != -1;e = next[e]){
                if(cap[e^1] > 0 && dist[to[e]] == -1){
                    q[tail] = to[e]; ++tail;
                    dist[to[e]] = dist[v]+1;
                }
            }
        }

        return dist[s] != -1;
    }

    int dfs(int v, int f){
        if(v == t) return f;

        for(int &e = now[v];e != -1;e = next[e]){
            if(cap[e] > 0 && dist[to[e]] == dist[v]-1){
                int ret = dfs(to[e],min(f,cap[e]));

                if(ret > 0){
                    cap[e] -= ret;
                    cap[e^1] += ret;
                    return ret;
                }
            }
        }

        return 0;
    }

    int max_flow(int source, int sink, int V){
        s = source; t = sink;
        int f = 0,df;

        while(bfs()){
            for(int i = 0;i < V;++i) now[i] = last[i];

            while(true){
                df = dfs(s,INT_MAX);
                if(df == 0) break;
                f += df;
            }
        }

        return f;
    }
}G;

char s[100][101];
const int INF = 100000;
int dr[] = {-1,1,0,0};
int dc[] = {0,0,-1,1};

int main(){
    int H,W;

    scanf("%d %d",&H,&W);

    for(int i = 0;i < H;++i)
        scanf("%s",s[i]);

    for(int i = 0;i < W;++i){
        G.add_edge(0,1 + i,INF);
        if(H >= 2) G.add_edge(0,1 + (H - 1) * W + i,INF);
    }

    for(int i = 1;i + 1 < H;++i){
        G.add_edge(0,1 + i * W,1);
        if(W >= 2) G.add_edge(0,1 + i * W + (W - 1),INF);
    }

    for(int i = 0;i < H;++i){
        for(int j = 0;j < W;++j){
            if(s[i][j] == 'X'){
                G.add_edge(1 + H * W + i * W + j,1 + 2 * H * W,INF);
                G.add_edge(1 + i * W + j,1 + H * W + i * W + j,INF);
            }else{
                G.add_edge(1 + i * W + j,1 + H * W + i * W + j,1);
            }

            for(int k = 0;k < 4;++k){
                int r = i + dr[k],c = j + dc[k];

                if(r >= 0 && r < H && c >= 0 && c < W){
                    G.add_edge(1 + H * W + i * W + j,1 + r * W + c,INF);
                }
            }
        }
    }

    int ans = G.max_flow(0,1 + 2 * H * W,2 + 2 * H * W);
    printf("%d\n",ans >= INF? -1 : ans);

    return 0;
}


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

bool dp[100005];
int arr[105];


int main(){
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	for(int i = 0; i <= k; i++){
		for(int j = 0; j < n; j++){
			if(i >= arr[j] && !dp[i-arr[j]]){
				dp[i] = 1;
			}
		}
	}
	
	if(dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
		
}


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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int N;
  cin >>N;
  long long int A[N];
  for(int i =0;i<N;i++){
    cin >> A[i];
  }
  
  sort(A ,A+N);
  long long O=A[N-1];
  int x=N-2;
  
  for(int i=2;i<N;i++){
    O = O + A[x];
    i++;
    if(i==N){
      break;
    }
    O = O + A[x];
    x--;
  }
  
  cout << O <<endl;
  
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 5148
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var S = _[0];var W = _[1];
        var re = W >= S ? "unsafe" : "safe";
        Console.WriteLine(re);
    }
   

public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}


Measured memory_bytes: 17908
def main():
    x, k, d = map(int, input().split())
    x = abs(x)
    if k % 2 == 1:
        x = abs(x-d)
        k -= 1
    if x > d*k:
        print(x-d*k)
    else:
        print(min(x % (2*d), abs(x % (2*d)-2*d)))


main()


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

int main(){
  int a,b;
  cin>>a>>b;
  if(b%a==0)cout<<a+b<<endl;
  else cout<<b-a<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <cmath>
#include <string>
#include <sstream>
#include <cstdlib>
#include <iomanip>

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define debug(x) cout << #x << " : " << x << endl

using namespace std;
typedef vector<int> VI;
typedef long long LL;


inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int N;

int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    long long x, y;
    n--;
    while (n--)
    {
        cin >> x >> y;
        long long r = max( (a + x - 1) / x, (b + y - 1) / y);
        //debug(r);

        x = x * r;
        y = y * r;
        //cout << a << ":" << b << endl;
        a = x;
        b = y;

    }

    cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int64_t N, A, B, C;
  cin >> N;
  A = 1;
  C = 1;
  while(true) {
    B = A;
    A = C * C;
    C++;
    if(A > N) {
      break;
    }
  }
  cout << B << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    vector<int> cnt(4);
    REP(i, N) {
        string S;
        cin >> S;
        if(S == "AC") cnt[0]++;
        else if(S == "WA")cnt[1]++;
        else if(S == "TLE") cnt[2]++;
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;
}

Measured memory_bytes: 3656
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

c = LI(3)

for a1 in range(c[0][0]+1):
    # print(a1)
    a = []
    b = []
    a.append( a1 )
    b.append( c[0][0] - a1 )
    b.append( c[0][1] - a1 )
    b.append( c[0][2] - a1 )
    a.append( c[1][0] - b[0] )
    a.append( c[2][0] - b[0] )
    if a[1]+b[1]==c[1][1] and a[1]+b[2]==c[1][2] and a[2]+b[1]==c[2][1] and a[2]+b[2]==c[2][2]:
        print("Yes")
        exit()
print("No")
exit()

Measured memory_bytes: 77204
A,B,C,D,E,F=map(int,input().split())
wDP=[False]*((F//100)+1)
wDP[0]=True
water=[]
for i in range(1,(F//100)+1):
    if(i>=B and wDP[i-B]):
        wDP[i]=True
    elif(i>=A and wDP[i-A]):
        wDP[i]=True
for i in range((F//100)+1):
    if(wDP[i] and i!=0):
        water.append(i*100)
water=list(set(water))
ans=[water[0],0]
mconc=0
for x in water:
    up=min(x*E//100,F-x)
    sDP=[0]*(up+1)
    for i in range(1,up+1):
        if(i>=D):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C,sDP[i-D]+D)
        elif(i>=C):
            sDP[i]=max(sDP[i-1],sDP[i-C]+C)
        else:
            sDP[i]=sDP[i-1]
    conc=100*sDP[-1]/(x+sDP[-1])
    if(conc>=mconc):
        mconc=conc;ans[0]=x+sDP[-1];ans[1]=sDP[-1]
print(*ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  vector<int> v;
  REP(i,n){
    int t;cin>>t;
    v.pb(t);
  }

  VSORT(v);
  ll ans = 0;

  for(int c = 2;c<n;c++){
    for(int a = 0;a<c;a++){
      int req = v[c] - v[a];
      auto Iter = upper_bound(v.begin(),v.end(),req);
      int minB = Iter - v.begin();
      minB = max(a+1,minB);
      ans += c-minB;
      //cout<<a<<"  "<<minB<<"  "<< c<<endl;
    }
  }

  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 256
def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt


def shellSort(arr, N):
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


N = int(input())
arr = [int(input()) for i in range(N)]

(cnt, G) = shellSort(arr, N)
print(len(G))
print(' '.join(map(str, G)))
print(cnt)
print('\n'.join(map(str, arr)))



Measured memory_bytes: 125988
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> as(n), bs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i] >> bs[i];
    }

    int64_t accum = 0;
    int64_t ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        const auto rest = (bs[i] - (accum + as[i]) % bs[i]) % bs[i];
        ans += rest;
        accum += rest;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int size = s.size();
  int check = 0;
  for (int i = 0; i < size; i++)
  {
    if (s[i] == '.')
    {
      check++;
    }
  }
  int ans = check;
  for (int i = 0; i < size; i++)
  {
    if (s[i] == '.')
    {
      check--;
    }
    else
    {
      check++;
    }
    ans = min(ans, check);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
/* created   : 2019-10-26 08:55:09
 * accepted  : 2019-10-26 09:16:04
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  vector<int> use(n);
  int ans = 0;
  trace(v);
  // abs(a - b) < c < a + b
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = v[i];
      int b = v[j];
      int x = upper_bound(v.begin() + j + 1, v.end(), abs(a - b)) - v.begin();
      int y = lower_bound(v.begin() + j + 1, v.end(), a + b) - v.begin();
      ans += (y - x);
    }
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <algorithm>
#include <bitset>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    vector<int> inp(N);
    for (int &x : inp) scanf("%d", &x);
    if (N == 1) {
        printf("%d\n", inp[0]);
        return 0;
    }
    bitset<4000001> BS;
    BS[0] = 1;
    for (int x : inp) BS = BS | (BS << x);
    int sum = accumulate(inp.begin(), inp.end(), 0);
    int target = (sum + 1) / 2;
    for (int i = target; ; i++) if (BS[i]) {
        printf("%d\n", i);
        break;
    }
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    string s;
    cin>>s;
    long long k;
    cin>>k;
    for(int i=0;i<s.size();i++){
        if(s[i]!='1'){
            if(i<k){
                cout<<s[i]<<endl;
                return 0;
            }
        }
    }
    cout<<'1'<<endl;
    
}

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



int main()
{
    int h,w,k;
    std::cin>>h>>w>>k;
    std::vector<std::string> hw(h);
    for(int i=0;i<h;i++)
    std::cin>>hw[i];
    
    int ans=0;
    for(int i=0;i<1<<h;i++)
    for(int j=0;j<1<<w;j++)
    {
        int num=0;
        for(int m=0;m<h;m++)
        {  
            if(i&(1<<m)) continue;
            for(int l=0;l<w;l++)
            {
                if(j&(1<<l)) continue;
                if(hw[m][l]=='#') num++;
            }
        }
        if(num==k) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int ch, cw; //Start
	cin >> ch >> cw;
	int sy = ch - 1, sx = cw - 1;
	int dh, dw; //End
	cin >> dh >> dw;
	int ey = dh - 1, ex = dw - 1;
	vector<vector<char>> grid(h, vector<char>(w));
	rep(i, h)
		rep(j, w)
		cin >> grid[i][j];
	vector<vector<int>> warp(h, vector<int>(w, -1));//そのマスに到達するためのwarp回数,-1で初期化
	
	queue<pair<int, int>> que; //moveAで移動できるマスの処理
	queue<pair<int, int>> next; //moveBで移動できるマスの処理,待機用
	que.push({ sy, sx });

	int count = 0;//現在のwarp回数
	while (que.size() != 0 || next.size() != 0) {
		while (que.size()) { //queの消化
			int y = que.front().first;
			int x = que.front().second;
			que.pop();
			
			if (warp[y][x] != -1 && warp[y][x] <= count)//既に処理済みのマスなら飛ばす
				continue;

			warp[y][x] = count;

			for (int dy = -2; dy <= 2; dy++) //周囲25マスの探索
				for (int dx = -2; dx <= 2; dx++) {
					int new_y = y + dy;
					int new_x = x + dx;
					if (new_y < 0 || new_y >= h || new_x < 0 || new_x >= w) {
						continue;
					}
					if (grid[new_y][new_x] == '#') {
						continue;
					}
					if (abs(dy) + abs(dx) == 0) {
						continue;
					}
					if (abs(dy) + abs(dx) == 1) { //moveA
						if (warp[new_y][new_x] == -1) {
							que.push({ new_y,new_x });
						}
					}
					if (abs(dy) + abs(dx) > 1) { //moveB
						if (warp[new_y][new_x] == -1) {
							next.push({ new_y,new_x });
						}
					}
				}
		}
		count++; //warp回数を1増やして次のループへ
		swap(que, next);  //待機中のmoveBのマスを探索する
	}
	/*
	rep(i, h) { //warp表示用
		rep(j, w)
			cout << warp[i][j];
		cout << endl;
	}
	*/
	
	cout << warp[ey][ex] << endl;

	return 0;
}

Measured memory_bytes: 8844
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
#define  N 300005
#define Mo 1000000007
 
int i,jm,n,p,k,inv[N],fac[N],len,vis[N];
 
int C(int x,int y)
{
     if (x<y) return 0;
     return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
 
int power(int x,int y)
{
 	int sum=1;
	for (;y;y>>=1)
	{
			if (y&1) sum=1ll*sum*x%Mo;
			x=1ll*x*x%Mo;
	}
	return sum;
}
 
int main()
{
           scanf("%d",&n);
           fac[0]=1;
           for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
           for (i=0;i<N;++i) inv[i]=power(fac[i],Mo-2);
           for (i=1;i<=n+1;++i) 
           {
                   scanf("%d",&k);
                   if (vis[k]) len=i-vis[k]+1;
                   vis[k]=i;
           }
           for (i=1;i<=n+1;++i) 
		   	printf("%d\n",(C(n+1,i)-C(n+1-len,i-1)+Mo)%Mo);
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int q;
  map<string,int>m;
  cin >> q;
  while(q--){
    int x, y;
    string key;
    cin >> x;
    if(!x){
      cin >> key >> y;
      m[key]=y;
    }
    else if(x==1){
      cin >> key;
      if(m.count(key)) cout << m[key] << endl;
      else cout << 0 << endl;
    }
    else if(x==2){
      cin >> key;
      m.erase(key);
    }
    else{
      string l,r; cin >> l >> r;
      map<string,int>::iterator end,it;
      it=m.lower_bound(l);
      end=m.upper_bound(r);
      for(;it!=end;it++){
        cout << (*it).first<<' ' << (*it).second<< endl;
      }
    }
  }
}


Measured memory_bytes: 27728
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll n, k; cin >> n >> k;
    ll ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<long long> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	vector<int> par(60); // parity
	rep(t,60) rep(i,n) if(a[i]&(1LL<<t)) par[t]^=1;

	vector<vector<int>> A; // augmented matrix
	vector<int> piv,res(60);
	for(int t=59;t>=0;t--) if(!par[t]) {
		A.emplace_back(vector<int>(n+1));
		int m=A.size();
		rep(i,n) if(a[i]&(1LL<<t)) A[m-1][i]=1; // lhs
		A[m-1][n]=1; // rhs

		// Gauss-Jordan
		rep(i,m-1) if(~piv[i] && A[m-1][piv[i]]) {
			rep(j,n+1) A[m-1][j]^=A[i][j];
		}
		int p=-1; // pivot of m-th row (-1: don't exist)
		rep(j,n) if(A[m-1][j]) { p=j; break; }
		if(p==-1 && A[m-1][n]){ // NG
			res[t]=0;
			A[m-1][n]=0;
		}
		else{ // OK
			res[t]=1;
		}
		piv.emplace_back(p);
	}

	long long ans=0;
	bool carry=false;
	rep(t,60){
		if(par[t]==0){
			if(res[t]==1){ // 1 + 1 + carry
				if(carry) ans+=1LL<<t;
				carry=true;
			}
			else{ // 0 + 0 + carry
				if(carry) ans+=1LL<<t;
				carry=false;
			}
		}
		else{ // 0 + 1 + carry
			if(!carry){
				ans+=1LL<<t;
			}
		}
	}
	if(carry) ans+=1LL<<60;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 24576
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  string q;
  cin >> q;
  int nq;
  cin >> nq;
  string s;
  int ans = 0;
  for(int i = 0; i < nq; i++){
    cin >> s;
    s += s;
    if(s.find(q) != string::npos) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define N 300010
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int sum[N];
inline int check(int dat,int n) {
    int Min=0;
    for (int i=2;i<=n;i+=2) 
        if (dat<=sum[i-1]-Min) Min=min(Min,sum[i]);
    return dat<=sum[n]-Min;
}
int main() {
    int n=read(),A=0,B=0;
    for (int i=1;i<=n;i++) {
        int dat=read(); sum[i]=sum[i-1];
        if (i&1) A+=dat,sum[i]+=dat; else B+=dat,sum[i]-=dat;
    }
    if (!(n&1)) return printf("%d %d",max(A,B),min(A,B)),0;
    int l=-1e8,r=1e8,ans=0;
    while (l<=r) {
        int mid=(l+r)>>1;
        if (check(mid,n)) ans=mid,l=mid+1; else r=mid-1;
    }
    printf("%d %d",max(A,B+ans),A+B-max(A,B+ans));
    return 0;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
def examA():
    A, B, X = LI()
    ans = "NO"
    if A<=X<=A+B:
        ans = "YES"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N,A,B,C,D;
string s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>A>>B>>C>>D>>s;
    A--; B--; C--; D--;
    if(C<D){
        rep(i,A,C){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout <<"No"<<"\n";
                return 0;
            }
        }
        rep(i,B,D){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout <<"No"<<"\n";
                return 0;
            }
        }
        cout <<"Yes"<<"\n";
    }
    else{
        rep(i,A,C){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout <<"No"<<"\n";
                return 0;
            }
        }
        rep(i,B,D+1){
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
                cout <<"Yes"<<"\n";
                return 0;
            }
        }
        cout <<"No"<<"\n";
    }
}


Measured memory_bytes: 592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;
const double EPS = 1e-9;
int M = 256;

signed main(){
    
    while(1){

        int n; cin >> n;
        if(!n) break;
        vector<int> I(n + 1);
        for(int i = 1; i <= n; i++) cin >> I[i];
        int SS, AA, CC;
        double ans = 100000000000.0;
        for(int S = 0; S < 16; S++){
            for(int A = 0; A < 16; A++){
                for(int C = 0; C < 16; C++){
                    vector<int> R(n + 1);
                    R[0] = S;
                    for(int i = 1; i <= n; i++) R[i] = (A * R[i - 1] + C) % M;

                    vector<int> O(n + 1);
                    for(int i = 1; i <= n; i++) O[i] = (I[i] + R[i]) % M;

                    double H = 0.0;
                    vector<int> cnt(257, 0);
                    for(int i = 1; i <= n; i++) cnt[O[i]]++;
                    for(int i = 0; i < 256; i++){
                        if(cnt[i] != 0) H -= (cnt[i] / (double)n) * (log(cnt[i] / (double)n));
                    }

                    if(ans > H + EPS){
                        ans = H;
                        AA = A;
                        SS = S;
                        CC = C;
                    }
                    
                }
           }
        }
        
        cout << SS << " " << AA << " " << CC << endl;
        
    }
    return 0;
}




Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const int sz = 31;

int n,m,ar[maxn];
map<int,int> ma;
vector<int> xx, yy;
int main()
{
    ll l,r;
    scanf("%lld%lld", &l, &r);
    if(r-l>=2020)printf("0\n");
    else{
        ll ans = 2019;
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++)ans = min(ans, i*j%2019);
        }
        printf("%lld\n", ans);
    }

    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

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

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,a,b; cin>>n>>a>>b;
  ll ans=modpow(2,n)-1;
  ll x=1, y=1;
  fact_init();
  rep(i,a){
    (x*=(n-i))%=MOD;
  }
  x=x*modpow(fact[a],MOD-2)%MOD;
  
  rep(i,b){
    (y*=(n-i))%=MOD;
  }
  y=y*modpow(fact[b],MOD-2)%MOD;
  ans-=x+y;
  
  while(ans<0) ans+=MOD;
  ans%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 78336
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
)

func main()  {
	scanner := bufio.NewScanner(os.Stdin)

	alfabet := "abcdefghijklmnopqrstuvwxyz"

	scanner.Scan()
	target := regexp.MustCompile(scanner.Text() + ".")

	answer := target.FindString(alfabet)

	fmt.Println(answer[1:2])

}

Measured memory_bytes: 1940
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s;cin >> s;
    vector<ll> sv(n);
    rep(i,n){
        if(s[i] == 'R')sv[i] = 1;
        if(s[i] == 'G')sv[i] = 2;
        if(s[i] == 'B')sv[i] = 3;
    }
    vector vec(3, vector<ll>(n+1, 0LL));
    rrep(i,n){
        rep(j,3)vec[j][i] = vec[j][i+1];
        if(s[i] == 'R')vec[0][i]++;
        if(s[i] == 'G')vec[1][i]++;
        if(s[i] == 'B')vec[2][i]++;
    } 

    // print(vec);
    ll ans = 0;
    rep(i,n)rep(j,n){
        if(i >= j)continue;
        if(j == n-1)continue;
        if(s[i] == s[j])continue;
        ll next = sv[i] ^ sv[j];
        next--;
        // debug(next);
        ans += vec[next][j+1];
        if(j*2-i < n && sv[j*2-i] == next+1)ans--;
        // debug(i);debug(j);debug(ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    long sum = 0;

    for (int i = 1; i <= n; i++) {
      if ((i%3==0)||(i%5==0)) {
         
      } else {
        sum += i;
      }
    }

    System.out.println(sum);

  }

}

Measured memory_bytes: 35804
class cmbs(object):
    def __init__(self, mod):
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 10 ** 6 + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)

    def cmb(self, n, r):
        if n > 10 ** 6:
            return self.cmbl(n, r)
        return self.cmbr(n, r)

    def cmbr(self, n, r):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod

    def cmbl(self, n, r):
        t = 1
        r = min(r, n-r)
        for i in range(n - r + 1, n + 1):
            t = t * i % self.mod
        return t * self.g2[r] % self.mod
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {}
    dif = 0
    for i, v in enumerate(A):
        if v not in d:
            d[v] = i
        else:
            dif = i - d[v]
            break
    mod = 10**9 + 7
    c = cmbs(mod)
    print(N)
    if N == 1:
        print(N)
        return
    if dif == 1:
        for i in range(2, N):
            if N-1 >= i:
                r = c.cmb(N-1, i-2) + c.cmb(N-1, i-1) + c.cmb(N-1, i)
            else:
                r = c.cmb(N-1, i-2) + c.cmb(N-1, i-1)
            print(r % mod)
        print(N)
        print(1)
        return
    for i in range(2, N):
        r = c.cmb(N-1, i-2) + c.cmb(N-1, i-1)*2 - c.cmb(N-dif, i-1) + c.cmb(N-1, i)
        print(r % mod)
    print(N+1)
    print(1)
main()


Measured memory_bytes: 141084
// abc043_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N;
  cin>>N;
  ll ans=0;
  for(int i=1;i<=N;++i) ans+=i;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3584
<?php
$s = str_split(trim(fgets(STDIN)));
$ans = 'Yes';
for($i=0; $i<count($s); $i++){
	$check_num = $i%2===0 ? 'L' : 'R';
	if($s[$i]===$check_num){
		$ans = 'No';
		break;
	} 
}
echo $ans. "\n";

Measured memory_bytes: 4728
#!python
# -*- coding: utf-8 -*-

N = int(input())
Xs = list(map(int, input().split(' ')))
sortX = sorted(Xs)
B1 = sortX[int(N / 2 - 1)]
B2 = sortX[int(N / 2)]


for X in Xs:
    if X <= B1:
        print(B2)
    else:
        print(B1)


Measured memory_bytes: 25220
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define hell 998244353 
#define endl "\n"

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


int32_t main()
{
    int n;

    cin>>n;

    int count = 0;
    int a, b;
    int digits_count;
    for(int i=1;i<=n;i++)
    {
        digits_count = 0;
        a=i;
        while(a)
        {
            digits_count++;
            a=a/10;
        }

        if(digits_count%2==1)
            count++;

    }

    cout<<count;


    return 0;
}   

Measured memory_bytes: 256