akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
int n,x,a,b,c,d = 1,sum = 0,count = 0;
cin >> n >> x;
while(n != 0 || x != 0){
  for(int i = 1; i <= n-2; i++){
  a = i;
  for(int j = a; j <= n-1;j++){
    b = j;
    for(int k = b; k <= n;k++){
      c = k;
      sum = a + b + c;
      if(sum == x && a != b && b != c){
        count++;
      }
    }
  }
}
cout << count << endl;
count = 0;
cin >> n >> x;
}

return 0;
}


Measured memory_bytes: 3084
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define pb push_back
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

int ccw(point a, point b, point c) {
  b = b-a; c = c-a;
  if (cross(b, c) > 0)   return +1;
  if (cross(b, c) < 0)   return -1;   
  if (dot(b, c) < 0)     return +2;     
  if (norm(b) < norm(c)) return -2;      
  return 0;
}

point intersection_l(point a1, point a2, point b1, point b2) {
  return a1 + (a2 - a1) * (cross(b2 - b1,b1 - a1) / cross(b2 - b1,a2 - a1));
}

vector<point> covex_cut(vector<point>pol,point a,point b){
  vector<point>q;
  for (int i = 0; i < pol.size(); i++) {
    point A = curr(pol, i), B = next(pol, i);
    if (ccw(a, b, A) != -1) q.push_back(A);
    if (ccw(a, b, A)*ccw(a, b, B) < 0)
      q.push_back(intersection_l(A,B,a,b));
  }
  return q;
}

int main(void){
  int n;
  point in;
  vector<point>pol,ans;

  while(cin >> n,n){
    pol.clear();
    ans.clear();
    for(int i=0;i<n;i++){
      cin >> in.x >> in.y;
      pol.pb(in);
    }

    ans.pb(point(0,0));
    ans.pb(point(10001,0));
    ans.pb(point(10001,10001));
    ans.pb(point(0,10001));

    for(int i=0;i<n;i++)
      ans=covex_cut(ans,curr(pol,i),next(pol,i));
    
    if(ans.size())cout << 1 << endl;
    else cout << 0 << endl;

  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <cstdio>

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

int main(void)
{
    int N;
    scanf("%d", &N);
    int K;
    scanf("%d", &K);
    int p[N];

    for (int i = 0; i < N; ++i)
    {
        scanf("%d", &p[i]);
    }
    sort(p, p + SIZE_OF_ARRAY(p));

    int price = 0;
    switch (K)
    {
    case 1:
        price = p[0];
        break;
    case 2:
        price = p[0] + p[1];
        break;
    default:
        for (int j = 0; j < K; ++j)
        {
            price = price + p[j];
        }
        break;
    }
    cout << price << "\n";

    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

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

using ll = long long;
using namespace std;

struct Node{
	vector<int> childs;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	bool flg[200000] = {0};
	cin >> n >> m;
	vector<Node> nodes(n);
	REP(i, m){
		int a, b;
		cin >> a >> b;
		nodes[a - 1].childs.push_back(b - 1);
		nodes[b - 1].childs.push_back(a - 1);
	}
	for(const auto& node : nodes[0].childs){
		for(const auto & node2 : nodes[node].childs){
			if(node2 == n - 1){
				cout << "POSSIBLE\n";
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE\n";
	return 0;
}


Measured memory_bytes: 12016
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	int N,M;
	scanf("%d %d",&N,&M);

	char A[50][50];
	char B[50][50];
	char input_A[50];
	char input_B[50];

	for(int i = 0; i < N; i++){
		scanf("%s",input_A);
		for(int j = 0; j < N; j++){
			if(input_A[j] == '#'){
				A[i][j] =  '#';
			}
			else{
				A[i][j] = '.';
			}
		}
	}
	for(int i = 0; i < M; i++){
		scanf("%s",input_B);
		for(int j = 0; j < M; j++){
			if(input_B[j] == '#'){
				B[i][j] =  '#';
			}
			else{
				B[i][j] = '.';
			}
		}
	}

	for (int i = 0; i < N; i++){
		// printf("A[%d] = %s\n",i,A[i]);
	}
	for (int i = 0; i < M; i++){
		// printf("B[%d] = %s\n",i,B[i]);
	}

	int k = 0;
	char *s;
	int place;

	for (int i = 0; i < N; i++){
		s = strstr(A[i],B[k]);
		place = s -A[i];

		/*printf("%d times s = %s\n",i,s);
		printf("place = %d\n",place);
		printf("A[%d] = %s\n",i,A[i]);
		printf("B[%d] = %s\n",k,B[k]);*/
		if(s != NULL){
			k++;
		}
		else{
			k = 0;
		}
		if(k == M){
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, t, a int
	fmt.Scan(&n, &t, &a)

	var hs []int
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		hs = append(hs, v)
	}

	min_i := 0
	min := diff(a, t, hs[min_i])
	for i, h := range hs {
		if d := diff(a, t, h); min > d {
			min = d
			min_i = i
		}
	}

	fmt.Println(min_i + 1)
}

func diff(a, t, h int) int {
	return abs(t*1000 - h*6 - a*1000)
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
    
    public static void main(String args[]) {
        int n = 0, w = 0;
        int[][] arr = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            w = scanner.nextInt();
            
            arr = new int[n][2];
            for (int i=0; i < n; i++) {
                for(int j = 0; j < 2 ; j++) {
                    arr[i][j] = scanner.nextInt();
                }
            }
        }
        long[][] dp = new long[n + 1][w + 1];
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j<= w ; j++) {
                dp[i][j] = dp[i - 1][j];
                if(j-arr[i-1][0] >= 0)
                dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - arr[i-1][0]] + arr[i-1][1]);
            }
        }
        
        System.out.println(dp[n][w]);
        
    }
}

Measured memory_bytes: 126932
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

ll N, Q;

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

    vector<pll> ss(N);
    vector<pll> ts(N);

    rep (i, N)
    {
        ll s, t, x;

        cin >> s >> t >> x;
        s -= x;
        t -= x;

        ss[i] = pll(s, x);
        ts[i] = pll(t, x);

    }

    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());

    multiset<ll> xs;

    ll si = 0;
    ll ti = 0;

    rep (i, Q)
    {
        ll d;
        cin >> d;

        while (si < ss.size() && ss[si].first <= d)
        {
            xs.insert(ss[si].second);
            ++si;
        }

        while (ti < ts.size() && ts[ti].first <= d)
        {
            xs.erase(xs.lower_bound(ts[ti].second));
            ++ti;
        }

        cout << (xs.size() == 0 ? -1 : (*xs.begin())) << endl;
    }

    return 0;
}


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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int lcm(int a , int b) {
    int g = __gcd(a,b) ; 
    return a * (b / g) ; 
}
int32_t main()
{
    fast;
    int n ; cin >> n ; 
    int ans = 1 ; 
    rep(i,1,n) {
        int x ; cin >> x ; 
        ans = lcm(ans , x) ; 
    }
    cout << ans ; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll dict[26] = { 0 };
	string s;
	cin >> s;
	for (char p : s) {
		dict[p - 'a'] = 1;
	}
	rep(i, 27) {
		if (i == 26) cout << "None" << endl;
		else {
			if (dict[i] == 0) {
				cout << char('a' + i) << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int h,w; cin>>h>>w;
    int ans=h*w;
    int hh,ww; cin>>hh>>ww;
    ans-=(hh*w+ww*h)-hh*ww;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    mi = min(A)
    idx = A.index(mi)
    h1 = idx
    h2 = N - idx - 1
    ans = N
    for k in range(K):
        cur = (max(0, (h1 - k))+(K-1)-1)//(K-1) + \
            (max(0, (h2 - ((K-1) - k)))+(K-1)-1)//(K-1) + 1
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52476
//
// Created on 2020/07/05.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


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

    int ans = 1000 - (n % 1000);
    if(ans == 1000){
        ans = 0;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ins insert
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define sz(a) (ll)((a).size())
#define matrix vector<vector<ll>>
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repd(i,a,b) for(ll i = a; i >= b; i--)
#define tr(container,it) for(typeof(container.begin())it=container.begin();it!=container.end();it++)
#define set_bits(n) __builtin_popcount (n)
const ll MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9;
const ll dx[4] = {0, 1, 0, -1};
const ll dy[4] = {1, 0, -1, 0};


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

    ll si=sz(str)+1;    

    ll dp1[si+3];memset(dp1,0,sizeof(dp1));

    dp1[sz(str)]=0;

    repd(j,sz(str)-1,0)
        if(str[j]=='>')
            dp1[j]=dp1[j+1]+1;

	ll dp2[si+3];memset(dp2,0,sizeof(dp2));
	
	dp2[0]=0;
	
	rep(i,1,si)
	if(str[i-1]=='<') dp2[i]=dp2[i-1]+1;
	
	ll su=0;
	rep(i,0,si)
		su+=max(dp1[i],dp2[i]);
	
	cout<<su<<"\n";
    return 0;
}



Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int N;
    ll K;
    cin >> N >> K;
    pq1<pair<int,ll>> A;
    rep(i,N){
        int a;
        ll b;
        cin >> a >> b;
        A.push({a,b});
    }
    
    ll a = 0;
    int ans = 0;
    while (a < K && !A.empty()) {
        pair<int,ll> aa = A.top();
        A.pop();
        ans = aa.fi;
        a += aa.se;
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


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

namespace ABC174D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string C = Console.ReadLine();
            int W = 0;
            int R = 0;
            for(int i = 0; i < N; i++)
            {
                if (C[i].ToString() == "R")
                {
                    R += 1;
                }
            }
            int min = R;
            for(int i = 0; i < N; i++)
            {
                if (C[i].ToString() == "R")
                {
                    R -= 1;
                }
                else
                {
                    W += 1;
                }
                int temp = Math.Max(W, R);
                if (temp < min)
                {
                    min = temp;
                }
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 37460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 1e6 + 5;
const int MAXN = 3e5 + 5;
const int M = 3e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const long double co = 0.0174533;
const int INF = 1e15;
const int LG = 21;
const long double PI = acos(-1);

int n;


void solve()
{
	int k;
	cin >> k;
	string input;
	cin >> input;
	if(input.size() > k)
	{
		cout << input.substr(0, k);
		cout << "...";
	}
	else
	{
		cout << input << endl;
	}
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> S;

    if(S=="SAT"){
        cout << 1 << endl;
    }
    else if(S=="FRI"){
        cout << 2 << endl;
    }
    else if (S == "THU")
    {
        cout << 3 << endl;
    }
    else if (S == "WED")
    {
        cout << 4 << endl;
    }
    else if (S == "TUE")
    {
        cout << 5 << endl;
    }
    else if(S=="MON"){
        
        
            cout << 6 << endl;
        
    }
    else{
        cout << 7 << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000005;

ll dp[101][100001];

int main()
{
	ll N,W;
	cin >> N >> W;
	vector<ll> v(N),w(N);
	rep(i,N)
	{
		cin >> w[i] >> v[i];
	}
	fill(dp[0],dp[N+1],0);
	rep(i,N)
	{
		rep(j,W+1)
		{
			if(j-w[i]<0)
			dp[i+1][j]=dp[i][j];
			else
			dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);

			//cout<<dp[i+1][j]<<endl;
		}
	}
	ll ans = 0;
	
	cout<<dp[N][W]<<endl;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int A,B;
  for(int i=1;i<1250;i++){
    A = (i*8)/100;
    B = i/10;
    if(A==a&&B==b){
      cout << i;
      return 0;
    }
  }
  cout << -1; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;
#define mod 1e9 + 7;

int main(){
	int x,n; cin >> x >> n;
	vector<int> v(n);
	//map<int,int> mp;
	if (n == 0){
		cout << x << endl;
		return 0;
	}
	rep(i,n){
		cin >> v[i];
		//mp.insert(i,abs(v[i] - x));
	}
	bool minus = false;
	int sa = 0;
	while(!minus){
		rep(i,n){
			if (v[i] == x - sa){
				sa++;
				break;
			}
			if (i == n - 1){
				minus = true;
			}
		}
	}
	int memsa = sa;
	int ans = x - sa;
	int memans = ans;
	bool plus = false;
	sa = 0;
	while(!plus){
		rep(i,n){
			if (v[i] == x + sa){
				sa++;
				break;
			}
			if (i == n - 1){
				plus = true;
			}
		}
	}
	ans = (memsa < sa) ? ans : x + sa;
	if(memsa == sa) ans = (memans < ans) ? memans : ans;
	cout << ans << endl;
	return 0;
}

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


int main(){
	
	string S;
	cin>>S;
	
	set<char> s;
	
	for(int i=0;i<S.size();i++){
		s.insert(S[i]);
	}
	
	if(s.size()==S.size()){
		cout<<"yes"<<endl;
	}
	else{
		cout<<"no"<<endl;
	}
	
	
	
	
    return 0;
}



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

int main(){
    int N, p, i, diff = 0, swap1, swap2;

    cin >> N;
    vector<int> array(N);
    for(i = 0; i < N; i++){
        cin >> p;
        array[i] = p;
        if(p != i + 1)diff++;
    }
    if(diff == 0){
        cout << "YES" << endl;
    }else if(diff == 2){
        for(i = 0; i < N; i++){
            if(array[i] != i+1){
                swap1 = i;
                break;
            }
        }
        for(i = swap1+1; i < N; i++){
            if(array[i] != i+1){
                swap2 = i;
                break;
            }
        }
        if(array[swap2] == swap1+1 && array[swap1] == swap2+1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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 int INF = 1e18;


signed main(){
    int n, m; cin >> n >> m;
    vector<int> G[n];
    vector<bool> used(n,false);
    deque<int> ans;
    int left_t,right_t;
    REP(i,m){
        int a, b; cin >> a >> b; a--; b--;
        if(i == 0){
            ans.push_front(a);
            ans.push_back(b);
            left_t = a;
            right_t = b;
            used[a] = used[b] = true;
        }
        G[a].eb(b);
        G[b].eb(a);
    }
    labl:;
    for(auto v:G[left_t]){
        if(used[v])continue;
        else{
            ans.push_front(v);
            used[v] = true;
            left_t = v;
            goto labl;
        }
    }
    for(auto v:G[right_t]){
        if(used[v])continue;
        else{
            ans.push_back(v);
            used[v] = true;
            right_t = v;
            goto labl;
        }
    }
    int k = SZ(ans);
    cout << k << '\n';
    REP(i,k){
        cout << ans.front()+1 << " ";
        ans.pop_front();
    }
}

Measured memory_bytes: 7168
#include<stdio.h>

int main()
{
	int i,high[10],flag=0,escape;

	for(i=0;i<10;i++)
	{
		scanf("%d",&high[i]);
	}
	
	while(flag<100)
	{
		for(i=0;i<9;i++)
		{
			if(high[i]<high[i+1])
			{
				escape=high[i];
				high[i]=high[i+1];
				high[i+1]=escape;
			}
		}
		
		flag += 1;
	}

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

return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n, k;
	cin >> n >> k;

	n *= 1.0;
	k *= 1.0;

	double ans = 0.0;
	int cnt = 0, num;
	for(int i = 0; i < n; i++){
		cnt = 0;
		num = i + 1;
		while(num < k){
			num *= 2;
			cnt++;
		}
		ans += (double)1.0 / pow(2.0,cnt) / n;
		//cout << cnt << " " << pow(2.0,cnt) << " " << ans << endl;
	}
	printf("%.12f", ans);
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S;
    cin >> S;

    int x, y;
    cin >> x >> y;


    vector<int> X;
    vector<int> Y;
    
    int n = S.length();
    int len = 0;
    int d = 0;
    for (int i = 0; i < n; ++i) {
        if (S[i] == 'T') {
            if (d == 0) {
                X.push_back(len);
            } else {
                Y.push_back(len);
            }
            d ^= 1;
            len = 0;
            continue;
        }
        ++len;
    }
    if (d == 0) {
        X.push_back(len);
    } else {
        Y.push_back(len);
    }

    auto check = [&](vector<int>& A, int beg, long long target) {
        int n = A.size();
        const int M = 8000 * 3 + 10;
        int offset = 8000 + 1;

        bitset<M> bits;
        bits.set(offset);
        auto nbits = bits;
        for (int i = beg; i < n; ++i) {
            nbits.reset();

            nbits |= bits << A[i];
            nbits |= bits >> A[i];
            bits = nbits;
        }

        if (target + offset >= 0 && target + offset < M) {
            return bits.test(target + offset);
        } else {
            return false;
        }
    };

    bool res = false;
    if (check(X, 1, x - X[0]) && check(Y, 0, y)) {
        res = true;
    }
    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
using namespace std;
const char* solve() {
    int N, M, K;
    cin >> N >> M >> K;
    for (int k = 0; k <= N; k++) {
        for (int l = 0; l <= M; l++) {
            if (k * (M - l) + l * (N - k) == K) return "Yes";
        }
    }
    return "No";
}
int main() {
    cout << solve() << endl;
}


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

int main(){
        int h, m, k;
        scanf("%d %d", &h, &m);
        int s = h*60 + m;
        scanf("%d %d", &h, &m);
        int g = h*60 + m;
        scanf("%d", &k);
        printf("%d\n", std::max(0, g-s-k));
        return 0;
}


Measured memory_bytes: 3812
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		long X = input.nextLong();
		long cnt = 0;
		long cur = 100;
		while (cur<X) {
			cur*=1.01;
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26972
def check(f):
        if g[l[1]][l[0]]==1:
                f+=1
        g[l[1]][l[0]]=2
        return f
while 1:
        g=[[0 for i in range(21)]for j in range(21)]
        n,g[10][10],l,f=input(),2,[10,10],0
        if n==0 : break
        for i in range(n):
                j=map(int,raw_input().split())
                g[j[1]][j[0]]=1
        m=input()
        for i in range(m):
                o=map(str,raw_input().split())
                for k in range(int(o[1])):
                        if o[0]=="N":
                                l[1]+=1
                                f=int(check(f))
                        if o[0]=="S":
                                l[1]-=1
                                f=int(check(f))
                        if o[0]=="E":
                                l[0]+=1
                                f=int(check(f))
                        if o[0]=="W":
                                l[0]-=1
                                f=int(check(f))
        if n<=f: print "Yes"
        else: print "No"

Measured memory_bytes: 4272
n,m=map(int,input().split())
kss=[list(map(int,input().split())) for _ in range(m)]
ps=list(map(int,input().split()))
ans=0
for i in range(2**n):
    stt=bin(i)[2:].zfill(n)
    cmp=0
    for ks,p in zip(kss, ps):
        c=0
        for k in ks[1:]:
            if stt[k-1]=='1':
                c+=1
        if c%2==p:
            cmp+=1
        else:
            break
    if cmp==m:
        ans+=1
print(ans)


Measured memory_bytes: 3188
/**
 * author: Behradm
 * Created: 2020.09.19 16:26:12
 * In The Name of God
**/
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

const int N = 600001;
int lanat_be_tle[N];

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  auto Bad = [&](int n) {
    int sq = sqrt(n);
    if (sq * sq == n)
      return true;
    return false;
  };

  int n;
  scanf("%d", &n);

  for (int i = 1; i < N; i++) {
    int cnt = 0;
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0)
        cnt += 2;
    }
    if (Bad(i))
      cnt -= 1;
    lanat_be_tle[i] = cnt;
  }

  int res = 0;
  //set<array<int, 3>> s;
  for (int k = 1; k < n; k++) {
    int cur = n - k;
    if (cur < N) {
      res += lanat_be_tle[cur];
      continue;
    }
    for (int i = 1; i * i <= cur; i++) {
      if (cur % i == 0) {
        res += 2;
      }
    }
    if (Bad(cur))
      res -= 1;

    /*for (int i = 1; i * i <= cur; i++) {
      int a = i, b = cur / i;
      if (a * a == cur) {
//        s.insert({i, i, k});
        res += 1;
      }
      if (a * b == cur && a != b) {
  //      s.insert({i, cur / i, k});
    //    s.insert({cur / i, i, k});
        res += 2;
      }
      if (b * b == cur && a != b) {
      //  s.insert({cur / i, cur / i, k});
        res += 1;
      }
    }*/

    /*int len = (int) d.size();
    for (int i = 0; i < len; i++) {
      for (int j = 0; j < len; j++) {
        if (d[i] * d[j] == cur && d[i] * d[j] + k == n) {
          s.insert({d[i], d[j], k});
        }
      }
    }*/
  }

  printf("%d\n", res);
  return 0;
}

/*
  set<tuple<int, int, int>> s;
  for (int k = 1; k < n; k++) {
    int cur = n - k;
    for (int i = 1; i * i <= cur; i++) {
      if (i * i == cur)
        s.insert(make_tuple(i, i, k));
      if (i * (cur / i) == cur) {
        s.insert(make_tuple(i, cur / i, k));
        s.insert(make_tuple(cur / i, i, k));
      }
      if ((cur / i) * (cur / i) == cur)
        s.insert(make_tuple(cur / i, cur / i, k));
    }
*/

Measured memory_bytes: 6120
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<utility>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 233;
vector<int> g[maxn],wa[maxn],wb[maxn];
ll fa[maxn],fb[maxn],res[maxn];
queue<int> q;
int n,m,s,t;
void spfa1()
{
	for(int i=1;i<=n;i++)fa[i] = 1LL<<60;
	fa[s]=0;q.push(s);
	while(!q.empty())
	{
		int x = q.front();q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			int y = g[x][i];
			if(fa[y]>fa[x]+wa[x][i])
			{
				fa[y] = fa[x]+wa[x][i];
				q.push(y);
			}
		}
	}
	return ;
}
void spfa2()
{
	for(int i=1;i<=n;i++)fb[i] = 1LL<<60;
	fb[t]=0;q.push(t);
	while(!q.empty())
	{
		int x = q.front();q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			int y = g[x][i];
			if(fb[y]>fb[x]+wb[x][i])
			{
				fb[y] = fb[x]+wb[x][i];
				q.push(y);
			}
		}
	}
	return ;
}
int main()
{
	cin>>n>>m>>s>>t;
	for(int i=1;i<=m;i++)
	{
		int x,y,a,b;
		scanf("%d%d%d%d",&x,&y,&a,&b);
		g[x].push_back(y);
		g[y].push_back(x);
		wa[x].push_back(a);
		wa[y].push_back(a);
		wb[x].push_back(b);
		wb[y].push_back(b);
	}
	spfa1();spfa2();
	ll ans = 1LL<<60;
	for(int i=n;i;i--)
	{
//		cout<<"!"<<fa[i]<<" "<<fb[i]<<endl;
		ans = min(ans,fa[i]+fb[i]);
//		cout<<"!"<<ans<<endl;
		res[i] = 1e15 - ans;
	}
	for(int i=1;i<=n;i++)printf("%lld\n",res[i]);
	return 0;
}

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

     signed main(){
    int n;
    cin>>n;
    int ans[n]={};
    for(int i=1;i<n;i++){
        for(int j=1;i*i+j*j+i*j+1+i+j<=n;j++){
            for(int k=1;i*i+j*j+k*k+i*j+j*k+k*i<=n;k++)ans[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
        }
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<endl;
     }


 


 






    





      

        


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

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

  ll west[N] = {}, east[N] = {};
  repi(i, 1, N) west[i] = west[i-1] + (S[i-1] == 'W');
  rrep(i, N-1) east[i] = east[i+1] + (S[i+1] == 'E');
  ll ans = N;
  rep(i, N) ans = min(ans, west[i] + east[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5380
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#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 rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,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 lcmpr(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 ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
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;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=0,N,M;
  char S[7];
  scanf("%s",S);
  if(S[2]==S[3]&&S[4]==S[5])ans=1;
  Yn(ans);

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


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

int calcSumofDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int X;
    cin >> X;
    int fx = calcSumofDigits(X);
    if (X % fx == 0) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int a,b;
    cin>>a>>b;
    int ans[3]={0};
    ans[0]=a+b;
    ans[1]=a-b;
    ans[2]=a*b;
    sort(ans,ans+3);
    cout<<ans[2];
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double r;
	double b;
	double c;

	scanf("%lf", &r);

	b=r*r*3.141592653589;
	c=2*r*3.141592653589;

	printf("%f %f\n", b, c);

	return 0;

}

Measured memory_bytes: 648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()) {
			int fin = scan.nextInt();
			if(fin <= 0) {
				break;
			}
			int[] num = new int[fin];
			for(int i = 0;i < fin;i++) {
				num[i] = scan.nextInt();
			}
			int max = Integer.MIN_VALUE;//intで入る一番小さい数字
			for(int i = 0;i < fin;i++) {
				int[] plus = new int[fin];
				for(int j = 0;j < fin - i;j++) {
					if(j == 0) {
						plus[j] = num[i];
					}else{
						plus[j] = plus[j - 1] + num[j + i];
					}
					if(plus[j] > max) {
						max = plus[j];
					}
				}
			}
			System.out.println(max);
			continue;
		}
		scan.close();
	}
}


Measured memory_bytes: 63272
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans < a - b) {
		ans = a - b;
	}
	if (ans < a * b) {
		ans = a * b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil

def solve(a, b, c):
    q, r = divmod(c, (a*7 + b))
    return q * 7 + min(ceil(r / a), 7)


def main(args):
    a, b, c = map(int, input().split())
    ans = solve(a, b, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int n,a,b;
int mod=1000000007LL;

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

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return x%m;
}

int inv(int x) {
    int res = 1;
    int k = mod - 2;
    int y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

int nCk(int n, int k) {
  int c = 1;
  for(int i=1; i<=k; i++) {
    assert(c>=0);
    int invi = inv(i);
    assert(invi>=0);
    assert(n-i+1>=0);
    c *= (n-i+1);
    c %=mod;
    c *= inv(i);
    assert(c>=0);
    c %= mod;
  }
  return c;
}

signed main() {
  cin >> n >> a >> b;
  int n2 = modpow(2, n, mod);
  int n21;
  if(n2 == 0) n21 = mod-1LL;
  else n21 = n2 - 1LL;

  int ans = n21 - nCk(n,a);
  if(ans < 0) ans +=mod;
  ans = ans - nCk(n,b);
  if(ans < 0) ans +=mod;
  cout << ans << endl;
}

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

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題156


            string[] line = Console.ReadLine().Split(' ');

            int n = int.Parse(line[0]);
            int k = int.Parse(line[1]);

            int ans = 0;
            while (n != 0)
            {
                ans++;
                n /= k;

                if (n == 0)
                {
                    Console.WriteLine(ans);
                    return;
                }
            }
        }

    }





    
}


Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s, ans = "YES", c[4] = { "dream", "dreamer", "erase", "eraser" };
    cin >> s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(c[i].begin(), c[i].end());
    }
    int n = s.size();
    bool flag;
    for (int i = 0; i < n;) {
        flag = false;
        for (int j = 0; j < 4; j++) {
            if (s.substr(i, c[j].size()) == c[j]) {
                flag = true;
                i += c[j].size();
            }
        }
        if (!flag) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,j,gou;
	int a[10001],b[10001],c[10001],d[10001],t[10001],jun[10001];
	scanf("%d",&n);
	gou=n*(n-1)/2;
	for(i=0;i<10001;i++){
		t[i]=0;
		jun[i]=1;
	}
	for(i=1;i<=gou;i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
		if(c[i]>d[i]){
			t[a[i]]+=3;
		}
		else if(c[i]<d[i]){
			t[b[i]]+=3;
		}
		else{
			t[a[i]]+=1;
			t[b[i]]+=1;
		}
	}
	for(i=1;i<n;i++){
		for(j=1+i;j<=n;j++){
			if(t[i]==t[j]){}
			else if(t[i]>t[j]){
				jun[j]+=1;
			}
			else if(t[i]<t[j]){
				jun[i]+=1;
			}
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",jun[i]);
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(void){
    string s;cin>>s;ll ans=0;ll cw=0;
    rep(i,s.size()){
        if(s.at(i)=='W'){ans+=i-cw;cw++;}
    }
    cout<<ans;
}

Measured memory_bytes: 640
n, m = input().split()
m = int(m)
n = int(n)
a = input().split()
sum_a = sum(int(i) for i in a) / (4 * m)

yes_num = 0
no_num = 0

ok = m
ng = n - m

for i in a:
    if int(i) < sum_a:
        no_num += 1
    else:
        yes_num += 1
    if no_num > ng:
        break
    if yes_num >= ok:
        print("Yes")
        exit(0)

print("No")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solve{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var P = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var Q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int a = 1, b = 1;
        var set = new HashSet<int>();
        for (int i = 0; i < N; i++){
            var pi = P[i];
            var x = pi - set.Count(s => s < pi);
            a += (x - 1) * Factorial(N - 1 - i);
            set.Add(pi);}
        set.Clear();
        for (int i = 0; i < N; i++) {
            var qi = Q[i];
            var x = qi - set.Count(s => s < qi);
            b += (x - 1) * Factorial(N - 1 - i);
            set.Add(qi);}
        var answer = Math.Abs(a - b);
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}

    public static int Factorial(int n){
        int result = 1;
        for (int i = n; i > 1; i--){
            result *= i;}
        return result;}}

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

bool cmp(const pair<int,int> &a,const pair<int,int> &b){
	if( a.first != b.first ) return a.first < b.first;
	else return a.second > b.second;
}
int main(){
	int n,W;
	int t = 1;
	while( cin >> W >> n && W ){
		vector< pair<int,int> > cur;
		cur.push_back({0,0});
		for(int i = 0 ; i < n ; i++){
			int w,c;
			scanf("%d,%d",&c,&w);
			for(int j = 0 , t = cur.size() ; j < t ; j++ )
				cur.push_back(pair<int,int>(cur[j].first+w,cur[j].second+c));
			sort(cur.begin(),cur.end(),cmp);
			int maxi = -1;
			vector< pair<int,int> > nex;
			for(int j = 0 ; j < cur.size() ; j++){
				if( maxi >= cur[j].second ) continue;

				if( cur[j].first <= W ) nex.push_back(cur[j]);
				maxi = cur[j].second;
			}cur = nex;
		}
		int ans = 0, ans2 ;
		for(int i = 0 ; i < cur.size() ; i++){
			if( cur[i].first <= W ){
				ans = cur[i].second;
				ans2 = cur[i].first;
			}
		}

		cout << "Case " << t++ << ":" << endl;
		cout << ans << endl;
		cout << ans2 << endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int b = 0;
    int sum = 0;
    rep(j,n){
        cin >> a[j];
        sum += abs(a[j] - b);
        b = a[j];
    }
    sum += abs(0 - b);
    a.push_back(0);
    reverse(a.begin(), a.end());
    a.push_back(0);
    reverse(a.begin(), a.end());
    for (int j = 1;j<=n;j++){
        int ret = sum;
        ret -= abs(a[j] - a[j - 1]);
        ret -= abs(a[j] - a[j + 1]);
        ret += abs(a[j + 1] - a[j - 1]);
        cout << ret << endl;
    }
}

Measured memory_bytes: 1656
n,m = map(int,input().split())
 
A = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
  x = input().split()
  for j in range(m):
    A[i][j] = int(x[j])
 
b = [0 for i in range(m)]
for i in range(m):
  b[i] = int(input())
 
c = [0 for i in range(n)]
for i in range(n):
  for j in range(m):
    c[i] += A[i][j]*b[j]
 
for i in range(n):
  print(c[i])


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;
using p64 = pair<i64, i64>;
using pp64 = pair<p64, p64>;

vector<i64> v;
i64 n, m, q;
vector<pp64> abcd;

i64 f(i64 depth, i64 pre) {
    i64 res = 0;
    if (depth == n) {
        for (auto& e : abcd) {
            i64 a, b, c, d;
            tie(a, b) = e.first, tie(c, d) = e.second;
            if (v[b] - v[a] == c) res += d;
        }
    } else {
        for (i64 i = pre; i < m; i++) {
            v.push_back(i);
            res = max(res, f(depth + 1, i));
            v.pop_back();
        }
    }
    return res;
}

void solve() {
    cin >> n >> m >> q;
    abcd.assign(q, {});
    for (auto& e : abcd) {
        i64 a, b, c, d;
        cin >> a >> b >> c >> d, a--, b--;
        e = {{a, b}, {c, d}};
    }
    cout << f(0, 0) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int a,b,c,d;
    string ans ;
    cin >> a;
    if (a <= 999) {
        ans = "ABC";
    }else{
        ans = "ABD";
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int m = 0 ;
    string s;

    cin >> s ;
    if((s[0]) == '1')
    {
        m = m + 1 ;
    }
    if(s[1] == '1')
    {
        m = m + 1 ;
    }
    if(s[2] == '1')
    {
        m = m + 1 ;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3616