akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<cassert>
using namespace std;
#define MAX 3
#define MAX2 9

struct Puzzle{
  int f[MAX2];
  int space;
  string path;

  bool operator < ( const Puzzle &p ) const{
    for ( int i = 0; i < MAX2; i++ ){
      if ( f[i] == p.f[i] ) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
char dir[4] = {'u', 'l', 'd', 'r'};

bool trush(Puzzle);
string bfs(Puzzle);

int main(){
  Puzzle in;
  int i;
  for (i=0;i<MAX2;i++){
    cin >> in.f[i];
    if ( in.f[i] == 0 ) {
      in.f[i] = MAX2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}
bool trush(Puzzle p){
  for ( int i = 0; i < MAX2; i++ )
    if ( p.f[i] != (i + 1) ) return false;
  return true;
}

string bfs(Puzzle s){
  int sx,sy,r,tx,ty;
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;
  
  while( !Q.empty() ){
    u = Q.front(); Q.pop();
    if ( trush(u) ) return u.path;
    sx = u.space/MAX;
    sy = u.space%MAX;
    for ( r = 0; r < 4; r++ ){
      tx = sx + dx[r];
      ty = sy + dy[r];
      if ( tx < 0 || ty < 0 || tx >= MAX || ty >= MAX ) continue;
      v = u;
      swap(v.f[u.space], v.f[tx*MAX+ty]);
      v.space = tx*MAX+ty;
      if ( !V[v] ){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  return "unsolvable";
}



Measured memory_bytes: 30596
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		GetResult(N);
	}
	
	static void GetResult(int n){
	    var input = Console.ReadLine().Split(' ');
	    var i = 0;
	    var result = "APPROVED";
	    for(; i < n; i++){
	        var num = int.Parse(input[i]);
	        if(num % 2 == 0 && num % 3 != 0 && num % 5 != 0)
	            break;
	    }
	    if(i != n) result = "DENIED";
	    
	    Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, i, w=1;
    double ans=0;
    vector<pair<int, int>> p(10);
    cin >> n;
    vector<int > tmp(n);
    for(i=0;i<n;i++){
        int a, b;
        cin >> a  >> b;
        p[i]=make_pair(a, b);
    }
    for(i=0;i<n;i++){
        tmp[i]=i;
        w=w*(i+1);
    }
    do{
    for(int x=0;x<n-1;x++){
        ans=ans+sqrt((p[tmp[x]].first-p[tmp[x+1]].first)*(p[tmp[x]].first-p[tmp[x+1]].first)
        +(p[tmp[x]].second-p[tmp[x+1]].second)*(p[tmp[x]].second-p[tmp[x+1]].second));
    }
    }while(next_permutation(tmp.begin(), tmp.end()));
    ans=ans/w;
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= (i+1);
    }

    sort(A.begin(), A.end());

    int cho = A.size()%2 == 0 ? (A[A.size()/2] + A[A.size()/2-1])/2 : A[A.size()/2];
    long long sum = 0;
    long long sum2 = 0;

    for (int i = 0; i < N; ++i) {
        sum += abs(cho - A[i]);
    }

    for (int i = 0; i < N; ++i) {
        sum2 += abs(cho+1 - A[i]);
    }

    cout << min(sum, sum2) << endl;

    return 0;
}

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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    long long h, n;

    cin >> h >> n;

    int a[n];
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    if (h <= sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e16;
using namespace std;
using ll = long long;

int main(void)
{
    ll X, K, D;
    cin >> X >> K >> D;

    if(X < 0){
        X = -X;
    }

    ll mv = X/D;

    ll A = X - mv * D;
    ll k = K - mv;

    if(k <= 0){
        cout << X - K*D << endl;
        return 0;
    }

    if(k%2 == 0){
        cout << A << endl;
    } else {
        cout << abs(A-D) << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        set<int> taro;
        for(int i=0; i<N; i++){
            int a;
            cin >> a;
            taro.insert(a);
        }
        set<int> hanako;
        for(int i=1; i<=2*N; i++){
            if(!taro.count(i)){
                hanako.insert(i);
            }
        }
        bool fst = true;
        int now = 0;
        while(1){
            bool did = false;
            if(fst){
                for(auto s: taro){
                    if(now <= s){
                        now = s;
                        taro.erase(s);
                        did = true;
                        break;
                    }
                }
                if(taro.size() == 0) break;
                if(!did) now = 0;
                fst = false;
            }else{
                for(auto s: hanako){
                    if(now <= s){
                        hanako.erase(s);
                        now = s;
                        did = true;
                        break;
                    }
                }
                if(hanako.size() == 0) break;
                if(!did) now = 0;
                fst = true;
            }
        }
        cout << hanako.size() << enld;
        cout << taro.size() << enld;
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3068
n = int(input())
hs = [int(x) for x in input().split()]

ans = 0
mh = max(hs)
for cur in range(1, mh + 1):
    c = False
    for h in hs:
        if cur <= h:
            if c:
                continue
            else:
                c = True
                ans += 1
        else:
            c = False
print(ans)

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

#define int long long

const int N = 1e5 + 10;
int n, m, ans, mark[N], cnt[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	mark[0] = 1;
	fill(cnt, cnt + n, 1);
	
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cnt[x]--; cnt[y]++;
		
		if (mark[x]) {
			if (!cnt[x])
				mark[x] = 0;
			mark[y] = 1;
		}
	}
	
	for (int i = 0; i < n; i++)
		ans += mark[i];
	cout << ans << endl;
}

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

int main(){
    long long int H,i=0,result=0;
    cin >> H;
    while(1){
        i++;
        result += pow(2.0,i-1);        
        long double memo,temp;
        temp = H / 2.0;
        memo = floor(temp);
        H = memo;
        // cout << memo;
        if(temp < 1.0) {
            cout << result;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    cout<<((n%2==0)?n:n*2);
  	return 0;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n;
  int a, b;

  scanf("%d",&n);

  int mx = 0;
  int mn = 1000000010;
  REP (i, n) {
    scanf("%d %d",&a, &b);
    if (mx < a) {
      mx = a;
      mn = b;
    }
  }
  printf("%d\n",mx + mn);
}


Measured memory_bytes: 256
input()
arr = list(map(int, input().split()))
def beki(a):
	beki_count = 0
	for i in range(a):
		if a % 2 == 0:
			a /= 2
			beki_count += 1
		else:
			break
	return beki_count
beki_arr = []
for i in range(len(arr)):
	beki_arr.append(beki(arr[i]))
print(min(beki_arr))

Measured memory_bytes: 3060
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

const n: number = input.split('\n')[0]
const s: string = input.split('\n')[1]
let max = 0
let x = 0
for (let i = 0; i < s.length; i++) {
  if (s[i] === "I") {
    x += 1
  }
  else {
    x -= 1
  }
  if (x > max) {
    max = x
  }
}
console.log(max)

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define N 500005
#define int long long
using namespace std;
map<int,int>mp;
int n,ans,a[N],b[N],c[N];
inline int sqr(int x){return x*x;}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++){
		int xb=a[i];
		for (int j=2;j*j*j<=a[i];j++){
			if (xb%(j*j*j)) continue;
			while (!(xb%(j*j*j))) xb=xb/(j*j*j);
		}
		mp[xb]++;
		b[i]=xb;
		int mul=1;int tmp=xb;
		for (int j=2;j*j*j<=tmp;j++){
			if (xb%j==0){
				if (xb%(j*j)==0){
					xb=xb/j;xb=xb/j;
					mul=mul*j;
				}
				else mul*=j*j,xb=xb/j;
			}
		}
		if (sqr(sqrt(xb))==xb) mul*=sqrt(xb);
		else mul*=xb*xb;
		c[i]=mul;
	}
	///for (int i=1;i<=n;i++) printf("%d %d\n",b[i],c[i]);return 0;
	if (mp[1]) ans++,mp[1]=0;
	for (int i=1;i<=n;i++) ans=ans+max(mp[b[i]],mp[c[i]]),mp[b[i]]=mp[c[i]]=0;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 21760
#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 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    ll N;cin>>N;
    ll a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    ll f = min({a,b,c,d,e});
    ll ans = 5+(N-1)/f;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <climits>
#include <algorithm>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int N, M;
int x, y;

bool prob[101010];
int cnt[101010];

signed main()
{
    cin >> N >> M;
    prob[0] = true;
    for (int i=1; i<N; i++) prob[i] = false;
    REP(i,N) cnt[i] = 1;

    REP(i,M) {
        cin >> x >> y;
        x--; y--;
        cnt[y]++;
        if (prob[x]) prob[y] = true;
        cnt[x]--;
        if (cnt[x] == 0) prob[x] = false;
    }

    int ans = 0;
    REP(i,N) if (prob[i]) ans++;

    cout << ans << endl;
}


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

// a x + b y = gcd(a, b)
int extgcd(int a, int b, int& x, int& y) {
    int g = a; x = 1; y = 0;
    if (b > 0) {
        g = extgcd(b, a % b, y, x);
        y -= a / b * x;
    }
    return g;
}

int main() {
    int T;
    scanf("%d", &T);
    for (int _ = 0; _ < T; ++_) {
        int x, y, p, q;
        scanf("%d%d", &x, &y);
        int g = extgcd(x, y, p, q);
        if (g < 49995)
            printf("3\n0 0\n%d %d\n%d %d\n", abs(q), abs(p), x, y);
        else
            printf("4\n0 0\n%d %d\n%d %d\n%d %d\n", x, y - 1, x / g, y / g, x - 1, y);
    }
    return 0;
}



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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

int main() {
	int x, y;
	cin >> x >> y;

	string ans = "No";
	if (y % 2 != 0) {
		cout << ans << endl;
		return 0;
	}
	rep(i, 100) {
		rep(j, 100) {
			if ((i + j == x) and (2*i + 4*j == y)) ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>


long long int calculate_sum(const std::vector<int>& digits, int pattern) {
	long long int sum{ 0 };
	long long int acc{ 0 };
	for (auto i = 0; i < digits.size(); ++i) {
		if ((pattern & 1) == 1) {
			sum += acc * 10 + digits[i];
			acc = 0;
		}
		else {
			acc *= 10;
			acc += digits[i];
		}
		pattern >>= 1;
	}
	return sum + acc;
}

int main() {
	std::string str; std::cin >> str;
	std::vector<int> digits;
	for (const auto c : str) digits.push_back(c - '0');
	long long int sum{ 0 };
	for (auto i = 0; i < (1 << (str.size() - 1)); ++i) {
		sum += calculate_sum(digits, i);
	}
	std::cout << sum << '\n';
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var ans = (int)Math.Ceiling((B - 1) / (A - 1));

        WriteLine(ans);
    }
}


Measured memory_bytes: 28104
n,h = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
a_max = 0
b = []
for i in range(0,n):
    if (a_max < x[i][0]):
        a_max = x[i][0]
for i in range(0,n):
    b.append(x[i][1])
b.sort()
b.reverse()
b.append(0)
d = 0
count = 0
k = 0
while (d < h):
    if (b[k] > a_max):
        d += b[k]
        count += 1
        k += 1
    else:
        if ((h-d)%a_max==0):
            count = count + (h-d)//a_max
        else:        
            count = count + (h-d)//a_max + 1
        break
print(count)

Measured memory_bytes: 28588
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <stack>
#include <list>
#include <vector>

using namespace std;
int A,B,C;
int N;
int resA[101];
int resB[101];
int resC[101];

struct Check{
  int a,b,c,r;
} check[1000];

void errorCheck(int i){
  if(resA[check[i].a-1] == 1 &&
     resB[check[i].b-A-1] == 1 &&
     resC[check[i].c-A-B-1] != 1)
     resC[check[i].c-A-B-1] = 0;
     
  if(resA[check[i].a-1] == 1 &&
     resB[check[i].b-A-1] != 1 &&
     resC[check[i].c-A-B-1] == 1)
     resB[check[i].b-A-1] = 0;
     
  if(resA[check[i].a-1] != 1 &&
     resB[check[i].b-A-1] == 1 &&
     resC[check[i].c-A-B-1] == 1)
     resA[check[i].a-1] = 0;
}

int main(){
  while(cin >> A >> B >> C && (A | B | C)){
    cin >> N;
    for(int i=0;i<A; ++i) resA[i] = 2;
    for(int i=0;i<B; ++i) resB[i] = 2;
    for(int i=0;i<C; ++i) resC[i] = 2;
    for(int i=0; i<N; ++i){
      cin >> check[i].a >> check[i].b >> check[i].c >> check[i].r;
      if(check[i].r == 1){
        resA[check[i].a-1] = 1;
        resB[check[i].b-A-1] = 1;
        resC[check[i].c-A-B-1] = 1;
      }
    }
    for(int i=0; i<N; ++i){
      if(check[i].r == 0) errorCheck(i);
    }
    
    for(int i=0;i<A; ++i) cout << resA[i] << endl;
    for(int i=0;i<B; ++i) cout << resB[i] << endl;
    for(int i=0;i<C; ++i) cout << resC[i] << endl;
  }
  return 0;
}

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

int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	
	if(n<=k){
		cout<<n*x<<endl;
	}else{
		cout<<(k*x)+((n-k)*y)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)

typedef long long ll;

using namespace std;

int N, Q;
char s[100005];
int dp[100005];

int query(int l, int r) {
  
  int ans = dp[r] - dp[l];
  
  return ans;

}

int main(void) {
    scanf("%d %d %s", &N, &Q, s);
    
    dp[0] = 0;
    REP(i, 1, N) {
      if ( s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i - 1] + 1;
      else dp[i] = dp[i - 1];
      
    }
    
    REP(i, 0, Q) {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%d\n", query(l-1, r-1));
    }

	return 0;
}


Measured memory_bytes: 1280
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);
    if(A[0] == n - 1){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0] + 1 < A[n-1]){
        cout << "No" << endl;
        return 0;
    }

    int num = A[n-1];
    int cnt = 0;
    int id = n;
    REP(i,n){
        if(A[i] == num){
            id = i;
            break;
        }
        cnt ++;
    }
    if(id == n- 1){
        cout << "No" << endl;
        return 0;
    }
    if(cnt == num and id != n){
        cout << "No" << endl;
        return 0;
    }
    while(cnt < num){
        if(id + 1 >= n) break;
        cnt ++;
        id += 2;
    }

    if(cnt != num) cout <<"No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> b(n - 1);
    for (Int i = 0; i < n - 1; i++) cin >> b[i];
    vector<Int> res(n, INF);
    for (Int i = 0; i < n - 1; i++) {
        res[i] = min(b[i], res[i]);
        res[i + 1] = b[i];
    }
    Int cnt = 0;
    for (Int i = 0; i < n; i++) cnt += res[i];
    dump(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, k, s = 0;
  cin >> n >> k;
  ++n;
  v1li v(n+1); v[0] = 0;
  rep(i, n) v[i+1] = v[i] + i+1;
  for(int i = k; i <= n; ++i){
    s += v[n]-v[n-i]-v[i]+1;
    s %= mod1;
  }
  cout << s << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i=0; i<n; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  int num = 1;
  for (int i=1; i<n; i++)
    if (d.at(i-1) < d.at(i))
        num++;
  cout << num << endl;
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,y,i;
    cin>>x>>y;
    if(x==y){
        cout<<"Draw";
    }
    else if(x==1){
        cout<<"Alice";
    }
    else if(y==1)
        cout<<"Bob";
    else if(x>y)
         cout<<"Alice";
    else 
        cout<<"Bob";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int w,h;
int sx,sy;

void solve(){
    vector<string> t(h);
    rep(i,h) cin >> t[i];

    rep(i,h) rep(j,w) if(t[i][j]=='@'){
        sx = i;
        sy = j;
        break;
    }

    bool visited[32][32];
    rep(i,32) rep(j,32) visited[i][j]=false;
    visited[sx][sy]=true;
    queue<pii> que;
    que.push(pii(sx,sy));
    while(!que.empty()){
        auto p = que.front();
        que.pop();

        int x = p.fi;
        int y = p.se;

        rep(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 or ny<0 or nx>=h or ny>=w) continue;
            if(t[nx][ny]=='#') continue;
            if(visited[nx][ny]) continue;

            visited[nx][ny] = true;
            que.push(pii(nx,ny));
        }
    }

    int ans = 0;
    rep(i,h) rep(j,w) if(visited[i][j]) ans++;
    cout << ans << endl;
}

int main(){
    while(1){
        cin >> w >> h;
        if(w==0 and h==0) break;
        solve();
    }
}

Measured memory_bytes: 3032
#include <bits/extc++.h>
using namespace std;
using i64=int64_t;

struct union_find
{
    union_find(const size_t n = 0) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        return link[x] < 0 ? x : (link[x] = find(link[x]));
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        x = find(x), y = find(y);
        if(x == y) return false;
        if(link[x] > link[y]) std::swap(x, y);
        link[x] += link[y];
        link[y] = x;
        return true;
    }

protected:
    std::vector<int> link;
}; // class union_find


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

    int n; cin>>n;
    bool chkd[1<<20]={};
    bool pw=1;
    bool sw=1;
    int cnt[1<<20]={};
    for(int i=0; i<n; ++i)
    {
        int a; cin>>a;
        cnt[a]++;
    }
    for(int d=2; d<1<<20; ++d)
    {
        if(chkd[d])
        {
            continue;
        }
        int sum=0;
        for(int x=d; x<1<<20; x+=d)
        {
            chkd[x]=1;
            sum+=cnt[x];
        }
        if(sum>1) pw=0;
        if(sum==n) sw=0;
    }
    if(pw)
    {
        puts("pairwise coprime");
    }
    else if(sw)
    {
        puts("setwise coprime");
    }
    else
    {
        puts("not coprime");
    }
}


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

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

    multiset<int> num;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        num.insert(a);
    }

    long long int small  = *num.begin();
    long long int large = *prev(num.end());
    num.erase(num.begin());
    num.erase(prev(num.end()));

    long long int ans = large - small;

    while(num.size() >= 2){
        ans += *prev(num.end()) - small;
        ans += large - *num.begin();

        small = *num.begin();
        large = *prev(num.end());

        num.erase(prev(num.end()));
        num.erase(num.begin());
    }
    if(num.empty() == false){
        ans += max(large - *num.begin(), *num.begin() - small);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8260
#include <iostream>
#define int long long
using namespace std;

signed main() {
  int A, B;
  cin >> A >> B;
  
  int a = A;
  int b = B;
  while (a % b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  
  cout << A * B / b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int a=0;

             int H = sc.nextInt();
             for(int i=1;i<=H;i++){
                 if (i%3==0) {
                     System.out.print(" "+i);
                 }else if(i%10==3){
                     System.out.print(" "+i);
                 }else{
                     a=i;
                     while(a>10){
                         a-=a%10;
                         a/=10;
                         if (a%10==3){
                             System.out.print(" "+i);
                             break;
                         }
                     }
                 }
             }

    System.out.println();
    }
}


Measured memory_bytes: 28864
S=reverse(chomp(readline()))
N=length(S)
id=1
while id<=N
	if id+4<=N&&S[id:id+4]=="maerd"
		id+=5
	elseif id+6<=N&&S[id:id+6]=="remaerd"
		id+=7
	elseif id+4<=N&&S[id:id+4]=="esare"
		id+=5
	elseif id+5<=N&&S[id:id+5]=="resare"
		id+=6
	else
		println("NO")
		exit()
	end
end
println("YES")

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

int main(int argc, char const *argv[]) {
    int N;
    int H [30];
    cin >> N;
    for (int i = 0; i < N; i++ ){
        cin >> H[i];
    }
    int count=0;
    int max = 0;
    for (int i = 0; i<N;i++){
        if (max <= H[i]){
                max = H[i];
                count++;
            }
      }
    cout << count << endl;
}

Measured memory_bytes: 256
i = j = 0
n = ''
m = ''


line = input()

while line[i] != ' ':
    n = n + line[i]
    i += 1
    
while i < len(line):
    m = m + line[i]
    i += 1
    
n = int(n)
m = int(m)

print(n*m,end=' ')
print(2*n+2*m)

Measured memory_bytes: 7664
#C
AB = input().split(' ')
A = int(AB[0]) ; B = int(AB[1])
ans = []
for x in range(1,10*(B + 1)):
    p = x * 0.1 - B
    q = x * 0.08 - A
    if (p >= 0) and (p < 1) and (q >= 0) and (q < 1):
        ans.append(x)
        break
if len(ans) == 0:
    print(-1)
else:
    print(ans[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    UF uf(n);
    rep(_, q) {
        int a, x, y;
        cin >> a >> x >> y;
        if(a == 0) uf.unite(x, y);
        else cout << uf.same(x, y) << '\n';
        
    }
    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<math.h>
int main()
{
	int n,m,p,q,max=0;
	scanf("%d%d",&n,&m);
	if(n==1)
	{
		printf("%d\n",m);
		return 0;
	}
	for(int i=1;i<=sqrt(m)+1;i++)
	{
		if(m%i==0)
		{
			if(m/i<=i)
			{
				p=m/i;
				q=i;
			}
			else
			{
				p=i;
				q=m/i;
			}
			if(n<=p)max=q>max?q:max;
			if(n>q)continue;
			else max=p>max?p:max;
		}
	}
	printf("%d\n",max);
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define REP(i,d) for(int i=0;i<(int)(d);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int i,j,n,tmp[28] = {0};
  int alp[28]={500};
  REP(i,26)alp[i]=500;
  char S[51][52];
  REP(i,50){
    REP(j,50)S[i][j] = '\0';
  }
  scanf("%d",&n);
  REP(i,n)scanf("%s",S[i]);
  REP(i,n){
    for(j=0;j<strlen(S[i]);j++){
      tmp[S[i][j]-'a']++;
      
    }
    REP(j,26){
      alp[j] = min(alp[j],tmp[j]);
    }
    REP(j,26){
      tmp[j] = 0;
    }
  }
  REP(i,26){
    REP(j,alp[i]){
        printf("%c",'a'+i);
        }
  }
  printf("\n");
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> is_red(n, false);
    is_red[0] = true;
    vector<int> num(n, 1);
    int x, y;
    for (int i = 0; i < m; i++){
        cin >> x >> y;
        x--; y--;
        if (is_red[x]){
            if (num[x] == 1){
                is_red[x] = false;
                is_red[y] = true;
            }
            else {
                is_red[y] = true;
            }
        }
        num[x]--;
        num[y]++;
    }
    cout << accumulate(is_red.begin(), is_red.end(), 0LL) << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<int, int>;

long long N;
long long d[300][300];
long long b[300][300];
long long dist[300][300] = {0}; 

int main() {
  cin >> N;

  for(long long i  =0; i < N; i++) {
    for(long long j = 0; j < N; j++) {
      cin >> d[i][j];
    }
  }
  for(long long i  =0; i < N; i++) {
    for(long long j = 0; j < N; j++) {
      b[i][j] = d[i][j];
    }
  }

  for(long long k = 0; k < N; k++) {
    for(long long i = 0; i < N; i++) {
      for(long long j = 0; j < N; j++) {
        b[i][j] = min(b[i][j], d[i][k] + d[k][j]);
        }
      }
    }

  bool f = false;
  for(long long i = 0; i < N; i++) {
    for(long long j = 0; j < N; j++) {
      if(b[i][j] < d[i][j]) {
        f = true;
      }
    }
  }
  if(f) {
    cout << -1 << endl;
    return 0;
  }

  long long ans = 0;
  bool flag[300][300];
  rep(i, N) {
    rep(j, N) {
      flag[i][j] = false;
    }
  }

  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
        if(k != i && k != j && b[i][j] == b[i][k] + b[k][j]) {
          flag[i][j] = true;
        }
      }
    }
  }

  rep(i, N) {
    rep(j, N) {
      if(flag[i][j] == false) ans += b[i][j];
    }
  }
  cout << ans / 2 << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int h,m,s;
	int st=7200,thi=21600;

	while(cin>>h>>m>>s,h!=-1)
	{
		st=7200;
		int ss=h*3600+m*60+s;
		st=st-ss; thi=st*3;

		printf("%02d:%02d:%02d\n",st/3600,st%3600/60,st%3600%60);
		printf("%02d:%02d:%02d\n",thi/3600,thi%3600/60,thi%3600%60);
	}
  return 0;
}

Measured memory_bytes: 1160
<?php
$a = trim(fgets(STDIN));
$L0=2;
$L1=1;
$ans=0;
if($a==1){
echo 1;
}else{
for($i=0;$i<$a-1;$i++){
$ans=$L0+$L1;
$L0=$L1;
$L1=$ans;
}

echo $ans;
}

Measured memory_bytes: 3700
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath> 
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f3f 
#define mem(a) (memset(a,0,sizeof(a))) 
typedef long long ll;
vector<int>v[200006];
int n,m,x,y,vis[200006];
bool flag;
void bfs(int x,int y,int k)
{
    if(x==y && k<=2)
    {
        printf("POSSIBLE\n");
        flag=true;
        return;
    }
    if(k>2) return;
    vis[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        if(!vis[v[x][i]])
        {
            vis[v[x][i]]=1;
            bfs(v[x][i],y,k+1);
            vis[v[x][i]]=0;
        }
    }
    vis[x]=0;
}
int main()
{
    scanf("%d%d",&n,&m);
    flag=false;
    memset(vis,0,sizeof(vis));
    while(m--)
    {
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    bfs(1,n,0);
    if(!flag) printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 12784
import java.util.Scanner;

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

		String str = sc.next();
		String[] array = str.split("");

		String before = "";
		int smcount = 0;
		int grcount = 0;
		long ans = 0;

		for (int i = 0; i < array.length; i++) {

			String tmp = array[i];

			if (tmp.equals("<")) {
				if (before.equals(tmp)) {
					smcount++;
				} else {
					long sum = getArraySum(grcount, smcount);
					ans = ans + sum;
					smcount = 1;
					grcount = 0;
				}

			} else {
				if (before.equals(tmp)) {
					grcount++;
				} else {
					grcount = 1;
				}
			}
			before = array[i];
		}
		long sum = getArraySum(grcount, smcount);
		ans = ans + sum;
		System.out.println(ans);

	}

	private static long getArraySum(int a, int b) {
		long large = a > b ? a : b;
		long small = a < b ? a : b;

		small--;

		long lsum = large * (large + 1) / 2;
		long ssum = small * (small + 1) / 2;

		long sum = lsum + ssum;

		return sum;

	}

}


Measured memory_bytes: 68588
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, A, B;
  scanln(N, A, B);
  writeln(N.floor(A + B) * A + min(N%(A + B), A));
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
n = int(input())
xxx = list(map(int, input().split()))
sort_xxx = sorted(xxx)
median = sort_xxx[n // 2 - 1]
for i in range(n):
    if xxx[i] <= median:
        ans = sort_xxx[n // 2]
    else:
        ans = sort_xxx[n // 2 - 1]
    print(ans)

Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[51][51][2501];
int n, A;
ll a[51];
ll go(int x, ll y, ll z) {
	if (x == n) {
		if (y > 0 && A * y == z)return 1;
		else return 0;
	}
	ll &ret = d[x][y][z];
	if (ret != -1)return d[x][y][z]; 
	ret = go(x + 1, y, z);
	ret += go(x + 1, y + 1, z + a[x]);
	return ret;
}
int main() {
	// 코틀린 ,문자열 알고리즘 보기, 앳코더, (시간되면 코드포스까지)
	ios_base::sync_with_stdio(false); cin.tie(NULL); //9 90 900 
	cin >> n >> A;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	memset(d, -1, sizeof(d));
	cout << go(0, 0, 0) << '\n';



}

Measured memory_bytes: 51072
#include <stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  if((N%10==2)||(N%10==4)||(N%10==5)||(N%10==7)||(N%10==9)){
    printf("hon\n");}
  if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8)){
        printf("pon\n");}
  if(N%10==3){
    printf("bon\n");}
  return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int showAll(vector<string> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i];
  }
  cout << endl;
  return 0;
}

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> v;
  string str;
  rep (i, n) {
    cin >> str;
    v.push_back(str);
  }
  sort(v.begin(), v.end()); // 昇順ソート
  showAll(v);

  return 0;
}

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

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

    long long i,j,k,l,m,n,o,p,q;

   while(cin>>n){
    if(n<30)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
   }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  vector<int> bus(C);
  rep(i, N){
    cin >> T[i];
  }
  sort(T.begin(), T.end());

  int i = 0;
  int cnt = 0;
  int cap = 0;
  int limit = -101010;
  rep(i, N){
    if(cap >= C || T[i] > limit){
      cnt++;
      limit = T[i] + K;
      cap = 0;
    }
    cap++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 896
//https://atcoder.jp/contests/abc118/tasks/abc118_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


using B=bitset<32>;
int main(){
    int N,M;
    cin>>N>>M;
    B ret(-1);
    for(int i:range(N)){
        int K;
        cin>>K;
        B in(0);
        for(int j:range(K)){
            int a;
            cin>>a;
            in[a-1]=true;
        }
        ret=ret&in;
        //cerr<<ret.to_string()<<endl;
    }
    cout<<ret.count()<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, t = map(int, input().split())
    a = list(map(int, input().split()))

    # min_l[i]: i番目以前の最小値
    min_l = [a[0]]
    for i in range(1, n):
        if min_l[-1] < a[i]:
            min_l.append(min_l[-1])
        elif min_l[-1] == a[i]:
            min_l.append(min_l[-1])
        else:
            min_l.append(a[i])

    # max_l[i]: i番目以降の最大値
    max_l = [0] * n
    max_l[n-1] = a[n-1]
    for i in range(n-2, -1, -1):
        if max_l[i+1] < a[i]:
            max_l[i] = a[i]
        else:
            max_l[i] = max_l[i+1]

    profit = []
    for i in range(n-1):
        profit.append(max_l[i+1] - min_l[i])

    max_profit = profit[0]
    for i in range(1, n-1):
        if max_profit < profit[i]:
            max_profit = profit[i]
    
    ans = 0
    for i in range(n-1):
        if max_l[i+1] - a[i] == max_profit:
            ans += 1
    print(ans)

main()

Measured memory_bytes: 97868
fun main(args: Array<String>) {
    val s = readLine()!!
    val map = mutableMapOf<Char, Int>()
    s.forEach {
        if (map.containsKey(it)) {
            map[it] = map[it]!! + 1
        } else {
            map[it] = 1
        }
    }
    if (map.size == 2 && map.all { it.value == 2 }) {
        println("Yes")

    } else {
        println("No")
    }
}

Measured memory_bytes: 33672
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
       

int main(){
  ll x;
  cin >> x;
  ll c1=x/500;
  ll c2=(x-c1*500)/5;
  cout << 1000*c1+c2*5 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N, M, X;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &X);
  std::vector<int > C(N);
  int A[15][15];
  for (int i=0; i<N; i++){
    scanf("%d", &C[i]);
    for (int j=0; j<M; j++){
      scanf("%d", &A[i][j]);
    }
  }
  int money_max=1000000000;
  int algo[15];
  int money;
  for (int i=0; i<(1<<N); i++){
    //printf("i=%d\n", i);
    // 初期化
    for (int j=0; j<M; j++){
      algo[j]=0;
    }
    money=0;
    for (int j=0; j<N; j++){
      if ((i&(1<<j))!=0){
        //printf("buy %d\n", j);
        // j番目の本を買う
        money+=C[j];
        for (int k=0; k<M; k++){
          algo[k]+=A[j][k];
        }
      }
    }
    // 判定
    bool ok = true;
    for (int k=0; k<M; k++){
      //printf("algo[%d]=%d\n", k, algo[k]);
      if (algo[k]<X) {
        ok=false;
        break;
      }
    }
    if (ok) {
      //printf("ok\n");
      money_max=std::min(money_max, money);
    }
  }
  if (money_max==1000000000){
    std::cout << "-1" << std::endl; 
  } else {
    std::cout << money_max << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3236
#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,i;

	cin >> n >> i;

	cout << n-i+1 << endl;

	return 0;
}

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

int main(void){
    int i;
    vector<int> x(6);
    for(i=1; i<=5; i++){
        cin >> x.at(i);
        if(i != x.at(i)){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
dic = {}
for i in range(n):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 0

l = sorted(dic.items(), key=lambda x: x[1], reverse=True)
num = l[0][1]
ok = []
for i in range(len(l)):
    if l[i][1] == num:
        ok.append(l[i][0])
    else:
        break
ok.sort()
for i in ok:
    print(i)

Measured memory_bytes: 45788
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;
    int ans=INF;
    cin >> s;
    
    rep(i,s.size()-2){
        int now = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0')*1;
        ans = min(ans,abs(753-now)); 
    }
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3572