akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=998244353;

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int d[n];
  for(i=0;i<n;i++)cin>>d[i];
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  if(d[0]!=0){
    cout<<0<<endl;
    return 0;
  }
  sort(d,d+n);
  if(d[1]==0){
    cout<<0<<endl;
    return 0;
  }
  for(i=1;i<n;i++){
    if(!(d[i]==d[i-1] || d[i]==d[i-1]+1)){
      cout<<0<<endl;
      return 0;
    }
  }
  ll c[n];
  for(i=0;i<n;i++)c[i]=1;
  for(i=1;i<n;i++){
    if(d[i]==d[i-1])c[cnt]++;
    else cnt++;
  }
  n=cnt+1;
  ll prod=1;
  for(i=2;i<n;i++){
    for(j=0;j<c[i];j++){
      prod=(prod*c[i-1])%MOD;
    }
  }
  cout<<prod<<endl;
}

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

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

int main() {
	int N;
	int hon[5] = { 2, 4, 5, 7, 9 };
	int pon[4] = { 0,1,6,8 };

	cin >> N;
	rep(i, 5) {
		if (N % 10 == hon[i]) {
			cout << "hon";
		}
	}
	rep(i, 4) {
		if (N % 10 == pon[i]) {
			cout << "pon";
		}
	}
	if (N % 10 == 3) {
		cout << "bon";
	}
}

Measured memory_bytes: 3072
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m, *a = map(int, read().split())
    MOD = 10**9 + 7
 
    if n == 1:
        print(1)
        exit()
 
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    is_broken = [False] * (n+1)
    for i in a:
        is_broken[i] = True
    if 1 in a:
        dp[1] = 0
    else:
        dp[1] = 1
 
    for i in range(2, n + 1):
        if is_broken[i]:
            continue
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
 
    print(dp[-1])
 
if __name__ == '__main__':
    main()

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

#define st first
#define nd second

const int N = 2e5+5, LOGN = 65;
int n, a[N], u = 1, lg;
bool in[N];
pair<int,long long> par[LOGN][N];
long long k, cnt = 0;
vector<int> v, cont[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cont[a[i]].push_back(i);
    }
    for (int i = 1; i <= N; i++)
    {
        int m = cont[i].size();
        if (!m) continue;
        if (m == 1)
        {
            if (cont[i][0] == n)
                par[0][cont[i][0]] = {1,2};
            else
                par[0][cont[i][0]] = {cont[i][0]+1,1};
            continue;
        }
        for (int j = 0; j < m-1; j++)
        {
            if (cont[i][j+1] == n)
                par[0][cont[i][j]] = {1,1};
            else
                par[0][cont[i][j]] = {cont[i][j+1]+1,0};
        }
        par[0][cont[i][m-1]].st = cont[i][0]+1;
        par[0][cont[i][m-1]].nd = 1;
    }

    int lg = log2(1LL*n*k);
    for (int j = 1; j <= lg; j++)
    {
        for (int i = 1; i <= n; i++)
        {
            par[j][i].st = par[j-1][par[j-1][i].st].st;
            par[j][i].nd = par[j-1][i].nd + par[j-1][par[j-1][i].st].nd;
        }
    }

    for (int j = lg; j >= 0; j--)
    {
        if (!par[j][u].st || cnt+par[j][u].nd >= k) continue;
        cnt += par[j][u].nd;
        u = par[j][u].st;
    }
    for (int i = u; i <= n; i++)
    {
        if (!in[a[i]])
        {
            v.push_back(a[i]);
            in[a[i]] = 1;
        }
        else
        {
            while(in[a[i]])
            {
                in[v.back()] = 0;
                v.pop_back();
            }
        }
    }
    for (int x: v)
        cout << x << ' ';

}


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

int main() {
  int sum = 0;
  vector<int> a;
  for (int i = 0; i < 5; i ++) {
    int t; cin >> t;
    if (t % 10 == 0) sum += t;
    else a.push_back(t);
  }

  if (a.size() == 0) {
    cout << sum << endl;
    return 0;
  }

  int x;
  int y = 10;
  for (int i = 0; i < a.size(); i ++) {
    int s = a[i] % 10;
    if (s < y) x = i, y = s;
  }
  sum += a[x];

  for (int i = 0; i < a.size(); i ++) {
    if (i == x) continue;
    sum += a[i] + 10 - (a[i] % 10);
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],cnt;

int main(){
    cin >> n;
    cnt = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        for(int j = n-1; j >= i+1; j--)
            if (a[j] < a[j-1]) {
                cnt++;
                swap(a[j],a[j-1]);
            }
    }
    for(int i = 0; i < n-1; i++) cout << a[i] << " ";
    cout << a[n-1];
    cout << '\n';
    cout << cnt << '\n';
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1]+'a'-'A';
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
 
# 拘束条件を用い、探索をO(N^3)からO(N^2)へ！
a, b, c = -1, -1, -1
for i in range(0, N+1):
  for j in range(0, N+1-i):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      a, b, c = i, j, k
  
print(a, b, c)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  double sum = 0;
  vector<pair<double, string>> a;
  rep(i,n){
    double x;
    string y;
    cin >> x >> y;
    a.pb(mp(x, y));
  }
  rep(i,n){
    if(a[i].S=="JPY"){
      sum += a[i].F;
    }
    else{
      sum += a[i].F * 380000;
    }
  }
  cout << fixed << setprecision(6) <<sum<< endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int):
    
    from math import floor, ceil
    ans = []
    for i in range(1, 20000):
        if floor(i*0.08) == A and floor(i*0.1) == B:
            ans.append(i)

    ans.sort()
    # print(ans)
    if len(ans) != 0:
        print(ans[0])
    else:
        print(-1)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <iterator>

using namespace std;

int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<vector<char>> ss;

    string  str = "abcdefghijklmnopqrstuvwxyz";
    vector<char> uniques(str.begin(), str.end());
    
    
    for(int i =0; i < N; i++){
        string tmp;
        cin >> tmp;
        vector<char> s(tmp.begin(), tmp.end());
        ss.push_back(s);
        sort(s.begin(),s.end());
        unique(s.begin(), s.end());
        vector<char> buff;
        set_intersection(uniques.begin(), uniques.end(),s.begin(), s.end(), inserter( buff, buff.end()) );
        uniques = buff;
    }
    
    sort(uniques.begin(), uniques.end());

    
    for(auto it = uniques.begin(); it != uniques.end(); ++it){
        int min = 100000000000;
        for(int i =0; i < ss.size() ;i++){
            int num = count(ss[i].begin(), ss[i].end(), *it);
            if(num < min){
                min = num;
            }
        }
        for(int i = 0; i < min; i++){
            cout << *it;
        }
    }
    cout << endl;    

    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include </Users/rsuazo/bits/stdc++.h>

using namespace std;
using Long = long long;

string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int N;
  string s;
  cin >> N >> s;
  for(int i = 0; i < s.size(); i++){
    int current = s[i]-'A';
    s[i] = alphabet[(current + N) % 26];
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;
const int N = 1e6+100;
typedef long long ll;
vector<int> G[N];
bool vis[N];
int ans;
void dfs(int x){
	vis[x]=1;
	for(auto v:G[x]){
		if(!vis[v]) dfs(v);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	int u,v,w;
	for(int i=1;i<=m;i++){
		cin>>u>>v>>w;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			ans++;
			dfs(i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

long long int N, a[114514], b[114514], m, i;
vector<pair<long long int, long long int> > v, u;

int main(){
    scanf("%lld", &N);
    for(i = 0; i < N; ++i){
        scanf("%lld", a + i);
        u.push_back(make_pair(a[i], i));
        if(m < a[i]){
            m = a[i];
            v.push_back(make_pair(i, a[i]));
        }else{
            b[i] = 0;
        }
    }
    u.push_back(make_pair(0, 0));
    sort(u.begin(), u.end(), greater<pair<long long int, long long int> >());
    m = u[0].second;
    for(i = 0; i < N; ++i){
        m = min(u[i].second, m);
        //cout << m << " " << u[i].first << " " << u[i].second << endl;
        b[m] += (u[i].first - u[i + 1].first) * (i + 1);
    }
    //for(i = v.size() - 1; i > 0; --i){
    //    b[v[i].first] = v[i].second - v[i - 1].second;
    //}
    for(i = 0;i < N; ++i)cout << b[i] << endl;
    return 0;
}


Measured memory_bytes: 5988
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

S = gets.chomp

good = true
S.split('').each_cons(2) do |a, b|
  good = false if a == b
end

puts good ? 'Good' : 'Bad'


Measured memory_bytes: 14440
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

from collections import Counter


def factorial(n):
    prime_count = Counter()

    for i in range(2, int(n**0.5) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def main():
    N = int(input())
    pc = factorial(N)                # O(N**0.5)

    ans = 0
    for k, v in pc.items():
        count = 0
        for i in range(1, v+5):
            v -= i
            if v < 0:
                break
            count += 1
        # print(k, v, count)
        ans += count
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 66552
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
int a1;
long long a2=0;
long long a[N]={0};
long long b=0;
for(int i=0;i<N;i++){
cin>>a1;
a[i]=a1-i-1;}
sort(a,a+N);
if(N%2==0){
b=(a[N/2]+a[N/2-1])/2;
for(int i=0;i<N;i++){
a2+=abs(a[i]-b);}
cout<<a2<<endl;
}
else{
b=a[(N-1)/2];
for(int i=0;i<N;i++){
a2+=abs(a[i]-b);}
cout<<a2<<endl;}}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
double pow(double x, ll ntimes) {
    double ret = 1.0;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,d;
    cin >> n >> m >> d;
    ll sum = 0;
    if(d==0){
        sum = n;
    }else if(n-d+1<=d){
        sum = n;
        sum -= d - (n-d+1) +1;
    }else{
        sum += 2*d;
        sum += 2*(n-2*d);
    }
    ll x = sum * (m-1);
    ll y = n*n;
    double ans = (double)x/y;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        //変数a, b, cを宣言
        int a, b, c;
        
        //a, b, cを入力
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        
        //a < b < c が成立しているか判定
        if(a < b && b < c) System.out.println("Yes");
        else  System.out.println("No");
        
    }
}



/*覚えよう！！
 
・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件

*/
  
  
/*前回の内容！！


・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
 
 
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
 
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
 

 
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
  
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
  
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
    
    
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
  
  
  
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
  
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
  
・println・・・画面に出力するときに使用
  
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
  
*/



Measured memory_bytes: 26136
while True:
    n_x = input()
    n_x_list = n_x.split(" ")
    n_int = int(n_x_list[0])
    x_int = int(n_x_list[1])
    if n_int == 0 and x_int == 0:
        break
    ans = 0
    fir = 1
    sec = 2
    thi = 3
    while True:
        if thi > n_int:
            break
        if fir + sec + thi == x_int:
            ans += 1
        if sec == n_int - 1:
            fir += 1
            sec = fir + 1
            thi = fir + 2
        elif thi == n_int:
            sec += 1
            thi = sec + 1
        else:
            thi += 1
    print(ans)


Measured memory_bytes: 5596
def travel(here, lb, ub, field, label):
	if field[here[1]][here[0]] == 1:
		field[here[1]][here[0]] = label
		if lb[0] < here[0] :
			travel((here[0]-1, here[1]), lb, ub, field, label)
			if lb[1] < here[1]:
				travel((here[0]-1, here[1]-1), lb, ub, field, label)

		if lb[1] < here[1] :
			travel((here[0], here[1]-1), lb, ub, field, label)
			if ub[0] > here[0] :
				travel((here[0]+1, here[1]-1), lb, ub, field, label)

		if ub[0] > here[0] :
			travel((here[0]+1, here[1]), lb, ub, field, label)
			if ub[1] > here[1]:
				travel((here[0]+1, here[1]+1), lb, ub, field, label)
				 
		if ub[1] > here[1] :
			travel((here[0], here[1]+1), lb, ub, field, label)
			if lb[0] < here[0] :
				travel((here[0]-1, here[1]+1), lb, ub, field, label)

import sys
sys.setrecursionlimit(100000)
while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0):
		break
	island = []
	for j in range(h):
		island.append(map(int, raw_input().split(" ")))
	label = 1
	for j in range(h):
		for i in range(w):
			if island[j][i] == 1:
				label += 1
				travel((i,j), (0,0), (w-1,h-1), island, label)
	print label - 1

Measured memory_bytes: 5904
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int a, b;

    scanf("%d %d", &a, &b);
    
    if(b%a==0){
        printf("%d",a+b);
        
    }else{

        printf("%d", b-a);
    }
    
    
    

    return 0;

}


Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

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

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

inline bool out(int x, int y, int w, int h) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

struct state {
	int x, y, hp;
	state(int x_, int y_, int hp_):x(x_), y(y_), hp(hp_) {}

	inline bool operator<(const state &s) const {
		if(x != s.x) return x < s.x;
		if(y != s.y) return y < s.y;
		return hp < s.hp;
	}
};

int bfs(int sx, int sy, const vector<vector<int>> &field) {
	const int w = field[0].size();
	const int h = field.size();
	
	queue<state> que;
	map<state, int> dist;

	que.push(state(sx, sy, MAX_HP));
	dist.insert({state(sx, sy, MAX_HP), 0});

	while(!que.empty()) {
		const state s = que.front();
		que.pop();

		const int next_dist = dist[s] + 1;

		rep(d, 4) {
			const int nx = s.x + dx[d];
			const int ny = s.y + dy[d];

			if(out(nx, ny, w, h) || field[ny][nx] == 0) continue;
			if(field[ny][nx] == 3) return next_dist;

			const int next_hp = (field[ny][nx] == 4 ? MAX_HP : s.hp - 1);

			if(next_hp == 1) continue;
			
			const state next_state(nx, ny, next_hp);
			
			if(!dist.count(next_state)) {
				dist[next_state] = next_dist;
				que.push(next_state);
			}
		}
	}

	return -1;
}

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

	for(int w, h; cin >> w >> h && w;) {
		int sx, sy;

		vector<vector<int>> field(h, vector<int>(w));
		rep(i, h) {
			rep(j, w) {
				cin >> field[i][j];

				if(field[i][j] == 2) {
					sx = j;
					sy = i;
				}
			}
		}

		cout << bfs(sx, sy, field) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <stdio.h>

int main (){
  

    int k,a,b;
    int flag = 0;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);

    for(int i=a; i<=b; i++){
        if(i%k==0){
          flag = 1;  
        }
    }
    if(flag == 1){
        printf("OK\n");
    } else {
        printf("NG\n");
    }
        return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 int a,b,x,t=0,res=0; cin>>a>>b>>x;

 if(x>=a&&x<=a+b)
  cout << "YES" << endl;
  else
    cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
queue<ll> que;
int main(){
    int k;scanf("%d",&k);
    if(k<=9){
        printf("%d",k);
        return 0;
    }
    for(int i=1;i<=9;i++) que.push(i);
    k-=9;
    while(true){
        ll val=que.front();que.pop();
        ll dig=val%10;
        if(dig==0){
            que.push(val*10);k--;
            if(k==0) break;
            que.push(val*10+dig+1);k--;
            if(k==0) break;
        }else if(dig==9){
            que.push(val*10+8);k--;
            if(k==0) break;
            que.push(val*10+9);k--;
            if(k==0) break;
        }else{
            que.push(val*10+dig-1);k--;
            if(k==0) break;
            que.push(val*10+dig);k--;
            if(k==0) break;
            que.push(val*10+dig+1);k--;
            if(k==0) break;
        }
    }
    printf("%lld\n",que.back());
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  int a,b,c;cin>>a>>b>>c;
  int ans = min(c,b/a);
  cout << ans << endl;
}


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

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


int main(){
	int n;
	cin >> n;
	int a;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a%2==0){
			if(a%3!=0 && a%5!=0){
				cout << "DENIED" << endl;
				return 0;
			}
		}
	} 

	cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
N=int(input())
n=list(map(int,(stdin.readline().strip().split())))
n.insert(0,None)
def maxheap(A,i):
    right=i*2+1
    left=i*2
    if left<=N and A[left]>A[i]:
        max_i=left
    else:
        max_i=i
    if right<=N and A[right] >A[max_i]:
        max_i=right
    if max_i!=i:
        A[i],A[max_i]=A[max_i],A[i]
        maxheap(A,max_i)
def build(A):
    for i in range(N//2,0,-1):
        maxheap(A,i)
build(n)
for i in range(1,N+1):
    print("",n[i],end="")
print()


Measured memory_bytes: 63704
#include <iostream>

using namespace std;

int main() {

	int n, number, suitnumber;
	char suit, outputsuit;
	bool card[4][13] = {0};
	

	cin >> n;

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

		cin >> suit >> number;

		if (suit == 'S') {
			suitnumber = 0;
		}
		else if (suit == 'H') {
			suitnumber = 1;
		}
		else if (suit == 'C') {
			suitnumber = 2;
		}
		else {
			suitnumber = 3;
		}

		card[suitnumber][number - 1] = true;

	}

	for (int j = 0; j < 4;j++) {//絵柄分

		for (int k = 0; k < 13;k++) {

			if (card[j][k] == false) {

				if (j == 0) {
					outputsuit = 'S';
				}
				else if (j == 1) {
					outputsuit = 'H';
				}
				else if (j == 2) {
					outputsuit = 'C';
				}
				else {
					outputsuit = 'D';
				}

				cout << outputsuit << ' ' << k + 1 << endl;
			}
		}

	}

	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main()

{
    int D,N;

    scanf("%d %d", &D, &N);

    if(D==0 && N<100){
        printf("%d\n", N);
    }
    else if(D==0 && N==100){
        printf("101\n");
    }
    else if(D==1 && N<100){
        printf("%d\n", (N*100));
    }
    else if(D==1 && N==100){
        printf("%d\n", 101*100);
    }
    else if(D==2 && N<100){
        printf("%d\n", (N*10000));
    }
    else if(D==2 && N==100){
        printf("%d\n", 101*10000);
    }

    return 0;
}


Measured memory_bytes: 128
from itertools import accumulate
N = 100000
prime = [True for _ in range(N+1)]
prime[0] = False
prime[1] = False
i = 2
for i in range(N+1):
    if prime[i]:
        for j in range(2*i, N+1, i):
            prime[j] = False

prime2 = [1 if prime[i] and prime[(i+1)//2] else 0 for i in range(N+1)]
acc = list(accumulate(prime2))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])


Measured memory_bytes: 8088
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define MAX 300005
#define endl '\n'
#define MOD 998244353

int mul(int a,int b)
{
    a%=MOD;
    b%=MOD;
    return (a*b)%MOD;
}
int add(int a,int b)
{
    a%=MOD;
    b%=MOD;
    return (a+b)%MOD;
}

int power(int a,int n)
{
    int res = 1;
    while(n>0)
    {
        if(n%2 == 1)
        {
            res= mul( res,a );
        }
        a = mul(a,a);
        n/=2;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    map<string,int> mp;
    for (int i = 0; i < n; ++i)
    {
        /* code */
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    
}

int32_t main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    int test;
    test = 1;
    // cin>>test;
    while(test--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3656
n = int(input())
a = []
b = []
for i in range(1, n+1):
    x = 0
    b.append(i)
    while i % 2 == 0:
        x += 1
        i /= 2
    a.append(x)
y = a.index(max(a))
print(b[y])


Measured memory_bytes: 2940
n,a = map(int,input().split())
x = list(map(int,input().split()))
x = [t-a for t in x]
p = [0]*5010
p[0] = 1
q = [0]*5010
for t in x:
  for i in range(5010):
    q[i] = p[i] + p[(i-t)%5010] 
  for i in range(5010):
    p[i] = q[i]
print(p[0]-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
	int Ac,Bc,ans=0;
	scanf("%d %d",&Ac,&Bc);
	
	if(Ac<Bc){
		if(Ac==1){
			printf("Alice");
		}
		else{
			printf("Bob");
		}
	}
	else if(Ac==Bc){printf("Draw");
	}
	else{
		if(Bc==1){
			printf("Bob");
		}
		else{
			printf("Alice");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  
  ll DP[65][3]={};
  DP[60][0]=1;
  
  for(int d=59; d>=0; --d){
    for(int s=0; s<=2; s++){
      for(int k=0; k<=2; k++){
        ll s2=min(2ll,2*s+((N>>d)&1)-k);
        if(s2>=0) DP[d][s2]=(DP[d][s2]+DP[d+1][s])%MOD;
      }
    }
  }
  
  ll ans=DP[0][0]+DP[0][1]+DP[0][2];
  ans=(ans%MOD+MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	var A : Int = scanner.nextInt()
	var B : Int = scanner.nextInt()
	var K : Int = scanner.nextInt()
	scanner.close()
	
	for (i in 1..K) {
		if (i % 2 == 1) {
			A = (A / 2)
			B += A
		} else {
			B = (B / 2)
			A += B
		}
	}
	println("$A $B")
}

Measured memory_bytes: 31124
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m;

void solve(){
    cin >> n >> m;
    int ans=n*(n-1)/2+m*(m-1)/2;
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

long long x, k, d, mk, t;

int main() {
	cin>>x>>k>>d; x = abs(x);
	mk = x/d+1;
	if (k <= mk) {
		cout<<abs(x-k*d)<<endl;
	} else {
		k -= mk, t = abs(x-mk*d);
		if (k%2==0) cout<<t<<endl;
		else cout<<abs(d-t)<<endl;
	}
}

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

int main() 
{
	long long int n,k,i;
	cin >> n>>k;
	long long int h[n],dp[n];
	for(i=0;i<n;i++)
	cin >> h[i];
	for(i=0;i<n;i++)
	dp[i]=INT_MAX;
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		for(int j=i+1;j<min(i+k+1,n);j++)
		dp[j]=min(dp[i]+abs(h[i]-h[j]),dp[j]);
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A

#include <iostream>

using namespace std;

int main () {
	int w = 0, h = 0;
	while (cin >> h >> w && (h != 0 && w != 0)) {
		for (int i = 0; i < h; i ++) {
			for (int i = 0; i < w; i++) cout << "#";
			cout << endl;
		}
		cout << endl;
	}
		
	return 0;
}
		
			


Measured memory_bytes: 3092
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/
#include<bits/stdc++.h>
using namespace std;
void    		print(int n)    {printf("%d ", n);}
void    		printl(long long n)     {printf("%I64d ", n);}
long long    	readline(){long long x;scanf("%I64d", &x);return x;}
/*
1.#define  gcd(a,b) __gcd(a,b) 2. #define  lcm(a,b) (a*b)/gcd(a,b) 3. #define  PI acos(-1.0) 4.#define  sqr(x) ((x)*(x))
5.#define  min3(a,b,c) min(a,min(b,c))6.#define  min4(a,b,c,d) min(d,min(a,min(b,c)))7.#define  max3(a,b,c) max(a,max(b,c))
8.#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
*/
//.............ignore it................//
/*....... scanf.......*/
template <typename T> inline void readline(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';n = n * f;}
template <typename T, typename TT> inline void readline(T &n, TT &m) { readline(n); readline(m); }
template <typename T, typename TT, typename TTT> inline void readline(T &n, TT &m, TTT &l) { readline(n, m); readline(l);}
/*..........error........*/
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {
  vector<string>v; stringstream ss(s); string x;
  while (getline(ss, x, c))v.emplace_back(x); return move(v);
} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}
//............ignore it..................//
typedef   pair<int, int> ii;
typedef   std::vector<ii> vii;
#define   vi   std::vector<int>
#define   vll  std::vector<ll>
#define   all(n) n.begin(),n.end()
#define  mpsi std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  nl                     printf("\n");
#define  happy          cin.tie(0);
#define  coding         ios::sync_with_stdio(false);
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)2e18 + 5;
const int N             = 500 + 5;
const int N1            = 3e5 + 5;
int visit[N][N];
string s[505];

int solve()
{
	//happy coding
    string s;
    cin>>s;
    sort(s.begin(),s.end());
	if(s[0]!=s[2]){
        cout<<"Yes"<<endl;
	}else{
        cout<<"No"<<endl;
	}
    //error()
	return 0;
}

int main(){
	int test = 1, tc = 0;
	//scanf("%d", &test);//(void)getchar();
	while (test--)solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
int n,a[100004],b[100004],c[100004];
ll f[100004],g[100004];
inline bool dex(int x,int y){return x>y;}
int LiangJiaJun(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    sort(a+1,a+n+1,dex);
    sort(b+1,b+n+1,dex);
    sort(c+1,c+n+1,dex);
    int lp=0;
    for(int i=1;i<=n;i++){
        while(b[i]<c[lp+1])++lp;
        f[i]=lp;
    }
    lp=0;
    g[0]=0;
    ll ans=0;
    for(int i=1;i<=n;i++)g[i]=g[i-1]+f[i];
    for(int i=1;i<=n;i++){
        while(a[i]<b[lp+1])++lp;
        ans+=g[lp];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt(),m=s.nextInt(); s.nextLine();
       int[][] arr=new int[n+1][m+1];
       for(int i=1;i<=n;i++){
        char[] r=s.nextLine().toCharArray();
        for(int j=1;j<=m;j++){
          if(r[j-1]=='#'){arr[i][j]=-1;}
        }
       }
       long mod=(long)1e9+7;
       long[][] dp=new long[n+1][m+1];

       for(int i=1;i<=m;i++){
        if(arr[1][i]==-1){break;}
        dp[1][i]=1;
       }
       for(int i=1;i<=n;i++){
        if(arr[i][1]==-1){break;}
        dp[i][1]=1;
       }

       for(int i=2;i<=n;i++){
        for(int j=2;j<=m;j++){
          if(arr[i-1][j]!=-1){
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
          }
          if(arr[i][j-1]!=-1){
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
          }

        }
       }

       System.out.println(dp[n][m]%mod);
        }
    }


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

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

  if((n[0]==n[1] && n[1]==n[2]) || n[1]==n[2] && n[2]==n[3])
    cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main() {
  string[] b_type = [ "A", "B", "AB", "O" ];
  int[string] b_counter;
  foreach (b; b_type) {
    b_counter[b] = 0;
  }

  foreach (string line; stdin.lines) {
    string b = line.chomp.split(",")[1];
    b_counter[b]++;
  }

  foreach (b; b_type) {
    b_counter[b].writeln;
  }
}

Measured memory_bytes: 1052
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    cout<<y[0]+y[1];
    return 0;
}


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

int64_t comb(int64_t n, int k)
{
	int64_t bunshi = 1;
	int64_t bunbo = 1;
	for (int64_t i = 0; i < k; i++) {
		bunshi *= n - i;
		bunbo *= i + 1;
	}
	return bunshi / bunbo;
}

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		vector<char> s_in(10);
		for (int j = 0; j < 10; j++) {
			cin >> s_in.at(j);
		}
		sort(s_in.begin(), s_in.end());
		string s_i = "";
		for (int j = 0; j < 10; j++) {
			s_i += s_in.at(j);
		}
		s.at(i) = s_i;
	}

	sort(s.begin(), s.end());
	int64_t ans = 0;
	int64_t cnt = 1;
	for (int i = 1; i < n; i++) {
		if (s.at(i - 1) == s.at(i)) {
			cnt++;
			if (i != n - 1) {
				continue;
			}
		}
		if (cnt >= 2) {
			ans += comb(cnt, 2);
		}
		cnt = 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7296
# -*- coding: utf-8 -*-

N, A, B = map(int, input().split())

ans = 0

for i in range(1, N+1):
    tmp_l = list(str(i))
    tmp_sum = 0
    for j in tmp_l:
        tmp_sum = tmp_sum + int(j)
    if A <= tmp_sum <= B:
        ans = ans + i

print(ans)

Measured memory_bytes: 9128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int N, A;
int x[50];
ll dp[51][5001];
const int g = 2500;

ll dfs(int a, ll s) {
	if (a >= N) return (s == 0 ? 1 : 0);
	return dfs(a + 1, s) + dfs(a + 1, s + x[a]);
}

int main(int argc, char **argv) {
	cin >> N >> A;
	REP(i, N) cin >> x[i];
	REP(i, N) x[i] -= A;
	CLEAR(dp);
	dp[0][g] = 1;
	REP(i, N) REP(j, 5001) {
		dp[i + 1][j] = (j - x[i] >= 0 ? dp[i][j - x[i]] : 0) + dp[i][j];
	}
	cout << (dp[N][g] - 1) << endl;
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, a[maxn];
int ans[maxn];
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  for (int i=1; i<=n; i++) {
    cin>>a[i];
  }

  for (int i=n; i>=1; i--) {
    int x=0;
    for (int j=i+i; j<=n; j+=i) {
      x += ans[j];
      x %= 2;
    }
    ans[i] = (x!=a[i]);
  }

  vector<int> v;
  for (int i=1; i<=n; i++) {
    if (ans[i]) {
      v.push_back(i);
    }
  }

  cout<<v.size()<<endl;
  if (v.size()) {
    for (int x: v) cout<<x<<" ";
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 6520
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
 int n;
   cin >> n;
  
  vector<long> s(n+1,0);
  long a;
   for(int i=1;i<=n;i++){
    cin >> a;
     s[i]=a+s[i-1];
   }
  
   sort(s.begin(),s.end());

    
  long res=0;
  long cnt=1;
  for(int i=1;i<=n;i++){
   if(s[i]==s[i-1]){ cnt++;
                   }
   else{ res+=cnt*(cnt-1)/2;
         cnt=1;
   }  
  }
  
  res+=cnt*(cnt-1)/2;
  
  
  cout << res << endl;

}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int ave_i,k[101],sum=0;
  double ave_d=0.0,t;
  cin >> t;
  for(int i = 0;i<(int)t;i++){
    cin >> k[i];
    ave_d+=k[i]/t;
  }
  if((int)(ave_d*10)%10 < 5){
    ave_i=(int)ave_d/1;
  }else{
    ave_i=1+(int)ave_d/1;
  }
  for(int i=0;i<(int)t;i++){
    sum+=(k[i]-ave_i)*(k[i]-ave_i);
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t K, N, answer;
  answer=K;
  vector<int64_t> vec(N+1);
  cin >> K >> N;
  for(int i=1;i<N+1;i++){
    cin >> vec.at(i);
  }
  for(int i=1;i<N+1;i++){
    int64_t A;
    if(i==1){
      A=vec.at(N)-vec.at(1);
    }
    else{
      A=K+vec.at(i-1)-vec.at(i);
    }
    answer=min(answer, A);
  }
  cout << answer << endl;
}
      
    
    
    
  
  

Measured memory_bytes: 33024
/*
                    Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
            
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }     
signed main()
{   jaldi
    int n;
    cin>>n;
    int d=n;
    if(n%2!=0)
    cout<<0;
    else
    {   int x,y=0,z=0,count=0;
        x=n;
        while(x)
        {   count++;
            x/=10;
        }
        count++;
        y=power(10,count);
        n=n-y;
        if(n==0)
        {   for(int i=1;i<count;i++)
            cout<<1;
        }
        else
        {   for(int i=10;i<=d;i*=5)
            z=z+(d/i);
            cout<<z;
        }
    }
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

const int N = 1005;

vi adj[N], ans;
int vis[N], par[N];

void dfs(int nd, int p, int st){
    vis[nd] = 1;
    par[nd] = p;

    for(auto ch : adj[nd]){
        if(ch == st){
            int curr = nd;
            vi temp;
            temp.pb(curr);
            while(curr != ch){
                curr = par[curr];
                temp.pb(curr);
            }

            if(sz(temp) < sz(ans)) ans = temp;
            return;
        }
        if(!vis[ch]) dfs(ch, nd, st);
    }
}

int main(){
    fIO

    int n, m;
    cin >> n >> m;

    int x, y;
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        adj[x].pb(y);
    }

    ans.resize(N);
    for(int i = 1; i <= n; i++){
        memset(vis, 0, sizeof(vis));
        memset(par, 0, sizeof(par));
        dfs(i, i, i);
    }
    if(sz(ans) == N) cout << -1;
    else{
        cout << sz(ans) << "\n";
        for(auto it : ans) cout << it << "\n";
    }
}








Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int const SIZ = 10001;

bitset<SIZ> sieve;
vector<int> primes;

void prepare() {
    primes.push_back(2);
    sieve.set();
    sieve.set(0, 0);
    sieve.set(1, 0);
    for (int i=4; i<SIZ; i+=2) {
        sieve.set(i, 0);
    }
    for (int i=3; i<SIZ; i+=2) {
        if ( ! sieve[i]) continue;
        primes.push_back(i);
        for (int j=2; i*j<SIZ; ++j) {
            sieve.set(i*j, 0);
        }
    }
}

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

    int n;
    cin >> n;

    prepare();

    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<n; ++i) {
        cin >> m;
        if (checked[m]) continue;
        if (m < SIZ && sieve[m]) {
            ++ ans;
            checked[m] = 1;
            continue;
        }
        bool isprime = true;
        for (int i=0; i<(int)primes.size(); ++i) {
            if (m % primes[i] == 0) {
                isprime = false;
                break;
            }
        }
        if (isprime) {
            ++ ans;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1528