akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
string s[500];
int h,w;
int a[500][500];
main()
{
	while(cin>>h>>w,h)
	{
		for(int i=0;i<h;i++)cin>>s[i];
		int ans=0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)a[i][j]=s[i][j]=='.'?1+(i>0?a[i-1][j]:0):0;
			stack<pair<int,int> >S;
			for(int j=0;j<w;j++)
			{
				int H=a[i][j];int k=j;
				while(!S.empty()&&S.top().second>=H)
				{
					k=S.top().first;int I=S.top().second;S.pop();
					ans=max(ans,I*(j-k));
				}
				S.push(make_pair(k,H));
			}
			while(!S.empty())
			{
				int k=S.top().first,I=S.top().second;S.pop();
				ans=max(ans,I*(w-k));
			}
		}
		cout<<ans<<endl;
	}
}




Measured memory_bytes: 4164
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))

  
def main():
    n = int(input())
    a = sorted(Input())
    while len(a) > 1:
        x, y = a[0], a[1]
        a[0:2] = [(x+y)/2]
    return a[0]


print(main())

Measured memory_bytes: 9012
n = int(input())
arr = list(map(int, input().strip().split()))

r = 0
for i in range(1, n-1):
    if (arr[i] > arr[i-1] and arr[i] < arr[i+1]) or (arr[i] < arr[i-1] and arr[i] > arr[i+1]):
        r += 1

print(r)

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

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	
	while(A > 0 && C > 0){
		C = C - B;
		if(C <= 0){
			cout << "Yes" << endl;
			break;
		}
		A = A - D;
		if(A <= 0){
			cout << "No" << endl;
			break;
		} 
	}
	return 0;
} 

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

int main() {
  string S;
  cin >> S;
  ll ans = 0;
  int c = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'W') {
      ans += i - c;
      c += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 10000000009;
ll v[205];
ll t[20000005];
ll a[10000005];
ll b[10000005];
ll dp[10005][10005];
ll ex = 1000000007;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	ll ans = inf;
	for (int i = 0; i <= n - k; i++) {
		ans = min(ans, abs(a[i + k - 1] - a[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, p[10], a, b, cnt;
  scanf("%lld", &n);
  if(n < 10) {
    printf("%lld", n);
    return 0;
  }
  p[0] = 1;
  for(i = 0; i < 9; ++i) p[i + 1] = p[i] * 10;
  for(i = 1; i < 10; ++i) for(j = 1; j < 10; ++j) {
    a = 0, b = 0;
    if(i == j) a++, b++;
    for(k = 10, cnt = 0; ; k *= 10, ++cnt) {
      if(i * k > n) break;
      if((i + 1) * k > n) {
        a += (n - i * k) / 10;
        if(j <= n % 10) ++a;
      } else a += p[cnt];
    }
    for(k = 10, cnt = 0; ; k *= 10, ++cnt) {
      if(j * k > n) break;
      if((j + 1) * k > n) {
        b += (n - j * k) / 10;
        if(i <= n % 10) ++b;
      } else b += p[cnt];
    }
    ans += a * b;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;
void lcs(char s1[],char s2[],int m,int n)
{
    int l[m+1][n+1];
    for(int i=0;i<=m;++i)
    {
        for(int j=0;j<=n;++j)
        {
            if(i==0||j==0)
            {
                l[i][j]=0;
            }
            else if(s1[i-1]==s2[j-1])
            {
                l[i][j]=l[i-1][j-1]+1;
            }
            else
            {
                l[i][j]=max(l[i-1][j],l[i][j-1]);
            }
        }
    }
    int ind=l[m][n];
    //watch(ind)
    char LCS[ind+1];
    LCS[ind]='\0';
    for(int i=m,j=n;i>0&&j>0;)
    {
        if(s1[i-1]==s2[j-1])
        {
            LCS[ind-1]=s1[i-1];
            --i;
            --j;
            --ind;
        }
        else
        {
            if(l[i-1][j]>l[i][j-1])
            {
                --i;
            }
            else
            {
                --j;
            }
        }
    }
    printf("%s",LCS);
}
int main()
{
    char s1[3003],s2[3003];
    scanf("%s%s",s1,s2);
    lcs(s1,s2,strlen(s1),strlen(s2));
    return 0;
}



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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		int amount = 0;
		int count = 0;
		List<Integer> S = new ArrayList<Integer>();
		List<Integer> H = new ArrayList<Integer>();
		List<Integer> C = new ArrayList<Integer>();
		List<Integer> D = new ArrayList<Integer>();
		try {
			while ((buffer = reader.readLine())  != null) {
				if (amount == 0) {
					amount = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				}
				else {
					String card = buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" "));
					buffer = buffer.substring(buffer.indexOf(" ") + 1);
					int number = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
					switch (card) {
					case ("S") : {
						S.add(number);
						break;
					}
					case ("H") : {
						H.add(number);
						break;
					}
					case ("C") : {
						C.add(number);
						break;
					}
					case ("D") : {
						D.add(number);
						break;
					}
					}
					if (++count == amount) {
						for (int s = 1; s <= 13; s++) {
							if (!S.contains(s)) {
								System.out.println("S " + s);
							}
						}
						for (int h = 1; h <= 13; h++) {
							if (!H.contains(h)) {
								System.out.println("H " + h);
							}
						}
						for (int c = 1; c <= 13; c++) {
							if (!C.contains(c)) {
								System.out.println("C " + c);
							}
						}
						for (int d = 1; d <= 13; d++) {
							if (!D.contains(d)) {
								System.out.println("D " + d);
							}
						}
					}
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

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

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**
const int N = 1e5+10;

int n;
int a[N];
int dp[N];

void solve(){
	cin >> n;
	rep(i,1,n+1)
		cin >> a[i];
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	rep(i,3,n+1)
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout << dp[n] << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


Measured memory_bytes: 5144
import java.util.Scanner;

class Main {
  private final static String INSERT = "insert";
  private static Tree ROOT = null;
  private static Tree END = null;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int times = Integer.parseInt(sc.next());

    for (int i = 0; i < times; i++) {
      if (sc.next().equals(INSERT)) {
        insert(Integer.parseInt(sc.next()));
      } else {
        createBuilderInorder(ROOT);
        System.out.println();
        createBuilderByRoot(ROOT);
        System.out.println();
      }
    }
  }

  public static void insert(int key) {
    Tree y = null;
    Tree x = ROOT;
    Tree z = new Tree();
    z.key = key;

    while (x != null) {
      y = x;
      if (z.key < x.key) {
        x = x.left;
      } else {
        x = x.right;
      }
    }

    z.parent = y;

    if (y == null) {
      ROOT = z;
    } else if (z.key < y.key) {
      y.left = z;
    } else {
      y.right = z;
    }
  }

  public static void createBuilderInorder(Tree tree) {
    if (tree != null) {
      createBuilderInorder(tree.left);
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderInorder(tree.right);
    }
  }

  public static void createBuilderByRoot(Tree tree) {
    if (tree != null) {
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderByRoot(tree.left);
      createBuilderByRoot(tree.right);
    }
  }
}

class Tree {
  public int key;
  public Tree left;
  public Tree right;
  public Tree parent;

  public Tree() { }
}



Measured memory_bytes: 213520
/*
    And I know I may end up failing too
*/




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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int>pii;
typedef unsigned long long ull;

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);auto hash2 = hash<T2> {}(p.second);return hash1 ^ hash2;
    }
};

ll t;
ll mod=N;
ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}

vector<ll>v;

int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,m,k;
    cin>>n;
    a=26;
    f=0;
    while(n>a)
    {
        n-=a;
        a*=26;
        f++;
    }
    a/=26;
    for(i=0;i<f;i++)
    {
        b=n/a;
        c=n%a;
        if(c==0)c+=a;
        if(n%a>0)b++;
        v.pb(b);
        n=c;
        a/=26;
    }
    v.pb(n);
    for(i=0;i<v.size();i++)
    {
        f=96+v[i];
        cout<<char(f);
    }
    cout<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

ll attack (ll h) {
    if (h == 1) return 1;

    return 2 * attack(h / 2) + 1;
}

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

    cout << attack(h) << endl;
    return 0;
}

Measured memory_bytes: 256
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Thu Sep 28 22:16:17 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int32_t main()
{
  string str;
  cin >> str;

  if ((str.size() % 2 == 0) ^ (str[0] == str[str.size() - 1])) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_d
// dynamic programming
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;

void main() {
    long N, W;
    readf("%d %d\n", &N, &W);

    long[] ws = new long[N+1];
    long[] vs = new long[N+1];

    long[][] dp = new long[][](N+1, W+1);

    foreach(i; 0..N)
        readf("%d %d\n", &ws[i], &vs[i]);

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= W; j++) {
            if(ws[i-1] <= j)
                dp[i][j] = max(dp[i-1][j],
                        dp[i-1][j-ws[i-1]] + vs[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    dp[N][W].writeln;
}




Measured memory_bytes: 82036
import java.util.Scanner;

//Hide-and-Seek Supporting System
public class Main{

	public static class Point {
		public double x;
		public double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
		public String toString() {return "(" +x+", "+ y +")";}
	}

	//¼üorüªÌNX
	public static class Line {
		public Point s,t;
		public Line(Point s_, Point t_) {
			s = s_; t = t_;
		}
		public String toString() {return s.toString() + " -> " + t.toString();}
	}

	public static double distanceSP(Line s, Point p) {
		Point r = proj(s, p);
		if (intersectSP(s, r)) return norm(sub(r, p));
		return Math.min(norm(sub(s.s, p)), norm(sub(s.t, p)));
	}

	public static boolean intersectSP(Line s, Point p) {
		return ccw(s.s, s.t, p) == 0;
//		return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
	}

	public static int ccw(Point a, Point b, Point c) {
		Point p = sub(b, a);
		Point q = sub(c, a);
		if(extp(p, q) > EPS) return 1;		// counter clockwise
		if(extp(p, q) < -EPS)return -1;		// clockwise
		if(inp(p, q) < -EPS) return 2;		// c--a--b on line
		if(Math.abs(norm(p) - norm(q)) < EPS) return -2;	// a--b--c on line
		return 0;				// a--c--b(or a--c=b) on line 
	}

	public static Point sub(Point p1, Point p2) {
		return new Point(p1.x-p2.x, p1.y-p2.y);
	}

	//àÏ
	public static double inp(Point p1, Point p2) {
		return p1.x*p2.x + p1.y*p2.y;
	}
	//OÏ
	public static double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}

	public static double norm(Point p) {
		return Math.hypot(p.x, p.y);
	}

	public static final double EPS = 1.0e-8;

	public static Point proj(Line l, Point p) {
		double t = inp(sub(p, l.s), sub(l.s, l.t)) / Math.pow(norm(sub(l.s, l.t)),2);
		Point tp = sub(l.s, l.t);
		return new Point(l.s.x + t*tp.x, l.s.y + t*tp.y);
	}

	static class C{
		public Point center;
		public double r;
		public C(Point center, double r) {
			this.center = center;
			this.r = r;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			C[] c = new C[n];
			for(int i=0;i<n;i++)c[i]=new C(new Point(sc.nextDouble(), sc.nextDouble()), sc.nextDouble());
			int m = sc.nextInt();
			while(m--!=0){
				Point u = new Point(sc.nextDouble(), sc.nextDouble());
				Point v = new Point(sc.nextDouble(), sc.nextDouble());
				Line line = new Line(u, v);
				boolean danger = true;
				for(int i=0;i<n;i++){
					double dsp = Math.max(distanceSP(line, c[i].center), distanceSP(new Line(v, u), c[i].center));
//					System.out.println("DSP: " + dsp);
					if(dsp <= c[i].r){
						double n1 = norm(new Point(u.x-c[i].center.x, u.y-c[i].center.y));
						double n2 = norm(new Point(v.x-c[i].center.x, v.y-c[i].center.y));
//						System.out.println("N1:" + n1 + " N2:" + n2);
						if(!(n1 <= c[i].r && n2 <= c[i].r))
							danger = false;
					}
				}
				System.out.println(danger?"Danger":"Safe");
			}
		}
	}
}

Measured memory_bytes: 13000
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> sieve(int n) {
  vector<int> primes;
  vector<bool> is_prime(n + 1, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    primes.push_back(i);
    for (int j = i + i; j <= n; j += i) {
      is_prime[j] = 0;
    }
  }
  return primes;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int x;
  cin >> x;
  auto res = sieve(x + 100000);
  for (int i : res) {
    if (i >= x) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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;
}

ll modinv(ll a, ll m) {
    ll x = a, y = m, u = 1, v = 0;
    while (y) {
        ll div = x / y;
        x -= div * y; swap(x, y);
        u -= div * v; swap(u, v);
    }
    return (u % m + m) % m;
}

ll comb(ll n, ll k, ll mod) {
    ll dividend = 1;
    ll divisor = 1;
    rep(i, k) {
        dividend = dividend * (n - i) % mod;
        divisor = divisor * modinv(i + 1, mod) % mod;
    }

    return dividend * divisor % mod;
}

int main()
{
    ll mod = 1e9+7;
    ll N, A, B; cin >> N >> A >> B;
    ll total = modpow(2, N, mod) - 1;
    total -= (comb(N, A, mod) + comb(N, B, mod));
    cout << ((total % mod + mod) % mod) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int x = scan.nextInt();
		
		if(500*k >= x) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(){
    int x;
    cin >>  x ;
    //int h,m,s;
    //h = x/3600;
    //m = (x%3600) /60; 
    cout << x/3600 << ":"<< (x%3600)/60 <<":" << x%60 << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
  int cntA = F/(A*100), cntB = F/(B*100);
  set<int> st;
  REP(i, cntA+1){
    REP(j, cntB+1){
      if(i*A*100+j*B*100 > F || i*A*100+j*B*100 == 0) continue; 
      st.emplace(i*A*100+j*B*100);
    }
  }
  double res = 0;
  int ansW = A*100, ansS = 0;
  for(auto i : st){
    int M = min(i/100*E, F-i);
    vector<bool> V(M+1, false);
    V[0] = true;
    REP(j, M+1){
      if(j+C <= M){
        if(V[j]) V[j+C] = V[j];
        if(V[j+C]){
          if(res < double((j+C)*100.0/(j+C+i))){
            res = double((j+C)*100.0/(j+C+i));
            ansW = i;
            ansS = j+C;
          }
        }
      }
      if(j+D <= M){
        if(V[j]) V[j+D] = V[j];
        if(V[j+D]){
          if(res < (((j+D)*100.0/(j+D+i)))){
            res = double((j+D)*100.0/(j+D+i));
            ansW = i;
            ansS = j+D;
          }
        }
      }
    }
  }
  cout << ansW+ansS << " " << ansS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a[5];
  int am[5];
  
  int ans = 0;
  
  int minimum = 124;
  int countzero = 0;
  
  for(int i = 0; i < 5; i++)
  {
    cin >> a[i];
    am[i] = a[i] % 10;
    if(am[i] == 0) countzero++;
    else if(minimum > am[i]) minimum = am[i];
  }
  
  if(minimum > 10) minimum = 10;
  
  for(int i = 0; i < 5; i++)
  {
    ans += (a[i]-am[i]);
    if(am[i] > 0) ans += 10;
    //cout << i << " " << ans << endl;
  }
  ans -= 10;
  ans += minimum;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<tuple>
using namespace std;
tuple<int,int,char,long long,string>a[1<<17];
main()
{
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int A,b;char c;long long d;string e;
        cin>>A>>b>>c>>d>>e;
        a[i]=make_tuple(A,b,c,d,e);
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<get<0>(a[i])<<" "<<get<1>(a[i])<<" "<<get<2>(a[i])<<" "<<get<3>(a[i])<<" "<<get<4>(a[i])<<endl;
    }
}



Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, x; cin >> n >> x;
    vint a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1) {
        int sum = a[i]+a[i+1];
        if (sum > x) {
            int sub = sum - x;
            a[i+1] = max(0,a[i+1]-sub);
            ans += sub;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int GCD(int, int);

main(){
  int a, b, gcd, lcm;

  while(scanf("%d %d", &a, &b) != EOF){
    gcd = GCD(a, b);
    lcm = a * (b / gcd);
    printf("%d %d\n", gcd, lcm);
  }

  return 0;
}

int GCD(int a, int b){
  int c, d;

  if(b > a){
    c = a;
    a = b;
    b = c;
  }
  d = b;

  while(1){
    c = a % b;
    if(c == 0){
      break;
    }else{
      d = c;
      a = b;
      b = c;
    }
  }
  return d;
}

Measured memory_bytes: 0
import java.io.*;
class Main{
  public static void main(String[] args)throws java.io.IOException{
             BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
             String hoge = input.readLine();
             int x = Integer.parseInt(hoge);
 
             System.out.println(x*x*x);
       }
}

Measured memory_bytes: 16860
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)

int main ()
{
    string S; cin >> S;

    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main()
{
	string S;
	cin >> S;

	int N = S.size();
	vector<int> l( N + 1 );
	int n = 0;
	for( int i = 0; i < N; i++ ) {
		if( S[i] == '<' ) n++;
		else n = 0;
		l[i + 1] = n;
	}
	vector<int> r( N + 1 );
	n = 0;
	for( int i = N - 1; i >= 0; i-- ) {
		if( S[i] == '>' ) n++;
		else n = 0;
		r[i] = n;
	}
	long long ans = 0;
	for( int i = 0; i < N + 1; i++ ) {
		ans += max( l[i], r[i] );
	}

	cout << ans << endl;
}


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

using namespace std;

int main(){
    string S;
    cin>>S;

    if(S[0] == S[1]){
        cout<<"Bad"<<endl;
        return 0;
    }
    if(S[1] == S[2]){
        cout<<"Bad"<<endl;
        return 0;
    }
    if(S[2] == S[3]){
        cout<<"Bad"<<endl;
        return 0;
    }
    cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()
{
    fast;
    ll i,j,n,m,k,ans;
    cin>>k>>n;
    ans=0;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(i=1;i<n;i++){
        ans=max(ans,a[i]-a[i-1]);
    }
    ans=max(ans,k-a[n-1]+a[0]);
    cout<<k-ans;
    return 0;
}



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

template<typename T>
T get_value(std::istream& is);

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

  const auto N {get_value<int>(cin)}, A {get_value<int>(cin)}, B {get_value<int>(cin)};
  auto res {0u};
  for (auto i {0u}; i <= N; ++i) {
    auto tmp {i};
    auto sum {0u};
    do {
      sum += tmp % 10;
    } while (tmp /= 10);

    if (A <= sum && sum <= B)
      res += i;
  }

  cout << res << '\n';

  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n, ans = 0;
    cin >> n;
    int cnt = n - 2;
    vector <int> a(n);
    loop(i, n)
        cin >> a[i];
    sort(all(a), greater<int>());
    ans = a[0]; 
    for (int i = 1; cnt; ++i) {
        if (cnt == 1) {
            --cnt; ans += a[i];
        }
        else {
            ----cnt; ans += a[i] * 2;
        }
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int A = 0;
		int B = 0;
		int C = 0;

		A = Integer.parseInt(lines[0]);//6
		B = Integer.parseInt(lines[1]);//4
		C = Integer.parseInt(lines[2]);//3

		C = B + C;

		if(A <= C) {
			C = C - A;
		}else {
			C = 0;
		}

		System.out.println(C);

	}

}


Measured memory_bytes: 21844
n = int(input())
R = []

for i in range(n):
    xi,li = map(int, input().split( ))
    R.append((xi+li,xi-li,i))
#左から貪欲
R.sort()
ans = 0
right = -10**10
for i in range(n):
    if R[i][1]>=right:
        ans+=1
        right = R[i][0]

print(ans)

Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    string S;
    cin >> S;
    if(S.size() != 26) {
        vector<int>cnt(26);
        for(int i = 0; i < S.size(); i++) {
            cnt[S[i]-'a']++;
        }
        for(int i = 0; i < 26; i++) {
            if(cnt[i] == 0) {
                cout << S << (char)(i+'a') << endl;
                return 0;
            }
        }
    }
    else {
        if(S == "zyxwvutsrqponmlkjihgfedcba") {
            cout << -1 << endl;
            return 0;
        }
        char c = S[25];
        string T = "";
        T+=c;
        for(int i = 24; i >= 0; i--) {
            if(S[i] < c) {
                cout << S.substr(0,i);
                for(int j = 0; j < T.size(); j++) {
                    if(S[i] < T[j]) {
                        c = min(c,T[j]);
                    }
                }
                cout << c << endl;
                return 0;
            }
            else {
                c = max(c,S[i]);
                T+=S[i];
            }
        }
    }
}

Measured memory_bytes: 3596
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var box = new List<stringex>() { new stringex("a", 'a') };

        box = func(box, n - 1);

        var buil = new StringBuilder();
        foreach(var i in box) {
            buil.AppendLine(i.str);
        }

        return buil;
    }

    static List<stringex> func(List<stringex> box, int power) {
        if (power <= 0) return box;

        var re = new List<stringex>();

        foreach(var s in box) {
            for(char i='a'; i<=s.max+1; i++) {
                re.Add(new stringex(s.str + i.ToString(), (char)Math.Max(i, s.max)));
            }
        }

        return func(re, power - 1);
    }

    class stringex
    {
        public String str;
        public char max;

        public stringex(string str, char max) {
            this.str = str;
            this.max = max;
        }
    }
}


Measured memory_bytes: 35728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}

vector<pll> pfac(ll n) {
	// prime factorization
	ll m = n;
	vecll primes;
	for (ll i = 2; i <= n; i++)
	{
		if (m % i == 0) {
			while (true) {
				primes.push_back(i);
				m /= i;
				if (m % i == 0) {
					continue;
				}
				else {
					break;
				}
			}
		}
		if (m == 1) {
			break;
		}
	}

	vector<pll> primep;
	ll pre, now, index;
	pre = -1;
	index = 0;
	for (ll i = 0; i < primes.size(); i++)
	{
		now = primes[i];
		if (pre == now) {
			primep[index].second++;
		}
		else {
			index++;
			primep.push_back(make_pair(now, 1));
			pre = now;
		}
	}

	return primep;

}

vecll divisors(vector<pll> primep) {
	vecll primes, primes2;
	for (ll j = 0; j < primep[0].second; j++)
	{
		primes.push_back(pow(primep[0].first, j));
	}

	for (ll i = 1; i < primep.size(); i++)
	{
		primes2 = vecll();
		for (ll j = 0; j < primes.size(); j++)
		{
			for (ll k = 0; k < primep[i].second; k++)
			{
				primes2.push_back(primes[j] * pow(primep[i].first, k));
			}
		}
		primes = vecll();
		for (ll i = 0; i < primes2.size(); i++)
		{
			primes[i] = primes2[i];
		}
	}

	return primes;
}


int main() {
	//
	ll n;
	cin >> n;
	for (ll i = 0; i < 3; i++)
	{
		if (((n / int(pow(10, i))) % 10) == 7) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


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

int main(){
  int A,B,M;
  std::cin >> A >> B >> M;
  std::vector<unsigned int> a(A), b(B);
  unsigned int amin = ~(0u);
  unsigned int bmin = ~(0u);
  for(int i = 0; i < A; ++i){
    std::cin >> a[i];
    amin = std::min(amin, a[i]);
  }
  for(int i = 0; i < B; ++i){
    std::cin >> b[i];
    bmin = std::min(bmin, b[i]);
  }
  unsigned int coupon_min = ~(0u);
  for(int i = 0; i < M; ++i){
    int x, y, c;
    std::cin >> x >> y >> c;
    unsigned int cost = a[x-1] + b[y-1] - c;
    coupon_min = std::min(coupon_min, cost);
  }
  unsigned int no_coupon_min = amin + bmin;
  std::cout << std::min(coupon_min, no_coupon_min) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){

  int a[3];
  int b[2];
  int i, j, min=100000, total;

  for (i = 0; i < 3; i++){
    scanf("%d", &a[i]);
  }
  
   for(j = 0; j < 2; j++){
    scanf("%d", &b[j]);
  }

  for(i = 0; i < 3; i++){
    for(j = 0; j < 2; j++){
      total = a[i] + b[j] - 50;
      if(total < min){
	min = total; 
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	int n;
	cin>>n;
	while(n){
		cout<<"ACL";
		n--;
	}



return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD=1e9+7;

int mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n, long k){
  long ans=1;
  for(long i=n; i>=n-k+1; i--){
    ans = (ans*i) %MOD;
  }
  return ans%MOD;
}

long minv(long k){
  long ans=1;
  for(long i=k; i>1; i--){
    ans = (ans*mpow(i,MOD-2))%MOD;
  }
  return ans%MOD;
}

long mcomb(long n,long k){
  return (mfact(n,k)*minv(k))%MOD;
}

int main(){
  long n, a, b;
  cin >> n >> a >> b;
  long ans = mpow(2,n);
  ans = (ans-mcomb(n,a))%MOD;
  ans = (ans-mcomb(n,b))%MOD;
  ans--;
  if(ans<0) ans+=MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<vector<int>>> state(N, vector<vector<int>>(15,vector<int>(2,0)));
    rep(i,0,N) {
        cin >> A[i];
        rep(j,0,A[i]) {
            int x,y;
            cin >> x >> y;
            state[i][j][0] = x-1;
            state[i][j][1] = y;
        }
    }
    int ans = 0;
    rep(bit_,0,(1<<N)) {
        bitset<15> bit(bit_);
        bool can = true;
        rep(i,0,N) {
            if (bit_ & (1<<i)) {
                rep(j,0,A[i]) {
                    int x = state[i][j][0];
                    if ((bool)(bit_ & (1<<x)) != state[i][j][1]) can = false;
                }
            }
        }
        if (can) {
            int num = bit.count();
            ans = num > ans ? num : ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

ll c[11];

int main() {
	repi(i, 0, 3) {
		ll r;
		rd(r);
		c[r]++;
	}
	if (c[5] == 2 && c[7] == 1) wrln("YES");
	else wrln("NO");
	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(sc.hasNext()){
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a == 0 && b == 0) break;
		if(a < b) System.out.println(a + " " + b);
		else System.out.println(b + " " + a);
		}
	}
}

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

int main()
{
	int n,i;
	cin>>n;
	
	int a[100+1]={0};
	
	for(i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]=1;
	}
	
	int s=0;
	
	for(i=1;i<=100;i++)
	{
		if(a[i]==1)
		   s++;
	}
	
	cout<<s;
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int P,Q,A,N;

int dfs(int p, int q, int n, int t){
  // P/Q == p/q
  if(P * q == p * Q) return 1;

  // P/Q < p/q
  if(P * q < p * Q) return 0;

  // N回探索して見つからなかったので 0 をreturn
  if(N == n) return 0;

  int ret = 0;
  for(int i = t; q * i <= A; i++){// 前回追加したiよりも以上iを追加する
    // 1/iを追加する
    // p/q + 1/i = (i*p + q) / q*i
    ret += dfs(p*i+q, q*i, n+1, i);
  }
  return ret;
}

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

  while(cin >> P >> Q >> A >> N, P || Q || A || N ){
    cout << dfs(0,1,0,1) << endl;
  }

  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <queue>

#define ll long long
using namespace std;

ll n;
vector<int> state;
vector<vector<int>> graph;

int bfs() {
    state = vector<int>(n);
    for (int i = 0; i < n; i++)state[i] = -1;
    queue<int> que;
    for (auto x:graph[0])que.push(x);
    que.push(-1);
    int depth = 1;
    while (true) {
        int next = que.front();
        que.pop();
        if (next == -1) {
            if (que.empty())break;
            depth++;
            que.push(-1);
        } else {
            if (state[next] >= 0 && state[next] != depth % 2) return -1;
            state[next] = depth % 2;
            for (auto x:graph[next])
                if (state[x] < 0)que.push(x);
        }
    }
    return 0;
}

int main() {
    ll m;
    cin >> n >> m;
    graph = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    if (0 > bfs())
        cout << n * (n - 1) / 2 - m;
    else {
        ll count = 0;
        for (auto x:state)if (x)count++;
        cout << count * (n - count) - m << endl;
    }
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
	int a, b;
	cin >> a >> b;
	if( a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0 )
		cout << "Possible";
	else cout << "Impossible";
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

void a()
{
    string s;
    cin >> s;
    s = s.substr(0, s.size() - 8);
    cout << s << endl;
    return;
}

void b()
{
    int n;
    map<int, int> d;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        if(d.count(temp) == 1)
        {
            d[temp]++;
        }else{
            d[temp] = 1;
        }
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
    {
        int t;
        cin >> t;
        if(d.count(t) == 1)
        {
           if(d[t] > 0)
           {
               d[t]--;
           }else{
               cout << "NO" << endl;
               return;
           }
        } else{
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
    return;
}

void c()
{
}

void d()
{

}

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


Measured memory_bytes: 9600
from itertools import accumulate
from collections import Counter

def nC2(n):
    return n * (n - 1) // 2

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(accumulate(A)).items()

ans = 0
for k, v in C:
    if k == 0:
        ans += v
    if v >= 2:
        ans += nC2(v)

print(ans)


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

int main() {
  int a,b,c,i=1,sum=0,time=0,t;
  cin >>a>>b>>t;
  time=a;
  while(time<=t+0.5){
     i++;
    sum+=b;
    time = (a * i);

  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
    {
        cout<<"YES"<<endl;return 0;
    }
    else 
        cout<<"NO"<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
vector<vector<int>> edges;
ll ans = 0;

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

int dfs(int i,int p = -1) {
    int sz = 1;
    for (int j : edges[i]) if (j != p) {
        int c = dfs(j,i);
        (ans += (1-pow_mod(2,-c))*(1-pow_mod(2,-n+c))%mod) %= mod;
        sz += c;
    }
    return sz;
}

int main() {
    cin >> n;
    edges.resize(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(0);
    (ans += 1-pow_mod(2,-n)-n*pow_mod(2,-1)) %= mod;
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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



  vector<int> p(n);
  vector<int> a;
  REP(i,n) cin >> p[i];

  for(int i = 0;i <= 101; ++i){
    a.push_back(i);
    REP(j,n){
      if( i == p[j]) a.pop_back();
    }
  }

  auto Iter1 = lower_bound(ALL(a), x);
  // cout << *Iter1  << endl;
  // cout << Iter1 - a.begin() << endl;
  int l = a[Iter1 - a.begin()];
  int r = a[Iter1 - a.begin()-1];

  if(abs(l-x) < abs(r-x)) cout << l << endl;
  else cout << r << endl;


  //
  // for(int i = 0;i < a.size() ; ++i){
  //   cout << a[i] << endl;
  // }


  return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
import re
import math
#import numpy as np

mod=int(10**9+7)
inf=int(10**20)

#main
N=int(input())
A=[]
for a in range(N):
    x,l=map(int,input().split())
    A.append([x-l,x+l])

A.sort(key=lambda x:x[1])

ans=0
n=-inf
for a in range(len(A)):
    b=A[a]
    if n<=b[0]:
        n=b[1]
        ans+=1
print(ans)

Measured memory_bytes: 21584
/*
	Created by Rahul Goel.
*/
 
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
 
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;
 
#define pii pair < int, int >
#define vi vector < int >
#define vb vector < bool >
#define vvi vector < vector < int > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main(){
    int k, n;
    cin >> k >> n;
    vi vec(n);
    for(int i=0; i<n; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end());
    int mx = 0;
    for(int i=1; i<n; i++)
        mx = max(mx, vec[i]-vec[i-1]);
    mx = max(vec[0] + k - vec[n-1], mx);
    cout << k - mx << endl;
    return 0;
}


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

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

	int H, W;
	scanf("%d %d", &H, &W);

	/* ピース
1	--- Hが3の倍数なら0 異なるならW
2	--| a<W/3<b で縦に切ってみるその後横にH/2で切る
3	-|| a<H/3<b で横に切ってみるその後縦にH/2で切る
4	||| Wが3の倍数なら0 異なるならH
*/
	int result_1, result_2, result_3, result_4;
	int result_2a, result_2b, result_3a, result_3b;
	if (H % 3 == 0 || W % 3 == 0)
	{
		cout << "0";
		return 0;
	}
	else
	{
		result_1 = W;
		result_4 = H;
	}

	int p1, p2, p3;

	p1 = (W / 3) * H;
	p2 = (W - (W / 3)) * (H / 2);
	p3 = H * W - p1 - p2;
	result_2a = max(max(abs(p1 - p2), abs(p2 - p3)), abs(p3 - p1));

	p1 = (W / 3 + 1) * H;
	p2 = (W - (W / 3 + 1)) * (H / 2);
	p3 = H * W - p1 - p2;
	result_2b = max(max(abs(p1 - p2), abs(p2 - p3)), abs(p3 - p1));

	result_2 = min(result_2a, result_2b);

	p1 = (H / 3) * W;
	p2 = (H - (H / 3)) * (W / 2);
	p3 = W * H - p1 - p2;
	result_3a = max(max(abs(p1 - p2), abs(p2 - p3)), abs(p3 - p1));

	p1 = (H / 3 + 1) * W;
	p2 = (H - (H / 3 + 1)) * (W / 2);
	p3 = W * H - p1 - p2;
	result_3b = max(max(abs(p1 - p2), abs(p2 - p3)), abs(p3 - p1));

	result_3 = min(result_3a, result_3b);

	// cout << result_1 << " " << result_2 << " " << result_3 << " " << result_4 << "\n";
	cout << min(min(result_1, result_2), min(result_3, result_4));

	return 0;
}

Measured memory_bytes: 256