akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}


ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll n, m, t, q, s,k,h,w;

void warshall_floyd(ll v_num,vector<vector<long long>> &d) {
	for (long long k = 0; k < v_num; k++) {       // 経由する頂点
		for (long long i = 0; i < v_num; i++) {    // 始点
			for (long long j = 0; j < v_num; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

ll findIndex(vl& vec, ll num) {
	rep(i, 0, vec.size()) {
		if (vec[i] == num)return i;
	}
	return -1;
}

int main() {
	cin >> n >> k;
	vector<pll> xy(n);
	vl x(n), y(n);
	rep(i, 0, n) {
		cin >> h >> w;
		xy[i] = pll{ h,w };
		x[i] = h; y[i] = w;
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	vvl zahyo(n, vl(n, 0)), dp(n + 1, vl(n + 1, 0));
	rep(i, 0, n) {
		ll xi, yi;
		xi = findIndex(x, xy[i].first);
		yi = findIndex(y, xy[i].second);
		zahyo[xi][yi] += 1;
	}
	rep(i, 0, n) {
		rep(j, 0, n) {
			dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + zahyo[i][j];
		}
	}
	ll ans = MAX_INF;

	rep(i, 0, n) {
		rep(j, 0, n) {
			rep(o, i+1, n) {
				rep(l, j+1, n) {
					ll kazu = dp[o + 1][l + 1] - dp[i][l + 1] - dp[o + 1][j] + dp[i][j];
					if (kazu >= k) {
						//printf("%lld %lld %lld %lld\n", i, j,k,l);
						ll menseki = (x[o] - x[i]) * (y[l] - y[j]);
						ans = min(ans, menseki);
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int a,b;
            cin>>a>>b;
            if(a<=5)
                cout<<0<<endl;
            else if(a<=12)
                cout<<b/2<<endl;
            else
                cout<<b<<endl;
        }
        return 0;
    }


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

int main() {
  string n;

  cin >> n;

  int num =0;

  for (int i=0; i<n.size() ; i++){
    num+= (n[i] - '0');
  }

  // cout << num << endl;

  if(num%9 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  int range = D * 2 + 1;
  if(N % range == 0) cout << N / range << endl;
  else cout << N / range + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, T; cin >> N >> T;
    vector<ll> a(N), b(N);
    for(int i=0; i<N; i++) cin >> a[i];

    ll minv = a[0];
    ll maxv = -1000000;
    for(int i=1; i<N; i++){
        b[i] = a[i]-minv;
        minv = min(minv, a[i]);
        maxv = max(maxv, b[i]);
    }

    int ans = 0;
    for(int i=1; i<N; i++) if(b[i] == maxv) ans++;
    cout << ans << endl;

}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int numStones = sc.nextInt();
		int[] stoneHeights = new int[numStones];
		
		for(int i = 0; i < numStones; i++) {
			stoneHeights[i] = sc.nextInt();
		}
		
		int[] minCostForStones = new int[numStones];
		Arrays.fill(minCostForStones, Integer.MAX_VALUE);
		minCostForStones[0] = 0;
 		for(int i = 0; i < numStones; i++) {
			for(int j = i + 1; j < i + 3; j++) {
				if(j < numStones) {
					minCostForStones[j] = Math.min(minCostForStones[j], minCostForStones[i] + Math.abs(stoneHeights[j] - stoneHeights[i]));
				}
			}
		}
		System.out.println(minCostForStones[numStones - 1]);
	}
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  int i;
  rep(i,n) cin >> p[i];
  sort(all(p));
  int ans = 0;
  rep(i,k) ans += p[i];
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int A, B, C;
	cin >> A >> B >> C;

	if (A < C&&C < B || A>C&&C>B)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
N = parseInt(readline())
A =parseInt.(split(readline()))
function main()
    f = true
    for i in 1:N
        if A[i] % 2 == 0
            if A[i] % 3 != 0 && A[i] % 5 != 0
                println("DENIED")
                return
            end
        end
    end
    println("APPROVED")
end

main()

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int ans[55]={2,31,61,151,181,211,241,271,331,421,541,571,601,631,661,691,751,811,991,1021,1051,1171,1201,1231,1291,1321,1381,1471,1531,1621,1741,1801,1831,1861,1951,2011,2131,2161,2221,2251,2281,2311,2341,2371,2521,2551,2671,2731,2791,2851,2971,3001,3061,3121,3181,};
signed main(){
  int n;cin>>n;
  rep(i,n){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=5000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 100000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int n,fa[N],siz[N],m=0,p[N],f[N];

int find(int x)
{
    if (fa[x]==x) return x;
    fa[x]=find(fa[x]);
    return fa[x];
}

int main()
{
    n=read();
    rep(i,1,n) {fa[i]=i;siz[i]=1;}
    rep(i,1,n)
    {
        p[i]=read();
        if (p[i]==-1) m++;
        else
        {
            int x=i,y=p[i];
            int fx=find(i),fy=find(p[i]);
            if (fx!=fy) {siz[fy]+=siz[fx];fa[fx]=fy;}
        }
    }
    f[0]=1;
    int ans=mul(n,qpow(n-1,m));
    rep(i,1,n)
    {
        if (find(i)!=i) continue;
        if (p[i]==-1)
        {
            per(j,n,1)
                f[j]=add(f[j],mul(f[j-1],siz[i]));
        }
        else ans=dec(ans,qpow(n-1,m));
    }
    f[1]=dec(f[1],m);
    int prod=1;
    for (int i=1;i<=m;prod=mul(prod,i),i++)
    {
        ans=dec(ans,mul(f[i],mul(prod,qpow(n-1,m-i))));
    }
    printf("%d",ans);
    return 0;
}
        

Measured memory_bytes: 3840
X, N = map(int, input().split())
nums = list(map(int, input().split()))

if X not in nums:
  print(X)
  exit(0)

diff_dict = {}
for n in nums:
  diff = abs(X - n)
  if diff in diff_dict.keys():
    diff_dict[diff].append(n)
  else:
    diff_dict[diff] = [n]

keys = list(diff_dict.keys())
keys.sort()

for i in range(1, max(keys)+2):
  if i not in keys:
    print(X - i)
    break
  else:
    targets = diff_dict[i]
    length = len(targets)
    if length > 1:
      continue
    else:
      t = targets[0]
      print(X - i if t > X else X + i)
      break

Measured memory_bytes: 9248
n = int(input())
a,b = map(int,input().split())
P = list(map(int,input().split()))

Q = [0]*3
for i in range(n):
  if P[i] <= a:
    Q[0] += 1
  elif P[i] <= b:
    Q[1] += 1
  else:
    Q[2] += 1
    
print(min(Q))    

Measured memory_bytes: 9192
#include <iostream>

#include<algorithm>
#include<vector>
#include<queue>
#include<string>

using namespace std;

int main()
{
	long long n;
	long long h[105] = {0};
	cin>> n ;

	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}

	long long ans = 12345678901234560;
	for (int i = 1; i <=100; i++) {
		long long sum = 0;
		for (int j = 1; j <= n; j++) {
			sum +=( (h[j] - i) * (h[j] - i));
		}
		
		if (ans > sum)ans = sum;
	

	}

	
	cout << ans << endl;

}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
out=10**18
for i in range(n):
    ans=ans*a[i]
    if out<ans:
        ans=-1
        break
for i in range(n):
    if a[i]==0:
        ans=0
        break
print(ans)


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

int main(){
  double x[3],y[3];
  rep(i,3) cin>>x[i]>>y[i];
  double hen[3];
  rep(i,3){
    hen[i]=sqrt(pow(x[i]-x[(i+1)%3],2.0)+pow(y[i]-y[(i+1)%3],2.0));
  }
  double S=abs((x[0]-x[2])*(y[1]-y[2])-(x[1]-x[2])*(y[0]-y[2]))/2;
  double r=2*S/(hen[0]+hen[1]+hen[2]);
  sort(hen,hen+3);
  cout<<setprecision(15);
  cout<<r*hen[2]/(2*r+hen[2])<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
xs = [int(x) for x in input().split()]

def solve(n, xs):
    x_min = min(xs)
    x_max = max(xs)

    if x_max - x_min > 1:
        return "No"

    if x_max == x_min:
        if n == x_max+1:
            return "Yes"
        elif x_max*2 <= n:
            return "Yes"
        else:
            return "No"

    solo_num = sum(1 for x in xs if x==x_min)

    if solo_num >= x_max:
        return "No"

    dup_color = x_max - solo_num
    dup_cat = sum(1 for x in xs if x==x_max)

    if dup_cat < dup_color*2:
        return "No"

    return "Yes"

print(solve(n, xs))


Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  int c=0;
  rep(i,a-1){
    c+=i;
}
cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  ll cntr=0,cntg=0,cntb=0;
  rep(i,n){
    if(s[i]=='R') cntr++;
    if(s[i]=='G') cntg++;
    if(s[i]=='B') cntb++;
  }
  ans=cntr*cntg*cntb;
  cntr=0;cntg=0;cntb=0;
  rep(i,n-2){
    ll j=1;
    while(i+2*j<n){
      if(s[i]=='R') cntr++;
      if(s[i]=='G') cntg++;
      if(s[i]=='B') cntb++;
      if(s[i+j]=='R') cntr++;
      if(s[i+j]=='G') cntg++;
      if(s[i+j]=='B') cntb++;
      if(s[i+2*j]=='R') cntr++;
      if(s[i+2*j]=='G') cntg++;
      if(s[i+2*j]=='B') cntb++;
      if(cntr==1&&cntg==1&&cntb==1) ans--;
      cntr=0;cntg=0;cntb=0;
      j++;      
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  int n;
  while(cin>>n,n){
    vector<int> ary(24*60*60,0);
    char b[9],e[9];
    while(n--){
      cin>>b>>e;
      int h,m,s;
      sscanf(b,"%d:%d:%d",&h,&m,&s);
      int start = ((h * 60) + m) * 60 + s; 
      sscanf(e,"%d:%d:%d",&h,&m,&s);
      int finish = ((h * 60) + m) * 60 + s; 
      for(int i = start ; i < finish ; i ++)ary[i]++;
    }
    int ret = -1;
    for(int i = 0 ; i < ary.size() ; i ++)ret = max(ret,ary[i]);
    cout<<ret<<endl;
  }
}

Measured memory_bytes: 1588
/*
    Author:zzugzx
    Lang:C++
    Blog:blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    stack<char> s;
    ll n;cin>>n;
    while(n){
        n--;
        s.push(n%26+'a');
        n/=26;
    }
    while(SZ(s))cout<<s.top(),s.pop();
    return 0;
}



Measured memory_bytes: 3656
while True:
    try:
        m = int(raw_input())
        a = sorted([list(map(int, raw_input().split())) for i in range(m)])
        dax = [a[i][0]-a[0][0] for i in range(m)]
        
        n = int(raw_input())
        b = sorted([list(map(int, raw_input().split())) for i in range(n)])
        bx = [b[i][0] for i in range(n)]
        
        for i in range(n-m):
            for da in dax:
                if bx[i]+da not in bx:
                    break
            else:
                print b[i][0]-a[0][0],b[i][1]-a[0][1]
                break
    except:
        break

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int k,a,b;
    cin>>k;
    cin>>a>>b;
    for(int i = a;i<=b;i++){
    	if(i%k==0){
    		cout<<"OK";
    		return;
    	}
    }
    cout<<"NG";
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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

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

int main(int argc, char const *argv[]) {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  int x[n], y[m];
  bool tf = false;
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < m; i++) cin >> y[i];
  for (int z = X+1; z <= Y && !tf; z++) {
    bool peace = true;
    for (int i = 0; i < n and peace; i++) {
      if (x[i] >= z) peace = false;
    }
    for (int i = 0; i < m and peace; i++) {
      if (y[i] < z) peace = false;
    }
    if (peace) tf =true;
  }
  if (tf) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int kaisuT = (c%b == 0) ? c/b: c/b+1;
		int kaisuA = (a%d == 0) ? a/d: a/d+1;
		if (kaisuT <= kaisuA) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35792
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;

int main() {
    string s ;
    cin >> s ;
    string::size_type i = 0;
    int uppers = 0;
    int c = 0;
    if (s[i] == 'A') {
        while (i < s.size()) {
            if (!islower(s[i])) uppers += 1;
            if (1 < i && i < s.size() - 1) {
                if (s[i] == 'C') c += 1;
            }
            i++;
        }
        if (uppers == 2 && c == 1) {
            cout << "AC" << endl;
        }
        else cout << "WA" << endl;
    }
    else cout << "WA" << endl;
        
    


    
   


    
    return 0;
}
    

Measured memory_bytes: 256
N, Y = map(int, input().split())

Y //= 1000

k = min((Y - N) // 4, Y // 5)
if 9 * k >= 2 * (Y - N):
    x = (Y - N) - 4 * k
    y = -2 * (Y - N) + 9 * k
    z = Y - 5 * k
    print(x, y, z)
else:
    print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,d; cin >> n >> d;
    ll res = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        if(x*x + y*y <= d*d)res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 3664
#include<stdio.h>

#define max 100001
#define nil -1

typedef struct{
  int right;
  int left;
  int parent;
}Node;

int height(int);
Node Tree[max],tmp;

int depth[max],length,child[max],sibling[max],degree[max];

int main(){
  int i,own,numberchild,j;
  scanf("%d",&length);
  for(i=0;i<length;i++){
    Tree[i].parent=nil;
    Tree[i].right=nil;
    Tree[i].left=nil;
  }
  for(i=0;i<length;i++){
    scanf("%d",&own);
    for(j=0;j<2;j++){
      scanf("%d",&child[j]);
      Tree[child[j]].parent=own;
      Tree[own].left = child[0];
      Tree[own].right = child[1];
    }
  }
  
  for(i=0;i<length;i++){
    int count=0,subi;
    subi=i;
    while(1){
      if(Tree[subi].parent==nil){
	break;
      }
      subi=Tree[subi].parent;
      count++;
    }
    depth[i]=count;
  }

  for(i=0;i<length;i++){
    if(depth[i]==0){
      sibling[i]=nil;
    }
    else if(Tree[Tree[i].parent].left==i){
	sibling[i]=Tree[Tree[i].parent].right;
      }
      else{
	sibling[i]=Tree[Tree[i].parent].left;
      }
    }

  int Dcount;
  for(i=0;i<length;i++){
    Dcount=0;
    if(Tree[i].right!=nil){
      Dcount++;
    }
    if(Tree[i].left!=nil){
      Dcount++;
    }
    degree[i]=Dcount;
    }
  
  for(i=0;i<length;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,Tree[i].parent,sibling[i],degree[i],depth[i],height(i));
    if(Tree[i].parent==nil){
      printf("root\n");
    }
    else if(Tree[i].left==nil && Tree[i].right!=nil || Tree[i].left!=nil && Tree[i].right==nil){
      printf("internal node\n");
    }
    else if(Tree[i].left!=nil && Tree[i].right!=nil){
      printf("internal node\n");
      }
    else {
      printf("leaf\n");
    }
  }

  return 0;
}

int height(int u){
    int HL=0,HR=0;
    if(Tree[u].left!=nil){
      HL=height(Tree[u].left)+1;
    }
    if(Tree[u].right!=nil){
      HR=height(Tree[u].right)+1;
    }
    if(HL<HR){
      return HR;
    }
    else{
      return HL;
    }
  }

Measured memory_bytes: 628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
typedef pair<int,int> pii;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

// graph //

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N) cin >> C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());

    ll ans = 0;
    REP(i,N){
        ll s = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
        ll t = C.end() - upper_bound(C.begin(),C.end(),B[i]);
        ans += s*t;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    vi v(n),a;;
    rep(i,n)cin>>v[i];
    a=v;
    double sum=0;
    for(int i=0;i<n;i++){
        v[i]-=(i+1);
    }

    Sort(v);
    int b1,b2=INF;
    if(v.size()%2==1)b1=v[n/2];
    else{
        b1=v[n/2];
        b2=v[n/2+1];
    }
    // cout<<b1<<" "<<b2<<endl;
    ll ans=0,ans2=0;
    rep(i,n){
        ans+=abs(a[i]-(b1+(i+1)));
    }
    rep(i,n){
        ans2+=abs(a[i]-(b2+(i+1)));
    }
    fin(min(ans,ans2));
    

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int w, h, n;
    cin >> w >> h >> n;
    int xmin = 0, xmax = w, ymin = 0, ymax = h;
    rep(i, n)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1)
            xmin = max(x, xmin);
        if (a == 2)
            xmax = min(x, xmax);
        if (a == 3)
            ymin = max(y, ymin);
        if (a == 4)
            ymax = min(y, ymax);
    }
    int xd = xmax - xmin;
    int yd = ymax - ymin;
    cout << max(0,xd) * max(0,yd) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999

int main() {
	int a, b, x;
	std::cin >> x >> a >> b;
	if (std::abs(x - a) > std::abs(x - b)) {
		std::cout << 'B' << std::endl;
	}
	else {
		std::cout << 'A' << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=2e5+100;
ll par[N];
map <int,int> t,vis;

int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=0;i<n;i++){
        ll x;
        cin >> x;
        par[i+1]=par[i]+x;
        t[par[i+1]]++;
    }
    t[par[0]]++;
    ll ans=0;
    for (int i=1;i<=n;i++){
        if (!vis[par[i]]){
            ans+=t[par[i]]*(t[par[i]]-1)/2;
            vis[par[i]]=1;
        }
    }

    cout << ans;

}


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

public class Main {
	public static void main(String[] rags) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(n);

		for(int i = 0;i < n;i++) {
			list.add(new ArrayList<Integer>());
		}

		for(int i =0;i < n - 1;i++) {
			list.get(scan.nextInt() - 1).add(1);
		}

		for(int i = 0;i < n;i++) {
			System.out.println(list.get(i).size());
		}
	}
}


Measured memory_bytes: 77012
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.nextLine();
    int ans = 0;
    int max = 0;

    for(int i=0; i<s.length(); i++){
      if(s.charAt(i) == 'R'){
        ans ++;
      }else{
        max = Math.max(ans,max);
        ans = 0;
      }
    }
    
    System.out.println(Math.max(ans,max));
   
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35648
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int ans = T*(N/X);
    if(N%X!=0)ans+=T;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#define PI 3.14159265359
#define TWO_PI 6.28318530718

int main(void){
    double r;
    std::cin >> r;
    std::cout << std::fixed;
    std::cout << std::setprecision(10) << PI*r*r << " " << TWO_PI*r << std::endl;
    return 0;
}


Measured memory_bytes: 3260
from collections import defaultdict
import heapq
import math

H, W = map(int, input().split())

edges = defaultdict(list)
field = []

for _ in range(H):
    field.append(input())

weight = 1
for i in range(H):
    for j in range(W):
        if j + 1 < W and field[i][j] == '.' and field[i][j + 1] == '.':
            edges[W * i + j].append((W * i + j + 1, weight))
            edges[W * i + j + 1].append((W * i + j, weight))
        if i + 1 < H and field[i][j] == '.' and field[i + 1][j] == '.':
            edges[W * i + j].append((W * (i + 1) + j, weight))
            edges[W * (i + 1) + j].append((W * i + j, weight))


def dijkstra(s):
    que = []
    dist = [float('inf')] * (H * W)
    dist[s] = 0
    heapq.heappush(que, (0, s))

    while que:
        p = heapq.heappop(que)
        v = p[1]
        if dist[v] < p[0]:
            continue
        for i in range(len(edges[v])):
            e = edges[v][i]
            if dist[e[0]] > dist[v] + e[1]:
                dist[e[0]] = dist[v] + e[1]
                heapq.heappush(que, (dist[e[0]], e[0]))

    dist = [0 if d == float('inf') else d for d in dist]
    return dist


ans = 0
for i in range(H*W):
    ans = max(ans, max(dijkstra(i)))

print(ans)


Measured memory_bytes: 3572
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			// Stream 使いたい
			List<Integer> a =  IntStream.range(0, n).mapToObj(x->sc.nextInt()).collect(Collectors.toList());
			int q = sc.nextInt();
			// また Stream 使ってしまった
			IntStream.range(0, q).mapToObj((x) -> {
				int b = sc.nextInt();
				int e = sc.nextInt();
				int k = sc.nextInt();
				return Collections.frequency(a.subList(b, e), k);
			}).collect(Collectors.toList()).forEach(System.out::println);
		}
	}
}


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

using namespace std;

long long p[1000001],x=0,y=0;

int main(){
 int N,K;
 long double z;

 cin>>N>>K;
 for(int i=0;i<N;i++){
   cin>>p[i];
 }

 for(int i=0;i<K;i++){
   x=x+p[i];
 }
 y=x;
 for(int i=K;i<N;i++){
   y=y-p[i-K]+p[i];
   x=max(x,y);
 }

 x=x+K;


 if(x % 2==1){
   x=(x-1)/2;
  cout<<x<<".5";
}else{
   cout<<x/2;
 }



 return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define MOD 10000
int dp[505][10][505][3][2];
int M;
vector<int> a,b;
int rec(vector<int> &vec,int index,int prev,int mod,int upper,bool free)
{
	if(index==vec.size())return (mod?0:1);
	if(dp[index][prev][mod][upper][free]>0)return dp[index][prev][mod][upper][free];
	int can;
	if(free){can=9;}
	else {can=vec[index];}
	int res=0;
	for(int i=0;i<=can;i++)
	{
		res%=MOD;
		if(upper==0&&prev>=i)continue;
		if(upper==1&&prev<=i)continue;
		if(upper==2&&prev&&prev==i)continue;
		int new_upper;
		if(upper==2)
		{
			if(prev==0)new_upper=2;
			else if(prev<i)new_upper=1;
			else new_upper=0;
		}
		else new_upper=!upper;
		res += rec(vec,index+1,i,(mod*10+i)%M,new_upper,free|(i!=vec[index]));
	}
	return dp[index][prev][mod][upper][free]=res%MOD;
}
int main()
{
	string s1,s2;
	cin >> s1;
	cin >> s2;
	cin >> M;
	for(int i=0;i<s1.size();i++)a.pb(s1[i]-'0');
	for(int i=0;i<s2.size();i++)b.pb(s2[i]-'0');
	for(int i=a.size()-1;i>=0;i--)
	{
		if(a[i]==0)a[i]=9;
		else
		{
			a[i]--;
			break;
		}
	}
	memset(dp,-1,sizeof(dp));
	int A=rec(a,0,0,0,2,false);
	memset(dp,-1,sizeof(dp));
	int B=rec(b,0,0,0,2,false);
	int ans=(B-A+MOD)%MOD;
	//cout << A << ' ' << B <<endl; 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 61072
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		//int a=sc.nextInt();
				
		Set<Integer>array=new HashSet<>();
		for(int i=0;i<n;i++) {
			array.add(sc.nextInt());
		}
		
		if(n<=array.size()) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		sc.close();	
	}
}

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

int main() {
    int n;cin >> n;
    int m[n];
    map<int, int> mp;
    for (int i=0;i<n;i++){
        cin >> m[i];
        mp[m[i]]++;
    }

    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

//int v1[105],v2[105];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		string s;
		cin>>s;
		ll dp[n+1];
		dp[0]=0;
		for(int i=1;i<=n;i++){
			if(s[i-1]=='W') dp[i]=dp[i-1]+1;
			else dp[i]=dp[i-1];
		}
		ll ans=dp[n-dp[n]];
		cout<<ans;
	}
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int ones(int i) {
    int res = 0;
    for(;0 < i;i /= 2) {
        res += i&1;
    }
    return res;
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) {
        cin >> S[i];
    }
    vector<vector<int>> choco(H, vector<int>(W, 0));
    REP(i, H) {
        REP(j, W) {
            choco[i][j] = S[i][j] == '1';
        }
    }

    int res = IINF;
    REP(h, 1<<(H - 1)) {
        int c = ones(h);
        vector<vector<int>> v(c + 1, vector<int>(W, 0));
        vector<vector<int>> s(c + 1, vector<int>(W, 0));
        int k = 0;
        REP(i, H) {
            REP(j, W) {
                int ch = choco[i][j];
                int x = v[k][j];
                v[k][j] += choco[i][j];
            }
            if(h&(1<<i)) {
                k++;
            }
        }
        bool quit = false;
        REP(i, c + 1) {
            REP(j, W) {
                quit = quit || K < v[i][j];
            }
        }
        if(quit) {
            continue;
        }

        int cut = c;
        REP(i, c + 1) {
            s[i][0] = v[i][0];
        }

        FOR(j, 1, W) {
            bool over = false;
            REP(i, c + 1) {
                s[i][j] = s[i][j - 1] + v[i][j];
                over = over || K < s[i][j];
            }
            if(over) {
                cut++;
                REP(i, c + 1) {
                    s[i][j] = v[i][j];
                }
            }
        }
        res = min(res, cut);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> X >> Y;
    int sou = (4*X-Y);
    int ashi = (-2*X+Y);
    if(sou >= 0 && ashi >=0)
    if((sou%2==0)&&(ashi%2==0))
    { cout << "Yes";
    return 0;
    }
    
    cout << "No";
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string.h>

using namespace std;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
char field[12][12];
int W = 12;
int H = 12;

void DFS(int y, int x)
{
	field[y][x] = '0';
	for(int i = 0; i < 4; ++i)
	{
		int X = x + dx[i];
		int Y = y + dy[i];
		if((0 <= X && X < W && 0 <= Y && Y < H) && field[Y][X] == '1')
		{
			DFS(Y, X);
		}
	}
}

void solve()
{
	char a;
	while(cin >> a)
	{
		int count = 0;
		memset(field, 0, sizeof(field));
		field[0][0] = a;
		for(int i = 1; i < W; ++i)
		{
			cin >> field[0][i];
		}
		for(int i = 1; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cin >> field[i][j];
			}
		}
		
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				if(field[i][j] == '1')
				{
					DFS(i, j);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
module Main where

main :: IO ()
main = do
  getLine
  a <- map read . words <$> getLine
  print . solve $ a


solve :: [Int] -> Int
solve list = snd $ s list (0, 0)
  where
    s (p:ps) (prev, total) = s ps (if p > prev then (p, total + p - prev) else (p, total))
    s [] r = r


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

int main(){
    int N, M;  cin >> N >> M;
    vector<pair<int, int>> P(M);
    for(int i=0; i<M; i++){
        cin >> P[i].first >> P[i].second;
    }
    sort(P.begin(), P.end(), [](const pair<int,int>& a, const pair<int,int>& b){
        return a.second < b.second;
    });

    int ans = 0;
    int left = 0;
    for(int i=0; i<M; i++){
        if(left <= P[i].first){
            ans++;
            left = P[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
s=[0]
p=[0]
for i in range(1,n+1):
  s.append(s[i-1]+a[i])
  p.append(p[i-1]+max(0,a[i]))
ans=0
for i in range(1,n-k+2):
  t=max(0,s[i+k-1]-s[i-1])
  t+=p[i-1]+p[n]-p[i+k-1]
  ans=max(ans,t)
print(ans)

Measured memory_bytes: 77856
if __name__ == '__main__':
    x1, y1, x2, y2 = list(map(int, input().split()))
    dis = [x2-x1, y2-y1]
    print(x2-dis[1], y2+dis[0] , x2-dis[1]-dis[0], y2+dis[0]-dis[1])
    

Measured memory_bytes: 2940
lis=input().split()
a=int(lis[0])
b=int(lis[1])
if a==1:
    if b==1:
        print("Draw")
    else :
        print("Alice")
elif b==1:
    print("Bob")
else :
    if a>b:
        print("Alice")
    elif a==b:
        print("Draw")
    else :
        print("Bob")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdint>

int const MAXN = 1e5;

int64_t a1[MAXN*3], a2[MAXN*2], a3[MAXN];
int X, Y, A, B, C;

int main() {
  std::cin >> X >> Y >> A >> B >> C;
  for(int i = 0; i < A; ++i) std::cin >> a1[i];
  for(int i = 0; i < B; ++i) std::cin >> a1[i+MAXN];
  for(int i = 0; i < C; ++i) std::cin >> a3[i];
  std::sort(a1, a1+A);
  std::sort(a1+MAXN, a1+MAXN+B);
  std::sort(a3, a3+C);
  std::merge(a1+(A-X), a1+A, a1+MAXN+(B-Y), a1+MAXN+B, a2);
  std::merge(a2, a2+X+Y, a3, a3+C, a1);
  std::cout << std::accumulate(a1+C, a1+C+X+Y, int64_t(0)) << std::endl;
  return 0;
}


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

using namespace std;

using LL = long long;

const int N = (int)1e5 + 5, LOG = 60;
int n, num[LOG];
LL a[N], xorSum, mx, ans;
vector<LL> basis;

int leftSetBit(LL val) { return (int)__lg(val); }

void updBasis(LL val) {
    for (vector<LL>::iterator it = basis.begin(); it != basis.end(); ++it) {
        if (!val) break ;
        int tmp1 = leftSetBit(*it), tmp2 = leftSetBit(val);
        if (tmp1 == tmp2) val ^= *it;
        else if (tmp1 < tmp2) {
            basis.insert(it, val);
            val = 0;
            break ;
        }
    }
    if (val) basis.push_back(val);
}

bool testBit(LL _a, int _bit) { return (_a >> _bit) & 1; }

int main() {
    scanf(" %d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf(" %lld", a + i);
        for (int j = 0; j < LOG; ++j) if (testBit(a[i], j) ) ++num[j];
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < LOG; ++j) if (testBit(a[i], j) && (num[j] & 1) ) a[i] ^= (1LL << j);
        updBasis(a[i]);
    }

    for (int i = 0; i < LOG; ++i) if (num[i] & 1) ans |= (1LL << i);

    for (LL _ : basis) {
        if (!testBit(mx, leftSetBit(_) ) ) mx ^= _;
    }

    printf("%lld", ans + (mx << 1) );

    return 0;
}


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

using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    int D[K];
    for (int i=0; i<K; ++i)
    {
        cin >> D[i];
    }
    // cout << N << K << endl;
    int MAX = 100000;
    int ans = -1;
    bool ok = true;
    for (int i=N; i<MAX; ++i)
    {
        string str = to_string(i);
        // cout << str << endl;
        // cout << str.size() << endl;
        for(int j=0; j<K; ++j)
        {
            for (int k=0; k<str.size(); ++k)
            {
                // cout << "str.size() " << str.size() << endl;
                // cout << str[0] << " " << str[1] << endl;
                // cout << k << " " << str.size() << endl;
                // cout << i << " " <<str[k]-48 << " " << D[j] << endl;

                // cout << "j:" << j << " k: " << k << " str[k]: " << str[k] << endl;
                // cout << "j: " << j << " k: " << k << endl;
                // cout << "D[j]: " << D[j] << " str[k]: " << str[k] << endl;
                if(str[k]-48==D[j])
                {
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
        if(ok)
        {
            // cout << "ok" << endl;
            ans = i;
            break;
        }
        // cout << ans << endl;
        ok = true;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    vector<ll> V(N);
    for (ll& x : V) cin >> x;
    ll res = 0;
    for (int l = 0; l <= K && l <= N; l++) {
      priority_queue<ll> minus;
      ll sum = 0, minusSum = 0;
      for (int i = 0; i < l; i++) {
        sum += V[i];
        if (V[i] < 0) {
          minus.push(V[i]);
          minusSum += V[i];
        }
      }
      for (int r = 0; l + r <= K && l + r <= N; r++) {
        int rem = K - l - r;
        if (r > 0) {
          sum += V[N - r];
          if (V[N - r] < 0) {
            minus.push(V[N - r]);
            minusSum += V[N - r];
          }
        }
        // minusはすてるやつが入っている
        // rem以降は捨てられない
        while (minus.size() > rem) {
          minusSum -= minus.top();
          minus.pop();
        }
        chmax(res, sum - minusSum);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256