akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int dayes, asi ;
    cin >> dayes >> asi ;
    int sum = 0 ;
    for (int i = 0 ; i < asi ; i++)
    {
        int xx ;
        cin >> xx ;
        sum += xx ;
    }
    if (sum<=dayes)cout<<(dayes-sum)<<endl;
    else cout << -1 << endl ;
}

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

typedef struct {
  char suit;
  int value;
}card;

void BubbleSort(card*, int);
void SelectionSort(card*, int);
int Stable(card*, card*, int);

int main(){
  int i,j,n;

  scanf("%d", &n);
  card tp[n], antp[n];

  for (i = 0 ; i < n ; i++) {
    scanf(" %c%d", &tp[i].suit, &tp[i].value);
    antp[i].suit = tp[i].suit;
    antp[i].value = tp[i].value;
  }

  BubbleSort(tp, n);
  SelectionSort(antp, n);

  for(i=0; i < n; i++){
    if(i){
      printf(" ");
    }
    printf("%c%d", tp[i].suit, tp[i].value);
  }
  printf("\nStable\n"); // バブルソートは安定なソート

  for(i = 0; i < n; i++){
    if(i){
      printf(" ");
    }
    printf("%c%d", antp[i].suit, antp[i].value);
  }
  // 安定なソートであるバブルソートから実行した選択ソートが安定であったかどうかを判定
  if(Stable(tp, antp, n)){
    printf("\nStable\n");
  }
  else{
    printf("\nNot stable\n");
  }

  return 0;
}

void BubbleSort(card *C, int N){
  int i,j,f=1;
  card tem;

  while(f){
    f = 0;
    for(j = N-1 ; j > 0 ;j--){
      if(C[j].value < C[j-1].value){
        tem  = C[j];
        C[j] = C[j-1];
        C[j-1] = tem;
        f = 1;
      }
    }
  }
}

void SelectionSort(card *C, int N){
  int i,j;
  int minj;
  card tem;

   for(i = 0 ; i < N ; i++){
     minj = i;
     for(j = i ; j < N ; j++){
      if(C[j].value < C[minj].value){
        minj = j;
      }
    }
    tem = C[i];
    C[i] = C[minj];
    C[minj] = tem;
  }
}

int Stable(card *A, card *B, int N){
  int i;
  for(i = 0; i < N ; i++){
    if(A[i].suit != B[i].suit)return 0;
  }
  return 1;
}



Measured memory_bytes: 2112
s=input()
tmpsum=0
ruiseki=[0]
dic={}
so=2019

for i in range(1,len(s)+1):
    tmpsum+=(int(s[-i])*pow(10,i-1,so)) % so
    tmpsum%=so
    ruiseki.append(tmpsum)

for rui in ruiseki:
    if rui in dic:
        dic[rui]=dic[rui]+1
    else:
        dic[rui]=1


output=0
for val in dic.values():
    output+=val*(val-1)/2

print(int(output))


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

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

Measured memory_bytes: 3560
N,M,X = map(int,input().split())
As=list(map(int,input().split()))

toN =0
to0 =0

for i in range(X+1,N):
  if i in As:
    toN +=1
for i in range(X-1,0,-1):
  if i in As:
    to0 +=1
print(min(toN,to0))

Measured memory_bytes: 9188
#include <iostream>
#include <string>
using namespace std;
struct shai{
	int num[6];
}; 
void ChangeE(struct shai &s){
	swap(s.num[5],s.num[2]);
	swap(s.num[2],s.num[0]);
	swap(s.num[0],s.num[3]);
	
};

void ChangeS(struct shai &s){
	swap(s.num[5],s.num[1]);
	swap(s.num[1],s.num[0]);
	swap(s.num[0],s.num[4]);
};

void ChangeW(struct shai &s){
	swap(s.num[5],s.num[3]);
	swap(s.num[3],s.num[0]);
	swap(s.num[0],s.num[2]);
};

void ChangeN(struct shai &s){
	swap(s.num[5],s.num[4]);
	swap(s.num[4],s.num[0]);
	swap(s.num[0],s.num[1]);
};


void swap(int &a,int &b){
	int temp =a;
	a=b;
	b=temp;
}

int main() {
	struct shai s;
	for(int i=0;i<6;i++){
		cin>>s.num[i];
	}
	string str;
	cin>>str;
	
	for(int i=0;i<str.length();i++){
		switch(str[i]){
			case 'E':
				ChangeE(s);
				break;
			case 'S':
				ChangeS(s);
				break;
			case 'W':
				ChangeW(s);
				break;
			case 'N':
				ChangeN(s);
				break;
			default:
				break;
							
		}
	}
	cout<<s.num[0]<<endl;
	return 0;
}

Measured memory_bytes: 3204
fun main(args: Array<String>){
  
  val (a,op,b) = readLine()!!.split(" ")
  var ans = 0
  
  when(op){
    "+" -> { ans = a.toInt() + b.toInt() }
    "-" -> { ans = a.toInt() - b.toInt() }
  }
  
  println(ans)
      
}
  

Measured memory_bytes: 37952
#include <stdbool.h>
#include <stdio.h>
int main() {
	int n, m, k[10], s[10][10], p[10], ans = 0, cnt = 0;
	bool isOK;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &k[i]);
		for (int j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &p[i]);
	}
	// swの状態on(1),off(0)
	for (int i = 0; i < (1 << n); i++) {
		isOK = true;
		for (int j = 0; j < m; j++) {  // m個の電球について全て確認
			cnt = 0;				   // onであるswの数
			for (int l = 0; l < k[j]; l++) {  // k[j]個のsw全てを確認
				if (((i >> (s[j][l] - 1)) & 1) == 1) {	// swがonだったら
					cnt++;
				}
			}
			if (cnt % 2 != p[j]) {
				isOK = false;
				break;
			}
		}
		if (isOK) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int S;
  int h;
  int m;
  int s;
  
  cin >> S;
  h=S/3600;
  m=(S-h*3600)/60;
  s=S%60;
  
  cout << h <<":"<< m <<":"<< s << endl;
}



Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    ll n;
    cin >> n;

    ll ans = ((n * (n - 1)) / 2);

    cout << ans;


    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    ll num_even = 0;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        if(tmp%2==0) num_even++;
    }

    if(num_even == N) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128


signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  std::vector<int> a(n);
  for(int i = 0; i < n; ++i) {
  	cin >> a[i];
  }
  sort(all(a));
  long long res = 0;
  for(int i = 0; i < n - 2; ++i) {
  	for(int j = i + 1; j < n - 1; ++j) {
  		int x = lower_bound(all(a), a[i] + a[j]) - a.begin();
  		res += x - j - 1;
  	}
  }
  cout << res << endl;
	return 0;
}

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

int a[100001],b[100001];
int a1,a2,b1,b2;

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    for(int i = 0; i< n; i+=2){
        int x,y;
        cin >> x >> y;
        a[x]++;
        b[y]++;
    }
    
    for(int i = 1; i < 100001; i++){
        if(a[i]>a[a1]){
            a2 = a1;
            a1 = i;
        } else if(a[i] > a[a2]) a2 = i;
        if(b[i] >= b[b1]){
            b2 = b1;
            b1 = i;
        } else if(b[i]>b[b2]) b2 = i;
    }
    if(a1 != b1) cout << n - a[a1] - b[b1];
    else cout << n - max(a[a1] + b[b2],a[a2] + b[b1]);
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;

int n,a[maxn],b[maxn],cnt=0;
ll ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n+1;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i) 
	{
		scanf("%d",&b[i]);
		if(b[i]<a[i]) ans+=b[i];
		else
		{
			ans+=a[i];
			if(b[i]-a[i]<a[i+1]) a[i+1]-=b[i]-a[i],ans+=b[i]-a[i];
			else ans+=a[i+1],a[i+1]=0;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x >= r && y >= r && W-r >= x && H-r >= y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
int main(void){
    long int n,i;
    scanf("%ld",&n);
    for(i=(int)sqrt(n);i>0;i--){
        // printf("%d\n",i);
        if(n%i==0){
            printf("%ld\n",i+(n/i)-2);
            return 0;
        }
    }
    printf("%ld\n",n-1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = ((ll)1<<31) - 1;

template <typename T>
class SegTree{
  using F = function<T(T,T)>;
  int n; T uni; F f;
  vector<T> dat;

public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] = x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  SegTree<ll> st(n,[](ll a, ll b){return min(a,b);},INF);
  vector<ll> ans;
  rep(i,q) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 1){
      ans.push_back(st.query(x,y+1));
    } else {
      st.update(x,y);
    }
  }
  for(auto k : ans) cout << k << endl; 
}


Measured memory_bytes: 5588
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
// constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int f(int x){
	if(x == 0) return 0;
	int pc = __builtin_popcountll(x);
	
	return f(x % pc) + 1;
}

signed main(){
	cout<<fixed<<setprecision(10);

	
	int N;
	string X;
	vector<int> t0, t1;
	int num0 = 0, num1 = 0;

	int mod0, mod1;
	
	cin>>N>>X;
	
	t0.resize(N+1);
	t1.resize(N+1);
	
	mod0 = count(X.begin(), X.end(), '1');
	mod1 = mod0;
	
	mod0--;
	mod1++;
	
	if(mod0 == -1) {
		for(int i = 0; i < N; i++){
			cout<<1<<endl;
		}
			
		return 0;
	}
	
	if(mod0 == 0) {
		
		t0[0] = t1[0] = 1;
	
		for(int i = 0; i < N; i++){
			num1 = num1 * 2 + X[i] - '0';
			num1 %= mod1;
		}
		
		for(int i = 1; i < t0.size(); i++){
			t1[i] = t1[i-1] * 2 % mod1;
			t1[i] %= mod1;
		}
		
		for(int i = 0; i < N; i++){
			if(X[i] == '0') {
				int n = num1;
				n = (n + t1[N-i-1]) % mod1;
			
				cout<<f(n)+1<<endl;
			} else {
				cout<<0<<endl;
			}
		}
			
		return 0;
	}
	
	t0[0] = t1[0] = 1;
	
	for(int i = 0; i < N; i++){
		num0 = num0 * 2 + X[i] - '0';
		num0 %= mod0;
		num1 = num1 * 2 + X[i] - '0';
		num1 %= mod1;
	}
	
	for(int i = 1; i < t0.size(); i++){
		t0[i] = t0[i-1] * 2 % mod0;
		t0[i] %= mod0;
	}
	for(int i = 1; i < t0.size(); i++){
		t1[i] = t1[i-1] * 2 % mod1;
		t1[i] %= mod1;
	}
	
	// cout<<"mod "<<mod0<<" "<<mod1<<endl;
	// cout<<"num "<<num0<<" "<<num1<<endl;
	
	for(int i = 0; i < N; i++){
		// cout<<f(i)<<endl;
		int ans = 0;
		
		if(X[i] == '0') {
			int n = num1;
			// cout<<"t "<<t1[N-i-1]<<endl;
			n = (n + t1[N-i-1]) % mod1;
			
			ans = f(n)+1;
		} else {
			int n = num0;
			
			n = (n + mod0 - t0[N-i-1]) % mod0;
			
			ans = f(n)+1;
		}
		
		cout<<ans<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 6760
from collections import deque

q = deque()
for _ in range(int(input())):
    command = input().split()
    if command[0] == "insert":
        q.appendleft(command[1])
    elif command[0] == "delete":
        try:
            q.remove(command[1])
        except ValueError:
            pass
    elif command[0] == "deleteFirst":
        q.popleft()
    elif command[0] == "deleteLast":
        q.pop()
    
print(" ".join(q))


Measured memory_bytes: 69740
from collections import Counter
H,W = map(int,input().split())
N = int(input())
a= list(map(int,input().split()))
c= [[0 for _ in range(W)] for _ in range(H)]
b= []
for i,num in enumerate(a):
  b += num*[i+1]
#print(b)

for i in range(H):
  for j in range(W):
    if i%2==0:
      c[i][j]= b[ W*i+j]
    else:
      c[i][j]= b[ W*(i+1)-1-j]
  print(*c[i])

Measured memory_bytes: 4304
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z>>w;
std::cout << ((x*y>z*w) ? x*y: z*w) << '\n';
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<bool> f(n, false);f[0] = true;
    vector<int> cnt(n, 1);
    for(int i=0;i<m;i++){
        int x, y;cin >> x >> y;x--;y--;
        if(f[x] == true) f[y] = true;
        cnt[x]--;
        if(cnt[x] == 0) f[x] = false;
        cnt[y]++;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(f[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  //分割代入,1行目がq,2行目がb,3行目がcに代入される
  const [a, b] = input
    .trim()
    .split("\n")
    .map((e) => Number.parseInt(e));
  // ここに処理を書く
  const mod = a % 500;
  if (mod <= b) {
    console.log("Yes");
  } else {
    console.log("No");
  }
  // console.logは標準出力に1行出力します (自動的に最後に改行が入ります)
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29568
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    String ans = "Yes";
    for(int i = 0; i < S.length(); i++){
      if((i%2 == 0 && S.charAt(i) == 'L') || (i%2 == 1 && S.charAt(i) == 'R')){
        ans = "No";
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 20

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

vll adj[N];
ll dp[N];
ll func(ll j)
{
  if(dp[j]) return dp[j];
  for(auto k:adj[j])
  {
    dp[j]=max(dp[j],1+func(k));
  }
  return dp[j];
}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  ll x,y;
  fori(i,0,m)
  {
    cin>>x>>y;
    adj[x].pb(y);
  }
  ll ans=0;
  fori(i,1,n+1)
  {
    ans=max(ans,func(i));
  }
  cout<<ans<<endl;
  return 0;
}

ll gcd(ll a,ll b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);
}

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


Measured memory_bytes: 10240
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

string s, t, res;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++){
		res += s[i];
		res += t[i];
	}	
	cout << res;













	return 0;
}


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

int t[200],v[200],l[200],r[200],pt[200],d[50000];
	
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin >> t[i];
		t[i] *= 2;
		pt[i]=pt[i-1]+t[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin >> v[i];
		v[i] *= 2;
		l[i]=min(l[i-1], v[i]-pt[i]);
	}
	r[n]=0;
	for(int i=n-1;i>=0;i--)
		r[i]=min(r[i+1], v[i+1]-(pt[n]-pt[i]));
	for(int i=1;i<=n;i++)
		for(int j=pt[i-1];j<=pt[i];j++)
		{
			d[j]=min(l[i-1]+j, r[i]+(pt[n]-j));
			d[j]=min(d[j], v[i]);
		}
	double ans=0;
	for(int i=0;i < pt[n];i++)
		ans+=d[i]+d[i+1];
	printf("%.15f\n",ans/8.0);
}


Measured memory_bytes: 384
<?php
    fscanf(STDIN, "%s", $s);
    $result = '';
    if($s === 'Sunny'){
        $result = 'Cloudy';
    }elseif($s === 'Cloudy'){
        $result =  'Rainy';
    }elseif($s === 'Rainy'){
        $result = 'Sunny';
    }
    echo $result;
  ?>

Measured memory_bytes: 3828
#include <iostream>
#include <queue>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<int,int> P;

int main() {
  ll n,x,y; cin>>n>>x>>y; x--; y--;
  int an[n]; fill(an,an+n,0);
  for(int st=0;st<n;st++) {
    int v[n]; fill(v,v+n,INF);
    queue<P> que; que.push({st,0}); v[st]=0;
    while(!que.empty()) {
      int nw = que.front().first;
      int cs = que.front().second;
      que.pop();
      if (v[nw] < cs) continue;
      if (nw != 0 && v[nw-1] > cs+1) v[nw-1] = cs+1, que.push({nw-1, cs+1});
      if (nw != n-1 && v[nw+1] > cs+1) v[nw+1] = cs+1, que.push({nw+1, cs+1});
      if (nw == x && v[y] > cs+1) v[y] = cs+1, que.push({y, cs+1});
      if (nw == y && v[x] > cs+1) v[x] = cs+1, que.push({x, cs+1});
    }
    //for(int i=0;i<n;i++) cout<<v[i]<<" "; cout<<endl;
    for(int i=0;i<n;i++) {
      an[v[i]]++;
    }
  }
  for(int i=1;i<n;i++) {
    cout<<an[i]/2<<endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
l = list(map(int, input().split()))

import itertools

ans = 0
for i, j, k in itertools.combinations(range(n), 3):
    if (l[i] == l[j]) or (l[i] == l[k]) or (l[j] == l[k]):
        continue
    else:
        if (l[i] + l[j] > l[k]) and (l[i] + l[k] > l[j]) and (l[j] + l[k] > l[i]):
            ans += 1
print(ans)


Measured memory_bytes: 68120
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define COUT(a) cout << a << endl;
#define PB push_back

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


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

    vector<vector<ll>> PY(N+1);
    vector<pair<ll, ll>> query(M);
    map<ll, string> answer;

    rep(i, N+1){
        PY[i] = vector<ll> ();
    }

    rep(i, M){
        ll p, y;
        cin >> p >> y;
        query[i] = pair<ll, ll>(p, y);
        PY[p].push_back(y);
    }

    rep(i, N+1){
        sort(PY[i].begin(), PY[i].end());
        rep(j, PY[i].size()){
            char _t[32];
            sprintf(_t, "%06d%06d", i % 1000000 , (j+1) % 1000000);
            ll key = i*10000000000+PY[i][j];
            answer[key] = string(_t);
        }
    }

    rep(i, M){
        COUT(answer[query[i].first * 10000000000 + query[i].second]);
    }


}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    int count=0;
    for(int i=0;i<n-1;i++){
        for(int j=n-1;j>i;j--){
            if(vec.at(j-1)>vec.at(j)){
                swap(vec.at(j-1),vec.at(j));
                count++;
                continue;
            }else{
                continue;

            }
        }
    }
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<vec.at(i);
    }
    cout<<endl;
    cout<<count<<endl;

}


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

int main()
{
	int N;

	cin >> N;

	int t,bt,dt,bx,x,dx,by,y,dy;
	bt = bx = by = 0;

	for (int i = 0; i < N; i++) {
		cin >> t >> x >> y;
		dt = t - bt;
		dx = abs(x - bx);
		dy = abs(y - by);
		if (dx + dy - dt > 0) {
			cout << "No" << endl;
			return 0;
		} else if ((dt - (dx + dy)) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
		bt = t;
		bx = x;
		by = y;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// struct union_find {
// 	vector<int> parent; //親の番号を格納する。親だった場合は-(その集合のサイズ)
// 	union_find(int N) {
// 		parent = vector<int>(N, -1); //parentの値を-1にする(すべてバラバラ)
// 	}
// 	int root(int A) { //Aがどのグループに属しているか調べる
// 		if (parent[A] < 0) return A;
// 		return parent[A] = root(parent[A]);
// 	}
// 	int size(int A) { //自分のいるグループの頂点数を調べる
// 		return -parent[root(A)];//親をとってきたい]
// 	}
// 	bool connect(int A, int B) { //AとBをくっ付ける．すでにつながっていた場合false
// 		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
// 		A = root(A);
// 		B = root(B);
// 		if (A == B) return false; //すでにくっついてるからくっ付けない
// 		if (size(A) < size(B)) swap(A, B); //大小が逆だったらひっくり返しちゃう。
// 		parent[A] += parent[B]; //Aのサイズを更新する
// 		parent[B] = A; //Bの親をAに変更する
// 		return true;
// 	}
// };

struct union_find {
    vector<int> parent; //親の番号を格納する。親だった場合は-(その集合のサイズ)
    union_find(int N) {
        parent = vector<int>(N, -1); //parentの値を-1にする(すべてバラバラ)
     }
    int root(int A) { //Aがどのグループに属しているか調べる
        if (parent[A] < 0) return A;
        return parent[A] = root(parent[A]);
    }
    int size(int A) { //自分のいるグループの頂点数を調べる
        return -parent[root(A)];//親をとってきたい
    }
    bool connect(int A, int B) { //AとBをくっ付ける．すでにつながっていた場合false
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) return false; //すでにくっついてるからくっ付けない
        if (size(A) < size(B)) swap(A, B); //大小が逆だったらひっくり返しちゃう。
        parent[A] += parent[B]; //Aのサイズを更新する
        parent[B] = A; //Bの親をAに変更する
        return true;
    }
};

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    union_find uf(N);
    REP(i, M){
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--;Y[i]--;
        uf.connect(X[i], Y[i]);
    }
    vector<int> ok(N, 0);
    int ans = 0;
    REP(i, N){
        if(uf.parent[i] < 0) ans++;
    }
    pr(ans);
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int a[3];
  
  REP(i,3){
    cin >> a[i];
  }
  
  sort(a,a+3);
  
  cout << a[0]+a[1] << endl;


 return 0;
}

Measured memory_bytes: 256
/*
***************************************************************************
 name  : ITP1_09_C.cpp
 title : Card Game
 make  : 2018/09/05 tanabe
***************************************************************************
*/

// Library
#include <iostream>  // standard input output object
#include <cstring>   // character functions

main(void){
  int n;          // number of cards
  std::string ct; // card of taro
  int pt=0;       // point of taro
  std::string ch; // card of hanako
  int ph=0;       // point of hanako
  int i;          // index

  std::cin >> n; // input "n"

  // initialized i = 0
  // continue i < n
  // increment i at loop update
  for(i = 0;i < n;i++){
    std::cin >> ct >> ch; // input "ct ch"

    if(ct > ch){
      pt += 3;
    }
    else
    if(ct < ch){
      ph += 3;
    }
    else{
      pt++;
      ph++;
    }
  }
  std::cout << pt << " " << ph << std::endl; // output "pt ph"

}



Measured memory_bytes: 3216
#include <iostream>
using namespace std;
int main(void)
{
  char b;
  cin >> b;
  switch(b)
  {
    case 'A':
      cout << 'T';
      break;
    case 'T':
      cout << 'A';
      break;
    case 'C':
      cout << 'G';
      break;
    case 'G':
      cout << 'C';
      break;
  }
  return 0;
}


Measured memory_bytes: 256
use num_integer::gcd;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
        d: u64,
    }
    let gcd = gcd(c, d);
    let lcm = c * d / gcd;
    let b_ans = b - b / c - b / d + b / lcm;
    let a_ans = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / lcm;
    let ans = b_ans - a_ans;
    println!("{:?}", ans);
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int h1,m1,h2,m2,k;
int main()
{
	cin>>h1>>m1>>h2>>m2>>k;
	
	int t1=h1*60+m1;
	int t2=h2*60+m2;
	t2-=k;
	cout<<max(0,t2-t1);
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main(){
    ll k;
    cin>>k;
    vector<vs> a;
    vs s={"1","2","3","4","5","6","7","8","9"};

    for(ll len=1;;len++){
        //for(auto q:s)cout<<q<<" ";cout<<endl;
        ll x=s.size();
        if(k<=x) cout<<s[k-1]<<endl,exit(0);
        vs z;
        for(string q:s) {
            if(q[len-1]!='0') z.pb(q+(char)(q[len-1]-1));
            z.pb(q+(char)(q[len-1]));
            if(q[len-1]!='9') z.pb(q+(char)(q[len-1]+1));
        }
        k-=x,s=z;
    }
}


Measured memory_bytes: 13600
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
    int a, b, c = 0;
    cin >> a >> b;

    rep2(i, a-1, b) {
    int j = i + 1;

    if ((j % 10 == j / 10000) && (j / 1000 % 10 == j % 100 / 10)) {
       c++;
    }
    }
    cout << c << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int X,Y,Z;
    cin >> X >> Y >> Z;
    
    int ans = 0;
    
    for(int i=0;i<X;i++){
        if((Y+Z)*i+Z<=X){
            ans = i;
        }else{
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
int main()
{
    fast;
    ll n,W;
    cin>>n>>W;
    ll a[n+2][2];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    vector<ll> dp(W+1,0);
    //a[i][0] -> wt
    //a[i][1] -> val
    vector<ll> ndp(W+1,0);
    for(int i=0;i<n;i++)
    {
        
        for(int j=1;j<=W;j++)
        {
            if(a[i][0] <= j)
            {
                ndp[j]=max(a[i][1] + dp[j-a[i][0]] , dp[j]);
            }
        }
        // for(int j:ndp)cout<<j<<" ";cout<<"\n";
        dp=ndp;
    }
    cout<<dp[W];
return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (n, a) = readLine()!!.split(" ").map(String::toInt)
    var dp = Array(n+1, {Array(a*n+1, {0.toLong()})}) 
    var dp_copy = Array(n+1, {Array(a*n+1, {0.toLong()})}) 
    val x = readLine()!!.split(" ").map(String::toInt)
    dp[0][0] = 1.toLong()
    dp_copy[0][0] = 1.toLong()
    for(i in 1..n){
        for(j in 0..n-1){
            for(k in 0..n*a-x[i-1]){
                dp_copy[j+1][k+x[i-1]] += dp[j][k]
            }
        }
        for(j in 0..n){
            for(k in 0..n*a){
                dp[j][k] = dp_copy[j][k]
            }
        }
    }
    var ans = 0.toLong()
    for(i in 1..n) ans += dp[i][i*a]
    println(ans)
}

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

int main() {
	char c;
	cin>>c;
	if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
		cout<<"vowel"<<endl;
	}
	else{
		cout<<"consonant"<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

mint f(ll n)
{
  if (n == 0)
    return 1;
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1)
    x *= 2;
  return x;
}

mint choose(ll n, ll a)
{
  mint x = 1, y = 1;
  rep(i, a)
  {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main()
{
  ll x, y;
  cin >> x >> y;
  ll n = (x + y) / 3;
  if ((x + y) % 3 != 0)
  {
    cout << 0 << "\n";
    return 0;
  }
  ll tx = x - n;
  ll ty = y - n;
  if (tx < 0 || ty < 0)
  {
    cout << 0 << "\n";
    return 0;
  }
  mint ans = choose(tx + ty, tx);
  cout << ans.x << "\n";
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<bool> dp(K + 1);
    for (int i = 0; i < K; ++i) {
        if (dp[i])
            continue;
        for (int j = 0; j < N; ++j) {
            if (i + a[j] > K)
                continue;
            dp[i + a[j]] = true;
        }
    }

    cout << (dp[K] ? "First" : "Second") << endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int mod = 1000000007;
long long dp[100000][2][100];
//dp[i][j][k] ：i桁目までの和をdで割った時の余りがkのとなる数の個数
//i;i桁目まで
//j;未満ふらぐ
//k;i桁目までの和の%dの値
//dp[i+1][j][k] = dp[i][j][k-xx] +  

int main() {
  string k;
  int d;
  cin >> k >>d;
  //s[0] - '0'
  //cout << k[0] - '0' << endl;
  for(int i = 0;i<= k[0] - '0';i++){
    //cout << i << endl;
    if(i != k[0] - '0'){
      dp[0][1][i%d] += 1;
    }else{
      dp[0][0][i%d] += 1;
    }
  }
  //cout << dp[0][1][0] + dp[0][0][0] << endl; 
  
  int s;
  for(int i = 1;i < k.size();i++){
    s = k[i] -'0';
    //cout << s << endl;
    for(int amari = 0;amari < d;amari++){
      for(int j = 0;j<=9;j++){
        dp[i][1][(amari+j)%d] += dp[i-1][1][amari];
        dp[i][1][(amari+j)%d] %= mod;
        //cout << dp[i][1][(amari+j)%d]  << " " << " " << j << " " << amari << " " << (amari+j)%d<< endl;
        //cout << j << " " << amari << " " << (amari+d-j%d)%d << " "  << dp[i][1][amari] << " " << dp[i-1][1][(amari+d-j%d)%d] << endl;
      }
      for(int j = 0;j< s;j++){
        dp[i][1][(amari+j)%d] += dp[i-1][0][amari];
      }
      dp[i][0][(amari+s)%d] += dp[i-1][0][amari];
    }
  }
  cout << (dp[k.size()-1][0][0] + dp[k.size()-1][1][0] -1)%mod;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    int ans = 10000;
    rep(i,10){
        int t = (i+1) * 1000;
        t = t - n;
        if(t>=0){
            ans = min(ans, t);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T> inline T next(){T x;cin>>x;return x;}

int main()
{
    int n; cin >> n;
    int sum=0;
    for(int i=0;i<n;i++) sum+=next<int>();
    cout<<sum-n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

set<int> make_prime_set(int lim){//10^7:4.938 10^6:0.265sec 10^5:0.015sec lim > 2
  set<int> ps;
  bool pflag;
  int num;
  ps.insert(2);
  for(num = 3; num < lim; num++){
    pflag = true;
    for(int p : ps){
      if(p * p > num) break;
      if(num % p == 0){
        pflag = false;
        break;
      }
    }
    if(pflag == true) ps.insert(num);
  }

  return ps;
}

int main(){
  int x;
  cin >> x;
  auto sp = make_prime_set(1e5+1000);
  auto itr = sp.lower_bound(x);
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, a, b;
    cin >> n >> a >> b;
    
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    string a, b, c;
    
    cin >> a >> b >> c;
    
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
        
    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const [n, k] = args[0].map(x => parseInt(x));
const snuke: boolean[] = Array(n).fill(false);
for (let i = 0; i < k; i++) {
    const d = parseInt(args[2 * i + 1][0]);
    for (let j = 0; j < d; j++) {
        snuke[parseInt(args[2 * i + 2][j]) - 1] = true;
    }
}

const cnt = snuke.filter(x => x === false).length;

console.log(cnt);

Measured memory_bytes: 29644
#include <bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}
int main(){
  int N; cin>>N;
  for(int i=N;i<100004;i++){
    if(IsPrime(i)){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3656
n=int(input())
import bisect
a=[]
b=[]
c=[]
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
sum=0
for i in range(n):
    s=b[i]
    kc=n-bisect.bisect_right(c,s)
    ka=bisect.bisect_left(a,s)
    sum+=kc*ka
print(sum)

Measured memory_bytes: 23156
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a[3];
    for(int i=0; i<3; i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if(a[0]==5 && a[2]==7 && a[1]==5)
    {
        cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
    return 0;
}


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

int main(){
int n;
cin >> n;
vector<int> a(n+1);
for(int i = 0; i < n ; i++)cin >> a[i];
a[n] = 0;
 
ll cash = 1000;
ll kabu = 0;
for(int i = 0; i < n-1; i++){
  if(a[i]<a[i+1]){
     kabu = cash/ a[i];
     cash += (a[i+1]-a[i])*kabu;
    }
}
cout << cash << endl;
return 0;
}

Measured memory_bytes: 3624
MOD = 10 ** 9 + 7
H, W, K = map(int, input().split())

if W == 1:
    print(1)
    exit()

pat = [0] * W
for i in range(2 ** (W - 1)):
    j = bin(i)
    if not str(j).count('11'):
        pat[len(j) - 2] += 1
for i in range(W - 1):
    pat[i + 1] += pat[i]
pat[0] = 1

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        k = j + 1
        if k == 1:
            dp[i + 1][j] += dp[i][j] * pat[max(0, W - 1 - 1)]
            dp[i + 1][j] += dp[i][j + 1] * pat[max(0, W - 1 - 2)]
        elif 1 < k < W:
            dp[i + 1][j] += dp[i][j] * pat[max(0, j - 1)] * pat[max(0, W - k - 1)]
            dp[i + 1][j] += dp[i][j - 1] * pat[max(0, j - 2)] * pat[max(0, W - k - 1)]
            dp[i + 1][j] += dp[i][j + 1] * pat[max(0, j - 1)] * pat[max(0, W - k - 2)]
        else:
            dp[i + 1][j] += dp[i][j] * pat[max(0, W - 1 - 1)]
            dp[i + 1][j] += dp[i][j - 1] * pat[max(0, W - 1 - 2)]

        dp[i+ 1][j] %= MOD

print(dp[H][K - 1])


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

int main() {
	int a,b,c,k,s=0;
	cin>>a>>b>>c>>k;
	if(a<=k){
	    s+=a;
	    k-=a;
	} else{
	    s+=k;
	    k=0;
	}
	if(k!=0){
	    if(b<=k){
	        k-=b;
	    }else{
	        k=0;
	    }   
	}
	if(k!=0){
	    s-=k;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    vector<ll> ans(50,49+k/50+1);
    ll c = 50-k%50;
    rep(i,c){
        rep(j,50){
            if (i == j) ans[j] -= 50;
            else ans[j]++;
        }
    }
    PRINT(50);
    array_output(all(ans));
}




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

int main() {
int g=0,p=0,c=0;
string s;
cin>>s;
for(int i=0;i<s.length();i++){
    if(s[i]=='p'){
        if(p>=g){
            c--;
            g++;
        }else{
            p++;
        }
    }else{
        if(p<g){
            c++;
            p++;
        }else{
            g++;
        }
    }
}
cout<<c<<endl;
	return 0;
}

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

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

    int cnt = 1;
    while(s != 4) {
        if (s <= 2) break;
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
        cnt++;
    }

    cout << cnt + 3 << endl;

    return 0;
}


Measured memory_bytes: 3620