akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll N;
  cin >> N;
  vector<ll> x(N), y(N), h(N);

  ll _x, _y, _h;
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] >= 1){
      _x = x[i]; _y = y[i]; _h = h[i];
    }
  }

  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      ll H = max(0LL, _h + abs(i - _x) + abs(j - _y));
      bool ok = true;
      for(int k = 0; k < N; k++){
	if(h[k] != max(0LL, H -  abs(i - x[k]) - abs(j - y[k]))){
	  ok = false;
	  break;
	}
      }
      if(ok){
	cout << i << " " << j << " " << H << endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a+b>=24){
      System.out.println(a+b-24);
    }else{
      System.out.println(a+b);
    }
  }
}


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

using namespace std;

int main(void){

  string s;
  while( cin >> s , s[0] != '0' ){

    int a = 0 ,b = 0;
    char ans;
    for( int i = 1 ; i < s.size() ; i++ ){
      if( s[i] == 'A' ) a++;
      if( s[i] == 'B' ) b++;
    }
    if( a > b ) a++;
    else b++;
    cout << a << " " << b <<  endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define LL long long
#define M 200200
#define mid (l+r>>1)
using namespace std;
int read(){
    int nm=0,fh=1;char cw=getchar();
    for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
    for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
    return nm*fh;
}
int n,m,ans,f[M],cnt,vis[M],last;
int fd(int x){return x==f[x]?x:f[x]=fd(f[x]);}
struct op{
    int L,R,id;
    void gtin(int x){L=read(),R=read(),id=x;}
    bool operator <(const op&ot)const{return R==ot.R?L>ot.L:R>ot.R;}
}t[M];
bool cmpL(op i,op j){return i.L<j.L;}
bool cmpR(op i,op j){return i.R<j.R;}
priority_queue<op> Q;
void del(int x,int maxn){
	x=fd(x);
	if(x<=maxn) f[x]=fd(x+1);
	else ans++;
}
int main(){
    n=read(),m=read(),f[0]=0,f[m+1]=m+1;
    for(int i=1;i<=n;i++) t[i].gtin(i);
    sort(t+1,t+n+1,cmpL),last=1;
    for(int i=1;i<=n;i++){
    	if(last<=t[i].L){last++,Q.push(t[i]);continue;}
		Q.push(t[i]); Q.pop();
	}
    for(int i=1;i<=m;i++) f[i]=i;
	while(!Q.empty()) vis[Q.top().id]=1,Q.pop();
	for(int i=1;i<=n;i++) if(vis[t[i].id]) del(1,t[i].L);
	sort(t+1,t+n+1,cmpR);
	for(int i=1;i<=n;i++) if(!vis[t[i].id]) del(t[i].R,m);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 9072
N, K = list(map(int, input().split()))
record = [0 for i in range(N)]
grid = []
for i in range(2*K):
    array = list(map(int, input().split()))
    grid.append(array)

for i in range(K):
    for j in range(grid[i * 2][0]):
        record[grid[i * 2 + 1][j]-1] = 1

flag = 0
for i in range(N):
    if record[i] == 0:
        flag += 1
print(flag)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define open freopen(input.txt,"r",stdin); freopen(output.txt,"w",stdout);
#define precise(t) cout << fixed << setprecision(t)
#define forr(i,n) for(int i(0);i<n;++i)
#define repup(i,a,b) for(int i(a); i <=b; ++i)
#define repdown(i,a,b) for(int i(a);i>=b;i--)
#define testcase(t) int t; cin >> t; wl(t)
#define input(n) int n; cin >> n;
#define sz(a) int((a).size())
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define bb begin()
#define ee end()
#define all(c) c.bb, c.ee
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;

const int inf = INT_MAX; 
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;


int main(){
	char arr[4];
	forr(i,4) {cin >> arr[i];}
	sort(arr,arr+4);
	if(arr[0]==arr[1] && arr[2]==arr[3] && arr[1]!=arr[2]){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	vector<ll> a, b;
	ll asum = 0;
	ll bsum = 0;
	rep(i, n) {
		ll tmp;
		cin >> tmp;

		if(tmp >= 0) {
			a.push_back(tmp);
			asum += tmp;
		} else {
			b.push_back(tmp);
			bsum += tmp;
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	vector<pair<ll, ll>> ret(n-1);
	if(b.size() > 0) { // 負の数がある
		if(a.size() == 0) {
			cout << -bsum + b.back() * 2 << endl;

			for(ll i = 0; i < b.size() - 1; ++i) {
				cout << b.back() << " " << b[i] << endl;
				b.back() -= b[i];
			}
			return 0;
		}

		cout << asum - bsum << endl;

		for(ll i = 0; i < a.size() - 1; ++i) {
			cout << b[0] << " " << a[i] << endl;
			b[0] -= a[i];
		}

		rep(i, b.size()) {
			cout << a.back() << " " << b[i] << endl;
			a.back() -= b[i];
		}
	} else {
		cout << asum - a[0] * 2 << endl;

		for(ll i = 1; i < a.size() - 1; ++i) {
			cout << a[0] << " " << a[i] << endl;
			a[0] -= a[i];
		}

		cout << a.back() << " " << a[0] << endl;
	}


	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 998244353;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
int L[10],R[10];

template<class T>
struct FenwickTree1D 
{
    vector<T> bit;  // binary indexed tree
    int n;

    FenwickTree1D(int a) {
        this->n = a + 1;
        bit.assign(a + 1, 0);
    }

    FenwickTree1D(vector<T> a): FenwickTree1D(a.size()) 
    {
        for (size_t i = 0; i < a.size(); i++)
        add(i, a[i]);
    }

    T sum(int idx) 
    {
        T ret = 0;
        for (++idx; idx > 0; idx -= idx & -idx)
        {
			ret += bit[idx];
			if(ret >= mod) ret -= mod;
		}
        return ret;
    }

    T sum(int l, int r) 
    {
        return (sum(r) - sum(l - 1) + mod)%mod;
    }

    void add(int idx, T delta) 
    {
        for (++idx; idx < n; idx += idx & -idx)
        {
			bit[idx] += delta;
			if(bit[idx]>=mod) bit[idx]-=mod;
		}
    }
};
FenwickTree1D<ll> T(200009);

void solve()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	cin>>L[i]>>R[i];
	
	T.add(1,1);
	ll val=0;
	for(int i=2;i<=n;i++)
	{
		val=0;
		for(int j=0;j<k;j++)
		{
			val += T.sum(i-R[j], i-L[j]);
			if(val>=mod) val-=mod;
		}
		T.add(i,val);
	}
	cout<<val<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4592
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    cout<<max(A*2-1,max(B*2-1,A+B))<<endl;
    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  string S;cin>>S;
  int N;N=S.size();
  if (S[0]!='A') {
    OUT("WA");
    return 0;
  }
  int idx = 2;
  while (idx < N-1) {
    if (S[idx]=='C') break;
    idx++;
  }
  if (idx==N-1) {
    OUT("WA");
    return 0;
  }

  for (int i=1;i<N;i++) {
    if (i==idx) continue;

    if ('A'<=S[i] && S[i]<='Z') {
      OUT("WA");
      return 0;
    }
  }

  OUT("AC");

  return 0;
}

Measured memory_bytes: 256
int M[10][10];
int x,y,s,i,j;

int main(){
	while(~scanf("%d,%d,%d",&x,&y,&s)){
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				if(s==2){
					if(fmax(abs(i-x),abs(j-y))<=1)M[i][j]+=1;
				}else{
					if(abs(i-x)+abs(j-y)<=(s+1)/2)M[i][j]+=1;
				}
			}
		}
	}
	int ac=0,ans=0;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(M[i][j]==0)ac++;
			ans=fmax(ans,M[i][j]);
		}
	}
	
	return !printf("%d\n%d\n",ac,ans);
}

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

int n;
const int mod = 1e9 + 7;

struct Matrix {
	vector<vector<long long>> m;
	
	Matrix() {
		m.resize(n, vector<long long>(n));
	}
	
	Matrix operator* (Matrix b) {
		Matrix pdt;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					pdt.m[i][j] += m[i][k]*b.m[k][j];
					pdt.m[i][j] %= mod;
				}
			}
		}
		return pdt;
	}
};

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long k;
	cin >> n >> k;
	vector<vector<long long>> foo(n, vector<long long>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> foo[i][j];
		}
	}
	Matrix graph, z;
	graph.m = z.m = foo;
	k--;
	while (k) {
		if (k&1) graph = (graph*z);
		z = (z*z);
		k /= 2;
	}
	
	long long ans{};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) ans = (ans + graph.m[i][j])%mod;
	}
	cout << ans;
}

Measured memory_bytes: 3676
m = int(input())

class Node:
    def __init__(self, key, left ,right):
        self.key = key
        self.left = left
        self.right = right


class BinaryTree():
    def __init__(self):
        self.root = None

    def getRoot(self):
        return self.root
    def setRoot(self, v):
        self.root = v

    def inorder(self, v=None):
        if v is None:
            v = self.root
        if v.left is not None:
            self.inorder(v.left)
        print(' ' + str(v.key), end='')
        if v.right is not None:
            self.inorder(v.right)
        
    def preorder(self, v=None):
        if v is None:
            v = self.root
        print(' ' + str(v.key), end='')
        if v.left is not None:
            self.preorder(v.left)
        if v.right is not None:
            self.preorder(v.right)

def insert(T, z):
    y = None
    x = T.getRoot()
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.p = y

    if y is None:
        T.setRoot(z)
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(T, k):
    x = T.getRoot()
    while x is not None:
        if x.key == k:
            print('yes')
            return
        elif x.key < k:
            x = x.right
        else:
            x = x.left
    print('no')


T = BinaryTree()

for i in range(m):
    inp = input().split()
    if inp[0] == 'print':
        T.inorder()
        print()
        T.preorder()
        print()
    elif inp[0] == 'find':
        find(T, int(inp[1]))
    else:
        v = Node(int(inp[1]), None, None)
        insert(T, v)

Measured memory_bytes: 153776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n,x;
    cin >> n >> x;
    ll ans = n;
    ll mx = max(x, n - x), mn = min(x, n - x);
    while(mx % mn != 0){
        ans += (mx / mn) * 2 * mn;
        ll k = mx % mn;
        mx = mn;
        mn = k;
    }
    ans += ((mx / mn) * 2 - 1) * mn;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

string s,t;
bool flag=false;

int main(void)
{
	cin >> s >> t;
	FOR(i, 0, s.length()) {
		int cnt = 0;
		FOR(k, 0, s.length()) {
			if (s[(i + k) % s.length()] == t[k])cnt++;
		}
		if (cnt == s.length()) {
			flag = true;
			break;
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main()
{
    int n, k;
    int cost[101][101];
    while (cin >> n >> k, n|k) {
        fill_n((int *)cost, 101*101, INF);
        bool ifwf = false;
        for (int cnt = 0; cnt < k; cnt++) {
            int z;
            if (cin >> z, z==1) {
                int c, d, e;
                cin >> c >> d >> e;
                cost[c][d] = cost[d][c] = min(cost[c][d], e);
                ifwf = true;
            } else {
                if (ifwf) {
                    for (int l = 1; l <= n; l++) {
                        for (int i = 1; i <= n; i++) {
                            for (int j = i+1; j <= n; j++) {
                                cost[i][j] = cost[j][i] = min(cost[i][j], cost[i][l] + cost[l][j]);
                            }
                        }
                    }
                    ifwf = false;
                }
                int a, b;
                cin >> a >> b;
                if (cost[a][b] != INF)
                    cout << cost[a][b] << endl;
                else
                    cout << -1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n;
    cin >> n;
    vector a(n,0LL);
    for (int64 i=0; i<n; i++) cin >> a[i];

    int64 x = 1000;
    int64 _min = a[0];
    int64 _max = a[0];
    for (int64 i=0; i<n; i++) {
        debug(i);
        int64 _max = a[i];
        int64 max_ind = -1;
        for (int64 j=i+1; j<n; j++) {
            if (a[i] > a[j] || _max > a[j]) {
                break;
            }
            if (_max < a[j]) {
                _max = a[j];
                max_ind = j;
            }
        }
        if (max_ind != -1) {
            x += (a[max_ind] - a[i]) * (x / a[i]);
            i = max_ind-1;
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(){
  int x;
  cin >> x;
  while(!IsPrime(x)){
    x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int H, W, a = 0, cnt = 0;
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(a < 300){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0)
				break;
			h.add(new Integer(H));
			w.add(new Integer(W));
			a++;
		}
		for(cnt = 0; a > cnt; ++cnt){
			if(cnt != 0)
				System.out.print("\n");
			for(int i = 0; i != h.get(new Integer(cnt)); i++){
				for(int j = 0; j != w.get(new Integer(cnt)); j++){
					System.out.print("#");
				}
				System.out.print("\n");
			}
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 38616
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);
		int n = sc.nextInt();

		String s = "";
		n = n % 10;
		switch (n) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			s = "hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			s = "pon";
			break;
		case 3:
			s = "bon";
			break;
		}

		System.out.println(s);
		sc.close();
	}
}


Measured memory_bytes: 35524
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

A = [0]
B = [0]
for i in range(n):
	A.append(A[i]+a[i])
for j in range(m):
	B.append(B[j]+b[j])

#print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if(l == -1):
			break
		elif((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)

Measured memory_bytes: 127328
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,k;
  cin >> n >> k;
  vi h(n);
  vi dp(n);
  rep(i,0,n)cin>>h[i];

  dp[0]=0;
  rep(i,1,n){
    dp[i]=INT_MAX;
    rep(j,1,min(i+1,k+1)){
      dp[i]= min(dp[i], dp[i-j]+abs(h[i-j]-h[i]));
    }
  }
  cout << dp[n-1];
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    vector<int> H(N);
    vector<int> A(M);
    vector<int> B(M);
    for(int i=0;i<N;i++) cin >> H.at(i);
    vector<int> res(N,1);
    for(int i=0;i<M;i++) {
        cin >> A.at(i) >> B.at(i);
        if(H.at(A.at(i)-1)>H.at(B.at(i)-1)){
            res.at(B.at(i)-1) = 0;
        }else if(H.at(B.at(i)-1)>H.at(A.at(i)-1)){
            res.at(A.at(i)-1) = 0;
        }else{
            res.at(A.at(i)-1) = 0;res.at(B.at(i)-1) = 0;
        }
    }
    
    int cnt=0;
    for(int i=0;i<N;i++){
        if (res.at(i)==1) cnt++;
    }
    cout << cnt << endl;
}

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

#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define int long long
const int N = 1e5 + 10;
vector<pair<int,int> > v[N];
int lev[N];
void dfs(int s , int p = 0){

	for(auto it : v[s]){

		if(it.ff!=p){

			lev[it.ff] = lev[s] + it.ss;
			dfs(it.ff,s);
		}
	}
}

signed main(){

	int n;
	cin>>n;

	for(int i = 1 ; i < n ; ++i){

		int u , x,w;
		cin>>u>>x>>w;
		v[x].pb({u,w});
		v[u].pb({x,w});
	}

	dfs(1);

	for(int i = 1 ; i <= n ; ++i){

		if(lev[i]&1){

			cout<<1<<endl;
		}
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 10240
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type scores []int

func (s scores) Len() int {
	return len(s)
}
func (s scores) Less(i, j int) bool {
	return s[i] < s[j]
}
func (s scores) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	N := nextInt()
	D := make(scores, N)

	for i := 0; i < N; i++ {
		D[i] = nextInt()
	}
	sort.Sort(D)

	abc := D[N/2-1]
	arc := D[N/2]

	if abc == arc {
		fmt.Println(0)
	} else {
		fmt.Println(arc - abc)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,k,i,l,sum,sum1,j;
    scanf("%lld%lld",&n,&k);
    long long int a[n+5];
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    sum=a[k-1]-a[0];
    for(i=1;i<n;i++)
    {
        sum1=a[k+i-1]-a[i];
        if(sum>sum1)sum=sum1;
    if(k+i-1==n-1)break;

    }
   printf("%lld\n",sum);
   return 0;
}

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



int main(){
  int N; cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++) cin>>p.at(i);
  
  int res=0;
  
  for(int i=1;i<N-1;i++){
    int a=max(p.at(i-1),p.at(i+1));
    int b=min(p.at(i-1),p.at(i+1));
    if(p.at(i)<a&&p.at(i)>b)
      res++;
  }
  
  cout<<res;
}

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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
    long long n;
    cin >> n;
    set<long long> s;
    for(long long i = 1;i <= n;i++){ 
        long long in;
        cin >> in;
        s.insert(in);
    }
    if(s.size() == n){
        cout << "YES";
    }
    else cout << "NO";
}

Measured memory_bytes: 9600
import java.util.Scanner;

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

        int a = Integer.parseInt(s);
        int[][] aaa = new int[a][a];
        for(int i = 0; i < a; i++){
            for(int j = 0; j < a; j++){
                aaa[i][j] = 0;
            }
        }
        for(int i = 0; i < a; i++){
            int a1 = sc.nextInt();
            int a2 = sc.nextInt();
            for(int j = 0; j < a2; j++){
                int a3 = sc.nextInt();
                aaa[a1-1][a3-1] = 1;
            }
        }

        for(int i = 0; i < a; i++){
            for(int j = 0; j < a; j++){
                if(j == a - 1) {
                    System.out.print(aaa[i][j]);
                }
                else
                System.out.print(aaa[i][j] + " ");

            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 32772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll N;
  cin >> N;
  ll count = 0;
  for(ll i = 1; i <= N; i++) {
    ll P = N / i;
    ll Q = N % i;
    if(Q != 0) {
      count += P;
    }
    else {
      count += (P - 1);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> Paint;
int gcd(int a,int b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
void yakubun(int &a, int &b){
  //cout << a << " " << b << endl;
  if(!(a==0&&b==0)){
    //cout <<"a"<<endl;
    if(a==0)b=(b>0?1:-1);
    else if(b==0)a=(a>0?1:-1);
    else{

      int tmp = gcd(abs(a),abs(b));
      a/=tmp;
      b/=tmp;
    }
  }
  //cout << a << " " << b << endl;
}
int main(){
  int n,k;cin>>n>>k;
  vector<Paint> a;
  for(int i = 0; n > i; i++){
    int x,y;cin>>x>>y;
    a.push_back(make_pair(x,y));
  }
  for(int i = 0; n > i; i++){
    vector<Paint> b;
    for(int j = 0; n > j; j++){
      if(i==j)continue;
      int x = a[i].first-a[j].first;
      int y = a[i].second-a[j].second;
      //cout << i <<" " << j << "->" << x << " " << y << endl;
      yakubun(x,y);
      //cout << i <<" " << j << "->" << x << " " << y << endl;
      b.push_back(make_pair(x,y));
    }
    sort(b.begin(),b.end());
    int doumx = 1;
    int tmpmx = 1;
    for(int j = 1; b.size() > j; j++){
      if((b[j-1].first == b[j].first) && (b[j-1].second == b[j].second)){
        tmpmx++;
      }else{
        doumx = max(doumx,tmpmx);
        tmpmx = 1;
      }
    } 
    doumx = max(doumx,tmpmx);
    //cout << doumx << endl;
    if(doumx+1 >= k){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int a,b,c;
		int count =0;
		char test[] = new char[50];
		Scanner sc = new Scanner(System.in);

		while(true) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			if(a==-1 && b==-1 && c==-1)
				break;
			test[count] = Judg(a,b,c);
			count++;
		}
		 for(int i = 0; i<count; i++){
	            System.out.println(test[i]);
	        }

	}
	public static char Judg(int a , int b, int c) {
		if (a+b < 30||a==-1||b==-1)
		return 'F';
		else if(a + b >=80)
			return 'A';
		else if(a + b >=65 && a+b < 80)
			return 'B';
		else if ((a+b >=50 && a+b <65)||(c>=50))
			return 'C';
		else if ((a+b >=30 && a+b <50)&&(c<50))
			return 'D';
		else
		    return 'R';
	}
}



Measured memory_bytes: 26208
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

INF = inf
MOD = 1000000007

n = int(input())

tmp = 0
res = 0

cnt = Counter(prime_factorize(n))
for i in cnt.values():
    res += floor((-1 + sqrt(1 + 8 * i)) / 2)

print(res)


Measured memory_bytes: 30136
function make(X,i)
	now=Int[]
	for j=1:length(X)
		if i!=j
			push!(now,X[j])
		end
	end
	now
end
function f(D,X,u)
	if isempty(X)
		return 0
	end
	ret=1145141919810
	for i=1:length(X)
		ret=min(ret,f(D,make(X,i),X[i])+D[u][X[i]])
	end
	ret
end
p(x)=map(y->parse(Int,y),split(x))
function floid(D,N)
	for k=1:N,i=1:N,j=1:N
		D[i][j]=min(D[i][j],D[i][k]+D[k][j])
	end
	D
end
function main()
	N,M,R=p(readline())
	r=p(readline())
	D=[[i!=j ? 1145141919810 : 0 for j=1:N] for i=1:N]
	for s=readlines()
		a,b,c=p(s)
		D[a][b]=D[b][a]=c
	end
	floid(D,N)
	ans=1145141919810
	for i=1:R
		ans=min(ans,f(D,make(r,i),r[i]))
	end
	println(ans)
end
main()


Measured memory_bytes: 138720
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

long int gcd(long int x, long int y){
    if(y == 0) return x;
    return gcd(y, x % y);
}

int main(){
    long int k;
    cin >> k;
    long int ans = 0;
    rep(i, k)rep(j, k)rep(l, k){
        ans += gcd(i + 1, gcd(j + 1, l + 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3160
N, x = [int(x) for x in input().strip().split()]
an = sorted([int(a) for a in input().strip().split()])
cumsum = 0
ans = 0
for i, a in enumerate(an, start=1):
  cumsum += a
  if cumsum > x:
    break
  ans = i
else:
  if cumsum != x:
    ans -= 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> prime(55556, true);
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i <= 55555; i++){
    if (prime[i]){
      for (int j = i * 2; j <= 55555; j += i){
        prime[j] = false;
      }
    }
  }
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 1; i <= 55555; i += 5){
    if (prime[i]){
      A.push_back(i);
      if (A.size() == N){
        break;
      }
    }
  }
  for (int i = 0; i < N; i++){
    cout << A[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

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

using namespace std;

typedef long long ll;

const ll M = 4e18;
ll n, m, k, ans = M;
ll a[15];
ll b[15][15];
ll d[15];

int main()
{
    scanf("%lld%lld%lld", &n, &m, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        for(ll j = 0; j < m; j++)
        {
            scanf("%lld", &b[i][j]);
        }
    }
    for(ll i = 0; i < (1 << n); i++)
    {
        bool v = false;
        ll now = 0;
        for(ll j = 0; j < n; j++)
        {
            if(i & (1 << j))
            {
                now += a[j];
                for(ll ii = 0; ii < m; ii++)
                {
                    d[ii] += b[j][ii];
                }
            }
        }
        for(ll j = 0; j < m; j++)
        {
            if(d[j] < k) v = true;
            d[j] = 0;
        }
        if(!v) ans = min(ans, now);
    }
    if(ans == M) printf("-1\n");
    else printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3836
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)

int main(){
    int A[5],ans=0,max=10;
    REP(i,5){
        cin >> A[i];
        if(max > A[i]%10 && A[i]%10 != 0) max = A[i]%10;
        ans += ((A[i]+9)/10)*10;
    }
    cout << ans-10+max << endl;
    return 0;
}

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

using Graph = vector<vector<int>>;
vector<vector<int>> tsort(Graph &g) {
    int n = g.size(), k = 0;
    vector<int> indeg(n), que, nxt;
    for (int u = 0; u < n; u++) for (int v: g[u]) ++indeg[v];
    vector<vector<int>> dist(n);
    for (int v = 0; v < n; v++) if (indeg[v] == 0) que.emplace_back(v);
    while (!que.empty()) {
        for (int u: que) {
            dist[k].emplace_back(u);
            for (int v: g[u]) if (--indeg[v] == 0) nxt.emplace_back(v);
        }
        swap(que, nxt); nxt.clear(); k++;
    }
    if (*max_element(indeg.begin(), indeg.end()) != 0) return {};
    dist.resize(k);
    return dist;
}

int main() {
    int V, E; cin >> V >> E;
    Graph g(V);
    while (E--) {
        int s, t; cin >> s >> t; s--, t--;
        g[s].emplace_back(t);
    }
    cout << tsort(g).size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 11520
# encoding: utf-8
s = input()
K = int(input())

N = len(s)
num = N * (N + 1) // 2

stat = [1] * N
for i in range(K):
    head = "z" * 5001
    j_head = -1
    # compare
    for j in range(N):
        if j + stat[j] > N: continue
        if s[j : j + stat[j]] < head:
            head = s[j : j + stat[j]]
            j_head = j
    # update status
    for j in range(N):
        if j + stat[j] > N: continue
        if s[j : j + stat[j]] == head: stat[j] += 1

print(head)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<cctype>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

  string ans;

  cin >> ans;

  if(ans[ans.length()-1] == 's') cout << ans << "es" << endl;
  else  cout <<  ans << "s" << endl;

  return 0;

}   


Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>> seq(n);
    for(auto &[h,p] : seq){
        cin>>h>>p;
    }
    sort(seq.begin(), seq.end(), [](const pair<int,int> &x, const pair<int,int> &y){return x.first + x.second < y.first + y.second;});
    ll height = 0;
    const int INF = 2e9 + 7;
    vector<vector<int>> dp(n+1, vector<int>(n+1, INF));
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=1;i<=n;i++){
        int h = seq[i-1].first, p = seq[i-1].second; 
        for(int j=1;j<=n;j++){
            dp[i][j] = dp[i-1][j];
            if(dp[i-1][j-1]<=h){
                dp[i][j] = min(dp[i][j], dp[i-1][j-1] + p);
            }
        }
    }
    for(int i=n;i>=0;--i){
        if(dp[n][i]<INF){
            cout<<i<<"\n";
            return;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 101120
import scala.io.StdIn.readLine

object Main extends App {
  println {
    readLine.trim match {
      case "1 0 0" => "Close"
      case "0 1 0" => "Close"
      case "1 1 0" => "Open"
      case "0 0 1" => "Open"
      case "0 0 0" => "Close"
      case _ => "Close"
    }
  }
}

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

int main() {
    int N; cin >> N;
    vector<int> As(N); for (int i = 0; i < N; i++) {cin >> As[i]; As[i]--;}
    vector<int> Bs(N); for (int i = 0; i < N; i++) cin >> Bs[i];
    vector<int> Cs(N); for (int i = 0; i < N-1; i++) cin >> Cs[i];

    int ans = Bs[As[0]];
    for (int i = 1; i < N; i++) {
        ans += Bs[As[i]];
        if (As[i] - As[i-1] == 1) ans += Cs[As[i-1]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
INF = 10**14
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
a = LI()
sn = [[0 for _ in range(N)] for _ in range(N)]
dp = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    x = 0
    for j in range(i,N):
        x += a[j]
        sn[i][j] = x
for i in range(N):
    dp[i][i] = 0

for j in range(1,N):
    for i in range(j-1,-1,-1):
        for k in range(0,j-i):
            dp[i][j] = min(dp[i][j],dp[i+k+1][j]+ dp[i][i+k] + sn[i][j])
print(dp[0][-1])

Measured memory_bytes: 44908
using System;

class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int small = int.Parse(input[0]);
    int big = int.Parse(input[1]);
    int N = int.Parse(input[2]);
    int count = 0;
    for(int i = 100; i > 0; i--)
    {
      if(big % i == 0 && small % i == 0)
      {
        count++;
        if(count == N) Console.WriteLine(i);
      }
    }
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
string str;
cin>>str;
int cnt = 0;
for(int i = 0 ; i <= (int)str.length()-3 ; i++){
 if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C')cnt++;
}
cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int sum = 15;

int main(){
  FAST_IO
  for(int rep = 0, x; rep < 5; ++rep){
    cin >> x;
    sum -= x;
  }

  cout << sum << '\n';
  return 0;
}



Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: u64,
        a: chars,
        b: chars,
        c: chars
    }
    let mut res = 0u64;
    for i in 0..n as usize{
        res += 
        if a[i] == b[i] && b[i] == c[i] {
            0
        }
        else if (a[i] == b[i]) | (b[i] == c[i]) | (a[i] == c[i]){
            1
        }
        else {
            2
        }
    }
    print!("{}", res);
}


Measured memory_bytes: 4352
n = int(input())
B = list(map(int, input().split()))
ans = []
for _ in range(n):
    for i in reversed(range(len(B))):
        if B[i] == i+1:
            x = B.pop(i)
            ans.append(x)
            break
if len(ans) == n:
    print(*ans[::-1], sep='\n')
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s,ans="";cin>>s;
    REP(i,s.size()){
        if(s[i]=='0')ans+="0";
        if(s[i]=='1')ans+="1";
        if(s[i]=='B')if(ans.size()!=0)ans.pop_back();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, c;
    int ans;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (a+b==c||b+c==a||a+c==b)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}



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

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

	if(X == 7 || X == 5 || X == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

n, k = list(map(int,input().split(" ")))
s = input()


def solve():
    cnt=0
    l=[]
    prev = "1"

    for i in s:
        if prev ==i:
            cnt+=1
        else:
            l.append(cnt)
            cnt = 1
        prev=i
    l.append(cnt)
    if prev=="0":
        l.append(0)

    w = 2*k+1

    if len(l)<=w:
        return n

    acc = [0]+list(accumulate(l))
    ans = 0
    for i in range(0, len(l)-w+1,2):
        ans = max(ans,acc[i+w]-acc[i])
    return ans
print(solve())


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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    s = r.readLine();

    if(s.contains("Y"))
    System.out.println("Four");
    else
      System.out.println("Three");
  }

}


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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int n = 0;

	for (int i = 0; i <= A; i++) {
		int Asum = 500 * i;
		int Bmax = (X - Asum)/100;
		Bmax = Bmax > B ? B : Bmax;
		if (Asum + 100 * Bmax + 50 * C < X) continue;
		for (int j = 0; j <= Bmax; j++) {
			int Bsum = 100 * j;
			int Cmax = (X - Asum - Bsum) / 50;
			Cmax = Cmax > C ? C : Cmax;
			if ((X - Asum - Bsum) / 50 <= Cmax) n++;
			if (Cmax < 0) break;
		}
	}

	cout << n;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
ll n;cin>>n;
ll a[n+1],b[n];
rep(i,n+1)cin>>a[i];
rep(i,n)cin>>b[i];
ll cnt=0;
rep(i,n){
    int left=min(a[i],b[i]);
    cnt+=left;
    a[i]-=left;
    b[i]-=left;
    int right=min(a[i+1],b[i]);
    cnt+=right;
    a[i+1]-=right;
    b[i]-=right;
}
 cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, m, map[16][16];
ll in[1 << 16], f[1 << 16][16];
int main()
{
	scanf("%d%d", &n, &m);
	int x, y;
	for (int i = 1; i <= m; i++)
		scanf("%d%d", &x, &y), x--, y--, scanf("%d", &map[x][y]), map[y][x] = map[x][y];
	for (int i = 0; i < (1 << n); i++)
		for (int j = 0; j < n; j++)
			if (i & (1 << j))
				for (int k = j + 1; k < n; k++)
					if (i & (1 << k))
						in[i] += map[j][k];
	memset(f, -0x3f, sizeof(f));
	f[1][0] = 0;
	for (int i = 1; i < (1 << n); i++)
		for (int j = 0; j < n; j++)
			if (i & (1 << j))
			{
				int x = i ^ (1 << j);
				for (int k = 0; k < n; k++)
					if (i & (1 << k) && map[k][j])
						f[i][j] = max(f[i][j], f[x][k] + map[k][j]);
				for (int k = x; k; k = (k - 1) & x)
					f[i][j] = max(f[i][j], f[i ^ k][j] + in[1 << j ^ k]);
			}
	printf("%lld\n", in[(1 << n) - 1] - f[(1 << n) - 1][n - 1]);
}

Measured memory_bytes: 8576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        if(n[0] == 1 || n[1] == 1)
        {
            WriteLine($"{0}");
            return;
        }
        if(n[2] == 1)
        {
            WriteLine($"{(long)((n[0] * 1) / (double)n[1]) - n[0] * (long)(1 / (double)n[1])}");
            return;
        }
        long count = Min(n[1] - 1, n[2]);
        long before = 0, current = 0, after = 0;
        long max = 0;
        while(0 < count)
        {
            before = (long)((n[0] * (count - 1)) / (double)n[1]) - n[0] * (long)((count - 1) / (double)n[1]);
            current = (long)((n[0] * count) / (double)n[1]) - n[0] * (long)(count / (double)n[1]);
            after = (long)((n[0] * (count + 1)) / (double)n[1]) - n[0] * (long)((count + 1) / (double)n[1]);
            max = Max(max, current);
            if(after <= current && before < current || after < current && before <= current)
            {
                WriteLine($"{current}");
                return;
            }
            count--;
        }
        WriteLine($"{max}");
    }
}


Measured memory_bytes: 19076
#include<bits/stdc++.h>
using namespace std;
const int MAXN =  305;
int n, m;
char th[MAXN][MAXN];
inline int calc(const int &x)
{
	static int f[MAXN][MAXN];
	for(register int i = 1; i <= n; ++i)
		for(register int j = 1; j <= n; ++j)
			f[i][j] = (th[i][x] == th[j][x + 1]);
	for(register int i = 1; i <= n; ++i)
		for(register int j = 1; j <= n; ++j)
			f[i][j] = f[i - 1][j - 1] + f[i][j];
	for(register int i = 1; i <= n; ++i)
		for(register int j = 1; j <= n; ++j)
			f[i][j] += min(f[i - 1][j], f[i][j - 1]);
	return f[n][n];
}
int main()
{
	scanf("%d %d", &n, &m);
	for(register int i = 1; i <= n; ++i)
		scanf("%s", th[i] + 1);	
	register int ans = 0;
	for(register int i = 1; i < m; ++i)
		ans += calc(i);
	cout << ans << endl;
}

Measured memory_bytes: 640