akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
using namespace std;

static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// uに隣接するvを番号順に取得
int next(int u){
    for(int v=nt[u]; v<n; v++){ // 訪問した場所は探索しなくていいため、v+1にしている？
        nt[u] = v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r){
    for(int i=0; i<n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1){
            if(color[v] == WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    // 初期化
    for(int i=0; i<n; i++){
        color[i] =WHITE;
        nt[i] = 0;
    }
    tt = 0;

    // 未訪問のuを始点として深さ優先探索
    for(int u=0; u<n; u++){
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << d[i] << " " << f[i] <<endl; 
    }
}

int main(int argc, char const *argv[])
{
    int u, k, v;

    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--; // 0 origin
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         100000000
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define csc(n)       scanf("%c",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         10000009
#define NUM2        1000000000


int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        int n,i,j,k,sm=0;
        cin >> n ;
        int aa[n];
        for(i=1;i<n;i++)
        {
            sc(aa[i]);
        }
        for(i=1;i<n-1;i++)
        {
            sm+=min(aa[i],aa[i+1]);
        }
        sm+=aa[1];
        sm+=aa[n-1];
        cout << sm ;
    }
}

//printf("Case %d: ",++QQ);


Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

const int mod = 998244353;

int main () {
    int n, s; cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll> (s+1));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, s+1) {
            dp[i+1][j] += dp[i][j]*2;
            dp[i+1][j] %= mod;
            if (j+a[i] <= s) {
                dp[i+1][j+a[i]] += dp[i][j];
                dp[i+1][j+a[i]] %= mod;
            } 
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73724
using System;
using System.Collections;
using System.Linq;
static class Num
{
    public static int GetNum(char c)
    {
        string alp = "abcdefghijklmnopqrstuvwxyz";
        int ans = -1;
        for (int i = 0; i < 26; i++)
            if (alp[i] == c)
                ans = i;
        return ans;
    }
}
class Program
{
    static void Main()
    {
        string s = Console.ReadLine();

        if (s == "zyxwvutsrqponmlkjihgfedcba")
            Console.WriteLine(-1);
        else if (s.Length != 26)
        {
            string alp = "abcdefghijklmnopqrstuvwxyz";
            char[] s2 = s.ToCharArray();
            for (int i = 0; i < alp.Length; i++)
            {
                if (!s2.Any(p => p == alp[i]))
                {
                    Console.WriteLine(s + alp[i]);
                    break;
                }
            }
        }
        else
        {
            string alp = "abcdefghijklmnopqrstuvwxyz";

            for (int i = 25; i > 0; i--)
            {
                if (Num.GetNum(s[i]) > Num.GetNum(s[i - 1]))
                {
                    char[] s2 = new char[i - 1];
                    for (int j = 0; j < i - 1; j++)
                    {
                        Console.Write(s[j]);
                        s2[j] = s[j];
                    }
                    for (int j = 1; ; j++)
                    {
                        if (!s2.Any(p => p == alp[Num.GetNum(s[i - 1]) + j]))
                        {
                            Console.Write(alp[Num.GetNum(s[i - 1]) + j]);
                            Console.WriteLine();
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#define MAXN 100000
#define ll long long
using namespace std;


vector<int> edges[MAXN+20];
int GetGrundy(int par, int u) {
    
    int g = 0;
    for(int j=0;j<edges[u].size();j++) {
        int v=edges[u][j];
        if (v != par)
            g ^= (GetGrundy(u,v)+1);
    }
    
    return g;
}

int main() {
    int N;
    cin>>N;
    for(int i=1;i<=N-1;i++) {
        int u,v;
        cin>>u>>v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    
    int g=GetGrundy(-1,1);
    
    if (g==0)
        cout << "Bob" << endl;
    else
        cout << "Alice" << endl;
    
}

Measured memory_bytes: 11904
/* ABC168_A
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>


int main(void){
    int num;
    scanf("%d",&num);
    num%=10; /*10で割った余りがnの1の位*/
    switch(num){
        case 3:
            printf("bon\n");
            break;
        case 0:
            printf("pon\n");
            break;
        case 1:
            printf("pon\n");
            break;
        case 6:
            printf("pon\n");
            break;
        case 8:
            printf("pon\n");
            break;
        default:
            printf("hon\n");
            break;
    }
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll N; cin >> N;
  vector<ll> A(N), B(N), C(N-1);
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> B[i];
  }
  REP(i, N-1) {
    cin >> C[i];
  }
  ll sum = 0;
  REP(i, N) {
    sum += B[i];
  }
  REP(i, N-1) {
    if(A[i] + 1 == A[i+1]) {
      sum += C[A[i]-1];
    }
  }
  cout << sum << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


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

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこの,プロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します

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

int main() {
  int N,K;
  int i;
  int S = 1;
  
  cin >> N >> K;
  
  for(i = 0; i < N;i++){
    int A,B;
    
    A = S * 2;
    B = S + K;
    
    if(A < B){
      S = A;
    }
    else{
      S = B;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>

int main(void) 
{
	int a, b;
	
	scanf("%d %d", &a, &b);
    if(a < b)
    {
    	printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else if(a == b)
	{
		printf("a == b\n");
	}
    return 0;
}


Measured memory_bytes: 2608
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		StringBuilder ans = new StringBuilder();

		for(int loop = 0; loop < N; loop++){

			String input_str = scanner.next();

			if(input_str.matches("\\A>'(=+)#\\1~\\z")){

				ans.append("A\n");

			}else if(input_str.matches("\\A>\\^(Q=)+~~\\z")){

				ans.append("B\n");

			}else{

				ans.append("NA\n");
			}
		}
		System.out.printf(ans.toString());
	}
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 37312
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //切り出しする文字列
        String S = sc.next();
        String T = sc.next();
        if(T.startsWith(S) && T.length() == S.length() + 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35644
// B. 

#include <sstream>
#include <iostream>
#include <vector>

using namespace std;

typedef long long LL;

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

int main(int argc, char *argv[])
{
	int t;
	cin >> t;
	for (int tt = 0; tt < t; ++tt) {
		LL a, b, c, d;
		cin >> a >> b >> c >> d;
		bool ans = d >= b;
		LL r = a;
		for (int i = 0; i < 10000; ++i) {
			r -= b;
			if (r < 0) {
				ans = false;
				break;
			}
			if (r <= c) {
				r += d;
			}
		}
		if (ans && b > c) {
			r = a % b;
			LL p = d % b;
			if (!p) {
				ans = r <= c;
			} else {
				LL g = gcd(p, b);
				LL y = r / g;
				LL x = b + r - (y + 1) * g;
				ans = x <= c;
			}
		}
		cout << (ans ? "Yes" : "No") << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define ull unsigned long long
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

int main() {
    FIO;
    string s, t;  cin >> s >> t;
    ll j = 0;
    set<string>ss;
    for(ll i = 0; i < s.size(); i++) {
            for(ll j = 1; j <= s.size() - i; j++) {
                string p = s.substr(i, j);
                if(p.size() == t.size()) {
                    ss.insert(p);
                }
            }

    }

    vector<string>pp(ss.begin(), ss.end());
    ll d = pp.size();
    ll c = 0;
    ll m = 0;
    ll ans = 0;
    while(d--) {
            ll c = 0;
            string k = pp[m];
        for(ll i = 0, j = 0; i < t.size(); i++, j++ ) {
            if(t[i] == k[j]) c++;
        }

        ans = max(ans, c);
        m++;
    }

    cout << t.size() - ans  << endl;
    return 0;

}



Measured memory_bytes: 3812
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n, m;
    cin >> n >> m;

    vi v(n);
    ll sum = 0;
    rep (i, 0, n-1) {
    	cin >> v[i];
    	sum += (ll)v[i];
    }

    sort(v.begin(), v.end());
   
    vector<pair<int,int> > q(m);
    rep (i, 0, m-1) {
    	int b, c;
    	cin >> b >> c;
    	q[i] = {c, b};
    }
    sort(q.begin(), q.end());
    ll cur_sum = 0;
    ll cur_ct = 0;
    repD(i, m-1, 0) {
    	int num = q[i].second;
    	int val = q[i].first;
    	auto it = lower_bound(v.begin(), v.end(), val);
    	int less = it - v.begin() - cur_ct;
    	int ct = min(num, less);
    	//db3(num, val, ct);
    	if (ct <= 0) {
    		continue;
    	}
    	cur_sum = cur_sum + ((ll)ct * (ll)val);
    	cur_ct += ct;;
    	//db2(cur_sum, cur_ct);
    }
    
    rep (i, cur_ct, n-1) cur_sum += (ll)v[i];
    cout << cur_sum  << "\n"; 
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include <algorithm>
typedef long long llong;
using namespace std;
int n,c,honsu,tp;
int p[65000];
int j[65000];
llong a,mx;
void syokika(){
  tp=0;
  mx=0;
  for(int k=0;k<65000;k++)j[k]=0;
}
int main(){
  while(true){
    cin>>n;
    if(n==0)break;
    syokika();
    for(int i=0;i<n;i++){
      cin>>p[i];
      tp+=p[i];
    }
    for(int i=0;i<n-1;i++){
      cin>>j[i];
    }
    sort(j,j+(n-1),greater<int>());
    // for(int k=0;k<n;k++)cout<<j[k]<<endl;
    for(int i=0,t=n,tj=0;t>=1;t--,i++){
      a=(llong)t*(tp+tj);
      tj+=j[i];
      if(mx<a)mx=a;
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 1684
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 510
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char A[maxn][maxn],B[maxn][maxn],C[maxn][maxn];
int n,m;
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		scanf("%s",C[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(C[i][j]=='#')A[i][j]=B[i][j]='#';
			else if(i==1||(i!=n&&(j&1)))A[i][j]='#',B[i][j]='.';
			else A[i][j]='.',B[i][j]='#';
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			putchar(A[i][j]);
		putchar('\n');
	}
	puts("");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			putchar(B[i][j]);
		putchar('\n');
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
		}
		
		int sum = 0;
		int S1 = 0;
		int S2 = 0;
		int del = 10000000;
		
		for(int i=0; i<N; i++) {
			sum += a[i];
		}
		
		for(int i=0; i<N-1; i++) {
			for(int j=0; j<=i ;j++) {
				S1 += a[j];
			}
			S2 = sum - S1;			
			del = Math.min(Math.abs(S1-S2), del);	
			S1 = 0;
		}
		
		System.out.println(del);
		
	}
}


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

int main() {
  string s;
  cin >> s;
  bool flag=1;

  reverse(s.begin(), s.end());
  
  while(flag){
    if(s.empty()){
      break;
    }
    if(s.substr(0,7) == "remaerd"){
      s = s.erase(0,7);
      continue;
    }
    if(s.substr(0,5) == "maerd"){
      s = s.erase(0,5);
      continue;
    }
    if(s.substr(0,6) == "resare"){
      s = s.erase(0,6);
      continue;
    }
    if(s.substr(0,5) == "esare"){
      s = s.erase(0,5);
      continue;
    }
    flag = 0;
  }
  if(flag){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" <<endl;
  }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++){
        cin >> array[i];
    }

    int value = -(1 << 31), min_value = array[0];
    for(int i=1;i<n;i++){
        value = (array[i] - min_value) > value ? (array[i] - min_value) : value;
        min_value = min_value > array[i] ? array[i] : min_value;
    }
    cout << value << endl;
}


Measured memory_bytes: 3540
n = int(input())
ans = [0, 0, 0, 0]
for _ in range(n):
    s = input()
    if s == 'AC':
        ans[0] += 1
    elif s ==  'WA':
        ans[1] += 1
    elif s == 'TLE':
        ans[2] += 1
    else:
        ans[3] += 1

lst = ['AC', 'WA', 'TLE', 'RE']
for i in range(4):
    print(lst[i], 'x', ans[i])



Measured memory_bytes: 69880
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

}


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

int main() {
  string s;
  cin >> s;
  set<char> se;
  for(int i=0; i<s.size(); i++) se.insert(s[i]);
  if(s.size()<26) {
    for(int i=0; i<26; i++) {
	  if(se.count((char)(i+'a'))) continue;
      s+=(char)(i+'a');
      break;
    }
    cout << s << endl;
    return 0;
  }
  string t=s;
  next_permutation(s.begin(),s.end());
  if(s<t) cout << -1 << endl;
  else {
    for(int i=0; i<s.size(); i++) {
      if(s[i]!=t[i]) {
        s=s.substr(0,i+1);
        break;
      }
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

ll POW(ll n, ll k) {
    if (k==0) return 1;
    ll ret = 1;
    while (k > 0) {
        if (k&1) ret = ret * n % MOD;
        n = (n * n) % MOD;
        k >>= 1;
    }
    return ret;
}

ll FACT(ll n, ll k) {
    ll ret = 1;
    for (int i = 0; i < k; ++i) {
        ret = ret * (n - i) % MOD;
    }
    return ret;
}

ll COM2(ll n, ll k) {
    ll x = FACT(n, k);
    ll y = FACT(k, k);
    ll mody = POW(y, MOD-2);
    return x * mody % MOD; 
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ret = POW(2, n);
    ret -= 1;
    ret -= COM2(n, a);
    ret -= COM2(n, b);
    while (ret < 0) ret += MOD;
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void leftrotate(string &s, int d)
{
    reverse(s.begin(), s.begin()+d);
    reverse(s.begin()+d, s.end());
    reverse(s.begin(), s.end());
}
void rightrotate(string &s, int d)
{
   leftrotate(s, s.length()-d);
}
int main() {
	string s,t,s1,t1;
	int flag = 0,cnt=0;
	cin>>s>>t;
	s1=s;
	t1=t;
	sort(s1.begin(),s1.end());
	sort(t1.begin(),t1.end());
	if(s == t)
		cout<<"Yes";
	else if(s1!=t1)
		cout<<"No";
	else{
		while(cnt<=(s.length())){
			leftrotate(s,1);
			if(s == t){
				flag = 1;
				break;
			}
			cnt++;
		}
		if(flag == 0)
			cout<<"No";
		else
			cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def rec_z():
    for i in range(N):
        for j in range(Hmax+1):
            if j >= a[i]:
                dp[j] = min(dp[j], dp[j-a[i]] + b[i])
    return min(dp[H:Hmax+1])
 
 
readline=stdin.readline
H, N = map(int,readline().split())
a = []
b = []
for i in range(N):
    aa, bb = map(int, readline().split())
    a.append(aa)
    b.append(bb)
Hmax = H + max(a)
INF = 10**9
dp = [INF for _ in range(Hmax+1)] 
dp[0] = 0
print(rec_z())


Measured memory_bytes: 39664
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let solve s t = (s + t) * t / 2L

[<EntryPoint>]
let main _ =
    let n = read int64
    solve 1L (n - 1L)
    |> printfn "%i"
    0

Measured memory_bytes: 13916
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int m=0;
	m+=(n/1000);
	if(n%1000!=0) ++m;
	cout<<(m*1000)-n;
	return 0;
}


Measured memory_bytes: 3620
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

public class Main {


    static class MyPair{
        int k,v;
        MyPair(int first,int second) {
            this.k = first;
            this.v = second;
        }
    }
    public static void main(String[] args) {
        java.util.Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        String s = input.next();
        int[] ss = new int[n];
        Vector<MyPair> d = new Vector<>();
        int prev = -1, cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') ss[i] = 0;
            else ss[i] = 1;
        }
        for (int i = 0; i < n; i++) {
            if (prev == ss[i]) cnt++;
            else {
                if (cnt > 0) d.add(new MyPair(prev, cnt));
                cnt = 1;
                prev = ss[i];
            }
        }
        if (cnt > 0) d.add(new MyPair(prev, cnt));
        int l = 0, r = 0, sum = 0, v = 0;
        for (int i = 0; i < d.size(); i++) {
            sum += d.get(i).v;
            if (d.get(i).k == 0) {
                v++;
                while (v > k) {
                    sum -= d.get(l).v;
                    if (d.get(l).k == 0) v--;
                    l++;
                }
            }
            if (r < sum) r = sum;
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 28548
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int N, ans, numA, numB, numBA;

int main() {
    cin >> N;
    string s;
    rep(i, N) {
        cin >> s;
        if (s[0] == 'B' && s[s.size()-1] == 'A') numBA++;
        else if (s[0] == 'B') numB++;
        else if (s[s.size()-1] == 'A') numA++;
        rep(j, s.size() - 1) {
            if (s[j] == 'A' && s[j+1] == 'B') ans++;
        }
    }
    ans += numBA + min(numA, numB);
    if (numBA && numA + numB == 0) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int xx = sc.nextInt();
		int yy = sc.nextInt();
		
		if (1 <= xx && xx <=9 && 1<= yy && yy <= 9){
			System.out.print(xx * yy);
		}else{
			System.out.print("-1");
		}
	}
}

Measured memory_bytes: 21712
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def extgcd1(a0,b0):
    u=1
    v=0
    a=a0
    b=b0
    while b:
        t=a//b
        a-=t*b
        a,b=b,a
        u-=t*v
        u,v=v,u
    if a!=1: 
        #print("not 素")
        return -1
    return u%b0 #a0*u=1(mod b0)

def main():
    mod =998244353
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    # dp=[0]*2
    # ndp=copy(dp)
    # dp[0]=0
    # dp[1]=M
    # for i in range(2,N+1):
    #     if i<=K+1:
    #         ndp[0]=((M-1)*(dp[0]+dp[1])+dp[0])%mod
    #         ndp[1]=dp[1]
    #     else:
    #         ndp[0]=(M*dp[0]+(M-1)*dp[1])%mod
    #         ndp[1]=0

    #     dp=copy(ndp)
    # ans=(dp[0]+dp[1])%mod
    # #print(ans)

    #n0=math.factorial(N-1)
    #ks=[1]*(N-1+1)
    #for k in range(2,N-1+1):
    #    ks[k]=ks[k-1]*k
    ans=0
    c0=1
    c1=pow(M-1,N-1,mod)
    inv=[1,1]+[pow(i,mod-2,mod) for i in range(2,N)]
    #print("ok1")
    ifac=[1]*(N)
    nfac=1
    for i in range(1,N):
        nfac=(i*nfac)%mod
        ifac[i]=(ifac[i-1]*inv[i])%mod
    #print("ok2")
    #print(ifac)
    
    
    mp=[1]*(N)
    for i in range(1,N):
        mp[i]=(mp[i-1]*(M-1))%mod
    #print("ok3")
    ans=0
    #print(nfac)
    #print(mp)
    
    for k in range(0,K+1):
        #print((n0//ks[k]//ks[N-1-k]))
        ans=ans+(mp[N-1-k]*nfac*ifac[k]*ifac[N-1-k])%mod
        ans%=mod
        #print(ans)
    #print(ks)
    ans=(ans*M)%mod
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 86784
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,(n))
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

inline ll toLL(string s) { ll v; istringstream sin(s); sin >> v; return v; }
typedef pair<int, ll> pil;

int main() {
	string S;
	cin >> S;
	int L = S.length();

	vvl n(L, vl(L));
	FOR(i, 0, L) {
		FOR(j, i, L) {
			n[i][j] = toLL(S.substr(i, j-i +1));
		}
	}

	ll ans = 0;
	queue<pil> Q;
	Q.push(pil(0, 0));
	while (!Q.empty()) {
		pil p = Q.front();
		Q.pop();

		if (p.first == L) {
			ans += p.second;
			continue;
		}

		FOR(i, p.first, L) {
			Q.push(pil(i+1, p.second+n[p.first][i]));
		}
	}

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

Measured memory_bytes: 256
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 銀貨を何枚持っているかの状態数、N*2501の都市, dijkstra
N, M, S = lr()
limit = 2500
S = min(S, limit)
graph = [[] for _ in range((N+1) * (limit+1))]  # 1-indexed
for _ in range(M):
    u, v, a, b = lr()
    for x in range(a, limit+1):
        graph[u*(limit+1) + x].append(((v*(limit+1)+x-a), b))
        graph[v*(limit+1) + x].append(((u*(limit+1)+x-a), b))

for i in range(N):
    i += 1
    c, d = lr()
    for x in range(limit-c+1):
        graph[i*(limit+1) + x].append((i*(limit+1) + x + c, d))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * ((N+1) * (limit+1))
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next, time in graph[prev]:
            d1 = d + time
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

dist = dijkstra(1*(limit+1)+S)
for i in range(2, N+1):
    answer = min(dist[i*(limit+1):(i+1)*(limit+1)])
    print(answer)


Measured memory_bytes: 114216
#include <cstdio>
#include <iostream>
using namespace std;
int n,x,y;
int ans[2005];
int main(){
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1;i<x;++i){
		for(int j=i+1;j<=x;++j)
			++ans[j-i];
		for(int j=x+1;j<=y-1;++j)
			++ans[min(j-x,y-x+1-j+x)+x-i];
		for(int j=y;j<=n;++j)
			++ans[j-y+1+x-i];
	}
	for(int i=x;i<=y;++i){
		for(int j=i+1;j<=y;++j)
			++ans[min(j-i,y-x+1-j+i)];
		for(int j=y+1;j<=n;++j)
			++ans[min(y-i,y-x+1-y+i)+j-y];
	}
	for(int i=y+1;i<=n;++i)	
		for(int j=i+1;j<=n;++j)
			++ans[j-i];
	for(int i=1;i<n;++i)printf("%d\n",ans[i]);
	return 0;
}



Measured memory_bytes: 256
N,M=map(int,input().split())
li=[0]*N
H=list(map(int,input().split()))

for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
            li[B-1]+=1
    elif H[A-1]<H[B-1]:
            li[A-1]+=1
    else:
            li[A-1]+=1
            li[B-1]+=1

print(li.count(0))


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

int main(){
  int a,b,c,k;
  int ans = 0;
  cin>>a>>b>>c>>k;
  for(int i = 0; i < a && k > 0 ; i++){
    ans++;
    k--;
  }
  for(int i = 0; i < b && k > 0 ; i++){
    k--;
  }
  for(int i = 0; i < c && k > 0 ; i++){
    ans--;
    k--;
  }
  cout<<ans;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
       char a = sc.next().charAt(0);
       char b = sc.next().charAt(0);
       
       if (a == b){
           System.out.println('H'); //(H,H), (D,D)
       } else {
           System.out.println('D'); //(H,D),(D,H)
       }

    }
}

Measured memory_bytes: 35720
#include <cmath>
#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int x;

  while (true) {
    std::string param;

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> x;

    if (x < 1 || x > 100) {
      std::cout << "Error: 1 <= x <= 100" << std::endl;
    } else {
      break;
    }
  }

  std::cout << (unsigned int)pow(x, 3) << std::endl;

  return 0;
}

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

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int sum = 0;

    REP(i, 3)
    {
        int a;
        cin >> a;
        sum += a;
    }

    if (sum >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;

    return 0;
}

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

using namespace std;

int main()
{
  int W, H;
  char c;

  cin >> W >> H >> c;

  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      if((i == 1 || i == H) && (j == 1 || j == W)) cout << "+";
      else if(i == 1 || i == H) cout << "-";
      else if(j == 1 || j == W) cout << "|";
      else if((H + 1) / 2 == i && (W + 1) / 2 == j)cout << c;
      else cout << ".";
    }
    cout << endl;
  }
}

Measured memory_bytes: 3080
from collections import Counter

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

c = Counter(A)
# print('c', c)


def f(v):
    return v * (v - 1) // 2


combi = {key: f(value) for key, value in c.items()}
# print('combi', combi)
sum_combi = sum(combi.values())
# print('sum_combi', sum_combi)

for i in range(N):
    v = c[A[i]]
    diff = f(v) - f(v - 1)
    print(sum_combi - diff)


Measured memory_bytes: 32028
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
typedef long double ld;
typedef vector<vector<int> > matrix;
typedef vector<int> arr;
typedef vector<string> vs;
typedef vector<pair<int,int> > pv;
#define test() int t;cin>>t;while(t--)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};
//=================================================================//
int n;
double dp[3000][3000];
double solve(int pos, int heads, double *p) {
    //base case
    if(pos == n) return (heads >= (n+1)/2);
    if(heads >= (n+1)/2) return 1;

    double &ans = dp[pos][heads];
    if(ans != -1) return ans;

    //recursive case
    //choose head
    double op1 = p[pos]*solve(pos+1,heads+1,p);
    //choose tail
    double op2 = (1-p[pos])*solve(pos+1,heads,p);
    return ans = op1 + op2;
}

#undef int
int main(){
#define int long long 
    fast;
    cin>>n;
    double p[n];
    FOR(i,0,n-1) cin>>p[i];
    FOR(i,0,2999)
        FOR(j,0,2999)
            dp[i][j] = -1.0;
    cout<<fixed<<setprecision(10)<<solve(0,0,p);
    return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>
int main(){
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
		
		if(c%i==0){
			count=count+1;
			}

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

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

void solve () {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    k--;
    for (int i = k + 1, j = 0; i < n; i++, j++) {
        if (a[i] > a[j]) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        cout << "\n";
    }


}

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


Measured memory_bytes: 4756
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
distance = [0] * (n + 1)
total = 0
for i in range(1, n + 2):
    distance[i - 1] = a[i] - a[i - 1]
    total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
    diff = abs(distance[i]) + abs(distance[i - 1]) - abs(distance[i] + distance[i - 1])
    print(total - diff)

Measured memory_bytes: 14048
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  ll ret = 1;
  rep(i,r){
    ret *= n-i;
    ret %= MOD;
    ret *= mpow(r-i, MOD-2);
    ret %= MOD;
  }
  return ret;
}

signed main(){
  int n; ll a,b; cin>>n>>a>>b;
	ll ans = (mpow(2,n)-1+MOD)%MOD;
	ans -= (nCr(n,a)+nCr(n,b))%MOD;
	ans = (ans+MOD)%MOD;
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	int ans=c-(a-b);
	if (ans<=0) cout<<"0";
	else cout<<ans;
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int D, G;
int p[11], c[11], cmp[11];


int ans(int use, int ten, int many){
	// cout << ten << ":" << many << endl;
	if(ten >= G) return many;

	int ret = inf;
	for(int i = 1; i <= D; i++){
		if( !(use&(1<<i) ) ){
			// cout << i << " ";
			ret = min(ret, ans(use|(1<<i), ten+cmp[i], many+p[i]) );
			if(i*100*p[i] >= G-ten){
				int how = (G-ten)%(i*100) ? (G-ten)/(i*100)+1 : (G-ten)/(i*100);
				ret = min(ret, ans(use|(1<<i), ten+how*i*100, many+how) );
			}
		}
	}


	return ret;
}

int main(){
	cin >> D >> G;
	for(int i = 1; i <= D; i++){
		cin >> p[i] >> c[i];
		cmp[i] = i*p[i]*100+c[i];
	}

	cout << ans(0, 0, 0) << endl;



	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			cnt += y-x+1;
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26036
#include <iostream>
using namespace std;
int main(){
    int w,h;
    while(cin>>w>>h){
        if(w == 0 && h == 0)break;
        for(int i = 0; w > i; i++){
            for(int j = 0; h > j; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

using namespace std;

int N = 0, M = 0;
vector<int> res(50,0);

int main(void){
    int a = 0, b = 0;

    cin >> N >> M;
    for(int i=0; i<M; ++i){
        cin >> a >> b;
        res[a-1]++;
        res[b-1]++;
    }
    for(int i=0; i<N; ++i){
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll t;
  cin>>t;
  cout<<(t<1200?"ABC":"ARC")<<endl;
	return 0;
}


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

int main() {
    string s;
    cin>>s;
    long long int ans = 0;
    long long int temp = 0;
    for(long long int i = 0;i<s.length();i++){
        if(s[i] == 'B'){
            temp++;
        } else {
            ans += temp;
        }
    }
    cout<<ans<<endl;
}



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

int main(){
    int i,j,l,r,c,k,m; 
    cin >> r >> c;
    int s[r+1][c+1];
    for ( i = 0; i < r; i++ ){
        for (j = 0; j < c; j++ ){
            cin >> l;
            s[i][j] = l;
        }
    }
    for (i = 0; i <= r; i++){
        for (j = 0; j <= c; j++){
            if (j == c){
                s[i][j] = 0;//s[i][c]初期化
                for (k = 0; k < c; k++){
                    s[i][j] = s[i][j] + s[i][k];
                }
            }
            else if(i == r){
                s[i][j] = 0;
                for(m = 0; m < r; m++){
                    s[i][j] = s[i][j] + s[m][j];
                }
            }
        }
    }
    for (i = 0; i <= r; i++){
        for (j = 0; j < c; j++){
            cout << s[i][j] << " ";
        }
        cout << s[i][c] <<'\n';
    }
    return 0;
}


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

#define I first
#define prob ' '
#define II second
#define pb push_back
#define tm (tl+tr)/2

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

void solve(ll rem_tests){
    if (!rem_tests) return;
    ll k;
    cin >> k;
    while(k--) cout << "ACL";
    solve(rem_tests-1);
}
int main(){
    ll N_of_tests = 1;
    //cin >> N_of_tests;
    solve(N_of_tests);
   return 0;
}


Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int t = fs.nextInt();
        int a = fs.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = fs.nextInt();
        }
        double diff = 100000000;
        int idx = -1;
        for(int i=0;i<n;i++){
            if(Math.abs(t-h[i]*0.006-a) < diff){
                diff = Math.abs(t-h[i]*0.006-a);
                idx = i;
            }
        }
        System.out.println(idx+1);
    }

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

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

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

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

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

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

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21332