akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

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

    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    if(arr[0]==5 && arr[1]==5 && arr[2]==7)
        cout<<"YES"<<"\n";
    else
        cout<<"NO"<<"\n";
}


Measured memory_bytes: 3616
N = int(input())
S = input()
s_list = list(S)
al_list = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
str_list = []
for w in s_list:
    str_list.append(al_list[(al_list.index(w) + N) % 26])
print(''.join(str_list))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}

// vector<int>g[N];
// int dp[N];
// int rec(int u){
// 	if(dp[u]!=-1)return dp[u];
// 	if(g[u].size()==0)return 1;
// 	int ans = 0;
// 	for(auto x:g[u]){
// 		ans = max(ans,rec(x));
// 	}
// 	dp[u]=ans+1;
// 	return dp[u];
// }

int main()
{	

	int n,k; cin >> n >> k;
	int a[n+1];
	FOR(i,1,n)cin >> a[i];
	int dp[k+1] = {0};

	dp[0] = 0;
	FOR(i,1,k){
		int ff = 0;
		FOR(j,1,n){
			if(i-a[j]>=0){
				if(dp[i-a[j]]==0)ff = 1;
			}
		}
		dp[i] = ff;
	}
	if(dp[k])cout << "First";
	else cout << "Second";


	return 0;
}

Measured memory_bytes: 640
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int h, w;
        cin >> h >> w;
        char c[h][w];
        rep(i, h) rep(j, w) cin >> c[i][j];
        rep(i, 2 * h) {
            rep(j, w) cout << c[i / 2][j];
            printf("\n");
        }

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
    int X;
    cin >> X;
    int ans = 1;
    for(int b = 2; b <= X; b++){
        int power = b * b;
        for(int p = 2;; p++){
            if(power > X) break;
            ans = max(ans, power);
            power *= b;
        }
    }
    cout << ans << endl;
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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

int main(){
    string red;
    cin >> red;
    string blue;
    cin >> blue;
    int r, b;
    cin >> r >> b;
    string target;
    cin >> target;
    if(target == red) r--;
    else if(target == blue) b--;
    cout << r << ' ' << b << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

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

		int N = sc.nextInt(), M = sc.nextInt(), R = sc.nextInt();
		R = R - N * M;
		M = 0;
		if (R <= 0) {
			System.out.println(0);
			return;
		}

		BigInteger L = new BigInteger("1");
		BigInteger Rp = new BigInteger("1"),
					Np = new BigInteger("1"),
					NRp = new BigInteger("1");
		for (int i = 1 ; i < N+R ; i++) {
			L = L.multiply(new BigInteger(String.valueOf(i)));
			if (i == R) Rp = L;
			else if (i == N-1) Np = L;
			else if (i == N+R-1) NRp = L;
		}
		System.out.println(NRp.divide(Rp.multiply(Np)));
	}
}

Measured memory_bytes: 153636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define infin ll (pow(10,9)+7);
int main()
{
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int ret = 0;;
	char s[10];
	cin >> s;

	
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
		
	return 0;
}


Measured memory_bytes: 256
#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 r;
  cin >> r;
  int ans;
  ans = 3*r*r;
  
  cout << ans <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	int n, l[200], ans=0;
	cin >> n;
	for(int i=0; i<2*n; i++){
		cin >> l[i];
	}
	sort(l, l+2*n);
	for(int i=0; i<2*n; i+=2){
		ans+=l[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int powm(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }



void solve()
{
    int n;
    cin>>n;
    int ans[3]={0};
    rep(i,n)
    {
        int a,b,c;
        cin>>a>>b>>c;
        int ta,tb,tc;
        ta=ans[0];
        tb=ans[1];
        tc=ans[2];
        ans[0]=max(tb+a,tc+a);
        ans[1]=max(ta+b,tc+b);
        ans[2]=max(tb+c,ta+c);
        // cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n";
    }
    cout<<max(ans[0],max(ans[1],ans[2]));
}



int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
   int t;
    t=1;
    while(t--)
   {
      solve();
   }
}

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


int main() {
    string s, t;
    cin >> s;
    cin >> t;
    t.pop_back();
    if(s==t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
	// your code goes here
	int n;
	int a[200000];
	cin >> n;
	int max=0;
	int max2=0;
	int f=0;
	for(int i=0; i!=n; i++){
		cin >> a[i];
		if(a[i] >= max){
			max2 = max;
			max = a[i];
			f = i;
		}
	}
	int max3=0;
	int max4=0;
	for(int i=n; i>=0; i--){
		if(a[i] >= max3){
			max4 = max3;
			max3 = a[i];
		}
	}
	int max5;
	if(max4 > max2){
		max5 = max4;
	}else{
		max5 = max2;
	}
	for(int i=0; i!=n; i++){
		if(f == i){
			cout << max5 << '\n';
		}else{
			cout << max << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <cmath>

double distance(const std::vector<int>& p1, const std::vector<int>& p2)
{
    double d2 = 0;
    for (int i = 0; i < p1.size(); ++i) {
        d2 += (p2[i] - p1[i]) * (p2[i] - p1[i]);
    }
    return std::sqrt(d2);
}

int main()
{
    std::vector<std::vector<int>> points;

    int N, D;
    std::cin >> N >> D;
    points.resize(N);
    for (int i = 0; i < N; ++i) {
        points[i].resize(D);
        for (int j = 0; j < D; ++j) {
            std::cin >> points[i][j];
        }
    }


    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            auto d = distance(points[i], points[j]);
            double i_part, f;
            f = std::modf(d, &i_part);
            if (f < 1e-4) {
                cnt++;
            }
        }
    }

    std::cout << cnt << std::endl;


    return 0;
}

Measured memory_bytes: 256
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e2 + 5, LG = 40;

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	ll n; cin >> n; n++;
	int m = 0;
	deque<int> DQ;
	int b = 0;
	for (int i = 0; i < LG; i++) if ((n >> i) & 1) b = i;
	for (int i = b - 1; i >= 0; i--) {
		DQ.push_back(++m);
		if ((n >> i) & 1) DQ.push_front(++m);
	}
	cout << 2 * m << endl;
	for (int i = 0; i < m; i++) cout << DQ[i] << ends;
	for (int i = 0; i < m; i++) cout << i + 1 << ends;
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
using namespace std;
int main()
{
    string s;
    int a, i;
    while (cin >> s )
    {
        for (i = 1;;i++)
            if (s[i] == '\0')
                break;
        while (i--)
            cout << "x";
        cout << '\n';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int H, W; cin >> H >> W;
  vector<vector<char>> Masu(H, vector<char>(W));
  vector<vector<int>> Map(H, vector<int>(W,-1));
  deque<int> queY;
  deque<int> queX;
  getchar();
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      Masu[i][j]=getchar();
      if (Masu[i][j]=='#') {queY.push_back(i);queX.push_back(j);Map[i][j]=0;}
    }
    getchar();
  }
  int dy[4]={1,0,-1,0};
  int dx[4]={0,1,0,-1};
  int ans=0;
 
  while(!queY.empty()) {
    int y=queY.front(), x=queX.front();
    queY.pop_front(); queX.pop_front();
    int cnt=Map[y][x]+1;
    for (int i=0; i<4; i++) {
      int newy=y+dy[i], newx=x+dx[i];
      if (newy<0||newy>=H||newx<0||newx>=W) continue;
      else if (Map[newy][newx]==-1) {
        queY.push_back(newy);
        queX.push_back(newx);
        Map[newy][newx]=cnt;
        ans =max(ans, cnt);
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 13440
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int A=0,B=0,card[]={2,3,4,5,6,7,8,9,10,11,12,13,1};

  cin >> A >> B;
  if(A==1) A+=13;
  if(B==1) B+=13;
  cout << (A>B?"Alice":(A<B?"Bob":"Draw")) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int W, a, b;
    io.read(W, a, b);
    if(a > b) swap(a, b);
    cout << max(0, b - (a + W));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll d, l, r;
    cin >> l >> r >> d;
    ll ans = 0;
    for(ll now = 0; now <= r; now += d) {
        if(now >= l) {
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632
N=int(input())
T,A=[int(i) for i in input().split()]
H=[int(i) for i in input().split()]
for i in range(N):
    H[i]=T-(H[i]*0.006)
    H[i]=abs(H[i]-A)
p=min(H)
print(H.index(p)+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 2010

vll g[M];
ll d[M][M];
vector<pii> edges;
int main(){
	IOS;
	tihs;

	ll n,k;cin>>n>>k;
	rep(i,0,n-1){
		ll u,v;cin>>u>>v;
		u--,v--;
		g[u].pb(v),g[v].pb(u);
		edges.pb({u,v});
	}
	queue<ll>q;
	rep(i,0,n){
		rep(j,0,n)d[i][j]=-1;
		q.push(i); d[i][i]=0;
		while(!q.empty()){
			ll u=q.front();q.pop();
			for(auto v:g[u])if(d[i][v]==-1)d[i][v]=d[i][u]+1,q.push(v);
		}
	}
	ll mn=n;
	if(k%2==0){
		rep(i,0,n){
			ll cnt=0;
			rep(j,0,n)if(d[i][j]>k/2 and j!=i)cnt++;
			mn=min(mn,cnt);
		}
		cout<<mn;
		return 0;
	}
	for(auto p:edges){
		ll v1=p.fi,v2=p.se,cnt=0;
		rep(j,0,n){
			if(j==v1 or j==v2)continue;
			if(min(d[v1][j],d[v2][j])>k/2)cnt++;
		}
		mn=min(mn,cnt);
	}
	cout<<mn;




	return 0;
}

Measured memory_bytes: 31872
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf")]*(n+1)
dp[1] = 0

for i in range(1,n+1):
  for j in range(max(1,i-k),i):
    dp[i] = min(dp[i],dp[j]+abs(h[i-1]-h[j-1]))
print(dp[-1])

Measured memory_bytes: 55008
fn main() {
    let x = read::<u32>();
    yn(x < 1200);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String s_ = sc.next();
        System.out.println((s_.substring(0, s_.length()-1)).equals(s) ? "Yes" : "No");
    }
}


Measured memory_bytes: 26968
n=gets.chomp.to_i
s = []
if n == 0
    puts 0
    exit
end

while(n != 0)
    if n%2 == 1
        s << "1"
        n -= 1
    else
        s << "0"
    end
    n /= -2
end
puts s.reverse.join("")

Measured memory_bytes: 1788
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, W; cin >> n >> W;
    vll w(n), v(n);
    REP(i, n) cin >> w[i] >> v[i];
    vvll dp(n+1, vll(n*1000+5, HIGHINF));
    dp[0][0] = 0;
    REP(i, n) {
        REP(j, n*1000+5) {
            if (j-v[i]>=0) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    ll ans = 0;
    REP(i, n*1000+5) if (dp[n][i] <= W) ans = i;;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] N =new int[5];
		int[] add =new int[5];
		int minmod = 10;
		int mini = 0;

		long sum=0;

		for (int i = 0; i < 5; i++) {
			N[i] =sc.nextInt();
			add[i] = N[i] % 10;
			if (add[i] != 0) {
				if (Math.min(minmod, add[i]) == add[i]) {
					minmod = Math.min(minmod, add[i]);
					mini = i;
				}
			}
		}
		if (minmod < 10) {
			for (int i = 0; i < 5; i++) {
				if (i == mini) {
					continue;
				}else {
					int let = N[i];
					if (let % 10 !=0) {
						let =(let/10 + 1)*10;
					}
					sum+=let;
				}
			}
			sum+=N[mini];
		} else {
			for (int i : N) {
				if (i % 10 !=0) {
					i =(i/10 + 1)*10;
				}
				sum+=i;
			}
		}

		System.out.println(sum);


	}
}




Measured memory_bytes: 35812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<tuple>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<vector<int>> s(m);
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int x;
            cin >> x;
            s[i].push_back(x);
        }
    }
    vector<int> p(n);
    for(int i = 0; i < m; i++){
        cin >> p[i];
    }
    for(int i = 0; i < (1 << n); i++){
        bool f = true;
        vector<int> on(n);
        for(int j = 0; j < n; j++){
            on[j] = (((i >> j) & 1) == 1? 1:0);
        }
        for(int j = 0; j < m; j++){
            int sum = 0;
            for(int k = 0; k < s[j].size(); k++){
                sum += on[s[j][k] - 1];
            }
            if(sum % 2 != p[j]){
                f = false;
                break;
            }
        }
        if(f){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


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

	for (int i = 0; i < N-2; i++)
	{
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
	}



	cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
int some(int x){
    int N =0;
  	REP(i,6){
        N += x%10;
        x = x/10;
    }
    return N;
}
signed main(){
    int N,A,B;
    cin>>N>>A>>B;
    int ans = 0;
    REP(i,N+1){
        if(some(i)>=A&&some(i)<=B){
            ans +=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(std::string S, std::string T){
	ll res = 0;
	REP(i, 3) {
		if (S[i]==T[i]) res++;
	}
	cout << res << "\n";
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//余事象で答えを求める

int n;
const ll mod=998244353;
ll l[330];
ll dp1[330][100001];
ll dp2[330][100001];

int main(){
    cin>>n;
    ll l[330];
    ll s=0;
    ll ans=1;
    const ll mod=998244353;
    for (int i=0;i<n;i++){
        cin>>l[i];
        s+=l[i];
        ans*=3;
        ans%=mod;
    }
    dp1 [0][0]=1;
    dp2 [0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<=s;j++){
            dp1[i+1][j+l[i]] += dp1[i][j]; // 色を塗り替えても同じ．
            dp1[i+1][j+l[i]] %= mod;
            dp1[i+1][j] += (2*dp1[i][j])%mod;
            dp1[i+1][j] %= mod;

            dp2[i+1][j+l[i]] += dp2[i][j];
            dp2[i+1][j+l[i]] %= mod;

            dp2[i+1][j] += dp2[i][j];
            dp2[i+1][j] %= mod;
        }
    }
    for (int i=(s+1)/2;i<=s;i++){
        ans-=(3*dp1[n][i])%mod;
        ans%=mod;
    }
    if (s%2==0){
        ans+=(dp2[n][s/2]*3)%mod;
    }
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 472448
m, d = map(int, input().split())
count = 0
for i in range(m):
    for j in range(d):
        d1 = (j+1) % 10
        d10 = (j+1) // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i+1:
            count += 1
print(count)

Measured memory_bytes: 3060
"""
dp[x][y] ... tのx文字目までで, y文字一致した場合の数
dp[x][y] = dp[x - 1][y] + dp[x - 1][y - 1] * (t[x] == b[y])
"""
MOD = 1000000007
t = input()
b = input()
lent = len(t)
lenb = len(b)
dp = [[0] * (lenb + 1) for _ in range(lent + 1)]
for i in range(lent + 1):
  dp[i][0] = 1

for x in range(1, lent + 1):
  for y in range(1, lenb + 1):
    dp[x][y] = (dp[x - 1][y] + dp[x - 1][y - 1] * (t[x - 1] ==  b[y - 1])) % MOD
print(dp[lent][lenb])


Measured memory_bytes: 29296
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;


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

	int n = l.length();
	vector<vector<ll>> dp(2, vector<ll>(n + 1));

	vector<ll> pow2(n + 1);
	vector<ll> pow3(n + 1);

	pow2[0] = pow3[0] = 1;
	for (int i = 1; i <= n; i++) {
		pow2[i] = (pow2[i - 1] * 2) % MOD_CONST;
		pow3[i] = (pow3[i - 1] * 3) % MOD_CONST;
	}

	for (int i = 1; i <= n; i++) {
		dp[0][i] = dp[0][i - 1];
		dp[1][i] = dp[1][i - 1];

		if (l[i - 1] == '1') {
			dp[0][i]++;
			dp[1][i] = (dp[1][i] + (pow2[dp[0][i - 1]] * pow3[n - i]) % MOD_CONST) % MOD_CONST;
		}

	}

	ll ans = (dp[1][n] + (pow2[dp[0][n]]) % MOD_CONST) % MOD_CONST;
	cout << ans << endl;

}




Measured memory_bytes: 3576
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

alias Appeal = Tuple!(int, "from", int, "to", bool, "isHonest");

void main() {
  auto N = readln.chomp.to!int;
  Appeal[] appeals;
  foreach(i; 0..N) {
    auto appeal_count = readln.chomp.to!int;
  
    foreach(o; 0..appeal_count) {
      auto xy = readln.split.to!(int[]);
      appeals ~= Appeal(i, xy[0] - 1, xy[1] == 1);
    }
  }

  int solve() {
    int answer;
    foreach(i; N.iota(-1, -1)) {
      i++;
      foreach(c; N.iota.array.combinations(i)) {
        auto honest_appeals = appeals.filter!(a => c.canFind(a.from));

        bool ok = true;
        bool[int] honests;
        foreach(ci; c) honests[ci] = true;
        foreach(n; 0..N+1) {
          auto list = honest_appeals.filter!(a => a.to == n).array;
          if (list.length == 0) continue;

          auto base = list[0].isHonest;
          if (!base && n in honests) {
            ok = false;
            break;
          }
          if (base) honests[n] = true;
          foreach(l; list.map!(a => a.isHonest)) {
            if (l != base) {
              ok = false;
              break;
            }
          }
          if (ok == false) continue;
        }
        if (ok) {
          if (honests.length != i) continue;
          if (!c.all!(a => a in honests)) continue;
          
          answer = i;
          debug writeln(c);
          debug writeln(honest_appeals);
          break;
        }
      }
      if (i == answer) break;
    }
    return answer;
  }

  solve().writeln;
}


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

ll gcd(ll x,ll y){
    if (y==0) return x;
    return gcd(y,x%y);
}
ll lcm(ll x,ll y){
    return x/gcd(x,y)*y;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<ll> a(N);
    for (int i=0;i<N;++i) cin >> a[i];
    int odd=0;
    for (int i=0;i<N;++i) odd|=a[i]&1LL;
    if (odd){cout << 0 << '\n'; return 0;}
    ll g=1;
    for (int i=0;i<N;++i){
        a[i]/=2; g=lcm(g,a[i]);
        if (M<g){cout << 0 << '\n'; return 0;}
    }
    for (int i=0;i<N;++i) if (!((g/a[i])&1)){
        cout << 0 << '\n'; return 0;
    }
    cout << (M/g+1)/2 << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ii = pair<int, int>;

int dijkstra(vector<vector<char>> graph, int sourcex, int sourcey, int endx, int endy) {
	priority_queue<pair<int, ii>> pq;
	set<pair<int, int>> visited;

	pq.push(make_pair(0, ii(sourcex, sourcey)));

	while (!pq.empty()) {
		pair<int, ii> val = pq.top();
		pq.pop();
		int d = val.first;
		int nodex = val.second.first;
		int nodey = val.second.second;

		if (visited.find(make_pair(nodex, nodey)) != visited.end()) {
			continue;
		}
		if (nodex == endx && nodey == endy) {
			return -d;
		}
		if (nodex > 0 && graph[nodex - 1][nodey] == '.') {
			pq.push(make_pair(d, ii(nodex - 1, nodey)));
		}
		if (nodex + 1 < graph.size() && graph[nodex + 1][nodey] == '.') {
			pq.push(make_pair(d, ii(nodex + 1, nodey)));
		}
		if (nodey > 0 && graph[nodex][nodey - 1] == '.') {
			pq.push(make_pair(d, ii(nodex, nodey - 1)));
		}
		if (nodey + 1 < graph[0].size() && graph[nodex][nodey + 1] == '.') {
			pq.push(make_pair(d, ii(nodex, nodey + 1)));
		}
		for (int i = nodex - 2; i <= nodex + 2; i++) {
			if (i < 0 || i >= graph.size()) {
				continue;
			}
			for (int j = nodey - 2; j <= nodey + 2; j++) {
				if (j < 0 || j >= graph[0].size()) {
					continue;
				}
				if (graph[i][j] == '.') {
					pq.push(make_pair(d - 1, ii(i, j)));
				}
			}
		}
		visited.insert(make_pair(nodex, nodey));
	}
	return -1;
}

int main() {
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  
	int H, W, Ch, Cw, Dh, Dw;
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	Ch--;
	Cw--;
	Dh--;
	Dw--;
	cin.get();
	vector<vector<char>> maze(W, vector<char>(H));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin.get(maze[j][i]);
		}
		cin.get();
	}
	cout << dijkstra(maze, Cw, Ch, Dw, Dh);
}

Measured memory_bytes: 25968
#include<stdio.h>

int main(){
  int n = 0;
  int rate[100] = {};
  int color[8] = {};
  int colors = 0;
  int freecolor = 0;
  int i = 0;
  int mincolor = 0;
  int maxcolor = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&rate[i]);
  }
  for(i=0;i<n;i++){
    if(rate[i] < 400){
      color[0]++;
    }else if(rate[i] < 800){
      color[1]++;
    }else if(rate[i] < 1200){
      color[2]++;
    }else if(rate[i] < 1600){
      color[3]++;
    }else if(rate[i] < 2000){
      color[4]++;
    }else if(rate[i] < 2400){
      color[5]++;
    }else if(rate[i] < 2800){
      color[6]++;
    }else if(rate[i] < 3200){
      color[7]++;
    }else{
      freecolor++;
    }
  }
  
  for(i=0;i<8;i++){
    if(color[i] > 0){
      colors++;
    }
  }
  
  if(colors == 0){
    mincolor = 1;
  }else{
    mincolor = colors;
  }
  maxcolor = colors + freecolor;
  
  printf("%d %d",mincolor,maxcolor);
  return 0;
}
  

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] line_ = line.split(" ");
        Integer i1 = Integer.valueOf(line_[0]);
        Integer i2 = Integer.valueOf(line_[1]);
        Integer i3 = Integer.valueOf(line_[2]);
        int counter = 0;
        for(int a = i1 ; a <= i2 ; a++ ) {
            if(i3 % a == 0)
            counter++;
        }
        System.out.println(counter);
    }
}

Measured memory_bytes: 17048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class315
    {
        static void Main()
        {
            var abck = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = abck[0], b = abck[1], c = abck[2], k = abck[3];
            int count = 0;
            count += Math.Min(a, k);
            if (a < k)
            {
                k -= a;
                if (b < k)
                {
                    k -= b;
                    count -= k;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28292
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
constexpr i64 M = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    int n;
    while (read(n)) {
        ivec d(n);
        read(d);


        ivec c(n);
        fore(di, d) {
            c[di]++;
        }

        if (c[0] != 1 || d[0] != 0) {
            cout << 0 << endl;
            continue;
        }

        sort(d.begin(), d.end());
        i64 ans = 1;
        forr(i, 1, n) {
            ans *= c[d[i] - 1];
            ans %= M;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(1<<n);
  for(Int i=0;i<(1<<n);i++) cin>>as[i];

  for(Int d=1;d<(1<<n);d<<=1)
    for(Int i=0;i<(1<<n);i+=d<<1)
      as[i]=as[i]==as[i+d]?as[i]:abs(as[i]-as[i+d]);

  cout<<as[0]<<endl;
  return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
const int maxn = 1e5 + 10;
const int MAX = 5e3 + 10;
typedef long long ll;
typedef vector< int> vi;		



//~ https://www.youtube.com/watch?v=WuWDvG1AXF4


int n, a[maxn];

int main (){
	//~ in
	
	cin >> n;
	int curmin = inf , ans = 0;
	for(int i = 0 ;i < n;i++){
		int x; cin >> x;
		if(x<=curmin){
			++ans;
		}
		curmin = min ( curmin, x);
		
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

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

int main() {

	int w, h;
	int map[70][70],dp[35][35];

	while (1) {
		cin >> w >> h;
		if (w==0 && h==0) break;

		int inp;
		for (int i = 0; i < 2 * h - 1; i++) {
			int t = 0;
			if (i % 2 == 0) t = 1;
			for (int j = t; j < 2*w-1; j = j+2) {
				cin >> inp;
				map[i][j] = inp;
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j <w; j++) {
				dp[i][j] = -1;
			}
		}

		dp[0][0] = 1;
		for (int d = 1; d <= w*h; d++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j ++) {
					if (dp[i][j] == d) {
						for (int k = 0; k < 4; k++) {
							int ny = i + dy[k], nx = j + dx[k];
							if (0<=ny && ny<h && 0 <= nx && nx<w) {
								if (map[i + ny][j + nx] == 0 && dp[ny][nx] == -1) {
									dp[ny][nx] = d + 1;
								}
							}
						}
					}
				}
			}
		}

		if(dp[h-1][w-1]==-1) cout << 0 << endl;
		else cout << dp[h - 1][w - 1] << endl;

	}

	return 0;
}

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

const int INF = 1001001001;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int A, B, C;

  A = c;
  B = a;
  C = b;

  cout<<A<<" "<<B<<" "<<C<<endl;

  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll c = a - a % x;
    ll d = b - b % x;
    ll n = (d - c) / x;
    if (a % x == 0) n++;
    cout << n << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,M,s,t = map(int,input().split())
    INF = 10**15
    
    yedge = [[] for _ in range(N)]
    sedge = [[] for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        yedge[u-1].append((a,v-1))
        yedge[v-1].append((a,u-1))
        sedge[u-1].append((b,v-1))
        sedge[v-1].append((b,u-1))
        
    def dij(x,z):
        q = [(0,x)]
        heapq.heapify(q)
        go = [INF for _ in range(N)]
        go[x] = 0
        while q:
            d,now = heapq.heappop(q)
            if go[now] > d:
                continue
            for d,fol in z[now]:
                if go[fol] > go[now]+d:
                    go[fol] = go[now]+d
                    heapq.heappush(q,(go[fol],fol))
        return go
        
    y,s = dij(s-1,yedge),dij(t-1,sedge)
    ans = []
    u = 0
    for i,j in zip(y[::-1],s[::-1]):
        u = max(u,INF-i-j) 
        ans.append(u)
        
    print(*ans[::-1],sep="\n")

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
  int dp[100000];
  int n,d,x,X,mx;
  int p[10][10];
  cin>>n>>d>>x;
  X=x;
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin>>p[i][j];
    }
  }
  for(int i=0;i<d-1;i++){
    mx=0;
    for(int j=0;j<100000;j++){
      dp[j]=0;
    }
    for(int j=0;j<n;j++){
      if(x<p[i+1][j]){
	dp[p[i][j]]=dp[p[i+1][j]];
      }
    }
    for(int j=0;j<=x;j++){
      for(int k=0;k<n;k++){
	if(j-p[i][k]>=0){
	  dp[j]=max(dp[j-p[i][k]]+p[i+1][k],dp[j]);
	}
      }
    }
    for(int j=0;j<=x;j++){
      mx=max(mx,dp[j]+x-j);
    }
    x=mx;
  }
  cout<<max(x,X)<<endl;
  return 0;
}



Measured memory_bytes: 3504
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	D=LI()+[0]

	D.sort()
	#print(D)

	DD=[]

	for i,v in enumerate(D):
		if i%2==0:
			DD.append(v)
		else:
			DD.append(24-v)
	DD.sort()
	DD.append(24)

	#print(DD)

	ans=25

	for i,j in zip(DD[:-1],DD[1:]):
		ans=min(ans,j-i)
	print(ans)











if __name__ == "__main__":
	main()


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

int main(){
    ll a, b;    cin >> a >> b;
    int cnt=0;
    for(ll i=a; i<=b; i++){
    int tmp = (i/1000%10)*10+i/10000;
       if(i%100 == tmp) cnt += 1;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  rep(i,N-2) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[105];
int main()
{
    int n, x,sum = 0;
    scanf("%d%d",&n,&x);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    sort(a,a+n);
    int e = (x-sum)/a[0];
    printf("%d\n",sum > x ? 0 : n + e);
    return 0;
}


Measured memory_bytes: 256
//ABC148 B

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;
string s,t;

int main() {
  cin >> n >> s >> t;
  
  string x(n*2,'x');
  rep(i,n){
    x[i*2] = s[i];
    x[i*2+1] = t[i];
  }
  printf("%s\n",x.c_str());
}


Measured memory_bytes: 256