akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std; 

int main(){
        string str;
    cin >> str;
    bool a(false),b(false);
    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'C')
            a = true;
        if(a && str[i] == 'F' )
            b = true;
    }
    if(a & b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
 
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char str1[3],str2[3];
  
  scanf("%s",str1);
  scanf("%s",str2);
  
  int ans=0;
  
  for(int i =0; i<3;i++){
    if(str1[i]==str2[i]){
      ans++;
    }
  }
  
  printf("%d",ans);
  
  return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(3*N);
    for(auto &in:a)cin >> in;
    sort(a.begin(),a.end());
    ll res = 0;
    for(int i = 0; i < N; i++){
        res += a[3*N - 2*(i+1)];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int sum=0;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
        sum+=w[i];
    }
    int mini=1e8;
    for(int i=0;i<n;i++){
        int r=0,l=sum;
        for(int j=0;j<i;j++){
            r+=w[j];
            l-=w[j];
        }
    mini=min(mini,abs(r-l));
    }
    cout<<mini<<endl;
}

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

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

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

    cout << "NG" << endl;


    return 0;
}

Measured memory_bytes: 3636
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 ans = a * b;
		System.out.println(a < 10 && b < 10 ? ans : -1);
	}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    long K;
    cin >> K;
    int cnt = 0;
    while(S[cnt] == '1'){
        cnt++;
    }
    if(K <= cnt) cout << 1 << endl;
    else cout << S[cnt] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    double v[50];
    for(int i=0;i<n;i++)cin >> v[i];
    sort(v,v+n,greater<int>());
    double sum = 0;
    for(int i=0;i<n-1;i++){
        sum += v[i]/pow(2,i+1);
    }
  sum += v[n-1]/pow(2,n-1);
cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char S[10] = {};
  int i, j, k;
  scanf("%s", S);
  if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void){
    // Your code here!
    char str[3][11];
    
    scanf("%10s%10s%10s",str[0],str[1],str[2]);
    
    if(str[0][strlen(str[0])-1] == str[1][0]){
        if(str[1][strlen(str[1])-1] == str[2][0]){
            printf("YES\n");
            return 0;
        }
    }
    
    printf("NO\n");
    
}


Measured memory_bytes: 128
import math
K =int(input())
L = [0 for _ in range(K)]
for a in range(1,K+1):
  for b in range(1,K+1):
    L[math.gcd(a,b)-1] +=1
s = 0
for c in range(1,K+1):
    for k in range(K):
        for _ in range(L[k]):
            s += math.gcd(c,k+1)
print(s)

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

using namespace std;
using ll = long long;

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

int main() {
  int x;
  cin >> x;
  int ans = 0;
  if (x <= 599)
    ans = 8;
  else if (x <= 799)
    ans = 7;
  else if (x <= 999)
    ans = 6;
  else if (x <= 1199)
    ans = 5;
  else if (x <= 1399)
    ans = 4;
  else if (x <= 1599)
    ans = 3;
  else if (x <= 1799)
    ans = 2;
  else if (x <= 1999)
    ans = 1;

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


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

namespace AtCoder
{
    public class AAddtion
    {
        public static void Main(string[] args)
        {
            new AAddtion().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var d = cin.ReadInt;

            var ans = n%(2*d+1) == 0? n/(2*d+1) : n/(2*d+1)+1;

            WriteLine(ans);
        }
    }
}
public class ConsoleInput
{
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
        this._separator = separator;
        this._stream = stream;
        inputStream = new Queue<string>();
    }
    public string Read
    {
        get
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(_separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
}

Measured memory_bytes: 11220
from sys import stdin

n, k = list(map(int, stdin.readline().split()))
ax = [0]*100001
c = 0
j = 0

for i in range(n):
    a, b = list(map(int, stdin.readline().split()))
    ax[a] += b

while c < k:
    c += ax[j]
    j += 1

print(j-1)


Measured memory_bytes: 5876
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC058_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String O = in.next();
            String E = in.next();
            int len = O.length() + E.length();
            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < len; ++i) {
                if ((i + 1) % 2 == 0) {
                    ans.append(E.charAt(i / 2));
                } else {
                    ans.append(O.charAt(i / 2));
                }
            }
            out.println(ans);
        }

    }
}



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

#define ll long long

using namespace std;

int main(void){
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll A = 1; A <= N; A++){
        for(ll B = 1; A * B <= N; B++){
            if(A * B < N) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i!=0)printf(" ");
  }
  printf("\n");
  return 0;
}

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

struct Edge{
    int from,to;
    Weight weight;
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

Weight INF=1e9+7;
vector<Weight> Dijkstra(int s,const Graph& g){
    int n=g.size();
    vector<Weight> res(n,INF);
    vector<int> used(n,0);
    res[s]=0;
    priority_queue<pair<Weight,int>,vector<pair<Weight,int>>,greater<>> que;
    que.push({Weight(0),s});
    while(!que.empty()){
        auto p=que.top(); que.pop();
        Weight dist=p.first;
        int v=p.second;
        if(used[v]) continue;
        used[v]=true;
        for(int i=0;i<g[v].size();i++){
            int tdist=dist+g[v][i].weight;
            if(tdist<res[g[v][i].to]){
                res[g[v][i].to]=tdist;
                que.push({tdist,g[v][i].to});
            }
        }
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            Edge e;
            e.from=u;
            cin>>e.to>>e.weight;
            g[u].push_back(e);
        }
    }
    auto d=Dijkstra(0,g);
    for(int i=0;i<n;i++){
        cout<<i<<" "<<d[i]<<endl;
    }

    return 0;
}

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

int main(){
    int n,k;
    long ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }

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

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

Measured memory_bytes: 3632
using System;

namespace SimpleCalculator
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true) {
				int answer = 0;
				string input = Console.ReadLine ();

				char[] CharSeparators = new char[] { ' ' };
				string[] array = input.Split (CharSeparators);

				string array1 = array [0];
				string array2 = array [1];
				string array3 = array [2];

				int a = int.Parse (array1);
				String op = array2;
				int b = int.Parse (array3);

				if(op.Equals("?")){
					break;
				}else if(op.Equals("+")){
					answer=a+b;Console.WriteLine(answer);
				}else if(op.Equals("-")){
					answer=a-b;Console.WriteLine(answer);
				}else if(op.Equals("*")){
					answer=a*b;Console.WriteLine(answer);
				}else if(op.Equals("/")){
					answer=a/b;Console.WriteLine(answer);
				}
			}
		}
	}
}

Measured memory_bytes: 5612
#include<stdio.h>
int main(){
  int n,i,d[100010],s=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<n;i++){
    if(d[i]==i+1){
      d[i+1]=d[i];
      s++;
    }
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 640
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 K = sc.nextInt();
    String ans = "No";
    for(int i = 0; i < K; i++) {
    	if(!(A < B)) {
    		B *=2;
    	}
    	else if(!(B < C)) {
    		C *= 2;
    	}
    	if(A < B && B < C) {
    		ans = "Yes";
    		break;
    	}
    }
    
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 35692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 6e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int pre[n + 5][k + 5] = {};
    int suf[n + 5][k + 5] = {};
    int v[n + 5] = {};
    pre[0][0] = 1;
    suf[n+1][0] = 1;
    for(int i = 1 ; i <= n ; i++) {
        cin >> v[i];
    }
    for (int i = 1 ; i <= n ; i++) {
        for (int j = 0 ; j <= k ; j++) {
            if (pre[i - 1][j]) {
                pre[i][j] = 1;
            }
            if (j >= v[i] && pre[i - 1][j - v[i]]) {
                pre[i][j] = 1;
            } 
        }
    }
    for (int i = n ; i >= 1 ; i--) {
        for (int j = 0 ; j <= k ; j++) {
            if (suf[i + 1][j]) {
                suf[i][j] = 1;
            }
            if (j >= v[i] && suf[i + 1][j - v[i]]) {
                suf[i][j] = 1;
            } 
        }
    }
    for (int i = n + 1 ; i >= 1 ; i--) {
        for (int j = 1 ; j <= k ; j++) {
            suf[i][j] += suf[i][j-1];
        }
    }
    int ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        int lb = max(k - v[i], 0);
        int ub = k - 1;
        for (int j = 0 ; j < k ; j++) {
            if (pre[i - 1][j] == 0)continue;
            int rlb = max(lb - j,0);
            int rub = ub - j;
            int cnt = 0;
            if (rlb == 0) {
                cnt = suf[i+1][rub];
            }
            else {
                cnt = suf[i+1][rub] - suf[i+1][rlb-1];
            }
            if (cnt) {
                ans++;
                break;
            }
        }
    }
    cout << n - ans << '\n';

}

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

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

    vector<int> sweets(N);
    for(int i = 0; i < N; i++){
        cin >> sweets.at(i);
    }

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

    int ans = 0;

    for(int i = 0; i < N; i++){
        x -= sweets.at(i);
        if(x >= 0){
            if(x > 0 && i == N - 1) break;
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
p = list(map(int, input().split()))
length = 0
ans = 0
for i in range(N):
    if p[i] == i+1:
        length += 1
    else:
        if length == 0:
            ans += 0
            length = 0
        if length  >= 2:
            ans += math.floor((length+1) / 2)
            length = 0
        if length == 1:
            ans += 1
            length = 0

if length != 0:
    if length >= 2:
        ans += math.floor((length + 1) / 2)
        length = 0
    if length == 1:
        ans += 1
        length = 0

print(ans)

Measured memory_bytes: 13812
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,tmp,cnt=0;
  vector <int> a,spread;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  for(int i=0,tmp=1;tmp<=n;i++){
    spread.insert(spread.begin(),tmp);
    tmp=3*tmp+1;
  }
  m=spread.size();
  cout<<m<<endl;
  for(int i=0;i<m-1;i++) cout<<spread[i]<<" ";
  cout<<spread[m-1]<<endl;
  for(int k=0;k<m;k++) for(int i=0;i+spread[k]<n;i++){
      int end=i+spread[k],first=i%spread[k];
        if(a[end]>a[end-spread[k]]) continue;
        int l;
        for(l=1;l<(end-first)/spread[k]+1;l++){
          if(a[end-(l-1)*spread[k]]<a[end-l*spread[k]]){
            swap(a[end-(l-1)*spread[k]],a[end-l*spread[k]]);
            cnt++;
          } else break;
        }
    }
  cout<<cnt<<endl;
  for(int i=0;i<n;i++) cout<<a[i]<<endl;
  return 0;
}


Measured memory_bytes: 7068
#include<cstdio>
int v[100001];
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x>n){
			ans++;
		}else{
			v[x]++;
		}
	}
	for(int i=1;i<=n;i++){
		if(v[i]<i){
			ans+=v[i];
		}else if(v[i]>i){
			ans+=v[i]-i;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int[][][] x = new int[N][][];
		for(int i=0;i<N;i++){
			x[i]=new int[nextInt()][];
			for(int k=0;k<x[i].length;k++){
				x[i][k]=nextInts();
			}
		}
		int ans = 0;
		for(int i=1;i<1<<N;i++){
			int[] p = new int[N];
			Arrays.fill(p, 0);
			int cnt=0;
			for(int k=0;k<N;k++){
				if((i>>k&1)==1){
					p[k]=1;
					cnt++;
				}
			}
			boolean flg = true;
			for(int k=0;k<N;k++){
				if(p[k]==1){
					for(int j=0;j<x[k].length;j++){
						if(p[x[k][j][0]-1]!=x[k][j][1]){
							flg=false;
							break;
						}
					}
				}
				if(flg==false){
					break;
				}
			}
			if(flg){
				ans=Math.max(cnt,ans);
			}
		}
		System.out.println(ans);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

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

	ll A,B,M;
	cin>>A>>B>>M;

	vector<ll>a; //prices of all refreigerators
	vector<ll>b; //prices of all microwaves

	for(ll i = 0;i<A;i++)
	{
		ll inp;
		cin>>inp;
		a.push_back(inp);
	}

	for(ll i = 0;i<B;i++)
	{
		ll inp;
		cin>>inp;
		b.push_back(inp);
	}

	ll cheap_ref = *min_element(a.begin(),a.end());
	ll cheap_mw = *min_element(a.begin(),a.end());

	ll no_dis_price = cheap_mw + cheap_ref; 

	vector<ll>prices; //prices after discount;

	for(ll i = 0;i<M;i++)
	{
		ll x_inp,y_inp,c;
		cin>>x_inp>>y_inp>>c;

		x_inp = x_inp - 1;
		y_inp = y_inp - 1;

		ll x_price = a[x_inp];
		ll y_price = b[y_inp];

		prices.push_back(x_price+y_price-c);
	}

	ll min_dis_price = *min_element(prices.begin(),prices.end());

	ll final_price = (no_dis_price>min_dis_price)?min_dis_price:no_dis_price;

	cout<<final_price<<endl;

	return 0;
}

Measured memory_bytes: 3316
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, X);
    IN(ll, T);
    OUT(((N + X - 1) / X) * T);
}

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);
#define ft first
#define sd second
#define all(v) (v.begin(),v.end())
#define vll vector<ll> 
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back
#define show(x) cout<<#x<<" "<<x<<endl;

void solve()
{
	ll a,b,c,k,ans;
	cin>>a>>b>>c>>k;
	if(k<=a)
		ans=k;
	else if(k>a && k<=a+b)
		ans=a;
	else if(k>a+b)
		ans=a-(k-(a+b));
	cout<<ans<<endl;
}

int main()
{
	fastio();

	ll T=1;	//cin>>T;
	while(T--) solve();
	
	//check_time();
	return 0;   
}   



Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int board[102][102];
int accum[102][102];
int accum2[102][102];

inline int readint(){
    int ret = 0, x;
    bool plus = true;
    while(x=getchar(), !('0'<=x&&x<='9' || x=='-'));
    if(x=='-') plus = false;
    else ret = (x&15);
    while(x=getchar(), '0'<=x&&x<='9') ret = (ret<<3) + (ret<<1) + (x&15);
    return plus?ret:-ret;
}

int main(){
    int w, h, s, t, n;
    int i, j;
    while(n = readint(), n){
        w = readint();
        h = readint();
        REP(i,h)REP(j,w) board[i][j] = 0;
        REP(i,h-t)REP(j,w-s) accum[i][j] = 0;
        REP(i,h-t)REP(j,w-s) accum2[i][j] = 0;

        REP(i,n){
            int x = readint()-1, y = readint()-1;
            board[y][x] = 1;
        }

        s = readint();
        t = readint();

        REP(i,h){
            int sum = accumulate(board[i],board[i]+s,0);
            accum[i][0] = sum;
            REP(j,w-s){
                accum[i][j+1] = accum[i][j] - board[i][j] + board[i][j+s];
            }
        }

        REP(j,w-s+1){
            int sum = 0;
            REP(i,t) sum += accum[i][j];
            accum2[0][j] = sum;
            REP(i,h-t){
                accum2[i+1][j] = accum2[i][j] - accum[i][j] + accum[i+t][j];
            }
        }

        int ans = 0;
        REP(i,h-t+1)REP(j,w-s+1) ans = max(ans, accum2[i][j]);

        printf("%d\n",ans);
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  int left = d[N/2-1];
  int right = d[N/2];
  int ans = right - left;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int N,m,s,temp,l,i,j,p,a[10],k;
	char c[101];
	
	scanf("%d",&N);
	
	while(N > 0){
		for(i = 0; i < N; i++){
			a[i] = 0;
		}
		k = 0;            //??´
		scanf("%s",&c);  //???????????????
		p = 0;
		for(i = 0; i < 100; i++){
			if('M' == c[i])
				a[p]++;
			else if('S' == c[i]){
				a[p]++;
				k = k + a[p];
				a[p] = 0;
			}
			else{
				a[p]++;
				a[p] = a[p]+k;
				k = 0;
			}
			p++;
			if(p == N)
				p = 0;
		}
		for(i = 0; i < N; i++){
			for(j = N-1; j > i; j--){
				if(a[i] > a[j]){
					temp = a[i];
					a[i] = a[j];
					a[j] = temp;
				}
			}
		}
		for(i = 0; i < N; i++){
			printf("%d ",a[i]);
		}
			printf("%d\n",k);
		scanf("%d",&N);
	}
	return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
const double er=1e-10;
LL n;
double a,b;
int main()
{
	int i,j;
	double k;
	scanf("%d",&n);
	for (i=1;i<=3500;i++)
	  for (j=1;j<=3500;j++)
	  {
	  	if (4*i*j-n*(i+j)<=0)  continue;
	  	k=(double)(n*i*j)/(double)(4*i*j-n*(i+j));
	  	if ((n*i*j)%(4*i*j-n*(i+j))==0&&k<=3500)
	  	{
	  	  printf("%d %d %d",i,j,(int)(k+0.5));
	  	  return 0;
	    }
	  }
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0){
        cout<<0<<endl;
        return 0;
    }
    ll q = n/(a+b);
    ll r = n%(a+b);
    if(r==0)cout<<q*a<<endl;
    else{
        ll ans = q*a;
        ll ans1 = min(r,a);
        cout<<ans+ans1<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
//Created Time:2019年09月28日 星期六 20时04分04秒
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[1000006];

int main(){
	int n, k, cnt = 0; cin >> n >> k;
	for(int i = 1; i <= n; ++i){
		int x; scanf("%d", &x);
		if(x >= k) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int total[1001];
int correct[1001];
int X[1000000];
int Y[1000000];
char C[1000000];
int main()
{
    int n,k;
    cin>>n>>k;
    for (int i=0;i<n;i++)
        cin>>X[i]>>Y[i]>>C[i];
    int ans=0;
    for (int i=1;i<=k;i++)
    {
        // (0,0) is in the ith column and first row of a white square.
        int cur=0;
        for (int j=1;j<=k;j++)
            total[j]=correct[j]=0;
        for (int j=0;j<n;j++)
        {
            int x=X[j],y=Y[j];
            if (x<=k-i)
            {
                if (y==0) //white
                {
                    total[1]++;
                    if (C[j]=='W')
                        correct[1]++,cur++;
                }
                else
                {
                    y--;
                    int need = k-(y%k);
                    if ((y/k)%2==0) //black
                    {
                        total[need]++;
                        if (C[j]=='B')
                            correct[need]++,cur++;
                    }
                    else //white
                    {
                        total[need]++;
                        if (C[j]=='W')
                            correct[need]++,cur++;
                    }
                }
            }
            else
            {
                x-=(k-i+1);
                y+=k-1;
                int Xswap = (x/k)%2;
                int Yswap = (y/k)%2;
                int need=k-(y%k);
                total[need]++;
                if ((Xswap^Yswap)==0) //black
                {
                    if (C[j]=='B')
                        correct[need]++,cur++;
                }
                else //white
                {
                    if (C[j]=='W')
                        correct[need]++,cur++;
                }
            }
        }
        ans=max(ans,max(cur,n-cur));
        for (int j=1;j<=k;j++)
        {
            cur-=correct[j];
            cur+=total[j]-correct[j];
            ans=max(ans,max(cur,n-cur));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2816
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std ;

#define MAXN 27

int n ;
int a[ MAXN ] ;
int b[ MAXN ] ;
int c[ MAXN ] ;

void input ( ) {
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &b[ i ] ) ;
    }
    for ( int i = 1 ; i < n ; ++ i ) {
        scanf ( "%d" , &c[ i ] ) ;
    }
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        ans += b[ i ] ;
    }
    for ( int i = 1 ; i < n ; ++ i ) {
        if ( a[ i ] == a[ i + 1 ] - 1 ) {
            ans += c[ a[ i ] ] ;
        }
    }
    printf ( "%d\n" , ans ) ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 256
s=input()
while 1:
    if s[-5:]=="dream":s=s[:-5]
    elif s[-7:]=="dreamer":s=s[:-7]
    elif s[-5:]=="erase":s=s[:-5]
    elif s[-6:]=="eraser":s=s[:-6]
    else:break
print(["NO","YES"][s==""])

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

using namespace std;

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

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

    int aa = a, bb = b;
    while (b != 0) {
        int c = a % b;
        a = b, b = c;
    }

    cout << (long long) aa / a * bb;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll m, n; cin >> m >> n;
    co(modpow(m, n, MOD));

    return 0;
}



Measured memory_bytes: 3112
n = int(input())
s = input()
MOD = 10 ** 9 + 7

ans = 1
for i in range(2, n + 1):
    ans = ans * i % MOD
pending = 0
for i, c in enumerate(s):
    if (i % 2 == 0 and c == 'B') or (i % 2 == 1 and c == 'W'):
        pending += 1
        continue
    ans = ans * pending % MOD
    pending -= 1
if pending != 0:
    ans = 0
print(ans)


Measured memory_bytes: 3572
#include <stdio.h>

void Sort(int array[],int n)
{
    int i,j,temp;

    for (i = 0;i < n - 1;i++) {
        for (j = 0;j < n - 1;j++) {
            if (array[j + 1] < array[j]) {
                temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;
            }
        }
    }
}

int main()
{


    int i, ara[10], max1=0,max2=1,max3=2;
    for(i=0;i<10;i++){
        scanf("%d",&ara[i]);
    }
    Sort(ara,10);
    printf("%d\n%d\n%d\n",ara[9],ara[8],ara[7]);
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		//たこ焼き数
		int N = scan.nextInt();

		//たこ焼き美味しさ　di入力
		int[] d = new int[N];
		for (int i=0; i<N;i++) {
			d[i] = scan.nextInt();
		}

		//総和 初期化
		int total = 0;
		int tmp_total = 0;

		//総和 算出
		for (int i=0; i<N-1; i++){
			tmp_total =0;
			for (int j=i+1; j< N; j++){
				tmp_total = tmp_total + d[j];
			}
			total = total + d[i]*tmp_total;
		}
		System.out.println(total );
	}

}


Measured memory_bytes: 27096
/*****And nothing else matters!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 3e5 + 10;

int main()
{
    fast;
    string s, t;
    cin >> s >> t;
    int ans = inf;

    f(i,0,sz(s)-sz(t)+1)
    {
        int cur = 0;
        f(j,0,sz(t))
        {
            if(s[i+j] == t[j])
                cur++;
        }
        ans = min(ans,sz(t) - cur);
    }
    cout << ans;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0, b = 0;
    rep(i,n)if(s[i] == 'R')r++;else b++;
    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/**
	Language: C++
	Author  : ebby21
**/

#include <bits/stdc++.h>

using namespace std;

#define fastio() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define debug(v) cerr << '\n' << #v << " :\t" << v << '\n'
#define loop(i, L, U) for (ll i = (L); i <= (U); ++i)
#define rloop(i, U, L) for (ll i = (U); i >= (L); --i)
#define foreach(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

const ll mod = 1000000007;

int main() {
	fastio();
	int n, m;
	cin >> n >> m;
	vi a(m);
	vi dp(n + 1, -1);
	dp[n] = 1;
	loop(i, 0, m - 1) {
		cin >> a[i];
		dp[a[i]] = 0;
	}
	rloop(i, n - 1, 0) {
		if (dp[i] == 0) continue;
		dp[i] = 0;
		if (i + 1 <= n) {
			dp[i] = (dp[i] + dp[i + 1]) %mod;
		}
		if (i + 2 <= n) {
			dp[i] = (dp[i] + dp[i + 2]) %mod;
		}
	}
	cout << dp[0] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/pypy
# coding: utf-8

N,M,L=map(int, raw_input().split())
RG=[[ 0 if i==j else float('inf') for i in range(N)] for j in range(N)]

for i in xrange(M):
    f,t,c = map(int, raw_input().split())
    if c <= L:
        RG[f-1][t-1] = c
        RG[t-1][f-1] = c

for k in xrange(N):
    for i in xrange(N):
        for j in xrange(i, N):
            t = RG[i][k] + RG[k][j]
            if RG[i][j] > t:
                RG[i][j] = t
                RG[j][i] = t

FG=[[float('inf') for i in range(N)] for j in range(N)]
for i in xrange(N):
    for j in xrange(i, N):
        if RG[i][j] <= L:
            FG[i][j] = 1
            FG[j][i] = 1

for k in xrange(N):
    for i in xrange(N):
        for j in xrange(i, N):
            t = FG[i][k] + FG[k][j]
            if FG[i][j] > t:
                FG[i][j] = t
                FG[j][i] = t

Q=int(raw_input())
for i in xrange(Q):
    s, t = map(int, raw_input().split())
    v = FG[s-1][t-1]
    if v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))

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

int D, N;
vector<int> a(110), e(110), r(110); //耐久力 経験値 必要な経験値
int dp[110][11000]; //耐久力 i の時に 経験値 j の時の回数

int solve(int d, int exp){
	int ret = 10e8;
	if(d <= 0) return 0;
	if(dp[d][exp] != -1) return dp[d][exp];
	for(int i=0; i< N; i++){
		int E = min(110, exp+e[i]);
		if(a[i] == 0 && E == exp) continue;
		if(r[i] <= exp) ret = min(ret, solve(d-a[i], E)+1);
	}
	dp[d][exp] = ret;
	return ret;
}

int main(){
	while(cin >> D >> N, D+N){
		for(int i=0; i< N; i++) cin >> a[i] >> e[i] >> r[i];
		for(int i=0; i < 110; i++)for(int j=0; j< 11000; j++) dp[i][j] = -1;
		int ret = solve(D, 0);
		if(ret == 10e8) cout << "NA" << endl;
		else cout << ret << endl;
	}
}

Measured memory_bytes: 5932
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

int main()
{
  int A, B, K;
  std::cin >> A >> B >> K;
  int limit = std::min(A, B);
  int ans = 0;
  for (int i = limit; i >= 0 ; --i)
  {
    if (A % i == 0 && B % i == 0)
    {
      --K;
      if (!K)
      {
        ans = i;
        break;
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
Imports System

Public Class Program

    Public Shared Sub Main(args As String())
        Dim N As Integer = Integer.Parse(Console.ReadLine)
        Dim Ai() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
        Dim Aj() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)

        Dim maxsum As Integer = 0

        For i As Integer = 0 To N - 1

            Dim sum As Integer = 0

            For j As Integer = 0 To N - 1

                If j <= i Then
                    sum += Ai(j)
                End If

                If j >= i Then
                    sum += Aj(j)
                End If
            Next

            If sum > maxsum Then
                maxsum = sum
            End If

        Next


        Console.WriteLine(maxsum)
    End Sub
End Class

Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
    int A, sum = 0;
    char c;
    int i;
    
    
    for(i=0; i<3; i++)
    {
        scanf("%d%c", &A, &c);
        sum += A;
    }
    
    if(sum >= 22)
        printf("bust\n");
    else
        printf("win\n");
    
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

void solve() {
	int N, A[200020], M, B[200020];
	scanf("%d", &N);
	rep(i, N) scanf("%d", A+i);
	scanf("%d", &M);
	rep(i, M) scanf("%d", B+i);
	sort(A, A+N); reverse(A, A+N);
	sort(B, B+M); reverse(B, B+M);
	int ok = 1;
	for(int i=0, j=0;i<M;i++) {
		while(j < N && A[j] > B[i]) ++j;
		if(j == N || A[j] != B[i]) ok = 0;
		else ++j;
	}
	puts(ok ? "YES" : "NO");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
package main

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

func main() {
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()
	h, w := sc.NextInt(), sc.NextInt()

	fmt.Println(H*W - (h*W + H*w - h*w))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
# include<bits/stdc++.h>
# include<unordered_map>
# include<unordered_set>
//# include<prettyprint.hpp>
using namespace std;
# define ll long long
# define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll a; cin >> a;
    long double b; cin >> b;
    long double ans = a*b;
    cout << (ll) ans << endl;
    return 0;
}

Measured memory_bytes: 3756
import sys
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
a = 0
def sub(p,q):
    return p-q
for i in range(n):
    a = abs(ls[i][1]) + abs(ls[i][2])
    if ((a -ls[i][0]) % 2 != 0) or (a -ls[i][0] > 0):
        print("No")
        sys.exit()
    if i != n-1:
        ls[i+1] = list(map(sub,ls[i+1],ls[i]))
    else:
        pass
print("Yes")

Measured memory_bytes: 27428
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int d;
    cin>>d;
    vector<int>c(26),t(d,1),t2(d,1),ans(d),nod(26);
    rep(j,26)cin>>c[j];
    vector<vector<int>>s(d,vector<int>(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    //rep(i,d)cin>>t[i];
    int pt,mx,tx,mxp=0;
    rep(k,365*3+1){
        pt=0;
        rep(j,26)nod[j]=0;
        rep(i,d){
            mx=-1000000;
            rep(j,26){
                if(k/365==1)tx=s[i][j]+nod[j]*c[j]*2;
                else if(k/365==2)tx=s[i][j]+nod[j]*c[j]*12/5;
                else tx=s[i][j]+nod[j]*c[j];
                if(tx>mx){
                    mx=tx;
                    t2[i]=t[i];
                    t[i]=j+1;
                }
            }
            if(i==k&&k!=1095)t[i]=t2[i];
            rep(j,26){
                if(t[i]-1==j){
                    pt+=s[i][j];
                    nod[j]=0;
                }
                else{
                    nod[j]++;
                    pt-=c[j]*nod[j];
                }
            }
        }
        //cout<<pt;
        if(pt>mxp||(k==1095&&ans[0]==0)){
            mxp=pt;
            rep(i,d)ans[i]=t[i];
        }
    }
    //cout<<mxp<<endl;
    
    rep(i,d)cout<<ans[i]<<endl;
	return 0;
}


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

int main(){
  int n;
  char s[100];

  cin>>n>>s;

  int temp=0, maxn=0;
  for(int i=0; i<n; i++){
    if(s[i]=='I')temp++;
    else temp--;
    maxn = max(maxn,temp);
  }
  cout<<maxn<<endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		
		if(n%10 == (n- n%100)/100) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int x,n;
    cin >> x >> n;
    map<int, bool> mp;
    rep(i,n){
        int t;
        cin >> t;
        mp[t] = true;
    }
    vector <pair<int ,int>> vi;
    for(int i= -3; i<=103 ; i++){
        if(mp.find(i) != mp.end()){
            continue;
        }
        else{
            vi.emplace_back(abs(i - x), i);
        }
    }
    sort(all(vi));
    cout << vi[0].second << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int a1,a2,i;
    while(1)
    {
        scanf("%d%d",&a1,&a2);
        if(a1==0&&a2==0)
            break;
        for(;a1>0;a1--){
            i=a2;
            for(;i>0;i--)
                printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2096