akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc174/tasks/abc174_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    // sort(ALL(A));
    // 二分探索
    int ng = 0, ok = 1e9;
    // 全ての丸太を長さtarget以下にする
    auto fn = [&](int target) {
        int cnt = 0;
        REP(i, N) {
            // 例えば長さ7を7以下にするなら切らなくていい。
            // 7未満にするなら1回切るように数える。
            cnt += DIV(A[i], target) - 1;
            if (cnt > K) {
                break;
            }
        }
        return cnt <= K;
    };
    while (ok - ng > 1) {
        int mid = (ng + ok) / 2;
        (fn(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4684
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <limits>
#include <map>
using namespace std;

int main()
{
    long n, min = -1000000, max = 1000000, sum = 0, a;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (i == 0)
        {
            min = a;
            max = a;
        }
        min = a < min ? a : min;
        max = a > max ? a : max;
        sum += a;
    }
    cout << min << ' ' << max << ' ' << sum << endl;

    return 0;
}


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

int main() {
    long long v[5], ans = 0;
    cin >> v[0] >> v[1] >> v[2];
    sort(v, v + 3);

    for (int i = 1; i <= v[2]; i++) {
        if (v[1] * i >= v[1] * v[2] / 2) {
            ans = abs(v[0] * i * v[1] - (v[0] * (v[2] - i) * v[1]));
            //cout << v[0] * i * v[1] << " " << v[0] * (v[2] - i) * v[1] << endl;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
	string s[] = {"AAA","AA","A","B","C","D","E","NA"};
	double f[] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0};
	double o[] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};
	double a,b;

	while(cin>>a>>b){
		int lf,lo;
		for(lf=0;a>=f[lf] && lf<7;lf++);
		for(lo=0;b>=o[lo] && lo<7;lo++);

		int level = max(lf,lo);
		cout<<s[level]<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long f[87];
    cin>>n;
    f[0]=2;f[1]=1;
    for(int i=2;i<=n;i++)
    f[i]=f[i-1]+f[i-2];
    cout<<f[n];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <set>
#include <map>
using namespace std;

void solve(vector<string> arr) {
    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */

    int i = 0;
    for (int k = 0; k < 3; k++) {
        int tmp = k;
        for (int j = 1; j <= 3; j++) {
            arr[i][tmp] = arr[i][tmp] == '1' ? '2' : '1';
            tmp+=3;
            i+=1;
        }
    }


    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */
    for (string s : arr) {
        cout << s << endl;
    }

}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    int tot = 0;
    for (int i = 0; i < k; i++){
        tot += arr[i];
    }

    cout << tot << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	if(b>a){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
def grouping():
	s1 = {1, 3, 5, 7, 8, 10, 12}
	s2 = {4, 6, 9, 11}
	s3 = {2}

	s4 = set(map(int, input().split()))

	for s in [s1, s2, s3]:
		if s & s4 == s4:
			print('Yes')
			return 0

	print('No')
	return 0

if __name__ == '__main__':
	grouping()

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskAtcoderHitachiB solver = new TaskAtcoderHitachiB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtcoderHitachiB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), m = in.nextInt();
            int ar[] = new int[a + 1];
            int br[] = new int[b + 1];
            int temp = Integer.MAX_VALUE;
            for (int i = 1; i < a + 1; i++) {
                ar[i] = in.nextInt();
                temp = Math.min(temp, ar[i]);
            }
            long ans = temp;
            temp = Integer.MAX_VALUE;
            for (int i = 1; i < b + 1; i++) {
                br[i] = in.nextInt();
                temp = Math.min(temp, br[i]);
            }
            ans += temp;
            for (int i = 1; i < m + 1; i++) {

                int x = in.nextInt();
                int y = in.nextInt();
                int z = in.nextInt();
                ans = Math.min(ans, ar[x] + br[y] - z);

            }

            out.println(ans);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 56816
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), m = in();
    vector<ll>imos(n + 2, 0);
    REP(i, m) {
        ll l, r; scanf("%lld%lld", &l, &r);
        ++imos[l];
        --imos[r + 1];
    }
    REP(i, n + 1)imos[i + 1] += imos[i];
    ll ans = 0;
    REPC(i, imos)if (i == m)++ans;
    cout << ans << endl;
}

Measured memory_bytes: 1024
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();
    int X = sc.nextInt();
    
    System.out.println(A <= X && A+B >= X ? "YES" : "NO");
  }
}

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

typedef long long LL;

const int N=100005;

int n,m;
LL stack[N],t[N],ans[N],a[N];

int binary(int r,LL k)
{
	int l=1;
	while (l<=r)
	{
		int mid=(l+r)/2;
		if (a[mid]<=k) l=mid+1;
		else r=mid-1;
	}
	return l-1;
}

int main()
{
	scanf("%d%d",&n,&m);
	int top=0;
	stack[++top]=n;
	for (int i=1;i<=m;i++)
	{
		LL x;cin>>x;
		while (x<=stack[top]) top--;
		stack[++top]=x;
	}
	m=top;
	for (int i=1;i<=top;i++) a[i]=stack[i];
	t[m]=1;
	for (int i=m;i>=1;i--)
	{
		LL k=a[i];int p=binary(i-1,k);
		while (p)
		{
			t[p]+=k/a[p]*t[i];
			k%=a[p];
			p=binary(p-1,k);
		}
		ans[k]+=t[i];
	}
	for (int i=n;i>=1;i--) ans[i]+=ans[i+1];
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

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

long int c[2020];
int main(){
    string S;
    cin >> S;
    int N=S.length();
    int i,j;
    long int ans=0;
    long int pow=10;
    long int sum=S[N-1]-'0';
    c[sum]++;
    for(i=1;i<N;i++){
        sum=(sum+(S[N-1-i]-'0')*pow)%2019;
        c[sum]++;
        pow=(pow*10)%2019;
    }
    for(i=1;i<2019;i++)ans+=(c[i]*(c[i]-1))/2;
    ans+=c[0]+(c[0]*(c[0]-1))/2;
    cout << ans << endl;
}

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

enum { N = 40 , A = 10, INF = 10000000 };
int n, ma, mb, sa = 0, sb = 0, sc = 0, mc = INF;
vector<int> a(N + 5), b(N + 5), c(N + 5);
vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(A*N+1, vector<int> (A*N+1, INF)));

void solve() {
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= N * A; j++) {
			for (int k = 0; k <= N * A; k++) {
				if (dp[i][j][k]==INF) continue;
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	solve();
	for (int j = 1; j <= N*A; j++) {
		for (int k = 1; k <= N*A; k++) {
			if (k*ma == j*mb) mc = min(mc, dp[n][j][k]);
		}
	}
	if (mc == INF) mc = -1;
	cout << mc << endl;
	return 0;
}

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

signed main() {
    
    int ans = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    repa(i, 1, n){
        int tmp = 0;
        /* a = 0, z = 25 */
        vector<bool> x(26, false), y(26, false);
        rep(j, i){
            x[s[j]-'a'] = true;
        }
        repa(k, i, n){
            y[s[k]-'a'] = true;
        }
        rep(l, 26){
            if(x[l] && y[l]){
                tmp++;
                // cout << l << " ";
            }
        }
        ans = max(ans, tmp);
        // cout << tmp << endl;
        // rep(t, 26) cout << x[t] << " " << y[t] << "   ";
        // cout << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  while(n--) {
    int runner = 0;
    int score = 0;
    int mask = (1<<3)-1;
    int n_out = 0;
    while(1) {
      string s;
      cin >> s;
      if(s == "HIT") {
        runner = ( (runner<<1) | 1 ) ;
        score += __builtin_popcount(runner & ~mask);
        runner &= mask;
      } else if(s == "HOMERUN") {
        score += __builtin_popcount(runner) + 1;
        runner = 0;
      } else if(s == "OUT") {
        if(++n_out == 3) {
          cout << score << endl;
          break;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1216
// AOJ 0165: Lottery
// 2017.8.15 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>

#define MAX  1000000
#define SQRT 1000     // sqrt(MAX)

char prime[MAX+2], *p, *q, *pmax = prime+MAX;
int table[MAX+2], *t;
char buf[20], *bp;

int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, P, M;
	int k, a, b, ans;

	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2) if (!*p) {
		for (q = p + k; q <= pmax; q += k) *q = 1;
	}
	table[2] = k = 1, t = table+3;
	for (p = prime + 3; p <= pmax; p += 2) {
		if (!*p) k++;
		*t++ = k, *t++ = k;
	}

	while (fgets(bp=buf, 10, stdin) && *buf != '0') {
		n = getint();
		ans = 0;
		while (n--) {
			fgets(bp=buf, 20, stdin);
			P = getint(), bp++, M = getint();
			a = P-M, b = P+M;
			if (a < 2) a = 2;
			if (b > 1000000) b = 1000000;
			ans += table[b] - table[a-1] - 1;
		}
		if (ans < 0) ans = 0;
		printf("%d\n", ans);
	}
	return 0;
}

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

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

  int x[N][D];

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < D; j++) {
      cin >> x[i][j];
    }
  }
  ll sum = 0;
  ll num = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      num = 0;
      for(int k = 0; k < D; k++) {
        num += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for(int l = 1; l <= num; l++) {
        if(l * l == num) sum++;
      }

  }
  }
  cout << sum;


 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,a;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'||s[i]=='1') a+=s[i];
    else if(a.size()>0) a.erase(a.size()-1);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        double b = sc.nextDouble();
        sc.close();

        BigDecimal ans = a.multiply(BigDecimal.valueOf(b));
        System.out.println(ans.longValue());
    }
}


Measured memory_bytes: 37692
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <string, int> psi;

string s;
priority_queue <psi, vector <psi>, greater <psi> > q;
int cnt[5010];
int n;
set <string> all;

void init(){
	n = s.length();
	for (int i = 0; i < n; i++){
		cnt[i] = 1;
		q.push(mp(s.substr(i, cnt[i]), i)), cnt[i]++;
	}
}

string pop(){
	while (all.find(q.top().fi) != all.end()){
		int id = q.top().se;
		if (cnt[id] + id <= s.length()) q.push(mp(s.substr(id, cnt[id]), id)), cnt[id]++;
		q.pop();
	}
	all.insert(q.top().fi);
	string res = q.top().fi;
	int id = q.top().se;
	if (cnt[id] + id <= s.length()) q.push(mp(s.substr(id, cnt[id]), id)), cnt[id]++;
	q.pop();
	return res;
}

int main(){
	cin >> s;
	int k; cin >> k;
	init();
	k--;
	while (k--) pop();
	cout << pop() << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi frist
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}



int main(){
	ll a,v,b,w,t;
	
	cin>>a>>v;
	cin>>b>>w;
	cin>>t;

	if(fabs(a-b)<=(v-w)*t){
		puts("YES");
	}
	else{
		puts("NO");
	}

	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long time = 1;
		while (time * (time + 1) / 2 < x) {
			time++;
		}
		System.out.println(time);
	}
}


Measured memory_bytes: 22100
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int num = 100*r+10*g+b;
    if (num%4==0){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;

void no(){cout << "Impossible" << '\n';}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	deque<int> vec;
	vi odd; vi even;
 	for(int i = 0; i < m; i++)
	{
		int x; cin >> x;
		if(x&1) odd.pb(x);
		else vec.pb(x);
	}
	if(odd.size() > 2)
	{
		no(); return 0;
	}
	if(!odd.empty())
	{
		vec.push_front(odd[0]);
	}
	if(odd.size() >= 2)
	{
		vec.pb(odd[1]);
	}
	
	vi ans;
	for(int i = 0; i < m; i++)
	{
		if(i == 0)
		{
			if(m == 1)
			{
				ans.pb(1);
			}
			if(vec[i] > 1) ans.pb(vec[i] - 1);
		}
		else if(i == m - 1)
		{
			ans.pb(vec[i] + 1);
		}
		else
		{
			ans.pb(vec[i]);
		}
	}
	
	for(int i = 0; i < vec.size(); i++)
	{
		cout << vec[i] << ' ';
	}
	cout << '\n';
	cout << ans.size() << '\n';
	for(int i = 0; i < ans.size(); i++)
	{
		cout << ans[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
#define MAX 100
static const int INFTY=(1<<21);
typedef long long ll;
int n,u;
int M[MAX][MAX];
int d[MAX];
int color[MAX];
void dijkstra(){
    rp(i,n){
        d[i]=INFTY;
        color[i]=0;
    }
    d[0]=0;
    color[0]=1;
    while(1){
        int minv=INFTY;
        rp(i,n){
            if(color[i]!=2&&d[i]<minv){
                minv=d[i];
                u=i;
            }
        }
        if(minv==INFTY)break;
        color[u]=2;
        rp(i,n){
            if(d[u]+M[u][i]<d[i]){
                d[i]=d[u]+M[u][i];
                color[i]=1;
            }
        }

    }
}
int main(){
    int u,k,v,c;
    cin>>n;
    rp(i,n){
        rp(j,n)M[i][j]=INFTY;
        cin>>u>>k;
        rp(j,k){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    dijkstra();
    rp(i,n)cout<<i<<" "<<d[i]<<endl;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        Map<Integer, Integer> dp = new HashMap<>();
        dp.put(0, 0);
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            new HashMap<>(dp).entrySet().stream().filter(entry -> entry.getKey() + a <= w).forEach(entry -> dp.merge(entry.getKey() + a, entry.getValue() + b, Math::max));
        }
        System.out.println(dp.values().stream().mapToInt(Integer::intValue).max().getAsInt());
    }
}

Measured memory_bytes: 33304
#include<cstdio>
#include<cstring>
const int MAXK = 1000;
int a[3 * MAXK + 5][3 * MAXK + 5][2];
int Sum(int x1,int x2,int y1,int y2,int t) {
	return a[x2][y2][t] - a[x1-1][y2][t] - a[x2][y1-1][t] + a[x1-1][y1-1][t];
}
int main() {
	int N, K, Max = 0, cnt = 0;
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) {
		int x, y;char ch;
		scanf("%d%d %c",&x,&y,&ch);
		x = x % (2*K) + 1;y = y % (2*K) + 1;
		if( ch == 'W' ) a[x][y][0]++;
		else a[x][y][1]++;
	}
	for(int i=1;i<=2*K;i++) {
		for(int j=1;j<=2*K;j++) {
			a[i][j][0] += a[i][j-1][0] + a[i-1][j][0] - a[i-1][j-1][0];
			a[i][j][1] += a[i][j-1][1] + a[i-1][j][1] - a[i-1][j-1][1];
		}
	}
	for(int i=1;i<=K+1;i++) {
		for(int j=1;j<=K+1;j++) {
			int ii = i+K-1, jj = j+K-1;
			int cntb = 0, cntw = 0;
			if( i != 1 ) {
				if( j != 1 )
					cntb += Sum(1,i-1,1,j-1,1);
				cntw += Sum(1,i-1,j,jj,0);
				if( j != K+1 )
					cntb += Sum(1,i-1,jj+1,2*K,1);
			}
			if( j != 1 )
				cntw += Sum(i,ii,1,j-1,0);
			cntb += Sum(i,ii,j,jj,1);
			if( j != K+1 )
				cntw += Sum(i,ii,jj+1,2*K,0);
			if( i != K+1 ) {
				if( j != 1 )
					cntb += Sum(ii+1,2*K,1,j-1,1);
				cntw += Sum(ii+1,2*K,j,jj,0);
				if( j != K+1 )
					cntb += Sum(ii+1,2*K,jj+1,2*K,1);
			}
			if( cntw + cntb > Max ) Max = cntw + cntb;
			if( N - cntw - cntb > Max ) Max = N - cntw - cntb;
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 46848
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long 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;
}

ll ex(ll k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll n,m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  ll i, o, t, j, l, s, z;
  cin >> i >> o >> t >> j >> l >> s >> z;

  ll a = 0;
  if (j>0 && l>0 && i>0) {
    a += 3;
    a += (j-1)/2*2 + (l-1)/2*2 + (i-1)/2*2;
  }
  ll b = j/2*2 + l/2*2 + i/2*2;

  cout << o + max(a,b) << endl;
}

Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {
    string a, b; cin >> a >> b;
    lld n = (lld) a.length();
    lld m = (lld) b.length();
    lld i = 0ll, j =0ll;
    while (i<n or j <m) {
    	if (i < n) cout << a[i++];
    	else break;
    	if (j < m) cout << b[j++];
    	else break;
    }
    return;
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    lld T3X0 = 0, T353 = 1;

    // TESTCASES() 
        solveEachTest(T353 - T3X0);
    return 0;
}
// Random Thought :  null  

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

int main(){
	ll a,b,c,k;cin>>a>>b>>c>>k;
	ll ans = 0;
	ans += min(k,a);
	k -= a;
	k -= b;
	if (k > 0)ans -= k;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	if(k%2==1 && a[n-1]<=0){
		ll ans=1;
		for(ll i=n-1;i>=n-k;i--){
			ans = (ans*a[i])%mod;
			if(ans<0) ans = (ans+mod)%mod;
		}
		cout<<ans;
		return 0;
	}
	ll ans=1,i=0,j=n-1;
	if(k%2){
		ans = (ans*a[j])%mod;
		j--;
		k--;
	}
	while(k!=0){
		ll v1 = a[j]*a[j-1],v2 = a[i]*a[i+1];
		//cout<<i<<" "<<j<<"\n";
		if(v1>=v2){
			v1 = v1%mod;
			if(v1<0) v1 = (v1+mod)%mod;
			ans = (ans*v1)%mod;
			j-=2;
		}
		else {
			v2 = v2%mod;
			if(v2<0) v2 = (v2+mod)%mod;
			ans = (ans*v2)%mod;
			i+=2;
		}
		k-=2;
		if(ans<0)ans = (ans+mod)%mod;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 5156
N, Ma, Mb = map(int, input().split())

ABC = []
for _ in range(N):
    a, b, c = map(int, input().split())
    ABC.append((a, b, c))

import sys
INT_MAX = sys.maxsize


drugstores = ABC[:]
drugstores = [(c, a, b) for a,b,c in drugstores]
drugstores = sorted(drugstores)


mix_list = [(0, 0, 0)]

ans = INT_MAX
import heapq
for d_c, d_a, d_b in drugstores:
    for m_c, m_a, m_b in mix_list[:]:
        a = d_a + m_a
        b = d_b + m_b
        c = d_c + m_c
        
        if a * Mb == b * Ma:
            #print(a, b, c)
            ans = min(ans, c)
        elif ans > c:
            heapq.heappush(mix_list, (c, a, b))

if ans == INT_MAX:
    ans = -1
print(ans)
            
            
            
        
    
    




Measured memory_bytes: 9492
a=[list(map(int,input().split())) for k in range(0,3)]
n=int(input())
b=[0]*n
bingo=0
for k in range(0,n):
  b[k]=int(input())

for k in range(0,n):
  for i in range(0,3):
    for j in range(0,3):
      if a[i][j]==b[k]:
        a[i][j]=0
for k in range(0,3):
  if (a[k][0]==0)and(a[k][1]==0)and(a[k][2]==0):
    bingo=bingo+1
for k in range(0,3):
  if (a[0][k]==0)and(a[1][k]==0)and(a[2][k]==0):
    bingo=bingo+1   
if (a[0][0]==0)and(a[1][1]==0)and(a[2][2]==0):
  bingo=bingo+1 
  
if (a[2][0]==0)and(a[1][1]==0)and(a[2][0]==0):
  bingo=bingo+1
if bingo>0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long H, long long W, long long h, long long w){
    cout << (H-h)*(W-w)<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int> p(n);
	rep(i, n) cin >> p[i];

	sort(p.begin(), p.end());

	int x = 0, y = 0, z = 0;

	for (int i = 0; i < n; i++) {
		if (p[i] <= a) {
			x++;
		}
		else if (p[i] <= b) {
			y++;
		}
		else {
			z++;
		}
	}

	if (x == 0 || y == 0 || z == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << min(x, min(y, z)) << endl;
	return 0;
}

Measured memory_bytes: 256
//A,Elebereth,Gilthoniel mantae!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
string s;int dp[200008]; 
vector<int> v[30];int ui[28][200008];
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{for(int j=0;j<26;j++)ui[j][i]=v[j].size();
		v[s[i]-'a'].push_back(i);dp[i]=1234578;
	}
	dp[s.size()]=1265478;
	for(int i=s.size()-1;i>-1;i--)
	{
		for(int j=0;j<26;j++)
		{
			if(ui[j][i]>=v[j].size()) {dp[i]=1;break;}
			dp[i]=min(dp[i],dp[v[j][ui[j][i]]+1]+1);
		}
	};
	string y="";
	for(int i=0;i<s.size();)
	{
		for(int j=0;j<26;j++)
		{
			if(ui[j][i]>=v[j].size()) 
			{
				cout<<char(j+'a');i=s.size();break;
			}
			if(dp[i]==dp[v[j][ui[j][i]]+1]+1) 
			{
				cout<<char(j+'a');i=v[j][ui[j][i]]+1;break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 24068
As = [ int(i) for i in input('').split()]
#As = "2 6 3"
#As = [ int(i) for i in As.split()]

As.sort()
As.reverse()

o = 0
diff = As[0] - As[1]
div, mod = divmod(diff,2)
o += div

if mod == 1:
    As[2] += 1
    o += 1

diff = As[0] - As[2]
div, mod = divmod(diff,2)
o += div
if mod == 1:
    o += 1
    o += mod
print(o)


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    char before[100003] = {};
    ll ans = 0;
    rep(i,N) {
        if(i<K) {
            if(T[i] == 'r') ans += P;
            else if (T[i] == 's') ans += R;
            else if (T[i] == 'p') ans += S;
            before[i] = T[i];
        } else {
            if(T[i] == 'r' && before[i%K] != 'r') {
                ans += P;
                before[i%K] = 'r';
            } else if (T[i] == 's' && before[i%K] != 's') {
                ans += R;
                before[i%K] = 's';
            } else if (T[i] == 'p' && before[i%K] != 'p') {
                ans += S;
                before[i%K] = 'p';
            } else {
                before[i%K] = '0';
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#define fst first
#define snd second

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);

  int n;
  cin >> n;
  for(int i = 0; i < 50; i++){
    if(4 * i <= n && (n - 4 * i) % 7 == 0){
      cout << "Yes\n"; return 0;
    }
  }
  cout << "No\n";
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define MOD 1e9+7

int main(void){
    int n;
    cin >> n;
    rep1(i,10){
        if(n <= 111*i){
            cout << 111*i <<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 384
A, B, C, X, Y = map(int, raw_input().split())

#print A, B, C, X, Y

currentX = X
currentY = Y
currentH = 0

#print cost_A, cost_B
while (currentX>0)or(currentY>0):
    if currentX > 0:
        tmpX = currentX - 1
    if currentY > 0:
        tmpY = currentY - 1
    if ((tmpX * A) +(tmpY * B) +((currentH + 2) * C)) < ((currentX * A) +(currentY * B) +((currentH) * C)):
        if currentX > 0:
            currentX -= 1
        if currentY > 0:
            currentY -= 1
        currentH += 2
    else:
        break

#print ((currentX * A) +(currentY * B) +((currentH) * C)),currentX, currentY, currentH
print ((currentX * A) +(currentY * B) +((currentH) * C))


Measured memory_bytes: 2568
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; // assert(a[i]<n ) // if we want to check for special cond , used for debug                     
using namespace __gnu_pbds; // make less_equal in order to make a multiset pbds
#define INF (ll)1e18 
const ll Mod = (ll)1e9+7;
ll CaseN=1;
const ld PI = 22/7.0;


ll tst()
{
ll ans=0;

return ans;
}

void solve()
{
	ll h,w,m;
	cin>>h>>w>>m;
	
	ll a[h+2],b[w+2];
	ll ans=0;
	set<pair<ll,ll>> ss;
	
	for(ll i=1;i<=h;i++)
	a[i]=0;
	for(ll i=1;i<=w;i++)
	b[i]=0;
	
	for(ll i=1;i<=m;i++)
	{
	ll u,v;
	cin>>u>>v;
	ss.insert({u,v});
	a[u]++;
	b[v]++;
	}
	
	// binary
	//sort(a+1,a+1+h);
	//sort(b+1,b+1+w);
	vector<pair<ll,ll>> v1,v2;
	
	
	//for(ll i=1;i<=h;i++)
	//cout<<a[i]<<" ";
	//cout<<endl;
	//for(ll i=1;i<=w;i++)
	//cout<<b[i]<<" ";
	//cout<<endl;
	
	for(ll i=1;i<=h;i++)
	{
	v1.push_back({a[i],i});	
	}
	for(ll i=1;i<=w;i++)
	{
	v2.push_back({b[i],i});	
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	
	ll i=h-1;
	ll j=w-1;
	ans = 0;
	while(i>=0 && j>=0)
	{ 
	ll mm = v1[i].first+v2[j].first ;
	//cout<<mm<<" + "<<endl;
	if(ss.find({v1[i].second,v2[j].second})!=ss.end())
	{
	mm--;
	//cerr<<"ye"<<endl;
	if(v1[i].first>v2[j].first)
	{
	j--;	
	}
	else
	{
	i--;	
	}
	ans = max(ans,mm);	
	}
	else
	{
	ans = max(ans,mm);
	break;	
	}
	
	}
		
	
	cout<<ans<<endl;
	//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
	
return ;

}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	}
	
}


Measured memory_bytes: 43688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << "\n";
}

Measured memory_bytes: 256
class Node():
    def __init__(self, p, l, r, deg):
        self.parent = p
        self.left = l
        self.right = r
        self.deg = deg

def GetDepth(T, u):
    d = 0
    while T[u].parent != -1:
        u = T[u].parent
        d += 1
    return d

def SetDepth(D, T, u, p):
    D[u] = p
    if T[u].right != -1:
        SetDepth(D, T, T[u].right, p)
    if T[u].left != -1:
        SetDepth(D, T, T[u].left, p + 1)

def GetChildren(T, u):
    children = list()
    c = T[u].left
    while c != -1:
        children.append(str(c))
        c = T[c].right
    
    return children

def Main():

    n = int(input())

    T = [Node(-1, -1, -1, 0) for i in range(n)]
    D = [0]*n

    for i in range(n):
        node_id, k, *children = map(int, input().split())
        T[node_id].deg = k

        if k > 0 :
            T[node_id].left = children[0]

            for i in range(k):
                T[children[i]].parent = node_id
                
                if i + 1 <= k - 1:
                    T[children[i]].right = children[i + 1]

    for i in range(len(T)):
        D[i] = GetDepth(T, i)

    for i in range(len(T)):
        t = T[i]
        node_type = ""

        if t.parent == -1:
            node_type = "root"
        elif t.deg == 0:
            node_type = "leaf"
        else:
            node_type = "internal node"

        print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, t.parent, D[i], node_type, "[" + ", ".join(GetChildren(T, i)) + "]"))

Main()


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

using namespace std;

typedef long long Int;

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

int main(){
  int N;
  cin >> N;
  double ans = 0;
  rep(i, N) {
    double x;
    string y;
    cin >> x >> y;
    if (y == "JPY") ans += x;
    else ans += x*380000.0;
  }
  printf("%.9f", ans);
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9
typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef long long ll;

#define mx 0
int main() {
   	ios_base::sync_with_stdio(0);cin.tie(NULL);
   	//Solution
   	int n, m, k;
   	cin >> n >> m >> k;
   	for (int i = 0; i <= n; ++i){
   		for (int j = 0; j <= m; ++j){
   			ll sum = n*j + m*i - 2*i*j;
   			if( sum == k){
   				cout << "Yes" << endl;
   				return 0;
   			}
   		}
   	}
   
   	cout << "No" << endl;
   	
   	return 0;
}
 
 
//g++-4.9 code_festival_2017_quala_b.cpp -o code_festival_2017_quala_b && ./code_festival_2017_quala_b < code_festival_2017_quala_b.in > code_festival_2017_quala_b.out
 
 
 
 
 

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

int main() {
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> At(N);
    At[0] = A[0]; for (int i = 1; i < N; i++) At[i] = At[i-1] + A[i];

    vector<ll> B(M); 
    for (int i = 0; i < M; i++) cin >> B[i];
    vector<ll> Bt(M);
    Bt[0] = B[0]; for (int i = 1; i < M; i++) Bt[i] = Bt[i-1] + B[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (K >= At[i]) {
            int ok = -1, ng = M, mid;
            while (ng - ok > 1) {
                mid = (ok + ng) / 2;
                if (At[i] + Bt[mid] > K) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            }
            ans = max(ans, i + ok + 2);
        } else {
            break;
        }
    }
    for (int i = 0; i < M; i++) {
        if (K >= Bt[i]) {
            int ok = -1, ng = N-1, mid;
            while (ng - ok > 1) {
                mid = (ng + ok) / 2;
                if (At[mid] + Bt[i] > K) {
                    ng = mid;
                } else {
                    ok = mid;
                }
            }
            ans = max(ans, i + ok + 2);
        } else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
int main(){
	ll N,M;
	cin >> N >> M;

	ll ans = 0;
	if(N * 2 <= M){
		ans = N + (M - N * 2) /4;

	}
	else{
		ans = M / 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/*
	 *	...*....**
	 *	..........
	 *	**....**..
	 *	........*.
	 *	..*.......
	 *	..........
	 *	.*........
	 *	..........
	 *	....*..***
	 *	.*....*...
	 */

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

		while (true) {
			final int N = sc.nextInt();

			if (N == 0) {
				break;
			}

			boolean[][] is_wall = new boolean[N][N];

			for (int i = 0; i < N; i++) {
				char[] str = sc.next().toCharArray();

				for (int j = 0; j < N; j++) {
					is_wall[i][j] = str[j] == '*';
				}
			}

			int max = 0;
			
			int[][] dp = new int[N][N];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					if(is_wall[i][j]){
						dp[i][j] = 0;
						continue;
					}
					
					if(i == 0 && j == 0){
						dp[i][j] = 1;
					}else if(i == 0){
						dp[i][j] = 1;
					}else if(j == 0){
						dp[i][j] = 1;
					}else{
						if(!is_wall[i-1][j] && !is_wall[i][j-1] && !is_wall[i-1][j-1]){
							dp[i][j] = Math.min(Math.min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]) + 1;
						}else{
							dp[i][j] = 1;
						}
					}
					
					max = Math.max(max, dp[i][j]);
				}
			}
			
			
			System.out.println(max);

		}

	}

}

Measured memory_bytes: 21000
s = list(input())
t = list(input())

if(t in s):
    print(0)

result = [0] * ((len(s) - len(t)) + 1)
for i in range(len(s) - len(t) + 1):
    result[i] = len(t)
    for j in range(len(t)):
        if(s[i+j] == t[j]):
            result[i] -= 1
 
print(min(result))


Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll A, B, K; cin >> A >> B >> K;
    ll i = min(A, B) + 1;
    while (K > 0) {
        i--;
        if (A % i == 0 && B % i == 0) {
            K--;
        }
    }
    cout << i << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

string convert(string s)
{
    while(s.size()<8) s="0"+s;
    string ret="";
    rep(i,s.size())
    {
        int num=s[i]-'0';
        if('a'<=s[i] && s[i]<='f') num=s[i]-'a'+10;
        int a=8;
        rep(j,4)
        {
            if(num>=a)
            {
                num-=a;
                ret+="1";
            }
            else ret+="0";
            a/=2;
        }
    }
    return ret;
}

int main()
{
    ll pw[32];
    pw[0]=1;
    for(int i=1; i<32; ++i) pw[i]=pw[i-1]*2;

    int T;
    cin >>T;
    while(T--)
    {
        vector<string> s(9);
        rep(i,9)
        {
            string tmp;
            cin >>tmp;
            s[i]=convert(tmp);
        }

        string key(32,'u');
        vector<int> carry(32,0);

        for(int i=31; i>=0; --i)
        {
            int a=0;
            rep(j,8) a+=s[j][i]-'0';

            int b=a+carry[i];

            if(b%2==s[8][i]-'0') key[i]='0';
            else
            {
                key[i]='1';
                b=8-a+carry[i];
            }

            if(b%2==1) --b;

            for(int j=30; j>0; --j)
            {
                if(b<pw[j]) continue;

                b-=pw[j];
                if(i-j>=0) ++carry[i-j];
            }
        }

        ll ans=0;
        rep(i,32)
        {
            if(key[i]=='1') ans+=pw[31-i];
        }
        printf("%llx\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,flag;
  cin >> n;
  flag = 0;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)%2==0){
      if(a.at(i)%3!=0&&a.at(i)%5!=0){
        flag+=1;
      }
    }
  }
  if(flag==0){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val p = io.StdIn.readLine.split(" ").map(_.toInt)

  var c = 0
  for(i <- 0 to p.length - 2; if /*p(i) >= p(i + 1)*/p(i) != i + 1) c += 1
//条件が違っていた, p(i) != i で カウントを増やし 2まで許容する
  if(/*c < 2*/c < 3){
    println("YES")
  }else{
    println("NO")
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,0,n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  rep(i,0,n-2) rep(j,i+1,n-1) rep(k,j+1,n) {
    if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
    if (l[i] + l[j] > l[k]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

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

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

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

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    map<int, set<int>> ma;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        ma[x].insert(y);
    }

    int ans = h, left = 1, right = 1;
    for (int x = 2; x <= h; x++) {
        if (ma.find(x) == ma.end()) right = min(right + 1, w);
        else {
            int first = *ma[x].begin();
            if (left <= first && first <= right) {
                cmin(ans, x - 1);
                break;
            }
            if (first != right + 1) right = min(right + 1, w);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 28416