akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

typedef long long ll;

int main(void)
{
  ll N, M;
  cin >> N >> M;
  ll ans;
  for (ll d = M / N; d > 0; d--) {
    if (M % d == 0) {
      if (M / d >= N) {
	ans = d;
	cout << ans << endl;
	return 0;
      }
    }
  }
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
int a,b;
  cin >> a >> b;
  if (a%3 == 0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k =  Integer.parseInt(sc.next());
		String s[] = sc.next().split("");
		int loop = 0;
		int cnt = 0;

		for (int i=0 ; i < n -1 ; i++) {
			if(s[i].equals(s[i+1])) {
				cnt++;
			}

		}

		while(cnt < n -1 && loop < k ) {


			cnt += 2;
			loop++;
		}
		if(cnt > n -1) {
			cnt = n-1;
		}

		System.out.println(cnt);
	}

}

Measured memory_bytes: 35184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;


bool ok(string s,string t,ll start){
	FOR(i,start,start+t.size()){
		ll j = i - start;
		if(s[i]!=t[j] && s[i]!='?'){
			return false;
		}
	}
	return true;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t,ans,w;
	bool anst = false;
	cin>>s>>t;
	w = s;
	FOR(i,0,w.size()){
		if(w[i]=='?')w[i]='a';
	}
	FOR(i,0,s.size()-t.size()+1){
		if(ok(s,t,i)){
			if(!anst){
				anst = true;
				ans = w;
				FOR(j,0,t.size())ans[i+j]=t[j];
			}else{
				string answ = w;
				FOR(j,0,t.size())answ[i+j]=t[j];
				ans = min(ans,answ);
			}
		}
	}
	if(anst){
		cout<<ans<<endl;
	}else{
		cout<<"UNRESTORABLE"<<endl;
	}
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int tmp;
set<int> bought;
rep(i,3){
    cin>>tmp;
    bought.insert(tmp);
}
cout<<bought.size()<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
//abc124_b.cpp
//Fri Apr 19 21:02:47 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int h[n];
	int ans = 0;
	for (int i=0;i<n;i++){
		cin >> h[i];
		if (i==0){
			ans++;
		}else{
			int flag = 1;
			for (int j=0;j<i;j++){
				if (h[i]-h[j]<0){
					flag = 0;
					break;
				}
			}
			if (flag){
				ans++;
			}
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

const int INF = 1001001001;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    if(A == B == C){
        cout << -1 << endl;
        return 0;
    }
    
    int cnt = 0;
    for(int i = 0; i < 10010010; ++i){
        int a = A / 2;
        int b = B / 2;
        int c = C / 2;
        
        A = a + b;
        B = b + c;
        C = c + a;
        cnt++;
        
        if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0){
            cout << cnt << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2e5 + 123;
int n, a[N], q, f[N], dp[N];
vi vec[N];

struct node {
	int l = 0, r = 0, mn = 0;
	void upd(int x) {
		mn = min(mn, x);
	}
};

node t[(1 << 19) + 1];

void build(int v, int l, int r) {
	t[v].l = l, t[v].r = r, t[v].mn = N;
	if (l == r) {
		return;
	}
	int m = l + r >> 1;
	build(v << 1, l, m);
	build(v << 1 | 1, m + 1, r);
}

void push(int v) {
	t[v << 1].upd(t[v].mn);
	t[v << 1 | 1].upd(t[v].mn);
}

void upd(int v, int l, int r, int x) {
	if (t[v].l > r || t[v].r < l) {
		return;
	}
	if (t[v].l >= l && t[v].r <= r) {
		t[v].upd(x);
		return;
	}
	push(v);
	upd(v << 1, l, r, x);
	upd(v << 1 | 1, l, r, x);
}

int get(int v, int pos) {
	if (t[v].l == t[v].r) {
		return t[v].mn;
	}
	push(v);
	int m = t[v].l + t[v].r >> 1;
	if (pos <= m) {
		return get(v << 1, pos);
	}	else {
		return get(v << 1 | 1, pos);
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s += a[i];
		f[i] = f[i - 1] + (a[i] == 0) - (a[i] == 1);
	}
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		vec[r].pb(l);
	}
	build(1, 1, n);
	for (int i = 1; i <= n; i++) {
		int res = N;
		for (int l : vec[i]) {
			int x = min(dp[l - 1] - f[l - 1], get(1, l));
			upd(1, l, i, x);
			res = min(res, x);
		}
		dp[i] = min(dp[i - 1], res + f[i]);
	}
	cout << dp[n] + s;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> lucas(87,0);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  
  for (int i = 2; i <= N; i++) {
    lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
  }
  
  cout << lucas.at(N) << endl;
}
  

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve (int i, int m){
      if( m == 0) return 1;
      if( i >= n) return 0;
      int res = solve(i + 1, m) || solve( i + 1, m - A[i]);
      return res;
}

int main(){
   int q, M, i;

   scanf("%d", &n);
   for( i = 0; i < n; i++) scanf("%d", &A[i]);
   scanf("%d", &q);
   for(i = 0; i < q; i++){
   scanf("%d", &M);
   if( solve(0, M)) printf("yes\n");
   else printf("no\n");
}
return 0;
}

Measured memory_bytes: 580
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 120000;

vector<int> eds[MAXN];

int n, m;

int was[MAXN];
vector<int> vv;

void dfs1(int v) {
	was[v] = 1;
	for (int u: eds[v])
		if (!was[u])
			dfs1(u);
	vv.push_back(v);
}

int dp[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
	}
	for (int i = 0; i < n; ++i)
		if (!was[i])
			dfs1(i);
	reverse(ALL(vv));
	int ans = 0;
	for (int i: vv) {
		ans = max(ans, dp[i]);
		for (int u: eds[i])
			dp[u] = max(dp[u], dp[i] + 1);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 8440
import Control.Monad

main = do
    n <- readLn
    xs <- replicateM n readLn
    if foldl (&&) True $ map ((>0) . foldl1 (\a b -> if (a-10) < 0 then 0 else max (a-10) b)) [xs, reverse xs]
        then putStrLn "yes"
        else putStrLn "no"



Measured memory_bytes: 210024
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int INF = 1e9;

const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	vector<vector<int>> d(H, vector<int>(W, INF));
	deque<pii> dq;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.') {
				a[i][j] = '0';
				dq.emplace_front(i * W + j, 0);
			}
		}
	}
	while (!dq.empty()) {
		auto p = dq.front(); dq.pop_front();
		int x = p.first / W, y = p.first % W;
		if (d[x][y] != INF) continue;
		int cnt = 0;
		for (int i = 0; i < 8; i++) {
			int tx = x + dx[i], ty = y + dy[i];
			cnt += (0 <= tx && tx < H && 0 <= ty && ty < W && d[tx][ty] < p.second);
		}
		if (cnt < a[x][y] - '0') continue;
		d[x][y] = p.second;
		for (int i = 0; i < 8; i++) {
			int tx = x + dx[i], ty = y + dy[i];
			if (tx < 0 || H <= tx || ty < 0 || W <= ty || d[tx][ty] != INF) continue;
			dq.emplace_front(tx * W + ty, d[x][y]);
			dq.emplace_back(tx * W + ty, d[x][y] + 1);
		}
	}
	int res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (d[i][j] != INF) {
				res = max(res, d[i][j]);
			}
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 9232
N = input()
if N[1] < N[0]:
  n = int(N[0])
  print(n + n*10 + n*100)
elif N[1]==N[0] and N[2] <= N[1]:
  n = int(N[0])
  print(n + n*10 + n*100)
else:
  n = int(N[0])+1
  print(n + n*10 + n*100)

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

int N;
int A[210];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int res = 0;
    
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N ; i++) {
            if(A[i] % 2 == 0){
                A[i] /= 2;
            } else {
                exist_odd = true;
                break;
            }
        }

        if (exist_odd) break;
        
        res++;
    }

    cout << res << endl;
    
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).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 INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;

string str[105];
int main(){
	int n;
	cin>>n;
	rep(i,3)cin>>str[i];
	int ans=0;
	rep(i,n){
		int cnt[27]={0};
		rep(j,3){
			int x=str[j][i]-'a';
			cnt[x]++;
		}
		int ma=0;
		rep(i,27){
			maxs(ma,cnt[i]);
		}
		//cout<<ma<<endl;
		ans+=(3-ma);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b = 0;
  cin >> N;
  vector<int> flag(101);
  
  for(int i = 0; i < N; i++){
    cin >> a;
    flag.at(a) = 1;
  }
  
  for(int i = 0; i < 101; i++){
    b += flag.at(i);
  }
  
  cout << b << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
ll a, b, c;
long double s = 1.0;
int main()
{
    cin >> a >> b >> c;
    ll p = c - a - b;
    ll g = 4 * a * b;
    ll o = p*p;
    if (p>=0&&o > g)
        puts("Yes");
    else
    {
        puts("No");
    }
}

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

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

  for (int i = 0; i < S.size(); i++) {
    if (0 == i % 2) {
      if ( ('R' == S[i]) || ('U' == S[i]) || ('D' == S[i]) ) {
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if ( ('L' == S[i]) || ('U' == S[i]) || ('D' == S[i]) ) {
        continue;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
  }

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

Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int main()
{
	int day, a, b, c, d;
	
	scanf("%d %d %d %d %d", &day, &a, &b, &c, &d);
	
	while(a > 0 || b > 0){
		
		a -= c;
		b -= d;
		day--;
	}
	
	printf("%d\n", day);
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  int D;
  cin >> D;
  
  if (D == 25)
    cout << "Christmas" << endl;
  
  if (D == 24)
    cout << "Christmas Eve" << endl;
  
  if (D == 23)
    cout << "Christmas Eve Eve" << endl;
  
  if (D == 22)
    cout << "Christmas Eve Eve Eve" << endl;
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000

int main(){

  int i, j, n, min, max;
  int num[N];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &num[i]);
  }

  min = num[0];
  max = num[1]-num[0];
  for(j=1; j<n; j++){
    if(max < num[j]-min){
      max = num[j]-min;
    }
    if(min > num[j]){
      min = num[j];
    }
  }

  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 1376
s = input()

res = 'Yes'
if s != s[::-1]:
    res = 'No'
t = s[:(len(s)-1)//2]
if t != t[::-1]:
    res = 'No'
u = s[((len(s)+3)//2)-1:len(s)]
if u != u[::-1]:
    res = 'No'

print(res)


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

using Graph = vector<vector<int>>;

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

    Graph G(n);

    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> dist(n, -1);
    vector<int> ans(n,0);
    queue<int> que;
    queue<int> where_from;

    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする
    where_from.push(-1);

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);

            ans[nv] = v;
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << endl;
    for (int v = 1; v < n; ++v) cout << ans[v] + 1 << endl;
}


Measured memory_bytes: 10740
import sys
N=int(input())
A=[[*map(int,ln.split())] for ln in sys.stdin]

ans=0
a=0
for i in range(N):
    a+=A[0][i]
    b=a
    for j in range(i,N):
        b+=A[1][j]
    ans=max(ans,b)

#print(A)
print(ans)


Measured memory_bytes: 9188
while True:
    try:
        A=list(map(str,input().split()))
        B=list(map(str,input().split()))
        h=0
        b=0
        for i in range(4):
            if A[i] in B:
                b+=1
            if A[i]==B[i]:
                h+=1
        print(h,b-h)
    except EOFError:
        break


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define erep(i, n) for(int i = 0; i <= (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1E-11;

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

//fixed << setprecision(10)

int main() {
	int n; cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n);

	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];

	sort(all(a));
	sort(all(b));
	sort(all(c));

	ll count = 0;

	//b[i]の値を固定する
	for (int i = 0; i < n; i++) {
			ll x = lower_bound(all(a), b[i]) - a.begin();
			ll y = c.end() - upper_bound(all(c), b[i]);

			//ll x = a.end() - upper_bound(all(a), b[i]);
			//ll y = lower_bound(all(c), b[i]) - c.begin();

			count = count + (x * y);
		}
	cout << count << endl;
}


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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	string a, b; cin >> a >> b;
	int cnt = 0;
	for (int i = 0; i < a.size(); ++i)
		if (a[i] == b[i]) ++cnt;

	cout << cnt << '\n';



	return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = list(input())
N = len(S)
d = defaultdict(int)

beki = [0]*N
now = 1
for i in range(N):
    beki[i] = now
    now *= 10
    now %= 2019

now = 0
d[0] = 1
ans = 0
for i in range(N):
    now += int(S[N-1-i])*beki[i]
    now %= 2019
    ans += d[now]
    d[now] += 1

print(ans)

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

int main() {
  int S = 0;
  int N;
  cin >> N;

  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    S += r - l + 1;
  }
  
  cout << S << endl;
}


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

int main(void){
    string s,t;
    cin>>s;
    cin>>t;
    int count=0;
    int size=s.size();
    rep(i,size){
        if(s[i]!=t[i])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3816
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

bool comp(int a, int b) 
{ 
    return (a < b); 
}

ll arr[200005]={0},diff[200005]={0};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll k,n,itr;
	cin>>k>>n;
	itr=0;
	ll start;

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

	for (int i = 0; i < n; i++)
	{
		if(i==0){
			//cout<<arr[0]<<" "<<arr[n-1]<<endl;
			start=arr[0]+k-arr[n-1];
			//cout<<start<<endl;
			diff[0]=start;
			// if(start<0){
			// //	cout<<"I was here"<<endl;
			// 	diff[0]=-start;
			// }
			// else{
			// //	cout<<"I was here(2)"<<endl;
			// 	diff[0]=start;
			// }
		}
		else{
			start=arr[i]-arr[i-1];
			diff[i]=start;
			// if(start<0){
			// 	diff[i]=-start;
			// }
			// else{
			// 	diff[i]=start;
			// }
		}
	}

	start=diff[0];
	for (int i = 1; i < n; i++)
	{
		if(diff[i]>start)
			start=diff[i];
	}

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<arr[i]<<" ";
	// }
	// cout<<endl;
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<diff[i]<<" ";
	// }
	// cout<<endl;
	// cout<<start<<endl;
	
	cout<<k-start;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#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 unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int INF = 1e9 + 10;
const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

int N;
int a[100010];
bool used[100010];

signed main()
{
	cin >> N;

	if (N == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	int l, r;

	rep(i, N + 1) {
		cin >> a[i];
		if (used[a[i]]) {
			r = i + 1;
			rep(j, i) {
				if (a[j] == a[i]) {
					l = j + 1;
					break;
				}
			}
		}
		used[a[i]] = true;
	}

	comb_init();

	int s = r - l - 1;

	rep1(k, N + 1) {
		int ans = 0;

		ans += C(N + 1 - 2, k);
		ans %= mod;
		if (k - 2 >= 0) {
			ans += C(N + 1 - 2, k - 2);
			ans %= mod;
		}
		if (N + 1 - 2 >= k - 1) ans += C(N + 1 - 2, k - 1) * 2 % mod;
		if (N + 1 - s - 2 >= k - 1) ans += (mod - C(N + 1 - s - 2, k - 1)) * 2 % mod;
		ans %= mod;
		if (N + 1 - s - 2 >= k - 1) ans += C(N + 1 - s - 2, k - 1);
		ans %= mod;

		printf("%lld\n", ans);
	}
}



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

ll INF = 1e+18;

int 
main()
{
  int N; cin >> N;
  map<string, ll> m;
  string s;
  rep(i, 0, N){
    string s; cin >> s;
    sort(s.begin(), s.end());
    m[s] += 1;
  }

  ll ans = 0;
  for(auto num: m){
    if(num.second >= 2) ans += (num.second * (num.second -1)) / 2;
  }

  cout << ans << endl;

}

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

#define INF 100000000

using namespace std;

int V,match[2001];
bool used[2001];
vector<int>G[2001];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i],w=match[u];
		if(w<0 || !used[w] && dfs(w)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bitpartite_matching(){
	int res=0;
	fill(match,match+2001,-1);
	for(int v=0;v<V;v++){
		if(match[v]<0){
			fill(used,used+2001,false);
			if(dfs(v))res++;
		}
	}
	return res;
}

int main(void){
	
	int n,m,l,u,v,d,dist[101][101],p[1001],t[1001];
	
	while(cin >> n >> m >> l,n|m|l){
		for(int i=0;i<2001;i++)G[i].clear();
		
		fill(dist[0],dist[101],INF);
		
		for(int i=0;i<101;i++)dist[i][i]=0;
		for(int i=0;i<m;i++){
			cin >> u >> v >> d;
			dist[u][v]=dist[v][u]=d;
		}
		
		for(int k=0;k<n;k++)
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		
		for(int i=0;i<l;i++)cin >> p[i] >> t[i];
		
		for(int i=0;i<l;i++){
			for(int j=0;j<l;j++){
				if(i==j)continue;
				if(dist[p[i]][p[j]]+t[i]<=t[j])add_edge(i,j+l);
			}
		}
		V=2*l;
		cout << l-bitpartite_matching() << endl;
	}
	return 0;
}

Measured memory_bytes: 9736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[85715];
		int[] sosu = new int[35813];
		int[] tansaku = new int[300001];
		for(int i=6;i<=300000;++i){
			if(i%7==6 || i%7==1){
				tansaku[i]=1;
			}
		}
		int end=(int)Math.sqrt((double)300000);
		for(int i=6;i<=end;i++){
			if(tansaku[i]==1){
				for(int j=i+i;j<=300000;j+=i){  // 素数の定数倍は素数とならないので排除するループ
					if(tansaku[j]==1){
						tansaku[j]=0;
					}
				}
			}
		}
		int m=0;
		for(int i=6;i<=300000;++i){
			if(tansaku[i]==1){
				sosu[m]=i;
				++m;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==1) break;
			System.out.print(n+":");
			for(int i=0;i<sosu.length;++i){
				if(n%sosu[i]==0) System.out.print(" "+sosu[i]);
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 32436
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 2e4 + 100;
long long a[N], b[N];

vector <pair <long long, long long> > v, nv;

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i] );

	int ans = 0;
	long long x = 1;
	for (int it = 0; it < 18; it++)
	{
		long long x10 = x * 10;
		for (int i = 0; i < n; i++)
			b[i] = a[i] % x10;
	
		bool win = false;
		for (int d = 9; d >= 0; d--)
		{
			v.clear();
			v.emplace_back(x * d, x * (d + 1) - 1);
			if (d == 0) win = true;
			for (int i = 0; i < n && !win; i++)
			{
				nv.clear();
				for (auto p : v)
				{
					long long l = p.first - b[i], r = p.second - b[i];
					if (l < 0 && r >= 0)
					{
						win = true;
						break;
					}
					if (l < 0 && r < 0)
					{
						l += 10 * x;
						r += 10 * x;
					}
					nv.emplace_back(l, r);
					if (l == 0)
					{
						win = true;
						break;
					}
				}
				if (win) break;
				for (auto p : nv)
					v.push_back(p);
				sort(v.begin(), v.end() );
				nv.clear();
				long long l = -1, r = -1;
				for (auto p : v)
				{
					if (p.first > r)
					{
						if (l != -1)
							nv.emplace_back(l, r);
						l = p.first;
						r = p.second;
					}
					r = max(r, p.second);
				}
				nv.emplace_back(l, r);
				v = nv;
				nv.clear();
			}
			if (win)
			{
				ans += d;
				break;
			}
		}

		x *= 10;
	}
	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	std::string w, a;
	int c {};
	std::cin >> w;
	for (;;) {
		std::cin >> a;
		if(a == "END_OF_TEXT") break;
		std::transform(a.begin(), a.end(), a.begin(), tolower);
		a == w && ++c;
	}
	std::cout << c << '\n';	
}

Measured memory_bytes: 3128
i_nums = []
x = True
while x == True:
    i_nums.append(list(map(int, input().split())))
    if i_nums[-1][0] == i_nums[-1][1] == 0:
        x = False
i_nums.pop()

for nums in i_nums:
    for i in range(nums[0]):
        for j in range(nums[1]):
            if i == 0 or i == nums[0]-1:
                print('#', end='')
            elif j == 0 or j == nums[1]-1:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')




Measured memory_bytes: 7012
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n),b(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
	}
	for (uint32 i = 0;i < n;++i) {
		std::cin >> b[i];
	}
	uint32 ans = 0;
	for (uint32 i = 0;i < n;++i) {
		uint32 cur = 0;
		for (uint32 j = 0;j <= i;++j) {
			cur += a[j];
		}
		for (uint32 j = i;j < n;++j) {
			cur += b[j];
		}
		ans = std::max(ans, cur);
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
n, m, X = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
    
for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)
        
    


Measured memory_bytes: 9240
import java.util.*;

public class Main {
	static int t[] = new int[100];
	static int low[] = new int[100];
	
	static int cnt = 0, n, m;
	static boolean adj[][] = new boolean[100][100];
	
	static int bridge = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		m = sc.nextInt();
		
		
		for(int i=0;i<m;i++){
			int u = sc.nextInt(), v = sc.nextInt();
			adj[u][v] = true;
			adj[v][u] = true;
		}
		
		dfs(0, 1);
		
		System.out.println(bridge);
	}
	
	static void dfs(int p, int u){
		t[u] = ++cnt;
		low[u] = t[u];
		
		for(int i=1;i<=n;i++){
			if(adj[u][i]){
				if(t[i] != 0 && i!=p){
					low[u] = Math.min(t[i], low[u]);
				}
				else if(t[i] == 0){
					dfs(u, i);
					low[u] = Math.min(low[i], low[u]);
					if(low[i] > t[u]){
						bridge++;
					}
				}
			}
		}
	}
}


Measured memory_bytes: 23892
while True:
    i = list(input().split())
    i[0] = int(i[0])
    i[2] = int(i[2])
    if i[1] == "?":
        break
    elif i[1] == "+":
        print(i[0]+i[2])
    elif i[1] == "-":
        print(i[0]-i[2])
    elif i[1] == "*":
        print(i[0]*i[2])
    elif i[1] == "/":
        print(i[0]//i[2])


Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll a,b,sum=0;
	cin>>a>>b;
	if(a>b){
		for(int i=0;i<a;i++)
		{
			sum+=b*pow(10,i);
		}

	}
	else
	{
		for(int i=0;i<b;i++)
		{
			sum+=a*pow(10,i);
		}
	}
	cout<<sum;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
 
N, M = map(int, input().split())
X = []
for _ in range(M):
    a, b = map(int, input().split())
    X.append((a-1, b-1))
X = X[::-1]
    
P = [-1] * N
CT = [1] * N
def pr(i):
    if P[i] < 0:
        return i
    t = pr(P[i])
    P[i] = t
    return t
 
ANS = [0] * M
ans = N * (N-1) // 2
ANS[-1] = ans
for m in range(M-1):
    a, b = X[m]
    pa = pr(a)
    pb = pr(b)
    
    if pa != pb:
        ans -= CT[pa] * CT[pb]
        P[pa] = pb
        CT[pb] += CT[pa]
 
    ANS[-m-2] = ans
 
for a in ANS:
    print(a)

Measured memory_bytes: 35804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		sc.close();
		if(N == 100){
			N++;
		}
		for(int a = 0 ; a < D ; a++){
			N = N * 100;
		}
		System.out.println(N);		
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n,k;
    cin >> n >> k;
    vector<double> v(n+1);
    v[0]=0.0;
    int id=1;
    for (int i=0;i < n;i++){
        int t;
        cin >> t;
        v[id]=v[id-1]+((t+1)/2.0);
        id++;
    }
    double ans=0.0;
    for (int j=0; j+k < n+1;j++){
        if (ans < (v[j+k]-v[j])){
            ans=(v[j+k]-v[j]);
        }
    }
    printf("%.8f\n",ans);

    return 0;
}
/*
5 3
1 2 2 4 5
*/

Measured memory_bytes: 1792
#include <stdio.h>
 
int main(void){
    
    int n;
    scanf("%d",&n);
 
    int a[1000000];
    for(int i=1; i<=n+1; i++){
        scanf("%d",&a[i]);
    }
 
    int b[1000000];
    for(int i=1; i<=n; i++){
        scanf("%d",&b[i]);
    }
 
    long long int cnt = 0;
    
    for(int i=1; i<=n+1; i++){
       if(a[i]+a[i+1]>=b[i]){
           cnt+=b[i];
           if(a[i]<=b[i]){
               a[i+1]=a[i]+a[i+1]-b[i];
           }
       }
       else{
            cnt+=a[i]+a[i+1];
            a[i+1]=0;
       }
    }
 
    printf("%lld\n", cnt);
 
    return 0;
}

Measured memory_bytes: 2560
A = {k:a for k,a in zip(list("IOTJLSZ"),map(int,input().split()))}
m = min(A["I"],A["J"],A["L"])
ans = 0
for i in range(min(2,m+1)):
    ans = max(ans, 3*i + A["O"] + (A["I"]-i)//2*2 + (A["J"]-i)//2*2 + (A["L"]-i)//2*2)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
bool debug=false;

int main(){
  int x,y,s;
  while(1){
    cin>>x>>y>>s;
    if(x==0&&y==0&&s==0)break;
    int before=100*s/(100+x)+1;
    if(debug)cout<<"before: "<<before<<endl;
    int ans=-1;
    for(int i=1;i<s;i++){
      for(int j=1;j<s;j++){
	if(i*(100+x)/100+j*(100+x)/100==s){
	  ans=max(ans,i*(100+y)/100+j*(100+y)/100);
	}
	if(debug)cout<<i*(100+y)/100+j*(100+y)/100<<endl;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll gcd(ll A,ll B){
 while(A != 0){
 if(A < B){
   swap(A,B);
 }

   A %= B;

 }
 return B;
}

int main() {
  ll A,B;
  cin >> A >>B;
  ll saidai = gcd(A,B);
  //cout << saidai <<endl;
  if(saidai == 0){
    cout << A*B <<endl;
  }else{
    A = A/saidai;
    B = B/saidai;
    cout << A*B*saidai <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;
int n,m,k;
int mat[3001][3001];
int dp[3001][3001][4];
int dfs(int i,int j,int cur){
    if(i == n or j == m or cur == 3){
        return 0;
    }
    if(dp[i][j][cur] != -1){
        return dp[i][j][cur];
    }
    int &ans = dp[i][j][cur];
    ans = 0;
    if(mat[i][j] == 0){
        ans = max({ans,dfs(i+1,j,0),dfs(i,j+1,cur)});
    }
    else{
        ans = max({ans,mat[i][j] + dfs(i+1,j,0),mat[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    }
    return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> k;
    memset(dp,-1,sizeof(dp));
    f(i,0,k){
        int x,y,val;
        cin >> x >> y >> val;
        x--;
        y--;
        mat[x][y] = val;
    }
    cout << dfs(0,0,0);
    return 0;
}
 

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

#define ff first
#define ss second
#define all(abcc) (abcc).begin(), (abcc).end()
#define endl '\n'
#define left aba
#define right abc

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N=103, V=100003;

int n, maxw;

int w[N], v[N];
ll dp[N][V];

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

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

    for(int i=0; i<=n; ++i) for(int j=0; j<V; ++j) dp[i][j]=(ll)(1e12);

    dp[0][0]=0;

    for(int i=1; i<=n; ++i) {
        for(int j=0; j<V; ++j) {
            dp[i][j]=dp[i-1][j];
            if(j>=v[i]) {
                dp[i][j]=min(dp[i][j], dp[i-1][j-v[i]]+(ll)w[i]);
            }
        }
    }

    int ans;
    for(ans=V-1; ans>0; --ans) {
        if(dp[n][ans]<=(ll)maxw) {
            break;
        }
    }

    cout<<ans<<endl;

    //cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<'\n';
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<ll> v(10010,0);
  for(ll i = 1;i <= 100;i++){
    for(ll j = 1;j <= 100;j++){
      for(ll k =1;k <= 100;k++){
        ll a = i*i+j*j+k*k+i*j+j*k+k*i;
        if(a < 10010)v[a]++;
      }
    }
  }
  for(int i = 1;i <= n;i++)cout << v[i] << endl;
  

  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  char c; cin >> c;
  if('A' <= c && c <= 'Z') {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }

}








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

using namespace std;

int main()
{
  long long N, W;
  cin >> N >> W;
  vector<long long> o[4];
  int cnt = 0;
  map<long long, long long> m1, m2;
  for (int i = 0; i < N; i++)
  {
    int w, v;
    cin >> w >> v;
    if (m1.count(w) == 0)
    {
      o[cnt].push_back(v);
      m1[w] = cnt;
      m2[cnt] = w;
      cnt++;
    }
    else
      o[m1[w]].push_back(v);
  }
  sort(o[0].begin(), o[0].end(), greater<long long>());
  sort(o[1].begin(), o[1].end(), greater<long long>());
  sort(o[2].begin(), o[2].end(), greater<long long>());
  sort(o[3].begin(), o[3].end(), greater<long long>());
  long long ans = 0;
  for (int i = 0; i <= o[0].size(); i++)
    for (int j = 0; j <= o[1].size(); j++)
      for (int k = 0; k <= o[2].size(); k++)
        for (int l = 0; l <= o[3].size(); l++)
        {
          if (W < m2[0] * i + m2[1] * j + m2[2] * k + m2[3] * l)
            continue;
          long long tmp = 0;
          for (int t = 0; t < i; t++)
            tmp += o[0][t];
          for (int t = 0; t < j; t++)
            tmp += o[1][t];
          for (int t = 0; t < k; t++)
            tmp += o[2][t];
          for (int t = 0; t < l; t++)
            tmp += o[3][t];
          ans = max(ans, tmp);
        }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>


using std::string;
using std::vector;

static const uint32_t PRIME_LIST_SIZE = 100000000 + 1;
// static const uint32_t PRIME_LIST_SIZE = 100000000 + 1;

void printList(const std::vector<bool>& list){
    for(int i = 0; i < list.size(); i++){
        printf("list[%d] = %d\n", i, list[i]);
    }
}

std::vector<bool> createPrimeList() {
    static std::vector<bool> list(PRIME_LIST_SIZE, true);
    // printList(list);
    list[0] = false;
    const int64_t sqrtMax = std::ceil(std::sqrt(PRIME_LIST_SIZE));
    for (int64_t p = 2; p < sqrtMax; p++){
        if (!list[p]) continue;

        for (int64_t mult = p * p; mult < PRIME_LIST_SIZE; mult += p){
            list[mult] = false;
        }
    }
    // printList(list);
    return list;
}


int main() {
    int n;
    scanf("%d", &n);
    auto list = createPrimeList();
    int count = 0;
    for (int i = 0; i < n; i++) {
        int32_t v;
        scanf("%d", &v);
        count += list[v] ? 1 : 0;
    }
    printf("%d\n", count);
    return 0;
}

// #define MAXVAL 100

// int main() {
//     int i, j, count = 0;
//     static int flags[MAXVAL + 1] = {};
//     for (i = 2; i <= MAXVAL; i++) {
//         if (flags[i] == 0) {
//             ++count;
//             for (j = i * 2; j <= MAXVAL; j += i) {
//                 flags[j] = 1;
//             }
//         }
//     }
//     printf("%d\n", count);
//     return 0;
// }


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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int x;
    cin>>x;
    if(x>=400&&x<=599) cout<<8<<endl;
    if(x>=600&&x<=799) cout<<7<<endl;
    if(x>=800&&x<=999) cout<<6<<endl;
    if(x>=1000&&x<=1199) cout<<5<<endl;
    if(x>=1200&&x<=1399) cout<<4<<endl;
    if(x>=1400&&x<=1599) cout<<3<<endl;
    if(x>=1600&&x<=1799) cout<<2<<endl;
    if(x>=1800&&x<=1999) cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 3664
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto ab = readln.chomp.split.to!(int[]);
  auto d = ab[1] - ab[0];
  int sum;
  foreach (i; 1..d) {
    sum += i;
  }
  writeln(sum - ab[0]);
}


Measured memory_bytes: 256
h,w = map(int,input().split())
s0 = "."*(w+2)
S = [s0]

for i in range(h):
    S.append("."+input()+".")
    
S.append(s0)

for i in range(1,h+1):
    for j in range(1,w+1):
        if S[i][j] == ".":
            num = 0
            for k in range(3):
                if S[i-1][j-1+k] == "#":
                    num += 1
            if S[i][j-1] == "#":
                num += 1
            if S[i][j+1] == "#":
                num += 1
            for k in range(3):
                if S[i+1][j-1+k] == "#":
                    num += 1
            S[i] = list(S[i])
            S[i][j] = str(num)
            S[i] = "".join(S[i])
            
for i in range(1,h+1):
    print(S[i][1:w+1])

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k;i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<int,int>;

int main()
{
   ll n;cin >>n;
   V s(n,0);
   rep(i,n-1){
    ll a;cin >>a;a--;
    s[a]++;
   }
   rep(i,n)cout <<s[i]<< endl;
    return 0;
}


Measured memory_bytes: 4840
#include<iostream>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::string S; std::cin >> S;
  S[1] = 'R'+'B' - S[1];
  fin(S);
  return 0;
}


Measured memory_bytes: 3596