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

using namespace std;

const int inf = 1 << 25;

struct edge
{
  int to, cap, rev, id, isrev;
  edge(){}
  edge(int to, int cap, int rev, int id, int isrev):to(to), cap(cap), rev(rev), id(id), isrev(isrev){}
};

struct Dinic
{
  vector< vector<edge> > G;
  //int level[333], iter[333];
  vector<int> level, iter;
  Dinic(int V):G(V), level(V), iter(V){};
  /*
  Dinic(int V)
  {
    G.clear(); G.resize(V);
  }
  */
  void add_edge(int f, int t, int id)
  {
    G[f].push_back(edge(t, 1, (int)G[t].size(), id, 0));
    G[t].push_back(edge(f, 1, (int)G[f].size()-1, id, 1));
  }
  void bfs(int s)
  {
    fill(level.begin(), level.end(), -1);
    //memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)G[v].size(); i++) {
	edge& e = G[v][i];
	if(e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int t, int f)
  {
    if(v == t) return f;
    for(int &i = iter[v]; i < (int)G[v].size(); i++) {
      edge& e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, t, min(f, e.cap));
	if(d > 0) {
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int s, int t)
  {
    int flow = 0;
    while(1) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      //memset(iter, 0, sizeof(iter));
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
};

int main()
{
  int N, M; cin >> N >> M;
  Dinic dinic(N);
  for(int i = 0; i < M; i++) {
    int X, Y; cin >> X >> Y; X--, Y--;
    dinic.add_edge(X, Y, i);
  }
  int S, T; cin >> S >> T; S--, T--;
  int ans = dinic.max_flow(S, T);
  vector<int> used_rev;
  for(int v = 0; v < (int)dinic.G.size(); v++) {
    for(int i = 0; i < (int)dinic.G[v].size(); i++) {
      edge e = dinic.G[v][i];
      if(e.cap < 1 && e.isrev == 1) used_rev.push_back(e.id);
    }
  }
  sort(used_rev.begin(), used_rev.end());
  cout << ans << endl;
  cout << (int)used_rev.size() << endl;
  for(int i = 0; i < (int)used_rev.size(); i++) cout << used_rev[i]+1 << endl;
  return 0;
}

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

int main()
{
  pair<int, int> p[2];
  cin >> p[0].first >> p[0].second >> p[1].first >> p[1].second;
  cout << p[1].first + p[0].second - p[1].second << ' ' << p[1].second + p[1].first - p[0].first << ' ' << p[0].first + p[0].second - p[1].second << ' ' << p[0].second + p[1].first - p[0].first << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s,t;cin>>s>>t;
    int len1=s.size(),len2=t.size();
    int ans=len2;
    for(int i=0;i<=len1-len2;i++){
        int sum=0;
        for(int j=0;j<len2;j++){
            //sum+=(s[i]!=t[j]);
            if(s[i+j]!=t[j]) sum++;
        }
        //cout<<sum<<endl;
        ans=min(ans,sum);
    }
    cout<<ans;
}




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

struct Item {
  string name;
  int value, index;
  
  bool operator<(const Item& it) const {
    if (name != it.name) return name < it.name;
    else return value > it.value;
  };
};

int main() {
  int n; cin >> n;
  vector<Item> items(n);
  for (int i = 0; i < n; i++) {
    items[i].index = i + 1;
   	cin >> items[i].name >> items[i].value;
  }
  sort(items.begin(), items.end());
  for (int i = 0; i < n; i++) {
    cout << items[i].index << endl;
  }
}

Measured memory_bytes: 256
#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>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int total = 0;
  rep(i, n) {
    cin >> a[i];
    total += a[i];
  }
  int cnt = 0;
  double div = (double) total / (4 * m);
  rep(i, n) {
    if (a[i] >= div) {
      cnt++;
    }
  }
  bool ok = cnt >= m;

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int q;
    cin>>q;
    while(q--){
        int a,b, c, d;
        cin>>a>>b>>c>>d;
        int ans=0;
        REP(i,a,c+1)REP(j,b,d+1){
            if(i%2==0||j%2==1)++ans;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
signed main(){
    int a,b,k,cnt=0;
    cin>>a>>b>>k;
    for(int i=gcd(a,b);i>0;i--){
        if(a%i==0&&b%i==0){
            cnt++;
            if(cnt==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

const int SIZE = 1000010;
int n, x;
int v[30];
bool dp[SIZE];
bool is_prime[SIZE];
vector<int> p;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  fill_n((bool*)is_prime, SIZE, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < SIZE; i++) {
    if (!is_prime[i]) continue;
    p.emplace_back(i);
    for (int j = 2 * i; j < SIZE; j += i) {
      is_prime[j] = false;
    }
  }

  while (cin >> n >> x, n) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    dp[0] = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j + v[i] <= x; j++) {
        if (dp[j]) dp[j + v[i]] = true;
      }
    }
    int ans = 0;
    for (int i : p) {
      if (i > x) break;
      if (dp[i]) ans = i;
    }
    if (ans == 0) cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5116
#include <iostream>
#include <string>
using namespace std;
int c[26];
int main()
{
  string S;
  cin >> S;
  for (int i = 0; i < 26; i++) c[i] = 0;
  for (int i = 0; i < 4; i++) {
    c[(int)(S[i]-'A')]++;
  }
  bool ans = true;
  for (int i = 0; i < 26; i++) {
    if (c[i]!=0 && c[i]!=2) ans = false;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// practice contest

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((n * a) > b) {
			System.out.println(b);
		} else if ((n * a) <= b) {
			System.out.println((n * a));
		}
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
char mp[100][100];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	int n,m;
	cin>>n>>m;
	int dap = 0;
	int k1 = ceil(1.0*n/50),k2;
	debug(k1);
	if(n>1) m-=1;
	k2 = k2=ceil(1.0*m/50);
	bool need = false;
	if(m>0) n--;
	k1 = ceil(1.0*n/50);
	while(k1--) 
	{
		n-=50;
		for (int i = 0; i < 100; ++i)
		{
			for (int j = 0; j < 3; ++j)
			{
				int tj= j+dap*3;
				if(((tj-1)%3==0)&&i&1) mp[i][tj]='.';
				else mp[i][tj]='#';
			}
		}
		if(n<0)
		{
			int tms = -1*n;
			debug(tms);
			for (int i = 0; i < 100; ++i)
			{
				for (int j = 0; j < 3; ++j)
				{
					int tj=j+dap*3;
					if(mp[i][tj]=='.'&&tms>0) 
					{
						mp[i][tj] = '#'; 
						tms--;
					}
				}
			}
			dap++;
			break;
		}
		dap++;
	}
	debug(k2);
	while(k2--) 
	{
		m-=50;
		for (int i = 0; i < 100; ++i)
		{
			for (int j = 0; j < 3; ++j)
			{
				int tj= j+dap*3;
				debug(tj);
				if(((tj-1)%3==0)&&i&1) mp[i][tj]='#';
				else mp[i][tj]='.';
			}
		}
		if(m<0)
		{
			int tms = -1*m;
			for (int i = 0; i < 100; ++i)
			{
				for (int j = 0; j < 3; ++j)
				{
					int tj=j+dap*3;
					if(mp[i][tj]=='#'&&tms>0) 
					{
						mp[i][tj] = '.'; 
						tms--;
					}
				}
			}
			dap++;
			break;
		}
		dap++;
	}
	cout<<100<<" "<<dap*3<<endl;
	for (int i = 0; i < 100; ++i)
	{
		cout<<mp[i]<<endl;
	}
	return 0;	
}

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

int main()
{
    string x;
    cin >> x;
    bool ok = true;
    int n = x.size();
    for (int i = 0, j = n - 1; i < j; i++, j--) {
        if (x[i] != x[j]) {
            ok = false;
            break;
        }
    }
    if (ok) {
        for (int i = 0, j = (n - 1) / 2 - 1; i < j; i++, j--) {
            if (x[i] != x[j]) {
                ok = false;
                break;
            }
        }
    }
    if (ok) {
        for (int i = n - 1, j = (n - 1) / 2 + 1; j < i; i--, j++) {
            if (x[i] != x[j]) {
                ok = false;
                break;
            }
        }
    }
    if (ok) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
n = int(input())
memo1 = 0
memo2 = 0
ans = 0
stra = ""
strb = ""
str1 = ""
str2 = ""

for a in range(1,10):
    for b in range(1,10):
        stra = str(a)
        strb = str(b)
        for i in range(1, n+1):
            str1 = str(i)[0]
            str2 = str(i)[-1]
            if str1 == stra and str2 == strb:
                memo1 += 1
            if str1 == strb and str2 == stra:
                memo2 += 1
        ans += memo1 * memo2
        memo1 = 0
        memo2 = 0



print(ans)

Measured memory_bytes: 43228
N,M,Q=map(int,input().split())
a=[];b=[];c=[];d=[]

for q in range(Q):
  a_,b_,c_,d_ =map(int,input().split())
  a.append(a_-1)
  b.append(b_-1)
  c.append(c_)
  d.append(d_)
  
def score(A):
  tmp=0
  for q in range(Q):
    if A[b[q]]-A[a[q]]==c[q]:
      tmp += d[q]
  
  return tmp

def dfs(A):
  if len(A)==N:
    return score(A)
  
  elif len(A)==0:
    Alast=1
  
  else:
    Alast=A[-1]
   
  ans=0
    
  for i in range(Alast,M+1):
    A.append(i)
    ans = max(ans,dfs(A))
    A.pop()
  
  return ans
    
print(dfs([]))  
  

Measured memory_bytes: 9172
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, k, h, ctr = 0;
   cin >> n >> k;
   FOR(i, 0, n)
   {
      cin >> h;
      if (h >= k)
         ctr++;
   }
   cout << ctr << endl;
   return 0;
}


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

int main(void)
{
	int N;
	cin >> N;

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

	int x=0, sum=0;
	long long ret = 0;
	for(int l=0, r=0; l<N; l++){
		while(r<N && (sum+A[r] == (x^A[r]))){
			sum += A[r];
			x ^= A[r];
			r++;
		}
		//cout << l << " : " << r << " " << sum << " " << xor << endl;

		ret += r - l;
		sum -= A[l];
		x ^= A[l];
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
char a[1005][1005];
long int dp[1005][1005];
int main()
{
	int r,c;
	cin>>r>>c;
	for(int i=0;i<r;i++)
	{
		scanf("%s",a[i]);
		
	}
	if(a[0][0]=='#')
	{
		return 0;
	}
	dp[0][0]=1;
	for(int i=1;i<c;i++)
	{
		dp[0][i]=(a[0][i]=='.'&&dp[0][i-1]==1)?1:0;
	}
	for(int i=1;i<r;i++)
	{
		dp[i][0]=(a[i][0]=='.'&&dp[i-1][0]==1)?1:0;
	}
	for(int i=1;i<r;i++)
	{
		for(int j=1;j<c;j++)
		{
			if(a[i][j]=='#')
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	cout<<dp[r-1][c-1]<<endl;
}

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

using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int main() {
	int a, b; cin >> a >> b;
	for (int i=1; i<=3; ++i)
		if (i != a && i != b) {
			cout << i << endl;
			return 0;
		}
}

Measured memory_bytes: 256
#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>;

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

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
// long long int MOD = 1e9 + 7;
long long int MOD = 998244353;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    long long int cnt[3] = {};
    long long int ans = 1;
    string patt = "RGB";
    for(char c : S){
        for(int i = 0; i < 3; i++){
            if(c == patt[i]){
                if(cnt[i] >= cnt[(i + 1) % 3] && cnt[i] >= cnt[(i + 2) % 3]){
                    ans *= N - cnt[i];
                    ans %= MOD;
                }else if(cnt[i] < cnt[(i + 1) % 3] && cnt[i] < cnt[(i + 2) % 3]){
                    ans *= min(cnt[(i + 1) % 3], cnt[(i + 2) % 3]) - cnt[i];
                    ans %= MOD;
                }else{
                    ans *= max(cnt[(i + 1) % 3], cnt[(i + 2) % 3]) - cnt[i];
                    ans %= MOD;
                }
                cnt[i] += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

int main()
{
    using namespace std;

    int n;
    cin >> n;

    int a[n] = {};

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


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<int> a(x);
    vector<int> b(y);
    vector<int> c(z);
    for(int i = 0; i < x; i++) cin >> a[i];
    for(int i = 0; i < y; i++) cin >> b[i];
    for(int i = 0; i < z; i++) cin >> c[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<int> d;
    for(int i = 0; i < x; i++) for(int j = 0; j < y; j++) d.push_back(a[i] + b[j]);
    sort(d.rbegin(), d.rend());
    vector<int> ans;
    
    for(int i = 0; i < k && i < d.size(); i++) for(int j = 0; j < k && j < c.size(); j++) ans.push_back(d[i] + c[j]);
    sort(ans.rbegin(), ans.rend());
    for(int i = 0; i < k; i++) cout << ans[i] << endl;


    return 0;
}


Measured memory_bytes: 43368
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    string s;
     
    int main()
    {
    	cin >> s;
     
    	int ope = 0;
    	for (int i = 0; i < s.length()-1; i++) {
    		if (s[i] == 'A') {
    			if (s[i + 1] == 'C') {
    				ope++;
    			}
    		}
    	}
    	if (ope != 0)cout << "Yes" << endl;
    	else cout << "No" << endl;
     
    	return 0;
    }

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int a;

int main(){
  cin >> a;
  cout << a*a*a <<endl;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

const getMax = (limit, numbers) => {
	return 
}

const getHighestPriceSum = (budget, priceList) => {
	const sums= [];
	for (i=0; i<priceList.length; i++) {
		const leftAddend = priceList[i]
		for (j=0; j<priceList.length; j++) {
			if (i !== j) {
				const rightAddend = priceList[j]
				sums.push(leftAddend + rightAddend);
			}
		}
	}

	return sums.reduce((acc, next) => {
		if (next > acc) {
			if (next <= budget) {
				return next
			}
			return acc	
		}
		return acc
	}, 0);
};

let ctr = 0;

const dataSets = [];

const objHolder = {};

while (line = lines.shift()) {
	if (ctr % 2 === 0) {
		const budget = line.split(' ').map(Number)[1];
		objHolder.budget = budget;
	} else {
		const priceList = line.split(' ').map(Number);
		objHolder.priceList = priceList;
		dataSets.push(Object.assign({}, objHolder))
	}
	ctr++
}

dataSets.forEach(obj => {
	const { budget, priceList } = obj;
	const highest = getHighestPriceSum(budget, priceList)
	if (highest === 0) {
		console.log('NONE')
	} else {
		console.log(highest)
	}
	
})




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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 999999999

typedef pair<ll, ll> LP;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<LP> a(n), b(m);
	REP(i, n){ cin >> a[i].first >> a[i].second; }
	REP(i, m){ cin >> b[i].first >> b[i].second; }
	REP(i, n){
		ll min = INF;
		ll ans = 0;
		REP(j, m){
			if (min > abs(a[i].first-b[j].first) + abs(a[i].second-b[j].second)){
				min = abs(a[i].first-b[j].first) + abs(a[i].second-b[j].second);
				ans = j;
			}
		}
		cout << ans+1 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n, m, k;
    cin >> n >> m >> k;
    VI a(n + 1), b(m + 1);
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < m; i++) cin >> b[i];
    a[n] = INF;
    b[m] = INF;
    for (i = 1; i <= m; i++) {
        b[i] += b[i - 1];
    }
    ll ans = upper_bound(b.begin(), b.end(), k) - b.begin();
    // cout << ans << endl;
    for (i = 0; i <= n; i++) {
        k -= a[i];
        if (k < 0) break;
        ll pre = i + 1 + (upper_bound(b.begin(), b.end(), k) - b.begin());
        chmax(ans, pre);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6356
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC155E
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = "00" + Console.ReadLine();

            bool next = false;
            long ans = 0;
            for (int i = S.Length - 1; i >= 1; i--)
            {
                int num = int.Parse(S[i].ToString());
                if (next)
                {
                    if (num == 9) continue;
                    else num++;
                }

                if (num < 5)
                {
                    ans += num;
                    next = false;
                }
                else if (num == 5)
                {
                    int n = int.Parse(S[i - 1].ToString());
                    if (n >= 5)
                    {
                        next = true;
                    }
                    else next = false;

                    ans += num;
                }
                else
                {
                    ans += 10 - num;
                    next = true;
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 20940
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
	string input;
	string output;
	getline(cin, input);
	if(input == "ABC"){
		printf("ARC");
	}
	else if(input == "ARC"){
		printf("ABC");
	} 
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> num(N+1);
  vector<double> pro(N+1);
  for (int i = 1; i <= N; i++){
    int point = i;
    for (int j = 0; j < K; j++){
      if (K <= point){
        num.at(i) = j;
        break;
      }
      point *= 2;
    }
  }
  double prob = 0;
  for (int i = 1; i <= N; i++){
    pro.at(i) = pow(0.5, num.at(i))/N;
    prob += pro.at(i);
  }
  cout << fixed << setprecision(12);
  cout << prob << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;
int n;
vector<int> ans;
//vector<int> edge[];

// void dfs(){
//     for(int i = 0; i < n; i++){
//         for(int j = 0; j < edge[i].size(); j++){
//             //cout << "i, j:" << i << " " << j << endl;
//             int v = edge[i][j];
//             if(G[i][v] != 0 && G[i][v] % 2 == 0){
//                 ans[i] = 0;
//                 ans[v] = 0;
//             }
//         }
//     }
// }

int main()
{
    cin >> n;
    
    ans.resize(n, -1);
    vector<int> to[n], cost[n];

    for(int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        to[u].push_back(v);
        cost[u].push_back(w);
        to[v].push_back(u);
        cost[v].push_back(w);
    }
    int root = 0;
    queue<int> q;
    ans[root] = 0;
    q.push(root);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int i = 0; i < to[now].size(); i++){
            int v = to[now][i];
            int c = cost[now][i];
            if(ans[v] != -1) continue;
            ans[v] = (ans[now] + c) % 2;
            q.push(v);
        }
    }

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

Measured memory_bytes: 14660
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
#define int long long
#define lowbit(x) ((x)&-(x))
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
struct node{
	int x,h;
	bool operator <(const node &b)const {return x<b.x;}
} a[200001];
int n,D,A,c[200001];	
ll tot;
inline void modify(int b,int d) {for(;b<=n;c[b]+=d,b+=lowbit(b));}
inline int query(int b) {int tot=0;for(;b;tot+=c[b],b^=lowbit(b));return tot;}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>D>>A;
	for(res i=1;i<=n;++i) cin>>a[i].x>>a[i].h,a[i].h=(a[i].h+A-1)/A;
	sort(a+1,a+1+n);
//	for(res i=1;i<=n;++i) cout<<a[i].x<<' '<<a[i].h<<'\n';
	for(res i=1;i<=n;++i) {
		if(query(i)>=a[i].h) continue;
		int now=upper_bound(a+1,a+1+n,(node){a[i].x+2*D,0})-a-1,nowh=a[i].h-query(i);
		tot+=nowh,modify(i,nowh);if(now<n) modify(now+1,-nowh);
	}
	cout<<tot<<'\n';
	cout<<flush;	 
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define M 1000000007

//// prime factor O(sqrt(n))
map<ll,ll> prime_factor(ll n){
	map<ll,ll> res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]=1;
	return res;
}

ll n;
map<ll,ll> allmp;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	ll res=1;
	repl(i,1,n+1){
		map<ll,ll> mp=prime_factor(i);
		repl(j,1,i+1){
			allmp[j]+=mp[j];
		}
	}
	repl(i,1,n+1){
		res=(res*(allmp[i]+1))%M;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
list = [int(i) for i in input().split()]

ans = 0
for i in list:
    if i==1:
        ans += 300000
    elif i==2:
        ans += 200000
    elif i==3:
        ans += 100000
if list[0]==1 and list[1]==1:
    ans += 400000
print(ans)

Measured memory_bytes: 3060
X,Y = input().split()
counter = 0

for x in range(int(X)+1):
    a = x
    b = int(X) - a
    y = 4*a + 2*b
    if int(Y) == y:
        counter = 1
        break

if counter == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[5];
char T[5];
int main(){
  int i, res=0;
  rd(S);
  rd(T);
  for(i=0;i<(3);i++){
    if(S[i]==T[i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190830-1

// --- original code ---
// char S[5], T[5];
// {
//   int res = 0;
//   rd(S,T);
//   rep(i,3) if(S[i]==T[i]) res++;
//   wt(res);
// }


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	x, y :=bs.IntScan(), bs.IntScan()
	n := x
	maxCount := 0
	for !isPrime(n) && n < y - 1 {
		count := countArray(n, y)
		if maxCount < count {
			maxCount = count
		}
		n++
	}
	count := countArray(n, y)
	if maxCount < count {
		maxCount = count
	}

	bw.Printf("%v", maxCount)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0  {
		return false
	}

	sNum := int(math.Sqrt(float64(n)))
	for i := 3; i <= sNum; i += 2 {
		if n % int(i) == 0 {
			return false
		}
	}

	return true
}

func countArray(x, y int) int {
	count := 0
	for x <= y {
		count++
		x *= 2
	}
	return count
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, a[82];
    cin >> n;
    a[0]=10000;
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }
    a[n+1]=0;

    ll x=1000;
    ll s=0;
    for(int i=1;i<=n;++i){
        if(a[i-1]<=a[i] && a[i]>=a[i+1]){
            //高値で売る
            x+=s*a[i];
            s=0;
        }
        if(a[i-1]>=a[i] && a[i]<=a[i+1]){
            //底値で買う
            ll n_buy = x/a[i];
            x-=n_buy*a[i];
            s+=n_buy;
        }
    }
    cout << x;

    return 0;
}


Measured memory_bytes: 3632
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll mod = (ll)1e9 + 7;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
set<string> s;
int ans[111];
int main()
{
    fast;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            pr(1);
            break;
        }
        a-=d;
        if(a<=0)
        {
            pr(0);
            break;
        }
    }
}






Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
void no(){
  cout<<"NO"<<endl;
  exit(0);
}
VI a,df;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  in sm=0;
  a.resize(n);
  forn(i,n){
    cin>>a[i];
    sm+=a[i];
  }
  in tr=n*(n+1)/2;
  if(sm%tr)
    no();
  sm/=tr;
  df=a;
  forn(i,n){
    df[i]-=a[(i+n-1)%n];
    df[i]-=sm;
    if(df[i]>0)
      no();
    if((-df[i])%n)
      no();
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1920
def countingsort(a, b, k):
    c = [0 for i in range(k + 1)]
    for i in range(len(a)):
        c[a[i]] += 1
    for i in range(1, len(c)):
        c[i] += c[i - 1]
    for i in range(len(a) - 1, -1, -1):
        b[c[a[i]] - 1] = a[i]
        c[a[i]] -= 1

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
countingsort(a, b, max(a))
print(*b)

Measured memory_bytes: 261872
#include "stdio.h"
#include "stdlib.h"

long long int kyori[100000];

int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  kyori[0] = 0;
  int w1;
  for(int i = 1; i < n; i++)
    {
      scanf("%d",&w1);
      kyori[i] = kyori[i - 1] + w1;
    }
  int ny = 0;
  int ny2;
  long long int sk = 0;
  for(int i = 0; i < m; i++)
    {
      scanf("%d",&w1);
      ny2 = ny + w1;
      sk = (sk + abs(kyori[ny2] - kyori[ny])) % 100000;
      ny = ny2;
    }
  printf("%lld\n",sk);
  return 0;
}

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

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

int main(void)
{
	string w,t;
	int ans,flg;

	cin >> w;

	ans = 0;
	while (true){
		cin >>t;
		if (t == "END_OF_TEXT")
			break;

		rep(i, t.length()) {
			if (t.at(i) >= 'A' && t.at(i) <= 'Z')
				t.at(i) += 'a' - 'A';
		}
		if (t == w)
			++ans;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3172
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N = int(input())
A = []
for i in range(N):
	s, p = input().split()
	p = int(p)
	A.append((s, -p, i + 1))
	
A.sort()
for i in range(N):
	print(A[i][2])

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 110;

char str[N]; 

int main()
{
	scanf("%s", str + 1);
	int n = strlen(str + 1);
	int ans = n;
	bool flag = 1;
	for (int i = 2; i <= n; ++i) flag &= (str[i] == str[i - 1]);
	if (flag) return puts("0"), 0;
	for (char ch = 'a'; ch <= 'z'; ++ch)
	{
		static char s[N], u[N];
		for (int i = 1; i <= n; ++i) s[i] = str[i];
		for (int i = 1; i <= ans; ++i)
		{
			for (int j = 1; j <= n - i; ++j)
				if (s[j + 1] == ch) u[j] = s[j + 1];
				else u[j] = s[j];
			for (int j = 1; j <= n - i; ++j)
				s[j] = u[j];
			s[n - i + 1] = '\0';
			bool flag = 1;
			for (int j = 1; j <= n - i; ++j)
				if (s[j] != ch) flag = 0;
			if (flag)
			{
				ans = i;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
s = input().split(" ")
s = [int(s[i]) for i in range(len(s))]
M1 = s[0]
D1 = s[1]

s = input().split(" ")
s = [int(s[i]) for i in range(len(s))]
M2 = s[0]
D2 = s[1]

if M1 == M2 - 1:
    print(1)
else:
    print(0)

Measured memory_bytes: 21668
n=int(input())
arr=list(map(int,input().split()))
dp=[0]*len(arr)
dp[0]=0
dp[1]=abs(arr[1]-arr[0])
for i in range(2,len(arr)):
    dp[i]=min((dp[i-1]+abs(arr[i-1]-arr[i])),(dp[i-2]+abs(arr[i-2]-arr[i])))
print(dp[len(arr)-1])

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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
map<pair<int, int>, int> f;
int fx[] = {0, 1, -1, 0, 0, 1, -1, 1, -1};
int fy[] = {0, 0, 0, 1, -1, -1, 1, 1, -1};
int ans[10], H, W, n;
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(H), read(W), read(n);
	for (int i = 1, x, y; i <= n; i++) {
		read(x), read(y);
		for (int j = 0; j <= 8; j++)
			if (x + fx[j] > 1 && y + fy[j] > 1 && x + fx[j] < H && y + fy[j] < W)
				f[make_pair(x + fx[j], y + fy[j])]++;
	}
	printf("%lld\n", 1ll * (H - 2) * (W - 2) - f.size());
	for (auto i : f) {
		ans[i.second]++;
	}
	for (int i = 1; i <= 9; i++) printf("%d\n", ans[i]);
	return 0;
}


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

int main()
{
    int n;

    while( cin >> n )
    {
        cout << "3C";
        if( n % 39 == 0 )
            cout << "39" << endl;
        else if( n % 39 < 10 )
            cout << "0" << n % 39 << endl;
        else
            cout << n % 39 << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll dp[35][35][105];
string s;
ll n,k;

vector<vll> solve(ll k)
{
  vector<vll> ret(26, vll(26, inf));
  if(k == 1)
  {
    afor(i, 0, 25)afor(j, 0, 25)
    {
      ret[i][j] = dp[i][j][n];
    }
  }
  else
  {
    vector<vll> ret2 = solve(k/2);
    afor(i1, 0, 25)afor(j1, 0, 25)afor(i2, 0, 25)afor(j2, 0, 25)
    {
      if(j1 == i2)continue;
      ll curr = ret2[i1][j1] + ret2[i2][j2];
      ret[i1][j2] = min(ret[i1][j2], curr);
    }
    if(k & 1)
    {
      ret2 = ret;
      ret.clear();
      ret.resize(26, vll(26, inf));

      afor(i1, 0, 25)afor(j1, 0, 25)afor(i2, 0, 25)afor(j2, 0, 25)
      {
        if(j1 == i2)continue;
        ll curr = ret2[i1][j1] + dp[i2][j2][n];
        ret[i1][j2] = min(ret[i1][j2], curr);
      }
    }
  }
  return ret;
}

int main()
{
  finp;
  cin>>s>>k;
  n = s.size();
  int c = s[0] - 'a';

  afor(i, 0, 25)afor(j, 0, 25)
  {
    if(i==j)
      {
        if(i==c)dp[i][i][1] = 0;
        else dp[i][i][1] = 1;
      }
      else dp[i][j][1] = inf;
  }

  afor(i, 2, n)
  {
    int c = s[i - 1] - 'a';
    afor(fr, 0, 25)afor(ls, 0, 25)dp[fr][ls][i] = inf;

    afor(fr, 0, 25)afor(ls, 0, 25)
    {
      if(dp[fr][ls][i - 1] == inf)continue;
      afor(curr, 0, 25)
      {
        if(curr == ls)continue;
        ll cst = 0;
        if(c != curr)cst++;
        dp[fr][curr][i] = min(dp[fr][curr][i], dp[fr][ls][i - 1] + cst);
      }
    }
  }

  ll ans = inf;
  vector<vll> ret = solve(k);
  afor(fr, 0, 25)afor(ls, 0, 25)
  {
    ans = min(ans, ret[fr][ls]);
  }
  assert(ans != inf);
  assert(ans >= 0);
  cout<<ans;
return 0;
}

Measured memory_bytes: 1152
_ = input()
h = list(map(int, input().split()))
ans = 0
run = 0
for i, hi in enumerate(h):
    if i == 0:
        continue
    elif hi <= h[i - 1]:
        run += 1
    else:
        run = 0
    
    if run > ans:
        ans = run

print(ans)

Measured memory_bytes: 14252
#include<iostream>

using namespace std;

int main(){

    int a, b;
    int max;

    cin >> a >> b;

    max = a + b;

    if(max <= a - b){
        max = a - b;
    }

    if(max <= a * b){
        max = a * b;
    }

    cout << max << endl;

    return 0;
}

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

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  int ans =0;

  for(int i=min(a,b);i>0;i--){
    if(a%i==0 && b%i==0){
      ans++;
      if(ans==k)
        cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[2000], B[2000];
vector<int> G[2000];
P E[2000];

// 0->a->0->X->b->X
int f(int X) {
  // a=X+1
  int m = INF;
  int b = X;
  for (int a=(X+1)%N; a<=N; a++) {
    //cout<<"a="<<a<<", b="<<b<<" | 2*("<<(N-a)%N<<"+"<<(b-X)<<")\n";
    m = min(m, 2*((N-a)%N) + X + 2*(b-X));
    for (int t : G[a%N]) b = max(b, t);
  }
  return m;
}

int solve() {
  rep(i, N) {
    // iの近傍を見つける
    int a = i, b = i;
    while (B[a] == 0) a=(a-1+N)%N;
    while (B[b] == 0) b=(b+1+N)%N;
    E[i] = P((a-i+N)%N, (b-i+N)%N);
  }

  int m = INF;
  for (int X=0; X<N; X++) {
    //cout<<"X="<<X<<"\n";
    int num = 0;
    rep(i, N) G[i].clear();
    rep(i, N) {
      if (A[i] != B[(i+X)%N]) {
        int a = E[i]._1, b = E[i]._2;
        num++;
        //cout<<"i="<<i<<": ("<<a<<","<<b<<")\n";
        if ((0 <= a && a <= X) || (0 <= b && b <= X)) continue;
        if (a < b) swap(a, b);
        G[a].pb(b);
      }
    }
    //int s = f(X); cout<<"X="<<X<<": "<<num<<"+"<<s<<"\n";
    m = min(m, num + f(X));
  }
  return m;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s, t;
  cin >> s >> t;
  N = s.length();
  rep(i, N) A[i] = s[i] == '1';
  rep(i, N) B[i] = t[i] == '1';

  bool f = false;
  rep(i, N) if (B[i] == 1) f = true;
  if (!f) {
    bool g = false;
    rep(i, N) if (A[i] == 1) g = true;

    if (g) cout << -1 << "\n";
    else cout << 0 << "\n";
    return 0;
  }

  int m = solve();
  reverse(A, A+N);
  reverse(B, B+N);
  m = min(m, solve());

  if (m == INF) m = -1;
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 384
import sys
import copy
a = [int(c) for c in input().split()]
N=a[0]
K=a[1]

#まずK*10*i<Nとなる最大のiを探す

while True:
    i = 0
    while K*10**(i+1)<N:
        i+=1
    N = abs(N-K*10**i)
    if K*10 >= N:
        break
Nmin = 10**18
while True:
    N = abs(N-K)
    if Nmin>N:
        Nmin=N
    else:
        print(Nmin)
        sys.exit(0)


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

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    int ans=0;
    while(true){
        if(ans*y+ans*z+z>x){
            break;
        }
        ans+=1;
    } 
    cout <<ans -1<< endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> P2;
ll dist[105][105]={0};
ll inf=17441744174417;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<P2> node;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i==j) dist[i][j]=0;
      else dist[i][j]=inf;
    }
  }
  for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    node.push_back(P2(P(a,b),c));
    dist[a][b]=c;
    dist[b][a]=c;
  }
  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  ll ans=0;
  for(int k=0;k<m;k++){
    ll s=node[k].first.first,t=node[k].first.second,cos=node[k].second;
    bool f=false;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        if(dist[i][j]==dist[i][s]+cos+dist[t][j]) f=true;
      }
    }
    if(!f) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 764
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N = I()

Graph = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = MI()
    Graph[a].append(b)
    Graph[b].append(a)

Fennec = [-1]*(N+1)  # Fennec の各頂点への最短距離
Snuke = [-1]*(N+1)  # Snuke の各頂点への距離

from collections import deque

q1 = deque([1])
q2 = deque([N])
Fennec[1] = 0
Snuke[N] = 0
while q1:
    n = q1.pop()
    for d in Graph[n]:
        if Fennec[d] == -1:
            Fennec[d] = Fennec[n] + 1
            q1.appendleft(d)
while q2:
    n = q2.pop()
    for d in Graph[n]:
        if Snuke[d] == -1:
            Snuke[d] = Snuke[n] + 1
            q2.appendleft(d)
            
a = sum(Fennec[i] <= Snuke[i] for i in range(1,N+1))
print('Fennec' if a >= N//2+1 else 'Snuke')


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

typedef long long ll;

int main(void){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    
    ll a = X / D;
    ll b = X - a*D;
    ll c = K - a;       
    
    if(c <= 0){
        X -= D*K;
        cout << X << endl;
        return 0;
    }else if(X % D == 0){
        if(K % 2 == 0){
            cout << X << endl;
            return 0;
        }else{
            ll e = min(abs(X+D),abs(X-D));
            cout << e << endl;
            return 0;
        }
    }else if(c % 2 == 0){
        cout << b << endl;
        return 0;
    }else{
        ll d = min(abs(b+D),abs(b-D));
        cout << d << endl;
        return 0;
    }
}


Measured memory_bytes: 3584
X, Y = map(int, input().split())
ans = 0
if X == Y == 1:
    ans = 400000 + 300000 + 300000
else:
    if X == 1 or Y == 1:
        ans += 300000
    if X == 2:
        ans += 200000
    if Y == 2:
        ans += 200000
    if X == 3:
         ans += 100000
    if Y == 3:
        ans += 100000
print(ans)

Measured memory_bytes: 3060