akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int a, b;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.b != t.b)
		return s.b < t.b; //syoujunn
	return s.a > t.a;
}


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

	int a[25][25];
	REP(i, n) {
		REP(j, d) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	REP(i, n) {
		int temp[25];
		REP(k, d) {
			temp[k] = a[i][k];
		}
		
		FOR(j,i+1,n-1) {
			int diff2 = 0;
			REP(k, d) {
				diff2 += pow(temp[k] - a[j][k], 2);
			}

			FOR(root, 1, 500) {
				if (diff2 == root*root) {
					ans++;
					break;
				}
			}

		}

		

	}

	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include<queue>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
using ll = long long;
using IR = pair<int, int>;

int A, B, C;

int main() {
	S3(A, B, C);
	if (A == B && B == C) {
		printf("No");
		return 0;
	}
	else if (A == B && C != B) {
		printf("Yes");
		return 0;
	}
	else if (B == C && A != C) {
		printf("Yes");
		return 0;
	}
	else if (A == C && B != C) {
		printf("Yes");
		return 0;
	}
	printf("No");
}



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

int main()
{
    int n;
    cin >> n;
    int a = n / 100;
    int b = a * 100 + a * 10 + a;
    if (n <= b)
        cout << b << endl;
    else
        cout << b + 111 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,i,s=0,m=0,a;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        m = max(a,m);
        s+=a; 
    }
    if(m<s-m) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	static List<Integer> path;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);

		List<List<Integer>> list = new ArrayList<List<Integer>>();
		for (int i = 0; i < 4; i++) {
			list.add(new ArrayList<Integer>());
		}
		sa = br.readLine().split(" ");
		int w1 = Integer.parseInt(sa[0]);
		list.get(0).add(Integer.parseInt(sa[1]));

		for (int i = 1; i < n; i++) {
			sa = br.readLine().split(" ");
			int wi = Integer.parseInt(sa[0]);
			list.get(wi - w1).add(Integer.parseInt(sa[1]));
		}
		br.close();

		for (int i = 0; i < 4; i++) {
			List<Integer> li = list.get(i);
			Collections.sort(li);
			Collections.reverse(li);
			for (int j = 1; j < li.size(); j++) {
				li.set(j, li.get(j - 1) + li.get(j));
			}
		}

		long ans = 0;
		List<Integer> list0 = list.get(0);
		List<Integer> list1 = list.get(1);
		List<Integer> list2 = list.get(2);
		List<Integer> list3 = list.get(3);
		for (int a = 0; a <= list0.size(); a++) {
			long sum = w1 * a;
			if (sum > w) {
				break;
			}

			for (int b = 0; b <= list1.size(); b++) {
				sum += (w1 + 1) * b;
				if (sum > w) {
					sum -= (w1 + 1) * b;
					break;
				}

				for (int c = 0; c <= list2.size(); c++) {
					sum += (w1 + 2) * c;
					if (sum > w) {
						sum -= (w1 + 2) * c;
						break;
					}

					for (int d = 0; d <= list3.size(); d++) {
						sum += (w1 + 3) * d;
						if (sum > w) {
							sum -= (w1 + 3) * d;
							break;
						}

						long val = 0;
						if (a > 0) val += list0.get(a - 1);
						if (b > 0) val += list1.get(b - 1);
						if (c > 0) val += list2.get(c - 1);
						if (d > 0) val += list3.get(d - 1);
						ans = Math.max(ans, val);

						sum -= (w1 + 3) * d;
					}
					sum -= (w1 + 2) * c;
				}
				sum -= (w1 + 1) * b;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22228
# coding: utf-8
# Your code here!

while True:
   n, m = map(int, input().split())
   if n + m == 0: 
      break
   
   sums = 0 #太郎のカードの和
   TARO = []
   for i in range(n):
      taro = int(input())
      TARO.append(taro)
      sums += taro

   sumh = 0 #花子のカードの
   HANAKO = []
   for i in range(m):
      hanako = int(input())
      HANAKO.append(hanako)
      sumh += hanako

   #print(sums, sumh)
   #print(HANAKO)
   
   mid = (sums + sumh) / 2  #合計点が等しくなるときの点数
   dif = abs(sums - mid)
   #print(mid, dif)
   
   TARO.sort()
   HANAKO.sort()
   
   c = 0
   for i in range(n):
      for j in range(m):
         if (sums + sumh) % 2 == 1:
            c += 0
         else:
            if sums == sumh:
               if TARO[i] == HANAKO[j]:
                  print(TARO[i], HANAKO[j])
                  c += 1
                  break
            if TARO[i] - HANAKO[j] == dif:
               if sums > sumh:
                  print(TARO[i], HANAKO[j])
                  c += 1
                  break
            if HANAKO[j] - TARO[i] == dif:
               if sumh > sums:
                  print(TARO[i], HANAKO[j])
                  c += 1
                  break
      else:#上記のどれかに当てはまったら２重ループを抜ける
         continue
      break

   if c == 0:
      print(-1)



Measured memory_bytes: 5616
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e18+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  vector<ll> x(n), y(n), p(n);
  rep (i, n) {
    cin >> x[i]; cin >> y[i]; cin >> p[i];
  }

  vector<vector<ll>> h_best(n+1, vector<ll>(1<<n, inf)), v_best(n+1, vector<ll>(1<<n, inf));
  vector<ll> h_super_dp(1<<n), v_super_dp(1<<n);

  for (int mask = 0; mask < 1<<n; mask++) {
    vector<ll> scores_v(n+1), scores_h(n+1); 
    int rest = mask ^ ((1<<n)-1);

    forbits(i, rest) {
      scores_h[i] = abs(x[i]*p[i]);
      scores_v[i] = abs(y[i]*p[i]);
      forbits(j, mask) {
        scores_h[i] = min(scores_h[i], abs(x[i] - x[j]) * p[i]);
        scores_v[i] = min(scores_v[i], abs(y[i] - y[j]) * p[i]);
      }
    }
    
    int chosen = __builtin_popcount(mask);
    h_super_dp[0] = v_super_dp[0] = 0;
    
    forsubm(sub, rest) {
      int sub_rev = sub ^ rest;
      if (sub_rev != 0) {
        int x = __builtin_ctz(sub_rev);
        h_super_dp[sub_rev] = h_super_dp[sub_rev ^ (1<<x)] + scores_h[x];
        v_super_dp[sub_rev] = v_super_dp[sub_rev ^ (1<<x)] + scores_v[x];
      }
      h_best[chosen][mask | sub_rev] = min(h_best[chosen][mask | sub_rev], h_super_dp[sub_rev]);
      v_best[chosen][mask | sub_rev] = min(v_best[chosen][mask | sub_rev], v_super_dp[sub_rev]);
    }
  }

  vector<ll> ans(n+1, inf);
  for (int mask_h = 0; mask_h < 1<<n; mask_h++) {
    int mask_v = ((1<<n)-1)^mask_h;
    rep (i, __builtin_popcount(mask_h)+1) {
      rep (j, __builtin_popcount(mask_v)+1) {
        ans[i+j] = min(ans[i+j], h_best[i][mask_h] + v_best[j][mask_v]);
      }
    }
  }

  rep(i, n+1) cout << ans[i] << endl;

  return 0;
}

Measured memory_bytes: 11968
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    string s, t;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;

    if (u == s) --a;
    else if (u == t) --b;

    cout << a << ' ' << b;

    return 0;
}


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

int main(){
	int i, j, k, l, n, count = 0;
	while(cin >> n){
		count = 0;
		for(i = 0; i <= 9; i++){
			for(j = 0; j <= 9; j++){
				for(k = 0; k <= 9; k++){
					for(l = 0; l <= 9; l++){
						if(i + j + k + l == n){
							count ++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n;

int main() {
    cin >> n;
    ld a[n];
    ld b[n];
    ld ab = 0;
    for(ll i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    for(ll j=0; j<n; j++){
        for(ll k=0; k<n; k++){
            ab += sqrt((a[j]-a[k])*(a[j]-a[k]) + (b[j]-b[k])*(b[j]-b[k]));
        }
    }
    cout << setprecision(13) << ab/n << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <bitset>
#include <cstring>
#include <string>


using namespace std;
typedef long long int ll;
typedef vector<int>  VI;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))

long int takakuwa[50];

int a(int i){
	if(i<0) return 0;
	return takakuwa[i];
}

void solve(){
	takakuwa[0] =1;
	REP(i,30){
		takakuwa[i+1] += takakuwa[i];
		takakuwa[i+2] += takakuwa[i];
		takakuwa[i+3] += takakuwa[i];
	}
}

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

	/*
	int n;
	cin >>n;
	for(int i;i<n;i++){
		cin >>;
	}
	*/

	solve();
	int n;
	while(cin >>n){
		if(n==0)return 0;
		cout << (takakuwa[n]-1)/(10*365) +1 <<endl;
		}	
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
#define int long long

signed main(){
  int n,l;cin>>n>>l;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int a=-1;
  for(int i=1;i<n;i++)if(v[i]+v[i-1]>=l)a=i;
  if(a<0)fin("Impossible");
  cout<<"Possible"<<endl;
  for(int i=1;i<a;i++)cout<<i<<endl;
  for(int i=n-1;i>=a;i--)cout<<i<<endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main(){
    lli n, x, ans=0;
    cin >> n >> x;
    vector<lli> a(n);

    for(int i=0;i<n;i++)
        cin >> a[i];
    int aux;
    for(int i=0;i<n-1;i++){
        aux=a[i]+a[i+1];
        if(aux>x){
            int aux2=aux-x;
            ans+=aux2;
            if(aux2>a[i+1]){
                aux2-=a[i+1];
                a[i+1]=0;
                a[i]-=aux2;
            }else
                a[i+1]-=aux2;
        }
    }
    cout << ans;
}
// 1 2 3 4 5 6 - 9

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



int main() 
{
  ll W,H,N; cin>>W>>H>>N;
  vector<ll> x(N);
  vector<ll> y(N);
  vector<ll> a(N);
  rep(i,N)
  {
    cin>>x.at(i)>>y.at(i)>>a.at(i);
  }
  vector<vector<ll>> white(H,vector<ll>(W,1));
  rep(i,N)
  {
    if(a.at(i)==1)
    {
      rep(j,x.at(i))
      {
        rep(k,H)
        {
          white.at(k).at(j)=0;
          continue;
        }
      }
    }  
    if(a.at(i)==2)
    {
      for(ll j=x.at(i);j<W;j++)
      {
        rep(k,H)
        {
          white.at(k).at(j)=0;
          continue;
        }
      }
    } 
    if(a.at(i)==3)
    {
      rep(j,y.at(i))
      {
        rep(k,W)
        {
          white.at(j).at(k)=0;
          continue;
        }
      }
    }  
    if(a.at(i)==4)
    {
      for(ll j=y.at(i);j<H;j++)
      {
        rep(k,W)
        {
          white.at(j).at(k)=0;
          continue;
        }
      }
    } 
  }
  ll ans=0;
  rep(i,W)
  {
    rep(j,H)
    {
      ans+=white.at(j).at(i);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var maxIndex = 0;
    var secondMax = 0;
    var max = 0;
    for(i in 1..n){
        val v = sc.nextInt();
        if(v > max){ 
          secondMax = max; 
          max = v;
          maxIndex = i;
        }
        else if(v > secondMax){
          secondMax = v;
        }
    }
  
    for( i in 1..maxIndex -1){
        println(max);
    }
    println(secondMax);
    for(i in maxIndex+1..n){
        println(max);
    }
}

Measured memory_bytes: 71432
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  bool  ans = false;
  for(int i=0;i<1000;i++)
  {
    if(b<10)
    {
      if(10*a+b==i*i)
      {
        ans = true;
        cout << "Yes" << endl;
        break;
      }
    }
    else if(b==100)
    {
      if(1000*a+100==i*i)
      {
        ans = true;
        cout << "Yes" << endl;
        break;
      }
    }
    else
    {
      if(100*a+b==i*i)
      {
        ans = true;
        cout << "Yes" << endl;
        break;
      }
    }
    
  }
  if(ans == false)
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5+1;
const long inf=1e9;
int N,K; long A[siz];
long calc(long x){
	long sum = 0;
	rep(i,0,N) sum += (A[i] - 1) / x;
	return sum;
}
int main(){
	cin>>N>>K;
	rep(i,0,N) cin>>A[i];
	long a = 0, b = inf;
	while(b - a > 1){
		long m = (a + b) / 2;
		if(calc(m) <= K) b = m;
		else a = m;
	}cout<<b<<endl;
}

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

bool checkSum(int* array, const int& target, const int& num, int index,
              const int& value) {
  bool flag = false;
  if (index == num) {
    if (value == target) {
      return true;
    } else {
      return false;
    }
  }
  flag = flag || checkSum(array, target, num, index + 1, value);
  flag = flag || checkSum(array, target, num, index + 1, value + array[index]);
  return flag;
}

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int m;
    cin >> m;
    if (checkSum(array, m, n, 0, 0)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}


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

using namespace std;

const int MAX_N = 100000, MAX_M = 100000;

int n, m, counter[MAX_N + 1];
bool isRed[MAX_N + 1];

int main() {
    scanf("%d %d", &n, &m);

    isRed[1] = true, counter[1] = 1;
    for (int i = 2; i <= n; i++) {
        isRed[i] = false;
        counter[i] = 1;
    }

    int x, y;
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &x, &y);
        if (isRed[x]) {
            isRed[y] = true;
        }

        counter[x]--;
        counter[y]++;

        if (counter[x] == 0) {
            isRed[x] = false;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (isRed[i]) {
            ans++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
typedef long long ll;

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

    ll ans = 0;
    ll now = 0;
    int flag = 0;
    while(1){
        if(now >= n){
            break;
        }

        if(n / 11 != 0){
            ans += (2 * (n / 11));
            n -= 11 * (n / 11);
        }else{
            if(flag == 0){
                now += 6;
                ans++;
                flag = 1;
            }else{
                now += 5;
                ans++;
                flag = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int H, W;
    cin >> H >> W;

    vector<string> c(H);
    REP(i, H) cin >> c[i];

    REP(i, H) {
        print(c[i]);
        print(c[i]);
    }
    
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int n,m,q;
char c[10]={'0','1','2','3','4','5','6','7','8','9'};
vector<string> t;
void f(int x,string s){
    if(x==n){
        t.push_back(s);
    }
    else if(x==0){
        for(int i=0;i<m;i++){
            f(1,s+c[i]);
        }
    }
    else{
        for(int i=s[s.size()-1]-'0';i<m;i++){
            f(x+1,s+c[i]);
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    f(0,"");
    vector<int> a(q),b(q),c(q),d(q);
    for(int i=0;i<q;i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--,b[i]--;
    }
    int ans=0;
    for(string x:t){
        int res=0;
        for(int i=0;i<q;i++){
            if(x[b[i]]-x[a[i]]==c[i]){
                res+=d[i];
            }
        }
        chmax(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7404
gets
t = readlines.map{|a|a.chomp}
e = t[0][0]
if(t.uniq.size != t.size)
  puts "No"
  exit
end
t.each do |a|
  if(a[0] != e)
    puts "No"
    exit
  else
    e = a[-1] 
  end
end
puts "Yes"
exit

Measured memory_bytes: 1788
n = gets.to_i

ans = ["a"]

(n-1).times do |i|
    o = ans
    ans = []
    # p o
    o.each do |t|
        n_type = t.chars.uniq.size
        (n_type+1).times do |j|
            # p (97 + j).chr
            ans.push(t+(97+j).chr)
        end
    end
end

puts ans

Measured memory_bytes: 17020
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( array[ 0 ] ))

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int a, b;
	cin >> a >> b;
	rep(i,1, 4){
		if (i != a && i != b)
		cout << i << endl;

	}

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b)
    printf("a < b\n");
  else if(a > b)
    printf("a > b\n");
  else
    printf("a == b\n");
  return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n+1,0);
    vector<int> b(n+1,1);
    rep(i,n+1){
        int k = s[i]-'0';
        a[i+1] = min(a[i] + k, b[i] + 10 - k);
        b[i+1] = min(a[i] + k + 1, b[i] + 9 - k);
    }
    cout << a[n] << endl;
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, a;
  cin >> N >> K;
  a = N % K; 
  if(a == 0) { 
    cout << 0 << endl;
  }
  
  else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

void Catch(std::string& t_S, int& t_i)
{
	if (t_i + 1 >= t_S.size())
	{
		return;
	}

	int end = -1;
	for (int i = t_i + 1, n = t_S.size(); i < n; ++i)
	{
		if (t_S.at(t_i) == t_S.at(i))
		{
			end = i;
		}
		else
		{
			break;
		}
	}

	if (end != -1)
	{
		for (int i = end; i > t_i; --i)
		{
			t_S.erase(t_S.begin() + i);
		}
	}

	t_i++;

	Catch(t_S, t_i);
}

int main()
{
	int N = 0;
	std::cin >> N;

	std::string S = "";
	std::cin >> S;

	int i = 0;
	Catch(S, i);

	std::cout << S.size() << "\n";

	return 0;
}

Measured memory_bytes: 512
while True:
    value = list(map(int, str(input()).split()))
    if value[0] == -1 and value[1] == -1 and value[2] == -1:
        break



    sum = value[0] + value[1]

    if value[0] == -1 or value[1] == -1:
        print("F")
    elif sum >= 80:
        print("A")
    elif sum >= 65:
        print("B")
    elif sum >= 50:
        print("C")
    elif value[2] >= 50:
        print("C")
    elif sum >= 30:
        print("D")
    else:
        print("F")




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

int a[100000];

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

    map<int,int> mp;
    
    for(int i=0;i<N;i++)
    
    
    {
        cin>>a[i];
        mp[a[i]]++;
    }

    int ans=0;

    for(auto p: mp)
    {
        int x=p.first;
        int n=p.second;
        
        if(n<x)ans+=n;
        else ans+=n-x;
    }

    cout<<ans<<"\n";

    return 0;
}



Measured memory_bytes: 5120
/*
 ID: swagchicken1
 PROG:
 LANG: C++11
 */

#include <iostream>
#include <tuple>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cctype>
using namespace std;

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

#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)

//#define endl '\n';

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1000000007;
double PI = 4*atan(1);

unsigned long long f(long long a) {
    long long res[] = {a,1,a+1,0};
    return res[a%4];
}

unsigned long long getXor(long long a, long long b) {
    return f(b)^f(a-1);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    //     ofstream fout("trapped.out");
    //      ifstream fin("trapped.in");
    unsigned long long A,B; cin >> A >> B;
    if(A != B && A > 0) {
        cout << getXor(A,B);
    }
    else if(A == 0 && B > 0) {
        unsigned long long ans = getXor(A+1,B)^0;
        cout << ans;
    }
 
    else {
        cout << A << endl;
    }
    
    //  fin.close();
    //    fout.close();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#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;
using namespace std;
int n;
struct node{
	double x;
	friend bool operator < (node A,node B){
		return A.x>B.x;
	}
};
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
signed main(){
	priority_queue<node> q;
	n=read();
	for(int i=1;i<=n;i++){
		double x;
		cin>>x;
		q.push((node){x});
	}
	for(int i=1;i<=n-1;i++){
		double x=q.top().x;
		q.pop();
		double y=q.top().x;
		q.pop();
		q.push((node){(x+y)/2.});
	}
	printf("%.7lf",q.top().x);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,f,r;
    while(cin>>m>>f>>r, m!=-1||f!=-1||r!=-1){
        if (m==-1||f==-1){
            cout<<"F\n";
            continue;
        }
        if (m+f>=80) cout<<"A\n";
        else if(m+f>=65) cout<<"B\n";
        else if(m+f>=50) cout<<"C\n";
        else if(m+f>=30){
            if (r>=50) cout<<"C\n";
            else cout<<"D\n";
        }else{
            cout<<"F\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
#define TR(it,c) for( typeof(c.begin()) it = c.begin(); it != c.end(); ++it )
#define TRR(it,c) for( typeof(c.rbegin()) it = c.rbegin(); it != c.rend(); ++it
#define REP(i,a) for (int i = 0; i < (a); i++)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)

#define DRI(a) int a; scanf("%d", &a);
#define DRII(a, b) int a, b; scanf("%d %d", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d", &a, &b, &c);
#define RI(a) scanf("%d", &a);
#define RII(a, b) scanf("%d %d", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define MM(arr, num) memset((arr), (num), sizeof((arr)))
#define DEB(x) cerr << ">>> " << (#x) << " -> " << (x) << endl;
#define DEBA(x,n) cerr << (#x) << " "; deba((x),(n));
void deba(int * a, int n){ cerr << "| "; REP(i,n) cerr << a[i] << " "; cerr << "|" << endl;}


inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

const int INF = 1<<30;
typedef long long ll;
typedef unsigned long long ull;
/*******************************************************/

char s[521][521];
int r[521];
int c[521];

int main() {

  DRI(n);
  REP(i,n)scanf("%s",s[i]);

  int cnt = 0;
  REP(i,n)REP(j,n) if(s[i][j] == '#')cnt++;
  if (cnt == 0){ cout <<  -1 << endl; return 0;}

  REP(i,n){
    REP(j,n){
        if( s[i][j] == '#') r[i]++;
    }
  }
  REP(j,n){
    REP(i,n){
        if( s[i][j] == '#') c[j]++;
    }
  }

  int mn = n;
  REP(i,n){

    if(n-r[i] < mn && c[i])  mn = n-r[i];
    if( (n+1)-r[i] < mn )  mn = (n+1)-r[i];
  }
  //cout << mn << endl;


  REP(i,n) if(c[i] < n) mn++;

  cout << mn << endl;


  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

void err() {
	puts(-1);
	exit(0);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	string s;
	cin >> s;
	int n = s.size();
	if (s[n - 1] != '0')err();
	if (s[0] != '1')err();
	for (int i = 0; i < n - 1; i++)if (s[i] != s[n - 2 - i])err();


	vector<pair<int, int>>edges;
	int ma = 1;
	for (int i = 1; i <= n-1; i++) {
		edges.pb({ ma,i + 1 });
		if(s[i-1] == '1')ma = i + 1;
	}
	fore(x, edges)cout << x.first << " " << x.second << endl;

	return 0;
}

Measured memory_bytes: 2372
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
#include <fstream>
#include <time.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long int MOD = 1000000000 + 7;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        for (int i = 0; i < N; i++) {
            parent[i] = -1;
        }
    }

    int root(int i) {
        if (parent[i] < 0) {
            return i;
        }
        return (parent[i] = root(parent[i]));
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int treeSize(int x) {
        

        return -parent[root(x)];
    }
};

long long int modpow(long long int base, long long int pow, long long int mod) {
    if (pow == 1) {
        return base;
    }
    else if (pow == 0) {
        return 1;
    }

    if (pow % 2 == 0) {
        auto temp = modpow(base, pow / 2, mod);
        return (temp * temp) % mod;
    }
    else {
        return base * modpow(base, pow - 1, mod) % mod;
    }
}

long long int moddiv(long long int X, long long int Y, long long int mod) {
    auto fermatDiv = modpow(Y, mod - 2, mod);

    return (X * fermatDiv) % mod;
}



int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int time1 = H1 * 60 + M1;
    int time2 = H2 * 60 + M2;

    int diff = time2 - time1;

    cout << diff - K << endl;
    return 0;
}

Measured memory_bytes: 3636
// ABC088A - Infinite Coins

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

int main() {
	int N, A;
	cin >> N >> A;

	if ((N % 500) <= A) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << 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;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<pair<int, int> > V(N);
    rep(i, N){
        int a, b; cin >> a >> b;
        V[i] = make_pair(b, a);
    }
    sort(V.begin(), V.end());

    ll total = 0;
    rep(i, N){
        total += V[i].second;
        if (total > V[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

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

    vector <int> A(N);

    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    cout << A[N-1] - A[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 100000000

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    vector<int> num(101, 0);
    int mx = 0;
    rep(i, n){
        cin >> b[i];
        num[b[i]]++;
        if(mx < b[i])mx = b[i];
    }

    int sb = b.size() - 1;
    vector<int> res;
    vector<int> a(n);

    int len = 0;
    vector<bool> ind(n+1);
    rep(i, n+1)ind[i] = false;

    rep(i, n){
        int tail = sb;
        int inp = min(i+1, mx);
        // << "inp:" << inp << endl;
        //cout << "-------------------\n";
        int mlen = 0;
        while(true){
            //cout << "b:" << b[tail]  << " inp:" << inp << " num:" << num[b[tail]]  << " len:" << len << " mlen:" << mlen << endl;
            if(ind[tail]){
                //cout << "already\n";
                mlen++;
                tail--;
                continue; 
            }
            if(num[inp] <= 0){
                inp--;
                mlen = 0;
                tail = sb;
                continue;
            }
            if(b[tail] == inp){
                if(len-mlen >= b[tail]-1){
                    a[tail] = b[tail];
                    //cout << "b = " << b[tail] << endl;
                    res.push_back(b[tail]);
                    ind[tail] = true;
                    num[inp]--;
                    len++;
                    break;
                }
                //cout << "out range\n";
                inp--;
                mlen = 0;
                tail = sb;
                continue;
            }
            tail--;
            if(inp <= 0){
                cout << -1;
                return 0;
            }
        }
    }
    rep(i, n)cout << res[i] << endl;
    cout << endl;
}

Measured memory_bytes: 256
/**
*    created: 05.05.2020 08:50:25
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    int a[n][m];
    int d[n];
    rep(i,m){
        cin >> b[i];
    }
    int k=0;
    rep(i,n){
        d[i] = 0;
        rep(j, m)
        {
            cin>>a[i][j];
            d[i]+=a[i][j]*b[j];
            //cout << a[i][j]*b[j] << endl;
         }
        if(d[i]+c>0){
            k++;
        }
        //cout << d[i] << endl;
    }
    cout << k << endl;
}

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

int main(){
    map<int,int>m;
    for(int i=0;i*200<5001;i++){
        for(int j=0;j*300<5001;j++){
            for(int k=0;k*500<5001;k++){
                int w=i*200+j*300+k*500;
                int p=i/5*5*380*0.8+i%5*380
                     +j/4*4*550*0.85+j%4*550
                     +k/3*3*850*0.88+k%3*850;
                if(m[w])m[w]=min(m[w],p);
                else m[w]=p;
            }
        }
    }
    int n;
    while(cin>>n,n){
        cout<<m[n]<<endl;
    }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

vector<int>ans;
P c[500];
signed main(){
	int a;cin>>a;
	for(int b=0;b<a;b++){
		int d;cin>>d;d--;
		c[b]={d,b};
		}	
	sort(c,c+a);
	int count[500]{};
	for(int b=0;b<a*a;b++){
		bool S=false;
		for(int d=0;d<a;d++){
			if(c[d].first==b){
				if(count[c[d].second]==c[d].second){
					ans.push_back(c[d].second+1);
					count[c[d].second]++;
					S=true;
					}
				else {puts("No");return 0;}	
				}
			}
		if(S)continue;	
		for(int d=0;d<a;d++){
				if(count[c[d].second]<c[d].second){
					ans.push_back(c[d].second+1);
					count[c[d].second]++;
					S=true;
					break;
					}
			}
		if(S)continue;
			for(int d=0;d<a;d++){
				if(c[d].first<b&&count[c[d].second]<a){
					ans.push_back(c[d].second+1);
					count[c[d].second]++;
					S=true;
					break;
					}
			}		
		}	
		if(ans.size()!=a*a){puts("No");return 0;}
		puts("Yes");
		for(int b=0;b<a*a;b++){
		if(b)cout<<" ";
		cout<<ans[b];
		}	
		cout<<endl;
	}


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


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

    ll n, k;
    cin >> n >> k;
    
    string s;
    cin >> s;
    
    vector<pair<char, int>> cnt;
    cnt.push_back(make_pair(s[0], 1));
    for(int i = 1; i < n; ++i){
        if(s[i] == cnt.back().first) ++cnt.back().second;
        else cnt.push_back(make_pair(s[i], 1));
    }

    int range = k*2;
    if(cnt[0].first == '1') ++range;

    ll res = 0;
    rep(i, min((int)cnt.size(), range)){
        res += cnt[i].second;
    }
    if(cnt.size() <= range){
        cout << res << endl;
        return 0;
    }

    int l = 0;
    int r = range;
    ll cur = res;
    while(1){
        ll inc = cnt[r].second;
        ++r;
        if(r < cnt.size()){
            inc += cnt[r].second;
            ++r;
        }
        ll dec = cnt[l].second;
        ++l;
        if(cnt[l].first == '0'){
            dec += cnt[l].second;
            ++l;
        }

        cur = cur - dec + inc;

        res = max(res, cur);

        if(r >= cnt.size()) break;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4492
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asum=[0]
bsum=[0]
current=0
for i in range(n):
  current+=a[i]
  asum.append(current)
current=0
pointer=0
for i in range(m):
  current+=b[i]
  bsum.append(current)
for i in range(n+1):
  if asum[i]>k:
    pointer=i-1
    break
  if i==n:
    pointer=n
ans=pointer
bpointer=0
for i in range(pointer,-1,-1):
  while bpointer<m+1 and bsum[bpointer]+asum[i]<=k:
    bpointer+=1
    if bpointer==m+1:
      break
  bpointer-=1
  ans=max(ans,i+bpointer)
print(ans)

Measured memory_bytes: 127060
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	int A[15][15] = {}, al[15] = {}, C[15] = {};
	int N, M, X;
	ll mn = INF;

	cin >> N >> M >> X;

	rep(i, N) {
		cin >> C[i];
		rep(j, M)cin >> A[i][j];
	}

	int mx = pow(2, N);
	rep(i, mx) {
		int sum = 0,ix=i;
		memset(al, 0, sizeof(al));
		rep(j, N) {
			if (ix % 2 == 1) {
				rep(k, M)al[k] += A[j][k];
				sum += C[j];
			}
			ix /= 2;
		}
		bool jg = 1;
		rep(j, M) {
			if (al[j] < X)jg = 0;
		}
		if (jg == 1)mn = min(mn, (ll)sum);
	}

	if (mn == INF)cout << -1 << endl;
	else cout << mn << endl;

	return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){

    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    forn(i,n){
        if(s[i]!=s[n-i-1]){
            ans++;
            s[i]=s[n-i-1];
        }
    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
void outPut(int Array[],char mark)
{
    for(int i=1;i<=13;i++)
    {
        if(Array[i]==0)
            printf("%c %d\n",mark,i);
    }
}
int main()
{
    char mark[2];
    int n,S[14],H[14],C[14],D[14],temp;
    for(int i=0;i<14;i++)
        S[i]=H[i]=C[i]=D[i]=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s%d",mark,&temp);
        switch(mark[0])
        {
        case'S':
            S[temp]=1;
            break;
        case'H':
            H[temp]=1;
            break;
        case'C':
            C[temp]=1;
            break;
        case'D':
            D[temp]=1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}



Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	string S, x;
  	cin >> S;
  	x = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  	for(int i=0; i<S.length(); i++){
      	if(S.at(i) == 'A') cout << x.at(N);
      	else if(S.at(i) == 'B') cout << x.at(1+N);
		else if(S.at(i) == 'C') cout << x.at(2+N);
      	else if(S.at(i) == 'D') cout << x.at(3+N);
		else if(S.at(i) == 'E') cout << x.at(4+N);
      	else if(S.at(i) == 'F') cout << x.at(5+N);
		else if(S.at(i) == 'G') cout << x.at(6+N);
      	else if(S.at(i) == 'H') cout << x.at(7+N);
		else if(S.at(i) == 'I') cout << x.at(8+N);
      	else if(S.at(i) == 'J') cout << x.at(9+N);
		else if(S.at(i) == 'K') cout << x.at(10+N);
      	else if(S.at(i) == 'L') cout << x.at(11+N);
		else if(S.at(i) == 'M') cout << x.at(12+N);
      	else if(S.at(i) == 'N') cout << x.at(13+N);
		else if(S.at(i) == 'O') cout << x.at(14+N);
      	else if(S.at(i) == 'P') cout << x.at(15+N);
		else if(S.at(i) == 'Q') cout << x.at(16+N);
      	else if(S.at(i) == 'R') cout << x.at(17+N);
		else if(S.at(i) == 'S') cout << x.at(18+N);
      	else if(S.at(i) == 'T') cout << x.at(19+N);
		else if(S.at(i) == 'U') cout << x.at(20+N);
      	else if(S.at(i) == 'V') cout << x.at(21+N);
		else if(S.at(i) == 'W') cout << x.at(22+N);
      	else if(S.at(i) == 'X') cout << x.at(23+N);
		else if(S.at(i) == 'Y') cout << x.at(24+N);
      	else if(S.at(i) == 'Z') cout << x.at(25+N);
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;
typedef long long ll;

ll n, m;
vector<vector<ll>> net;
vector<bool> visited;
vector<ll> cur_nxt;

bool check(ll start){
    unordered_set<ll> v;

    ll cur = start;
    do{
        if(cur == -1){ return false; }
        v.insert(cur);
        cur = cur_nxt.at(cur);
    }while(cur != start);

    for(ll x : v){
        for(ll to : net.at(x)){
            if(cur_nxt.at(x) != to && v.count(to)){
                cur_nxt.at(x) = to;
                return check(x);
            }
        }
    }

    cout << v.size() << endl;
    for(ll x : v){
        cout << x + 1 << endl;
    }
    return true;
}

bool dfs(ll cur){
    visited.at(cur) = true;
    for(ll nxt : net.at(cur)){
        cur_nxt.at(cur) = nxt;
        if(visited.at(nxt)){
            if(check(nxt)){
                return true;
            }
        }else if(dfs(nxt)){
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n >> m;
    net.resize(n);
    for(int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).push_back(b);
    }

    visited.resize(n, false);
    cur_nxt.resize(n, -1);
    for(int i = 0; i < n; ++i){
        if(visited.at(i)){
            continue;
        }
        if(dfs(i)){
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;
typedef long long int lld;

int main(){
	lld n,p;
	cin >> n >> p;
	lld ans = 1;
	if(n == 1){
		 ans = p;
	}else{
		for(int i = 2;i < p;i++){
			lld num = 1;
			for(int j = 0;j < n;j++){
				num *= i;
				if(num > p) break;
			}
			if(num > p){
				break;
			}else{
				if(p % num == 0) ans = i;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//        VIVEK UPADHYAY
//        MANIT, BHOPAL(M.P)


//                         JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18+ 10 ;

int main() {
    
    int N , K ;
    cin >>N >>K ;
    if(N%K==0) cout<<"0\n";
    else cout<<"1\n" ;
    return 0 ;
}


Measured memory_bytes: 256