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

const int N=103;
const int NN=1e5+3;
typedef long long ll;
int n,we;
int w[N],v[N];
ll dp[N][NN];
ll solve(int i,int sum){
    if(i==n)return 0;
    ll &ret =dp[i][sum];
    if(~ret)return ret;
    ll path1=-1;
    if(w[i]<=sum)
        path1=v[i]+solve(i+1,sum-w[i]);
    ll path2=solve(i+1,sum);
    return ret=max(path1,path2);
}
int main()
{
    scanf("%d%d",&n,&we);
    for(int i=0;i<n;i++)scanf("%d %d",w+i,v+i);
    memset(dp,-1,sizeof dp);
    cout<<solve(0,we);
}



Measured memory_bytes: 80768
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
	cout<<(b-a)/2<<endl;
	return 0;
    }
    ll ans=3e18;
    chmin(ans,a+(b-a-1)/2);
    a=n+1-a,b=n+1-b;
    chmin(ans,a+(b-a-1)/2);
    cout<<ans<<endl;
}




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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 998244353;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  ll N, M, K;
  cin >> N >> M >> K;
  if(N == 1){
    cout << M << endl;
    return 0;
  }
  if(M==1){
    if((N-1) == K){
      ll ans = 1;
      REP(i, K){
        ans *= M;
      }
      cout <<ans << endl;
      return 0;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 0;
  ll beki = M;
  REP(i, N-1){
    beki *= (M-1);
    beki %= mod;
  }
  REP(i, K+1){
    ans += (COM(N-1, i) * beki) % mod;
    ans %= mod;
    beki *= inv[M-1];
    beki %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15600
fn main() {
    let mut count_line = String::new();
    std::io::stdin().read_line(&mut count_line).ok();
    let mut values_line = String::new();
    std::io::stdin().read_line(&mut values_line).ok();
    let it = values_line.trim().split_whitespace();
    let mut dividable_count = 0;
     
     
    for i in it {
        let mut u:u64 = i.parse().unwrap();
        let mut current_divide = 0;
        while u % 2 == 0 {
            u = u / 2;
            current_divide = current_divide + 1;
        }
        dividable_count = dividable_count + current_divide;
    }
    println!("{}",dividable_count);
}


Measured memory_bytes: 4352
#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 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};

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(){

  ll n;cin>>n;
  ll a[6];
  ll hito[6];
  REP(i,6){
    cin>>a[i];
    hito[i] = 0;
  }
  int minNum = 0;
  ll minVal = a[0];
  REP(i,5){
    if(a[i]<minVal){
      minVal = a[i];
      minNum = i;
    }
  }
  
  ll ans = 0;
  ans = (n- 1)/minVal + 5;
  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
h2=sorted(h,reverse=True)
if n<k:
    print(0)
else:
    total=0
    for i in range(n):
        total+=h2[i]
    for i in range(k):
        total-=h2[i]
    print(total)

Measured memory_bytes: 26024
// AOJ 2731 Shifting a Matrix
// 2018.2.11 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define SIZE 700

int N;
typedef struct { short r, c; } T;
T ans[101][101], t0[101][101];
T tbl[SIZE+1][101][101];
char used[SIZE+1]; int top;
char s[1002], *p;

char *seq(T res[101][101], char *s);

// malloc
int new() { int i, k;
	used[k=i=top] = 1;
	while (++i < SIZE) if (!used[i]) { top = i; break; }
	return k;
}

// free
void dis(int k) { used[k] = 0; if (k < top) top = k; }

char *in(int *res, char *p) { int n = 0;
	while (isdigit(*p)) n = (n<<3)+(n<<1) + (*p++ & 0xf); *res = n; return p;
}

void calc(T a[101][101], T b[101][101])
{
	int r, c;
	T t[101][101];

	for (r = 0; r < N; r++) for (c = 0; c < N; c++) {
		t[r][c] = a[b[r][c].r][b[r][c].c];
	}
	memcpy(a, t, sizeof(t));
}

char *ope(T a[101][101], char *s)
{
	int k, r, c;
	char x;

	x = *s++;
	s = in(&k, s), k--;
	memcpy(a, t0, sizeof(t0));

	if      (x == 'L') { for (c = 0; c < N; c++) a[k][c].c = c+1; a[k][N-1].c = 0; }
	else if (x == 'R') { for (c = 0; c < N; c++) a[k][c].c = c-1; a[k][0].c = N-1; }
	else if (x == 'U') { for (r = 0; r < N; r++) a[r][k].r = r+1; a[N-1][k].r = 0; }
	else               { for (r = 0; r < N; r++) a[r][k].r = r-1; a[0][k].r = N-1; }
	return s;
}

char *rep(T a[101][101], char *s)
{
	int n, _b;
	T (*b)[101];
	
	b = tbl[_b=new()];
	s = seq(b, s)+1;
	s = in(&n, s);
	memcpy(a, t0, sizeof(t0));

	while (n) {
		if (n & 1) calc(a, b);
		calc(b, b);
		n >>= 1;
	}
	dis(_b);
	return s;
}

char *seq(T res[101][101], char *s)
{
	int _t;
	T (*t)[101];

	memcpy(res, t0, sizeof(t0));
	t = tbl[_t=new()];
	while (*s == '(' || isalpha(*s)) {
		if (*s == '(') s = rep(t, s + 1);
		else           s = ope(t, s);
		calc(res, t);
	}
	dis(_t);
	return s;
}

int main()
{
	int L, r, c;
	
	fgets(p=s, 16, stdin), p = in(&N, p), in(&L, p+1);
	fgets(s, 1002, stdin);

	for (r = 0; r < N; r++) for (c = 0; c < N; c++)
		t0[r][c].r = r, t0[r][c].c = c;

	seq(ans, s);
	for (r = 0; r < N; r++) {
		printf("%d", N*ans[r][0].r + ans[r][0].c + 1);
		for (c = 1; c < N; c++)
			printf(" %d", N*ans[r][c].r + ans[r][c].c + 1);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 28420
#include<bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
int main(){
    int a,b,c1=0,c2=0,flag=0;
string s;
cin>>a>>b;
cin>>s;

int x=s.size();
for(int i=0;i<x;i++){
    if(s[i]=='-'){
        flag=1;}
    if(flag==0){
        if(s[i]>='0'&&s[i]<='9')
            c1++;
    }
    else{
        if(s[i]>='0'&&s[i]<='9')
        c2++;
}}
if(c1==a&&c2==b)
cout<<"Yes";
else
    cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<functional>
#include<set>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  while(true){
    int n,x;
    cin>>n>>x;
    if(!n&&!x)break;
    vector<int> menu(n);
    for(int i=0;i<n;i++){
      cin>>menu[i];
    }
    int p = -1;
    bool money[x+1];
    money[0] = true;
    for(int i=1;i<x+1;i++){
      money[i] = false;
      for(int j=0;j<n;j++){
	if(i>=menu[j]&&money[i-menu[j]]){
	  money[i] = true;
	  break;
	}
      }
      if(money[i]&&prime[i])p=i;
    }
    if(p==-1)cout<<"NA"<<endl;
    else cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 2860
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    cnt+=a[i]+a[i+1]-max(a[i]+a[i+1]-b[i],0)
    a[i+1]=max(0,a[i+1]-max(0,b[i]-a[i]))
print(cnt)

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << "\n";
    else
    {
        cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  string S;
  cin >> S;
  rep(i, 3){
    cout << S[i];
  }
  cout << '8';
  for(int i = 4; i < S.length(); i++) {
    cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    deque<ll> que;
    rep(i, n){
        if(i == 0 || (i%2)) que.push_back(v[i]);
        else que.push_front(v[i]);
    }
    if(n%2){
        for(auto p : que) cout<<p<<" ";
    }
    else{
        while(!que.empty()){
            auto p = que.back();
            cout<<p<<" ";
            que.pop_back();
        }
    }
    cout<<endl;
    return 0;
}

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

typedef long long ll;

int main(){
    int N;
    vector<int> time(N);
    int M,P,X;
    vector<int> ans;
    int sum;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> time[i];
    }
    cin >> M;
    for(int i=0;i<M;i++){
        cin >> P >> X;
        for(int j=0;j<time.size();j++){
            if(j == P-1){
                sum += X;
            }else{
                sum += time[j];
            }
        }
        ans.push_back(sum);
        sum = 0;
    }
    for(int i=0;i<ans.size();i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,K;


int main()
{
  int r, D, x;
  cin >> r >> D >> x;

  REP(i,0,10){
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}

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

typedef struct {
    int sx, sy;
    int ex, ey;
} RECT;

int min(int a, int b)
{
    return (b > a ? a : b);
}

int max(int a, int b)
{
    return (a > b ? a : b);
}

int comp(const void *a, const void *b)
{
    RECT x, y;
    x = *(RECT *)a;
    y = *(RECT *)b;
    
    return (x.sx - y.sx);
}

int comp_int(const void *a, const void *b)
{
    int x, y;
    x = *(int *)a;
    y = *(int *)b;
    
    return (x - y);
}

int area;
int length;

RECT calc[10000];
RECT before[10000];
int bsize;

void mergeArea(RECT *grid, int n, int *sq)
{
    int i, j;
    int num;
    int start, end;
    
    if (n == 0){
        return;
    }
    num = 0;
    start = grid[0].sx;
    end = grid[0].ex;
    for (i = 1; i < n; i++){
        if (grid[i].sx <= end){
            end = max(end, grid[i].ex);
        }
        else {
            calc[num].sx = start;
            calc[num++].ex = end;
            start = grid[i].sx;
            end = grid[i].ex;
        }
    }
    calc[num].sx = start;
    calc[num++].ex = end;
    for (i = 0; i < num; i++){
        area += calc[i].ex - calc[i].sx;
    }
    
    *sq = num;
}

void mergeLength(RECT *grid, int n)
{
    int total[40000];
    int i;
    int res, num;
    
    num = 0;
    for (i = 0; i < n; i++){
        total[num++] = grid[i].sx;
        total[num++] = grid[i].ex;
    }
    for (i = 0; i < bsize; i++){
        total[num++] = before[i].sx;
        total[num++] = before[i].ex;
    }
    
    qsort(total, num, sizeof(int), comp_int);
    res = 0;
    for (i = 0; i < num; i += 2){
        res += total[i + 1] - total[i];
    }
    length += res + 2 * n;
}

int main(void)
{
    int n, query;
    static RECT p[10000];
    static RECT grid[10000];
    int num;
    int i, j;
    int sq;
    int miny, maxy;
    
    while (1){
        scanf("%d%d", &n, &query);
        
        if (n + query == 0){
            break;
        }
        area = length = 0;
        miny = 1000000;
        maxy = -100000;
        for (i = 0; i < n; i++){
            scanf("%d%d%d%d", &p[i].sx, &p[i].sy, &p[i].ex, &p[i].ey);
            miny = min(miny, p[i].sy);
            maxy = max(maxy, p[i].ey);
        }
        bsize = 0;
        memset(before, 0, sizeof(before));
        qsort(p, n, sizeof(RECT), comp);
        area = length = 0;
        for (i = miny; i <= maxy; i++){
            memset(grid, 0, sizeof(grid));
            num = sq = 0;
            for (j = 0; j < n; j++){
                if (p[j].sy <= i && i < p[j].ey){
                    grid[num++] = p[j];
                }
            }
            mergeArea(grid, num, &sq);
            if (query == 2 && (bsize != 0 || num != 0)){
                mergeLength(calc, sq);
            }
            memcpy(before, calc, sizeof(calc));
            bsize = sq;
        }
        printf("%d\n", area);
        if (query == 2){
            printf("%d\n", length);
        }
    }
    
    return (0);
}

Measured memory_bytes: 1284
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	int p = 0;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '(') {
			p++;
		}
		else if (S[i] == ')') {
			p--;
		}
		else {
			ans = p;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll cnt=0;
    cin>>s;
    map<ll,ll> mp;
    rep(i,(ll)s.size()){
        mp[s[i]-'a']++;
    }
    rep(i,26){
        if(mp[i]>0) cnt++;
    }
    if(cnt==2){
        cout<<"Second"<<endl;
        return 0;
    }
    if(s[0]==s[s.size()-1]){
        if(s.size()%2==0){
            cout<<"First"<<endl;
        }
        else{
            cout<<"Second"<<endl;
        }
    }
    else{
        if(s.size()%2==0){
            cout<<"Second"<<endl;
        }
        else{
            cout<<"First"<<endl;
        }
    }
    return 0;
}

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

class mint {
  int value;
  static vector<int> _fact;

public:
  static const int MOD = 998244353;
  mint(long long x)
      : value(x % MOD) {}
  mint operator+(mint y) const {
    return mint(value + y.value);
  }
  mint &operator+=(mint a) {
    return *this = *this + a;
  }
  mint operator*(mint y) const {
    return mint(long(value) * y.value);
  }
  mint &operator*=(mint a) {
    return *this = *this * a;
  }
  mint operator-() const {
    return *this * mint(-1);
  }
  mint operator-(mint y) const {
    return *this + (-y);
  }
  mint &operator-=(mint a) {
    return *this = *this - a;
  }
  operator int() const {
    return value;
  }
  static mint pow(mint a, int n) {
    if (n <= 0) {
      return 1;
    }
    else if (n == 1) {
      return a;
    }
    mint half = mint::pow(a, n / 2);
    return n % 2 ? half * half * a : half * half;
  }
  static mint fact(int n) {
    if (size_t(n) < _fact.size()) {
      return _fact[n];
    }
    mint ans = fact(n - 1) * mint(n);
    _fact.push_back(ans);
    return ans;
  }
  mint inv() {
    return pow(value, MOD - 2);
  }
  static mint comb(int n, int k) {
    return fact(n) * fact(k).inv() * fact(n - k).inv();
  }
};
vector<int> mint::_fact = {1};

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  mint ans = 0;
  for (int i = 0; i <= K; i++) {
    ans += mint(M) * mint::comb(N - 1, i) * mint::pow(M - 1, N - 1 - i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 10508
const Main = args => {
  const [_, allNumbers] = args.split('\n');
  const numbers = allNumbers.split(' ').map(Number);

  const max = Math.max(...numbers);
  const sum = numbers.reduce((c, n) => c + n, 0);
  const rest = sum - max;
  return rest - max > 0 ? 'Yes' : 'No';
};

const args = require('fs').readFileSync('/dev/stdin', 'utf8');
console.log(Main(args))

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main(){
int n,x,i=1;
cin >>n;
for(i=1;i<=n;i++){
int x=i;
if(x%3 == 0){
cout <<" "<<i;
}else if(x%10 == 3){
cout <<" "<<i;
}else{
while ( x ){
x /=10;
if(x%10 == 3){
cout <<" "<<i;
break;
}
}
}
}
cout << endl;
}




Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  stack<char> sc;
  
  string s;
  cin >> s;
  
  int count = 0;
  
  for (char c : s) {
    if (sc.empty()) {
      sc.push(c);
    } else {
      if (c == sc.top()) {
        sc.push(c);
      } else {
        sc.pop();
        count += 2;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3828
inputArr = input().split(" ")
n = int(inputArr[0])
a = int(inputArr[1])
b = int(inputArr[2])

counter = 0
result = 0
for num in range(n + 1):
  numStr = str(num)
  sum = 0
  for i in range(len(numStr)):
    sum += int(numStr[i])
  if a <= sum and sum <= b:
    result += num
    
print(result)
  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long[] a = new long[n];
		long res = 1;
		double realRes = 1;
		boolean isOver = false;

		for (long elt: a) {
			elt = sc.nextLong();

//			int keta1 = keta(elt);
//			int keta2 = keta(res);

			res *= elt;
			realRes *= elt;

//			int keta_res = keta(res);
//
//			if ((res != 1000000000000000000l) && (keta1 + keta2 - 1 >= 18)) {
//				isOver = true;
//			}
//
//			if (res > 1000000000000000000l) {
//				isOver = true;
//			}
		}

//		if(res != 0 && isOver) {
//		if((res != 1000000000000000000l) && (keta(realRes) > 18)) {
		if((res != 1000000000000000000l) && (realRes >= 1000000000000000000l)) {
			res = -1;
		}

		System.out.printf("%d", res);
	}

	private static int keta (long num) {
		long tmp = num;
		int res = 0;
		while (tmp > 0) {
			tmp /= 10;
			res++;
		}
		return res;
	}
	private static int keta (double num) {
		double tmp = num;
		int res = 0;
		while (tmp >= 1) {
			tmp /= 10;
			res++;
		}
		return res;
	}
}


Measured memory_bytes: 61152
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// Nの入力
		int N = sc.nextInt();
		
		// Biの入力
		ArrayList<Integer> b = new ArrayList<>();
		for (int i = 1; i <= N-1; i++) {
			b.add(sc.nextInt());
		}
		
		// Aiの作成
		ArrayList<Integer> a = new ArrayList<>();
		a.add(b.get(0));
		for (int i = 0; i < N-2; i++) {
			if (b.get(i) <= b.get(i+1)) {
				a.add(b.get(i));
			}
			else {
				a.add(b.get(i+1));
			}			
		}
		a.add(b.get(N-2));
		
		// Aiの要素を合計
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += a.get(i);
		}
		
		// 結果の出力
		System.out.println(sum);
		
		sc.close();
	}

}


Measured memory_bytes: 23892
n, l = map(int, input().split())
ans = 0
if 0 <= l-1:
  for i in range(l+1, n+l):
    ans += i
elif l+n-1 < 0:
  for i in range(l, n+l-1):
    ans += i
else:
  for i in range(l, n+l):
    ans += i
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;


int main() {
    int n;
    cin >> n;
    vi a(n);
    for (auto& x : a) cin >> x;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if (a[i] == a[j] || a[i] == a[k]) continue;
                if (a[j] == a[k]) continue;
                int arr[4] = {a[i], a[j], a[k]};
                sort(arr, arr+3);
                ans += arr[2] < arr[0] + arr[1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static String S;

	public static void main(String[] args) {
		readInput();

		solve();
	}

	static void solve() {
		char[] c_array = S.toCharArray();
		
		int[] sum = new int['z'- 'a' + 1];
		for(int idx = 0; idx < c_array.length; idx++) {
			sum[c_array[idx] - 'a']++;
		}
		
		long ans = 0;
		
		long[] conv = new long[1 << 26];
		Arrays.fill(conv, -1);
		conv[0] = 1;
		
		int max = 1 << 26;
		
		for(int bit = 1; bit < max; bit++) {
			conv[bit] = 0;
			
			for(int idx = 0; idx < 26; idx++) {
				int b_idx = 1 << idx;
				if((bit & b_idx) > 0) {
					conv[bit] = (conv[bit - b_idx] * sum[idx]) % 1000000007;
					break;
				}
			}
			
			ans = (ans + conv[bit]) % 1000000007;
		}
		
		System.out.println(ans);
	}
	

	static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			sc.nextLine();
			S = sc.nextLine();
		}
	}
}


Measured memory_bytes: 556896
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, K; cin >> H >> W >> K;
	vector<vector<char>> s(H, vector<char>(W));
	rep(i, 0, H) rep(j, 0, W) { cin >> s[i][j]; }
	int chi = 0;
	vector<vector<int>> ans(H, vector<int>(W, -1));
	rep(i, 0, H) {
		int cnt = 0;
		rep(j, 0, W) {
			if (s[i][j] == '#')
				cnt++;
		}

		if (cnt == 0)continue;

		int x = 0;

		rep(j, 0, W) {
			ans[i][j] = chi;
			if (s[i][j] == '#') {
				chi++;
				x++;
				if (x == cnt) chi--;
			}
		}
		chi++;
	}
	rep(i, 1, H) {
		if (ans[i][0] == -1) {
			rep(j, 0, W) {
				ans[i][j] = ans[i - 1][j];
			}
		}
	}
	rrep(i, 0, H - 1) {
		if (ans[i][0] == -1) {
			rep(j, 0, W) {
				ans[i][j] = ans[i + 1][j];
			}
		}
	}

	rep(i, 0, ans.size()) {
		cout << ans[i][0] + 1;
		rep(j, 1, ans[i].size()) { cout << " " << ans[i][j] + 1; }
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main(){
	double a,b;
	

	double table1[] = {35.5,37.5,40.0,43.0,50.0,55.0,70.0};
	double table2[] = {71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	string rank[] = {"AAA","AA","A","B","C","D","E","NA"};

	while(~scanf("%lf %lf",&a,&b)){
		int c=7,d=7;
		for(int i=0;i<sizeof(table1)/sizeof(double);i++){
			if(a < table1[i]) { c = i; break; }
		}

		for(int i=0;i<sizeof(table2)/sizeof(double);i++){
			if(b < table2[i]) { d = i; break; }
		}

		cout << rank[max(c,d)] << endl;

	}
}

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

class DecimalNAN {};

struct Decimal{
 vector<UL> V = {0};
 void fix() {while(V.size()>1 && V.back()==0) V.pop_back();}
 void print() {
  rep(i,V.size()) cout<<V[V.size()-1-i];
 }
 Decimal(string s){
  reverse(s.begin(),s.end());
  V.clear();
  if(s.size()==0) throw DecimalNAN();
  rep(i,s.size()){
   if(s[i]<'0' || '9'<s[i]) throw DecimalNAN();
   V.push_back(s[i]-'0');
  }
  fix();
 }
 Decimal() :Decimal("0") {}
 operator bool() const{return V!=vector<UL>({0});}
 bool operator<(const Decimal& r) const {
  if(V.size()!=r.V.size()) return V.size()<r.V.size();
  for(UL i=V.size()-1; i!=~0u; i--)
   if(V[i]!=r.V[i]) return V[i]<r.V[i];
  return false;
 }
 bool operator>(const Decimal& r) const {return r<*this;}
 bool operator<=(const Decimal& r) const {return !(*this<r);}
 bool operator>=(const Decimal& r) const {return !(*this<r);}
 Decimal operator+(const Decimal& r) const{
  Decimal tmp=*this;
  tmp.V.resize(max(V.size(),r.V.size())+1);
  UL crr=0;
  rep(i,tmp.V.size()){
   if(i<V.size()) crr+=V[i];
   if(i<r.V.size()) crr+=r.V[i];
   tmp.V[i]=crr%10;
   crr/=10;
  }
  tmp.fix();
  return tmp;
 }
 Decimal operator-(const Decimal& r) const{
  Decimal tmp=*this;
  tmp.V.resize(max(V.size(),r.V.size())+2);
  UL crr=0;
  rep(i,tmp.V.size()){
   if(i<V.size()) crr+=V[i];
   if(i<r.V.size()) crr-=r.V[i];
   crr+=10;
   tmp.V[i]=crr%10;
   crr/=10; crr-=1;
  }
  if(tmp.V.back()!=0) throw DecimalNAN();
  tmp.fix();
  return tmp;
 }
 Decimal operator<<(const UL& r) const{
  Decimal tmp; tmp.V.clear();
  rep(i,r) tmp.V.push_back(0);
  for(UL v:V) tmp.V.push_back(v);
  tmp.fix();
  return tmp;
 }
 Decimal operator>>(const UL& r) const{
  Decimal tmp; tmp.V.clear();
  for(UL i=r; i<V.size(); i++) tmp.V.push_back(V[i]);
  if(tmp.V.empty()) tmp.V.push_back(0);
  tmp.fix();
  return tmp;
 }
 Decimal operator*(const Decimal& r) const{
  Decimal tmp;
  rep(i,r.V.size()){
   Decimal off=*this<<i;
   rep(j,r.V[i]) tmp=tmp+off;
  }
  return tmp;
 }
 Decimal operator/(const Decimal& r) const{
  if(V.size()<r.V.size()) return Decimal();
  UL shifts = V.size()-r.V.size();
  Decimal buf=*this;
  Decimal tmp; tmp.V.resize(shifts+1);
  for(UL i=shifts; i!=~0u; i--){
   Decimal off=r<<i;
   while(buf>=off){tmp.V[i]++; buf=buf-off;}
  }
  tmp.fix();
  return tmp;
 }
 Decimal operator%(const Decimal& r) const{
  if(V.size()<r.V.size()) return *this;
  UL shifts = V.size()-r.V.size();
  Decimal buf=*this;
  for(UL i=shifts; i!=~0u; i--){
   Decimal off=r<<i;
   while(buf>=off){buf=buf-off;}
  }
  buf.fix();
  return buf;
 }
};

int main() {
 string a,b; cin >>a>>b;
 bool sign=false;
 if(a.front()=='-') {sign=!sign;a=a.substr(1,-1);}
 if(b.front()=='-') {sign=!sign;b=b.substr(1,-1);}
 Decimal A{a}, B{b};
 Decimal D=A/B;
 if(sign&&D) cout<<"-";
 D.print(); cout << endl;
 return 0;
}




Measured memory_bytes: 3228
N = int(input())
dict = {}
for _ in range(N):
    a = int(input())
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1

ans = 0
for v in dict.values():
    if v % 2 != 0:
        ans += 1
print(ans)

Measured memory_bytes: 15068
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean[] r = new boolean[n];
		r[0] = true;
		int[] b = new int[n];
		Arrays.fill(b, 1);

		for (int i = 0; i < m; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			b[x]--;
			b[y]++;
			if (r[x]) {
				r[y] = true;
				if (b[x] == 0) r[x] = false;
			}
		}

		int count = 0;
		for (int i = 0; i < n; i++) {
			if (r[i]) count++;
		}

		out.println(count);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long nextLong() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

}

Measured memory_bytes: 22224
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int[] T = new int[N];
		for(int i = 0; i < N; i++) T[i] = sc.nextInt();
		Arrays.sort(T);
		int ans = 0;
		int start = 0;
		int count = 0;
		
		
		for(int i = 0; i < N; i++){
			
			if(count == 0){
				start = T[i] + K;
				ans++;
				count++;
			}else{
				if(start < T[i]){
					start = T[i] + K;
					ans++;
					count = 0;
					count++;
				}else{
					count++;
				}
			}
			
			if(count == C) count = 0;
		}
		
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 24644
#include <stdio.h>

int main(void){
    int array[100];
    int i;
    int n, a;
    scanf("%d", &n);
    for (i = n - 1; i >= 0; i--){
        scanf("%d", &a);
        array[i] = a;
        //printf("%d ",array[i]);
    }
    for (i = 0; i < n; i++){
        printf("%d", array[i]);
        if (i < n - 1)printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Node{
	int location;
	int p,left,right;
};

struct Point{
	Point(){
		id = x = y = 0;
	}

	Point(int arg_id,int arg_x,int arg_y){
		id = arg_id;
		x = arg_x;
		y = arg_y;
	}
	bool operator < (const Point & arg)const{
		return id < arg.id;
	}
	void print(){
		printf("%d\n",id);
	}
	int id,x,y;
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int number;

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }

int makeKDTree(int left,int right, int depth){

	if(!(left < right))return NIL;

	int mid = (left+right)/2;

	int node_id = number++;

	if(depth%2 == 0){
		sort(P+left,P+right,lessX);
	}else{
		sort(P+left,P+right,lessY);
	}

	T[node_id].location = mid;
	T[node_id].left = makeKDTree(left,mid,depth+1);
	T[node_id].right = makeKDTree(mid+1,right,depth+1);

	return node_id;
}

void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){

	int x = P[T[node_id].location].x;
	int y = P[T[node_id].location].y;

	if(sx <= x && x <= tx && sy <= y && y <= ty){
		ans.push_back(P[T[node_id].location]);
	}

	if(depth%2 == 0){
		if(T[node_id].left != NIL){
			if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}else{
		if(T[node_id].left != NIL){
			if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[node_id].right != NIL){
			if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
		}
	}
}


int main(){

	int x,y;
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		P[i] = Point(i,x,y);
		T[i].left = T[i].right = T[i].p = NIL;
	}

	number = 0;

	int root = makeKDTree(0,N,0);

	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i = 0; i < q; i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j = 0; j < ans.size(); j++){
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}



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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; 

static const long long INF = 1e18;

using lll = __int128_t;

ll popcount(lll x) {
    ll c = 0;
    rep(i, 128) c += !!(x & ((lll)1 << i));
    return c;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, qnum; 
    while (cin >> n >> qnum && n && qnum) {
        vector<ll> a(qnum); 
        rep(i, qnum) rep(j, n) { 
            char c; cin >> c; 
            if (c - '0') 
                a[i] |= 1ll << (n-1-j); 
        }

        map<lll, ll> memo; // 1 if impossible
        function<ll(lll, ll)> f = [&](lll x, ll counter) -> ll {
            if (popcount(x) == qnum - 1) 
                return 0;
            if (popcount(x) == qnum) 
                return INF;
            if (memo.count(x)) 
                return memo[x];

            ll ret = INF;
            rep(j, n) {
                lll yes, no; yes = no = x; 
                rep(i, qnum) {
                    ((a[i] & ((ll)1 << (n-1-j))) ? yes : no) |= ((lll)1 << i);
                }
                ll tmp = -1;
                ll yes_ret = INF, no_ret = INF; 
                if (yes != x)
                    yes_ret = f(yes, counter+1);
                if (no != x)
                    no_ret = f(no, counter+1);
                if (yes_ret != INF)
                    chmax(tmp, yes_ret);
                if (no_ret != INF)
                    chmax(tmp, no_ret);
                if (tmp != -1)
                    chmin(ret, tmp + 1);
            }
            return memo[x] = ret;
        };
        cout << f(0, 0) << endl;
    }
    return 0;
}

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

int main() {
  int N,yellow=0;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      yellow++;
      break;
    }
  }
  if(yellow==0)
    cout<<"Three"<<endl;
  else
    cout<<"Four"<<endl;
}


Measured memory_bytes: 256
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i).count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n,k,a,b;
	cin>>n>>k>>a>>b;
	cout<<min(n,k)*a+max(n-k,0)*b<<endl;
	return 0;
}

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

int main() {
  vector<char> S(3);
  vector<char> T(3);
  int count = 0;
  for(int i = 0; i < 3; i++){
    cin >> S.at(i);
  }
  for(int i = 0; i < 3; i++){
    cin >> T.at(i);
  }
  for(int i = 0;i < 3; i++){
    if(S.at(i) == T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

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

int main(){
  int d,n;
  int ans;
  cin >> d >> n;
  ans = pow(100,d)*n;
  if (n==100) ans = pow(100,d)*101;
  cout << ans << endl;
}
//n=100のとき考えるのをteratailで指摘していただいた

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,t,A[200000],B[200000],ans=1;
    cin>>n>>t;
    rep(i,n) cin>>A[i];
    B[n-1]=A[n-1];
    for(int i=n-2;i>=0;i--) B[i]=max(B[i+1],A[i]);
    rep(i,n) B[i]-=A[i];
    sort(B,B+n,greater<int>());
    rep(i,n-1) if(B[i+1]==B[0]) ans++;
    cout<<ans;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int n,l;

	cin>> n >> l;
	vector<string> v;
	for(int i = 0; i < n; i++){
		string in;
		cin >> in;
		v.push_back(in);
	}

	sort(BE(v));
	for(auto x : v)
		cout << x;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  char cur;
  int JOI[3]={};
  char pre='A';
  int answer=0;
  while(cin >> cur){
    if(cur=='J'){
      if(pre!='J') REP(j,3) JOI[j]=0;
      JOI[0]++;
    }
    else if(cur=='O'){
      if(pre!='J'&&pre!='O') REP(j,3) JOI[j]=0;
      JOI[1]++;
    }else{
      JOI[2]++;
      if(JOI[0]>=JOI[1]&&JOI[1]<=JOI[2]) answer=max(answer,JOI[1]);
    }
    pre = cur;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;
ll dp[100010][3];
void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}
//dp[i] i-1日目までで得られる幸福度の最大値
//dp[ i + 1 ][ j ] := i 日目までの活動履歴のうち、
//最終日である i 日目には活動 j (0: A, 1: B, 2: C) を選んだ場合の、得られる幸福度の最大値
int main ()
{
    int N;cin>>N;
    vector<vector<int>> a(N,vector<int>(3));
    REP(i,N){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j==k) continue;//同じのはだめ
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }

        }
    }
    ll res = 0;
    REP(j,3) chmax(res,dp[N][j]);
    cout<<res<<endl;
  return 0;
}

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


void solve(long long X, long long A){
    cout << (X<A ? 0 : 10) << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


Measured memory_bytes: 256
#全員初期値を問題数分マイナスし正解者に1点足していくようにする

N, K , Q = map(int, input().split())
members = [K-Q for _ in range(N)]
A = []
for i in range(Q):
    a = int(input())
    members[a-1] += 1

for k in members:
    if k < 1:
        print('No')
    else:
        print('Yes')

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

using namespace std;

vector< int > A;
vector< int > m;
bool dfs(int m,int n){
		if (n > A.size()) return false;
		if (m < 0) return false;
		if (m == 0) return true;
		bool ans;
		ans = dfs(m-A[n],n+1) || dfs(m,n+1);
		return ans; 
}


int main(){
		int n; cin >> n;
		for (int i = 0; i < n; i++){
				int a; cin >> a;
				A.push_back(a);
		}
		int q; cin >> q;
		for (int i = 0; i < q; i++){
				int _m; cin >> _m;
				m.push_back(_m);
		}
		for (size_t i = 0; i < m.size(); i++){
				if (dfs(m[i],0)){
						cout << "yes" << endl;
				}else{
						cout << "no" << endl;
				}
		}
		return 0;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    auto H=vector<int>(n);
    for(auto it=H.begin(); it!=H.end(); it++){
        scanf("%d", &(*it));
    }
    for(auto it=H.begin(); it!=H.end(); it++){
        int idx=distance(H.begin(), it);
        printf("node %d: key = %d, ", idx+1, *it);
        int parent=(idx-1)/2;
        if(parent>=0 && idx){
            printf("parent key = %d, ", H[parent]);
        }
        int left=(idx+1)*2-1;
        if(left<n){
            printf("left key = %d, ", H[left]);
            int right=(idx+1)*2;
            if(right<n){
                printf("right key = %d, ", H[right]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; 
	while (cin >> n, n)
	{
		vi v(n); cin >> v;
		int ans = 1e9;
		REP(i, n)REP(j, i)
		{
			chmin(ans, abs(v[i] - v[j]));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun p(value: Any?) {
    pw.println(value)
}

fun solve() {
    val b = readLine()!!
    val mp = mapOf("A" to "T", "T" to "A", "C" to "G", "G" to "C")
    p(mp[b])
}

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

Measured memory_bytes: 31820