akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int max(int a, int b){
    return (a>b)? a : b;
}

int main(void){
    int N, a, b, c, d;
    scanf("%d%d%d%d%d", &N, &a, &b, &c, &d);
    char s[N+1];
    scanf("%s", s);
    int flag1 = 0; //#が2連続以上で1
    int flag2 = 0; //...が存在で1
    
    for(int i = a; i <= max(c,d)-1; i++){
        if((i < d-1) && (s[i] == '#') && (s[i+1] == '#')){
            flag1 = 1;
        }
        if((i >= b-2) && (i <= d-2) && (s[i] == '.') && (s[i+1] == '.') && (s[i+2] == '.')){
            flag2 = 1;
        }
    }
    if(c<d && flag1 == 0){
        printf("%s", "Yes");
        return 0;
    }
    if(c>d && flag1 == 0 && flag2 == 1){
        printf("%s", "Yes");
        return 0;
    }
    printf("%s\n", "No");
    return 0; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N=105;
int b[N],a[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n-1;i++){
		cin>>b[i];
	} 
	a[1]=b[1];
	for(int i=2;i<=n-1;i++){
		a[i]=min(b[i],b[i-1]);
	}
	a[n]=b[n-1];
	int sum=0;
	for(int i=1;i<=n;i++){ 
		sum+=a[i]; 
	} 
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
// BISMILLAHIR RAHMANIR RAHEEM
// ALLAH IS WATCHING ME
// ALLAH save us from COVID-19.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll     long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses    "\n"
#define all(x) (x).begin(), (x).end()
#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;
const ll MOD = 1000000007;

template <class T> inline T bigmod(T p,T e,T M)
{
    if(e==0)
        return 1;
    if(e%2==0)
    {
        ll t=bigmod(p,e/2,M);
        return (T)((t*t)%M);
    }
    return (T)((ll)bigmod(p,e-1,M)*(ll)p)%M;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);   // when M is prime;
}

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge
{
    int u, vv;
    bool operator<(Edge const& other)
    {
        return vv > other.vv;
    }
}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better


//***********************************************  The END **********************************************************************************************************************************


/////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
    ios
    ll n,k;
    cin>>n;
    ll arr[4];
    vector<ll> dp(4,0);
    for(ll day=1; day<=n; day++)
    {
        for(ll i=1; i<=3; i++)
            cin>>arr[i];

        vector<ll> newdp(4,0);

        /// 3
        /// 10 40 70
        /// 20 50 80
        /// 30 60 90
        for(ll i=1; i<=3; i++)
        {
            for(ll j=1; j<=3; j++)
            {
                if(i!=j)
                {
                    newdp[j]=max(newdp[j],dp[i]+arr[j]);
                }
            }
            //cout<<i<<" "<<newdp[1]<<" "<<newdp[2]<<" "<<newdp[3]<<ses;
        }

        dp=newdp;
    }
    cout<<max(dp[1],max(dp[2],dp[3]));
}
/*

*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  string k;
  int answer=0;
  int kouho=0;
  cin >> S;
  char c = 'Z';
  S = S+c;
  int L=S.size();
  int i=0;
  while (i<L){
    kouho =0;
    for (int j = 0; j < (L-i); j++) {
      k = S.at(i+j);
    if ( k == "A" ||k == "T" || k == "G" || k == "C"  ){
      kouho ++ ;
    }
    else {
      answer = max(answer,kouho);
      break;
    }
    }
    i++;
    
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
 string s;
int main(){
  cin >> s;
  cout << (s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I' ? "Yes":"No") << endl; 
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var goalDeposit int
	fmt.Scan(&goalDeposit)

	var nowDeposit int = 100

	var years int = 0
	for {
		years++
		nowDeposit = int(float64(nowDeposit) * 1.01)

		if nowDeposit >= goalDeposit {
			break
		}
	}

	fmt.Println(years)
}


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

int main() {
  int k, x;
  cin >> k >> x;
  
  for (int i = x - k + 1; i <= x + k - 1; i++) {
    cout << i << ' ';
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()

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

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


int main() {
  int n;
  cin >> n;
  
  vector<pair<int,int>> p(n);
  rep(i,n) cin>>p[i].second>>p[i].first;
  
  sort(ALL(p));
  
  bool b=true;
  long long sum=0;
  rep(i,n){
    sum += p[i].second;
    if(sum>p[i].first) b=false;
  }
  
  if(b) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
  return 0;
}

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

int kg(char in) {
  if (in == '+') {
    return 1;
  } else {
    return -1;
  }
}

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

  ans += kg(a[0]);
  ans += kg(a[1]);
  ans += kg(a[2]);
  ans += kg(a[3]);

  cout << ans << endl;
}

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

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

#define MAX 100005
#define INF INT_MAX

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

void maxHeapify(vector<ll>& a, int i)
{
    int l = 2*i;
    int r = 2*i+1;
    int h = a.size()-1;

    int largest = i;
    if (l <= h && a[l] > a[largest]) largest = l;
    if (r <= h && a[r] > a[largest]) largest = r;
    if (largest != i) {
        swap(a[largest], a[i]);
        maxHeapify(a, largest);
    }
}

void buildMaxHeap(vector<ll>& a)
{
    int h = a.size()-1;
    for (int i = h/2; i >= 1; i--) {
        maxHeapify(a, i);
    }

}
int main(int, char**)
{
    int n;
    cin >> n;

    vector<ll> a(n+1, 0LL);
    for (int i = 1; i <= n; i++) cin >> a[i];

    buildMaxHeap(a);

    for (int i = 1; i <= n; i++) {
        cout << " " << a[i];
    }
    cout << endl;
    return 0;
}



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

int main(){
	int n;
	int m;
	cin >> n >> m;
	vector<vector<int>> hash(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		if(a==0||a==n-1)
			hash[b].push_back(a);
		if(b==0||b==n-1)
			hash[a].push_back(b);
	}
	bool can=false;
	for(int i=1;i<n-1;i++){
		bool x = false;
		bool y = false;
		for(int j=0;j<hash[i].size();j++){
			if(hash[i][j]==0) x = true;
			if(hash[i][j]==n-1) y = true;
		}
		if(x&&y){
			can = true;
			break;
		}
	}
	if(can) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int i;
	int a[12][10]={0};
	int b,f,r,v;
	for(i=0;i<n;i++){
		scanf("%d%d%d%d",&b,&f,&r,&v);
		a[3*b-(3-f)-1][r-1]+=v;
	}
	
	int j;
	for(i=0;i<12;i++){
		if(i==3||i==6||i==9||i==12) printf("####################\n");
		for(j=0;j<10;j++){
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}



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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, k, a[MAXN], sum;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> k >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], sum += a[i];
	if (sum >= k)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


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

using namespace std;

const int maxn = 1e5+5;

int n, k, i, v[maxn];

int main()
{
    int mn = 0x3f3f3f3f;
    cin >> n >> k;
    for(i = 1; i <= n; i ++) {
        cin >> v[i];
    }
    sort(v+1, v+n+1);

    for(i = k; i <= n; i ++) {
        if(v[i] - v[i-k+1] < mn) {
            mn = v[i] - v[i-k+1];
        }
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 640
//#include "debug.h"
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

template<class T>
void printa(const T *a, int n) {
	cout << '[';
	for (int i=0; i<n; i++) {
		if (i) cout << ',';
		cout << a[i];
	}
	cout << ']' << endl;
}

template<class T>
void printa_nz(const T *a, int n) {
	cout << '[';
	for (int i=0, k=0; i<n; i++) {
		if (!(a[i]==0)) {
			if (k++) cout << ',';
			cout << i << ':' << a[i];
		}
	}
	cout << ']' << endl;
}

template<class T>
void printa_i(const T *a, int n) {
	cout << '[';
	for (int i=0; i<n; i++) {
		if (i) cout << ',';
		cout << i << ':' << a[i];
	}
	cout << ']' << endl;
}

template<class T1,class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &x) {
	return os<<'('<<x.first<<','<<x.second<<')';
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	int n = a.size();
	for (int i=0; i<n; i++) {
		if (i) os << ',';
		os << a[i];
	}
	os << ']';
	return os;
}

template<class K, class T>
ostream &operator<<(ostream &os, const map<K,T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x.first << ':' << x.second;
	}
	return os << '}' << endl;
}


template<class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x;
	}
	return os << '}';
}


template<class T>
ostream &operator<<(ostream &os, const multiset<T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x;
	}
	return os << '}';
}
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

int n, k;
i64 a[MAXN], b[MAXN];

int input() {
	if (scanf("%d %d", &n, &k) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%lld", &a[i]);
	return 1;
}

void init() {
}

i64 solve() {
	map<int, int> z;
	i64 s = 0;
	int j = k-1;
	if (!j) return 0;
	for (int i=0; i<j && i<n; i++) {
		s = (s + a[i] + k - 1) % k;
		b[i] = s;
		//cout << '=' << s << endl;
		if (z.find(s)==z.end()) z[s] = 1; else z[s]++;
	}
	i64 x = 0;
	i64 r = z.find(x)==z.end() ? 0: z[x];
	//cout << '=' << r << ' ' << x << ':' << z << endl;
	for (i64 i=j; i<i64(n)+j; i++) {
		auto p = z.find(b[i-j]);
		if (p != z.end()) {
			if (--p->second==0)
				z.erase(p);
		}
		if (i<n) {
			s = (s + a[i] + k - 1) % k;
			b[i] = s;
			if (z.find(s)==z.end()) z[s] = 1; else z[s]++;
		}
		x = (x + a[i-j] + k - 1) % k;
		r += z.find(x)==z.end() ? 0: z[x];
		//cout << '=' << r << ' ' << x << ':' << z << '+' << s << '-' << b[i-j] << endl;
	}
	return r;
}

void output(i64 ans) {
	printf("%lld\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		break;
	}
}




Measured memory_bytes: 12800
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;
 
#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 3005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';
 
LL dp[MAX][MAX][4];
LL a[MAX][MAX];
 
LL _max(LL n1, LL n2) {
	if(n1 > n2) return n1;
	return n2;
}
 
void solve() {
	int r, c, k;
	in2(r, c);in(k);
	for(int i=0;i<r;i++) {
		for(int j=0;j<c;j++) {
			a[i][j] = 0;
			for(int x=0;x<4;x++) dp[i][j][x] = 0;
		}
	}
			
	for(int i=0;i<k;i++) {
		int x,y;
		LL v;
		in2(x, y);inl(v);
		a[x-1][y-1] = v;
	}
	
	dp[0][0][1] = a[0][0];
	for(int j=1;j<c;j++) {
		dp[0][j][0] = dp[0][j-1][0];
		dp[0][j][1] = _max(dp[0][j-1][1], a[0][j]!=0 ? (dp[0][j-1][0] + a[0][j]) : 0);
		dp[0][j][2] = _max(dp[0][j-1][2], a[0][j]!=0 ? (dp[0][j-1][1] + a[0][j]) : 0);
		dp[0][j][3] = _max(dp[0][j-1][3], a[0][j]!=0 ? (dp[0][j-1][2] + a[0][j]) : 0);
	}
	
	for(int i=1;i<r;i++) {
		LL maxi = 0;
		for(int x=0;x<4;x++) maxi = max(dp[i-1][0][x], maxi);
		dp[i][0][0] = dp[i-1][0][0];
		dp[i][0][1] = _max(dp[i-1][0][1], a[i][0]!=0 ? maxi + a[i][0] : 0);
		dp[i][0][2] = _max(dp[i-1][0][2], a[i][0]!=0 ? (dp[i-1][0][1] + a[i][0]) : 0);
		dp[i][0][3] = _max(dp[i-1][0][3], a[i][0]!=0 ? (dp[i-1][0][2] + a[i][0]) : 0);
	}
	
	for(int i=1;i<r;i++) {
		for(int j=1;j<c;j++) {
			LL maxi = 0;
			for(int x=0;x<4;x++) maxi = _max(maxi, dp[i-1][j][x]);
			
			dp[i][j][0] = _max(maxi, dp[i][j-1][0]);
			if(a[i][j]!=0) {
				dp[i][j][1] = _max(maxi+a[i][j], dp[i][j-1][0]+a[i][j]);
				dp[i][j][2] = dp[i][j-1][1]+a[i][j];
				dp[i][j][3] = dp[i][j-1][2]+a[i][j];
			}
			dp[i][j][1] = _max(dp[i][j][1], dp[i][j-1][1]);
			dp[i][j][2] = _max(dp[i][j][2], dp[i][j-1][2]);
			dp[i][j][3] = _max(dp[i][j][3], dp[i][j-1][3]);
		}
	}
	
	LL ans = 0;
	for(int x=0;x<4;x++) ans = _max(ans, dp[r-1][c-1][x]);
	
	cout<<ans<<en;
}
 
int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 355772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

signed main() {
    capi(n);

    vector<vi> graph(n, vi());
    vector<pair<int, int>> vp;

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b; --a; --b;
        if (b < a) swap(a, b);

        graph[a].push_back(b);
        graph[b].push_back(a);
        vp.push_back(make_pair(a, b));
    }

    int m = 0;

    rep(i, n) {
        chmax(m, (int)(graph[i].size()));
    }

    cout << m << endl;

    map<pair<int, int>, int> mc;

    int p = 0;
    queue<pair<int, int>> q;
    q.push(make_pair(p, -1));

    while (!q.empty()) {
        auto u = q.front(); q.pop();
        int c = 1;
        for (auto v: graph[u.first]) {
            int x = min(u.first, v);
            int y = max(u.first, v);

            if (auto it = mc.find(make_pair(x, y)); it == mc.end()) {
                if (u.second == c) ++c;
                mc.emplace(make_pair(x, y), c);
                q.push(make_pair(v, c));
                ++c;
            }
        }
    }

    for (auto &p: vp) {
        cout << mc[p] << endl;
    }

    return 0;
}


Measured memory_bytes: 16724
import java.util.*;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int w=in.nextInt();
			int a[]={1,2,4,8,16,32,64,128,256,512};
			boolean b[]=new boolean[10];
			Arrays.fill(b, false);
			for(int i=9;i>=0;i--)
			{
				if(w>=a[i])
				{
					w-=a[i];
					b[i]=true;
				}
			}
			boolean f=false;
			for(int i=0;i<10;i++)
			{
				if(b[i])
				{
					if(f)
						System.out.print(" ");
					System.out.print(a[i]);
					f=true;
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, n;
  cin >> a >> b;
  n = a * b;
  string ans;
  if(n % 2 == 0){
    ans = "Even";
  }
  else {
    ans = "Odd";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

F,P,b,T = [],[],1,-9999999999

for i in range(N):
    F.append(list(map(int,input().split())))
for i in range(N):
    P.append(list(map(int,input().split())))

while b < 1 << 10:
    bs = "{0:10b}".format(b)
    bsi = 0
    S = [0]*N
    for c in bs:
        if c == "1":
            for i in range(N):
                S[i] += F[i][bsi]
        bsi += 1
    t = 0
    for i in range(N):
        t += P[i][S[i]]
    if T < t:
        T = t
    b += 1
print(T)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}

bool compareg(Pi a, Pi b) {
    if(a.second != b.second){
        return a.second > b.second;
        
    }else{
        return a.first > b.first;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



int main() {
    ll N,W;
    cin>>N>>W;
    vector<ll> v(N);
    vector<ll> w(N);
    rep(i,N){
        cin>>v[i]>>w[i];
    }

    //ll dp[105][10010] = {};
    vector<vector<ll>> dp(105,vector<ll>(10010));
    rep(i,N){
        rep(j,W+1){
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
            
        }
    }
    ll ans = 0;
    rep(i,W+1){
        chmax(ans,dp[N][i]);
    }

    cout<<ans<<endl;
    return 0;
    

}



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

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> V(N),A(N);
  vector<int> B(N);
  for(int i=0;i<N;i++) cin >> V[i].second;
  for(int i=0;i<N;i++) cin >> V[i].first;
  sort(V.begin(),V.end());
  for(int i=0;i<N;i++){
    A[i] = make_pair(V[i].second,i);
    B[i] = V[i].first;
  }
  
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){
    if(A[i].first>B[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  vector<bool> state(N,false);
  state[0] = true;
  int now = 0;
  for(int i=1;;i++){
    now = A[now].second;
    if(state[now]==true){
      if(i<N){
        cout << "Yes" << endl;
        return 0;
      }
      else break;
    }
    else state[now] = true;
  }
  
  for(int i=1;i<N;i++){
    if(A[i].first<=B[i-1]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << 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) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif

void solve()
{
	long long n;
	cin>>n;
    string ch;
	while(n){

		long long rem=n%26;
		n=n/26;

		if(rem==0){
			rem=26;
			n--;
		}
		rem--;
	
		ch.push_back((char)(rem+'a'));
	}

	reverse(ch.begin(),ch.end());
	cout<<ch<<nl;
}

int main()
{
	FIO;

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String ans = "NO";
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		for (int i = 1; i <= B; i++) {
			int tmp = A * i;
			if (tmp % B == C) {
				ans = "YES";
			}
		}
		System.out.println(ans);
		reader.close();

	}

}


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

int main() {
	int k, s;
	scanf("%d %d", &k, &s);
	int ans = 0;
	for(int i = 0; i <= k; i++) {
		for(int j = 0; j <= k; j++) {
			if(s - i - j >= 0 && s - i - j <= k) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, b, n) for (int i = (b); i < (n); i++)
using namespace std;
using ll = long long;
const ll M = 1000000007;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll> a(n + 10);
	vector<ll> s(n + 10);
	rep(i, n) {
		cin >> a[i];
		s[i + 1] += s[i] + a[i];
		s[i + 1] %= M;
	}
	rep(i, n - 1) {
		if (s[n] - s[i + 1] < 0) ans += a[i] * (s[n] - s[i + 1] + M);
		else ans += a[i] * (s[n] - s[i + 1]);
		ans %= M;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6292
using System;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder
{
	class Programs
	{
		static void Main ()
		{
			var inp = Array.ConvertAll (Console.ReadLine ().Split (), long.Parse);
			var a = Array.ConvertAll (Console.ReadLine ().Split (), long.Parse);
			var b = new long[a.Count () + 1];
			b [0] = 0;
			for (int i = 0; i < a.Count (); i++) {
				b [i + 1] = b [i] + a [i];
			}
			var list = new List<long> ();
			for (int i = 0; i < b.Count (); i++) {
				list.Add (b [i] % inp [1]);
			}
			list = list.OrderBy (f => f).ToList ();
			long check = -1;
			long count = 0;
			long ans = 0;
			for (int i = 0; i < list.Count (); i++) {
				if (check != list [i]) {
					ans += count * (count - 1) / 2;
					check = list [i];
					count = 1;
				} else {
					count++;
				}
			}
			ans += count * (count - 1) / 2;
			Console.WriteLine (ans);
		}
	}
}

Measured memory_bytes: 25568
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;

struct Node{
  int key;
  Node *prev, *next;
};

Node *nil;

void initiation(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int x){
  Node *a = (Node *)malloc(sizeof(Node));
  a->key = x;
  a->next = nil->next;
  nil->next->prev = a;
  a->prev = nil;
  nil->next = a;
}

void delete1(Node *cur){
  if(cur == nil){return;}
  cur->prev->next = cur->next;
  cur->next->prev = cur->prev;
  free(cur);
}

Node *listserch(int x){
  Node *cur = nil->next;
  while(cur != nil && cur->key != x){
    cur = cur->next;
  }
  return cur;
}




int main(){

  int size;

  cin >> size;

  //char *inst = new char[100];

  string inst;
  int x;

  initiation();


  for(int i = 0; i < size; i++){

    cin >> inst;

    if(inst == "insert"){
      cin >> x;
      insert(x);
    }
    else if(inst == "delete"){
      cin >> x;
      delete1(listserch(x));
    }
    else if(inst == "deleteFirst"){
      delete1(nil->next);
    }
    else if(inst == "deleteLast"){
      delete1(nil->prev);
    }

    /*Node *cur = nil->next;

    while(cur != nil){
      if(cur == nil->next){
        cout << cur->key;
      }
      else{
        cout << ' ' << cur->key;
      }
      cur = cur->next;
    }

    cout << endl;*/
  }

  Node *cur = nil->next;

  while(cur != nil){
    if(cur == nil->next){
      cout << cur->key;
    }
    else{
      cout << ' ' << cur->key;
    }
    cur = cur->next;
  }

  cout << endl;

  return 0;
}



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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {

    vector<string> term = {"dream", "dreamer", "erase", "eraser",};

    string s;
    cin >> s;
    vector<bool> dp(s.size() + 1, false);
    dp[0] = true;

    for (int i = 0; i < s.size(); i++) {
        if (!dp[i]) continue;
        for (string t : term) {
            bool b = [&] {
                for (int j = 0; j < t.size(); j++) {
                    if (s[i + j] != t[j]) return false;
                }
                return true;
            }();
            if (b) {
                dp[i + t.size()] = true;
            }
        }
    }

    cout << (dp.back() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;
constexpr ll MOD = 1000000007;
constexpr ll INF = 2000000000000000000;

ll solve(vecll v, ll a, ll b) {
  int n = v.size();
  v.insert(begin(v), -INF);
  vecll dp(n+1);
  vecll psum(n+2);
  dp[0] = 1;
  dp[1] = 1;
  psum[1] = 1;
  psum[2] = 2;
  int lastng = 0;
  FOR(i,2,n+1) {
    auto last = begin(v) + i;
    auto itr = prev(upper_bound(begin(v), last, v[i] - b));
    int idx = itr - begin(v);
    if (idx < lastng) {
      dp[i] = 0;
    } else {
      dp[i] = (psum[idx+1] + MOD - psum[lastng]) % MOD;
    }
    psum[i+1] = (psum[i] + dp[i]) % MOD;
    if (v[i] - v[i-1] < a) lastng = i - 1;
  }
  return (psum[n+1] + MOD - psum[lastng]) % MOD;
}

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  if(a>b) swap(a,b);
  vecll s(n);
  for(auto&& e : s) cin>>e;
  s.insert(begin(s), -INF);
  ll ans = 1;
  vecll tmp;
  REP(i,n) {
    if (i > 0 && s[i+1] - s[i-1] < a) ans = 0;
    if (s[i+1] - s[i] >= b) {
      if (!tmp.empty()) {
        ans *= solve(tmp, a, b);
        ans %= MOD;
      }
      tmp.clear();
    }
    tmp.push_back(s[i+1]);
  }
  ans *= solve(tmp, a, b);
  ans %= MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4208
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.00001;

int main() {
    int n;
    cin >> n;
    long long *a = new long long[n];
    multiset<long long> b;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b.insert(a[i]);
    }
    sort(a,a+n,greater<>());
    int c = 0;
    for(int i = 0;i < n;i++) {
        if(b.find(a[i]) == b.end()) continue;
        b.erase(b.find(a[i]));
        long long t = 1;
        while(t <= a[i]*2) {
            if(b.find(t-a[i]) != b.end()) {
                c++;
                b.erase(b.find(t-a[i]));
                break;
            }
            t = t << 1;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define scs(ch) scanf("%s", ch)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define PI 3.14159265358979323846264338327950L

int main()
{
	double a,b,h,m,h_a,m_a,angle,degree,rad,ans;
	scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    h_a=(h*60+m)*0.5;
    m_a=6*m;
    angle=abs(h_a-m_a);
    degree=min((360-angle),angle);
    rad=(PI*degree)/180;
    ans=sqrt(a*a+b*b-2*a*b*cos(rad));
    printf("%.9lf\n",ans);
}

Measured memory_bytes: 4248
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#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>
#include <math.h>

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;

int main(){
  ll N;
  cin >> N;
  vector<ll> V(N);
  rep(i,N)cin >> V[i];
  bool flag = true;
  rep(i,N){
    if(V[i]%2==0){
      if(V[i]%3!=0 && V[i]%5!=0){
        flag = false;
        break;
      }
    }
  }
  if(flag)cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


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

int main(){
//  int N,K;
    long long N,K;
    cin >> N >> K;
    long long ans=0;
//  for(int i=K;i<=N+1;i++){
    for(long long i=K;i<=N+1;i++){
//     long long under = (i*(i-1)/2)%MAX;
//     long long top = (i*(2*N-i+1)/2)%MAX;
//     ans += under - top + 1;
        ans += i*(N-i+1) + 1;
        ans %= MAX;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll x){if(x==0) return 0;else return x%10+f(x/10);}
int main(){
	std::ios::sync_with_stdio(false);
	int k;cin>>k;
	int num=0;ll ans=1;ll p=1;
	while(num<k){
		cout<<ans<<endl;
		ll ans1=ans+p;
		ll ans2=ans+p*10;
		if(ans1*f(ans2)<=ans2*f(ans1)){ans=ans1;}
		else{ans=ans2;p*=10;}
		num++;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner s=new Scanner(System.in);
    public static void main(String[] args){
        int lim=7368792;
        
        BitSet b=new BitSet(lim);
        while(true){
            int m=s.nextInt(),n=s.nextInt();
            if(m+n==0)return;
            
            b.clear();
            
            int v=m;
            for(int i=0;i<n;++i){
                v=b.nextClearBit(v);
                for(int j=v;j<lim;j+=v)
                    b.set(j);
            }
            System.out.println(b.nextClearBit(m));
        }
    }
}



Measured memory_bytes: 28292
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int n,k,mod;
int dp[303][303];
int C[303][303];
int main(){
	cin>>n>>k>>mod;
	for(int i=0;i<=300;i++){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
		}
	}
	for(int i=0;i<=300;i++)dp[0][i]=1;
	for(int i=1;i<=n;i++){
		dp[i][1]=1;
		for(int j=2;j<=k;j++){
			dp[i][j]=dp[i][j-1];
			for(int t=1;t<=i;t++){
				dp[i][j]+=((ll)dp[t-1][j-1]*dp[i-t][j]%mod*C[i][t-1]%mod);
				if(dp[i][j]>=mod)dp[i][j]-=mod;
			}
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

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

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

	int flag = 0;
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			if (n*i + m*j - 2 * i*j == k) {
				flag = 1;
			}
		}
	}

	if (flag == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <cstdlib>
    #include <stdlib.h>
    #include <cmath>
    #include <algorithm>
    using namespace std;
     
    int main() {
    	int rate1 = 0, rate2 = 0, rate3 = 0, rate4 = 0, rate5 = 0, rate6 = 0, rate7 = 0, rate8 = 0, all = 0, N, a[100], i, resmin, resmax;
    	scanf("%d", &N);
    	for (i = 0; i<N; i++) {
    		scanf("%d", &a[i]);
    	}
    	for (i = 0; i<N; i++) {
    		if ((1 <= a[i]) && (a[i] <= 399)) {
    			rate1 = 1;
    		}
    		else if ((400 <= a[i]) && (a[i] <= 799)) {
    			rate2 = 1;
    		}
    		else if ((800 <= a[i]) && (a[i] <= 1199)) {
    			rate3 = 1;
    		}
    		else if ((1200 <= a[i]) && (a[i] <= 1599)) {
    			rate4 = 1;
    		}
    		else if ((1600 <= a[i]) && (a[i] <= 1999)) {
    			rate5 = 1;
    		}
    		else if ((2000 <= a[i]) && (a[i] <= 2399)) {
    			rate6 = 1;
    		}
    		else if ((2400 <= a[i]) && (a[i] <= 2799)) {
    			rate7 = 1;
    		}
    		else if ((2800 <= a[i]) && (a[i] <= 3199)) {
    			rate8 = 1;
    			int *error = (int*)malloc(pow(10000000, 100000000000000));
     
    		}
    		else if (3200 <= a[i]) {
    			all++;
    		}
    		else int *error = (int*)malloc(pow(100000,100000));
    	}
    	resmin = rate1 + rate2 + rate3 + rate4 + rate5 + rate6 + rate7 + rate8;
    	if (resmin == 0) {
    		resmin = 1;
    	}
    	resmax = rate1 + rate2 + rate3 + rate4 + rate5 + rate6 + rate7 + rate8 + all;
     
    	printf("%d %d", resmin, resmax);
    	return 0;
    }

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

int main(){
int n;
cin >> n;
vector <int> b(n);
int count;
for (int i = 0; i<n; i++){
cin >> b[i];
}
sort(b.begin(),b.end());
count = b[n/2] - b[n/2 - 1];
cout << count << "\n";
return 0;
}


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

int main()
{
	int n,m;cin>>n>>m;
	if(n<m)
		for(int i=0;i<m;i++)
			cout<<n;
	else for(int i=0;i<n;i++)
			cout<<m;
	
  return 0;
}


Measured memory_bytes: 256
#include <atcoder/lazysegtree>
#include <cstdio>

using namespace std;
using namespace atcoder;


using ll = long long;
const ll MAX = 3e5+10;

ll op(ll l, ll r) { return ll{max(l,r)}; }

ll e() { return ll{0}; }

ll mapping(ll l, ll r) { return ll{max(r , l)};}; 

ll composition(ll l, ll r) { return ll{max(r,l)};}; 

ll id() { return ll{0};};

int main() {
  ll n,k,ans=0;
  cin >> n >> k;

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

  lazy_segtree<ll, op, e, ll, mapping, composition, id> seg(
      vector<ll>(MAX,0));
  for(int i=0;i<n;i++){
    ll val = seg.get(a[i]);
    val++;
    ans = max(ans,val);
    ll l = min(MAX,max(0ll,a[i]-k));
    ll r = min(MAX-1,a[i]+k) + 1;
    seg.apply(l,r,val);
  }
  cout << ans << endl;
}


Measured memory_bytes: 20156
import itertools
import networkx as nx
H, W = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]

graph = nx.DiGraph()
for h, w in itertools.product(range(H), range(W)):
    if A[h][w] == 'S':
        s = (h, w)
        graph.add_edge(s, (h, -1), capacity=10**10)
        graph.add_edge(s, (-1, w), capacity=10**10)
    elif A[h][w] == 'T':
        t = (h, w)
        graph.add_edge((h, -1), t, capacity=10**10)
        graph.add_edge((-1, w), t, capacity=10**10)
    elif A[h][w] == 'o':
        graph.add_edge((h, -1), (-1, w), capacity=1)
        graph.add_edge((-1, w), (h, -1), capacity=1)
ans = nx.minimum_cut_value(graph, s, t)
print(-1 if ans >= 10**10 else ans)


Measured memory_bytes: 70272
n, a, b = map(int, input().split())
s = list(input())
cnt = 0
kaigai = 1
for i in s:
    if i == "c":
        print("No")
    elif cnt < a + b and i == "a":
        print("Yes")
        cnt += 1
    elif cnt < a + b and i == "b" and kaigai <= b:
        print("Yes")
        cnt += 1
        kaigai += 1
    else:
        print("No")

Measured memory_bytes: 4716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
    public static void main(String[] args){
    	//行ごと読んで分割するロジックに変更
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
        	//1行目はサイコロの個数
            int n = Integer.parseInt(br.readLine());
            int o[][] = new int[n][6];

            for (int i=0; i < n; i++){
            	String str[] = br.readLine().split("\\s+");
                for(int j = 0; j < str.length; j++){
                	o[i][j] = Integer.parseInt(str[j]);
                }

            }
        br.close();
        Dice3 dice[] = new Dice3[n];

        final String order = "NNNNWNNNWNNNENNNENNNWNNNWNNNWNNNENNNENNNWNNN";
        //diceが全てあったときのフラグfalseにしておいて１つでもtrueになったら終了
        boolean flg = false;
        for(int k=0; k < n-1; k++){
            dice[k] = new Dice3(o[k][0],o[k][1],o[k][2],o[k][3],o[k][4],o[k][5]);
            for(int l=k+1;l < n;l++) {
                dice[l] = new Dice3(o[l][0],o[l][1],o[l][2],o[l][3],o[l][4],o[l][5]);
                //order 回して合ってるか確認する。
                for(int r=0;r < order.length(); r++){
            		if (dice[k].equals(dice[l])) {
            				flg = true;
            				break;
            		}
            		String odr = order.substring(r, r+1);
            		if ("N".equals(odr)){
            			dice[l].N();
            		} else if ("E".equals(odr)) {
            			dice[l].E();
            		} else if ("W".equals(odr)) {
            			dice[l].W();
            		} else if ("S".equals(odr)) {
            			dice[l].S();
            		}
            	}
            }
        }
        if(flg) {
        	System.out.println("No");
        } else {
        	System.out.println("Yes");
        }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
    class Dice3{
		int one;
		int two;
		int three;
		int four;
		int five;
		int six;
		int tmp;
    	Dice3(int a, int b, int c, int d, int e, int f){
    		one=a;
    		two=b;
    		three=c;
    		four=d;
    		five=e;
    		six=f;
    	}
    	boolean equals(Dice3 b) {
    		if ((this.one==b.one)&&(this.two==b.two)&&(this.three==b.three)&&(this.four==b.four)&&(this.five==b.five)&&(this.six==b.six)){
    			return true;
    		}
    		return false;
    	}
       	void N(){//1-2-6-5
    		tmp =this.one;
    		one=this.two;
    		two=this.six;
    		six=this.five;
    		five=tmp;
    	}
    	void E(){//1-4-6-3
    		tmp =this.one;
    		one=this.four;
    		four=this.six;
    		six=this.three;
    		three=this.tmp;
    	}
    	void W(){//1-3-6-4
    		tmp =this.one;
    		one=this.three;
    		three=this.six;
    		six=this.four;
    		four=tmp;
    	}
    	void S(){//1-5-6-2
    		tmp =this.one;
    		one=this.five;
    		five=this.six;
    		six=this.two;
    		two=tmp;
    	}
    	void turnR(){
    		tmp=this.two;
    		two=this.three;
    		three=this.five;
    		five=this.four;
    		four=tmp;
    	}
    	void print(){
    		System.out.printf("%d %d %d %d %d %d %n", one,two,three,four,five,six);
    	}
    }



Measured memory_bytes: 37132
def friendly_pairs(red_points, blue_points):
    def can_be_friends(r, b):
        return r[0] < b[0] and r[1] < b[1]
    
    red = sorted(red_points, key=lambda x: (x[1], x[0]), reverse=True)
    blue = sorted(blue_points, key=lambda x: (x[0], x[1]))
    count = 0
    for b in blue:
        potential_friends = filter(lambda x: can_be_friends(x, b), red)
        if potential_friends:
            count += 1
            red.remove(potential_friends[0])
    return count


if __name__ == '__main__':
    n = int(raw_input())
    red_points = [map(int, raw_input().split())  for _ in xrange(n)]
    blue_points = [map(int, raw_input().split())  for _ in xrange(n)]
    print friendly_pairs(red_points, blue_points)


Measured memory_bytes: 2820
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] rank = new int[9];
        for(int n=0; n<N; n++){
            int a = sc.nextInt();
            if(a>=3200) rank[8]++;
            else rank[a/400]++;
        }
        int fixedColor = 0;
        for(int i=0; i<=7; i++) fixedColor += (rank[i]>0 ? 1 : 0);
        if(fixedColor==0) System.out.printf("%d %d\n", 1, rank[8]);
        else System.out.printf("%d %d\n", fixedColor, fixedColor+rank[8]);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define endl '\n'
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define F first
#define S second
#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 pb push_back
#define eb emplace_back
#define mp(a,b) make_pair(a,b)
#define cans cout<<ans<<endl
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}

//}}}
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int maxk = 1e5+5;
int dp[maxk];
int arr[100];
int32_t main(){
    int n,k;
    cin>>n>>k;
    rep(i,n)
        cin>>arr[i];
    memset(dp,0,sizeof(dp));
    //0 lose
    //1 win
    rep(i,arr[0])
        dp[i]=0;
    for(int i=0;i<=k;i++){
        for(int j=0;i-arr[j]>=0&&j<n;j++){
            dp[i]|=(!dp[i-arr[j]]);
        }
    }
    if(dp[k])
        cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  vl v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<v[k-1]<<endl;
}

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

int main(){
    int n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    auto ary = new long[](MAX);
    foreach (e; a)
    {
        ary[e]++, ary[e + 1]++, ary[e + 2]++;
    }
    ary.reduce!(max).writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

using namespace std;
long long X,N;
int A[2000010]{};

int main()
{
  cin>>N;
  bool flag =true;
  int count=0;
  for(;0<=N;){
    if(N<10)break;
    if(N%10!=9)flag=false;
    count++;
    N/=10;
  }
  count*=9;
  if(flag)count++;
  count+=N-1;
  cout<<count;
  return 0;
}





Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << endl;
}

Measured memory_bytes: 256