akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a+b,min(a+c,b+c)) << endl;
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2])cout << "Yes" << endl;
  else if (S[1] == S[2] && S[0] == S[3] && S[1] != S[0])cout << "Yes" << endl;
  else if (S[0] == S[2] && S[1] == S[3] && S[0] != S[1])cout << "Yes" << endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string day = "";
  string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  cin >> day;
  for (int i=0;i<7;i++){
    if (days[i] == day)
      cout << 7 - i;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    int ans=0;
    cin >> N;
    int A[N],B[N],C[N];
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
        ans+=B[i];
    }
    rep(i,N-1){
        cin >> C[i];
    }
    rep(i,N-1){
        if(A[i+1]-A[i]==1){
            ans+=C[A[i]-1];
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N;
    cin >> N;
    VI C(N - 1), S(N - 1), F(N - 1);
    REP(i, N - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(i, N - 1) {
        LL t = S[i] + C[i];
        FOR(j, i + 1, N - 1) {
            t = max(S[j], F[j] * (LL)ceil((double)t / F[j])) + C[j];
        }
        cout << t << endl;
    }
    cout << "0" << endl;
	
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.polygon();
    }

    private void polygon() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int[] l = IntStream.range(0, n).map(i -> Integer.parseInt(scan.next())).toArray();
            int max = Arrays.stream(l).max().getAsInt();
            int sumWithoutMax = Arrays.stream(l).sum() - max;

            System.out.println(sumWithoutMax > max ? "Yes" : "No");
        }
    }

    private void entranceExamination() {
        try (Scanner scan = new Scanner(System.in)) {
            int t = Integer.parseInt(scan.next());
            int x = Integer.parseInt(scan.next());

            System.out.println((double)t / (double)x);
        }
    }
}


Measured memory_bytes: 27348
#include<iostream>

using namespace std;

int main()
{
	int h, w;

	while (1)
	{
		cin >> h >> w;
		if (h == 0 && w == 0)
		{
			break;
		}

		if (h == 0 || w == 0)
		{
			continue;
		}

		for (int i = 0; i != h; ++i)
		{
			for (int j = 0; j != w; ++j)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

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

int main() {
    int t = read();
    if(t >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,pas=999999999;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(c=1; c<=a; c++){
		cin>>d>>e;
		if(e<=b&&pas>d) pas=d;
	}
	if(pas==999999999) cout<<"TLE"; else cout<<pas;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;




int main(){
string n;
cin>>n;
for(ll i=0;i<n.size();i++){
  if(n[i]=='1')
  n[i]='9';
  else if(n[i]=='9')
  n[i]='1';
}
cout<<n<<endl;

}


Measured memory_bytes: 256
import numpy as np
import sys 
import math 

readline = sys.stdin.readline

N, D = map(int, readline().split())
# XY = [list(map(int, readline().split())) for _ in range(N)]

count = 0
for i in range(N):
    X, Y = map(int, readline().split())
    distance = math.sqrt(X**2 + Y**2)

    if distance <= D:
        count += 1

print(count)


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

int main(){
    while(true){
        int x, y;
        cin >> x >> y;

        if(x == 0 && y == 0){
            break;
        }
        else{
            vector<string> v(x);
          for(int i = 0; i < x; i++){
            for(int j = 0; j < y; j++){
                v[i] += "#";
            }
            cout << v[i] << endl;
            if(i == x - 1){
                cout << endl;
            }
          } 
        }     
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    multiset<int> s;
    rep(i,n) {
        auto id = s.lower_bound(a[i]);
        if (id != s.begin()) s.erase(--id);
        s.insert(a[i]);
    }
    int ans = s.size();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8284
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
    st s,t;
    cin >> s >> t;
    ll cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>

typedef long long ll;

using namespace std;

int main() {
    int a, b, ans1, ans2, ans3, max1;

    cin >> a >> b;

    // 足し算
    ans1 = a + b;

    // 引き算
    ans2 = a - b;

    // 掛け算
    ans3 = a * b;

    max1 = max(ans1, ans2);

    cout << max(max1, ans3) << endl;

    return 0;
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(*a.rbegin()==*b.begin() and *b.rbegin()==*c.begin())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  cout << n * m - (x * m + y * n - x * y);
  return 0;
}




Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)

int main(void){
    int N; cin >> N;
    vector<int> V(N), C(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];

    int X=0, Y=0;

    rep(i, N){
        if(V[i] > C[i]){
            X+=V[i];
            Y+=C[i];
        }
    }
    cout << X-Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define mod 1000000007LL

struct node { ll l,x; };
vector<node> v[310];

ll f[310][310][310],n,m,ans;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool check(ll r,ll g,ll b)
{
	ll x=max(max(r,g),b);
	for (ll siz=v[x].size(),i=0;i<siz;i++)
	{
		ll l=v[x][i].l,hh=v[x][i].x,hhh=0;
		if (r>=l) hhh++;
		if (g>=l) hhh++;
		if (b>=l) hhh++;
		if (hh!=hhh) return false;
	}
	return true;
}

int main()
{
	n=rd();m=rd();
	for (ll i=1;i<=m;i++)
	{
		ll l=rd(),r=rd(),x=rd();
		v[r].push_back((node){l,x});
	}
	f[0][0][0]=1LL;ans=0LL;
	for (ll r=0;r<=n;r++) for (ll g=0;g<=n;g++) for (ll b=0;b<=n;b++)
	{
		if (!f[r][g][b]) continue;
		if (!check(r,g,b)) continue;
		ll x=max(max(r,g),b)+1;
		if (x==n+1) { ans=(ans+f[r][g][b])%mod;continue; }
		f[x][g][b]+=f[r][g][b]%mod;
		f[r][x][b]+=f[r][g][b]%mod;
		f[r][g][x]+=f[r][g][b]%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 227584
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N, M, X;
	vector<int> map;
	int l_cost, r_cost;

	cin >> N >> M >> X;

	map.resize(N+1, 0);

	for (int i = 0; i < M; i++) {
		int index;
		cin >> index;
		map[index] = 1;
	}

	l_cost = 0;
	for (int i = X; i >= 0; i--) {
		l_cost += map[i];
	}

	r_cost = 0;
	for (int i = X; i <= N; i++) {
		r_cost += map[i];
	}

	int min = l_cost < r_cost ? l_cost : r_cost;

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x 



void solve()
{
	int n;
	cin>>n;
	if(n>=30)
	   cout<<"Yes"<<endl;
	else
	    cout<<"No"<<endl;
   return ;	       
}



int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl << "\n" ;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		ll x;
		cin >> x;
		ll a = x / 500;
		ll ans = 1000 * a;
		a = x%500;
		ans += 5 * (a/5);
		cout << ans endl
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();
        long y = sc.nextLong();

        int count = 0;

        while(x <= y){
            x *= 2;
            count++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,n;
	cin>>h>>n;
	int x,cnt=0;
	for(int i=0;i<n;++i){
		cin>>x;
		cnt+=x;
	}
	if(cnt>=h){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

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

int main() {
   long N, K;
   cin >> N >> K;
   long a = 1, count = 0;

   while(a <= N) {
      a *= K;
      count++;
   }
   if (count < 1) count++;
   cout << count << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

ll pow2(ll a, ll b) {
    if (b == -1 ) {
        return 0;
    }
    if (b == 0) {
        return 1;
    }
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

ll calcR(ll l) {
    for (int i = 20;; i--) {
        if (pow2(2, i) <= l) {
            return i;
        }
    }
}

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

    ll r = calcR(l);

    vector<vector<ll>> vers;
    for (int i = 0; i < r; i++) {
        vector<ll> ver0 = {i, i + 1, 0};
        vector<ll> ver1 = {i, i + 1, pow2(2, i)};
        vers.push_back(ver0);
        vers.push_back(ver1);
    }

    for (int t = r; t >= 0; t--) {
        ll a = l - pow2(2, t);
        if (a >= pow2(2, r)) {
            vector<ll> ver = {t, r, a};
            vers.push_back(ver);
            l -= pow2(2, t);
        }
    }

    cout << r + 1 << ' ' << vers.size() << endl;

    rep(i, vers.size()) {
        vector<ll> ver = vers[i];
        printf("%lld %lld %lld\n", ver[0] + 1, ver[1] + 1, ver[2]);
    }


}


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


int main(){
  int i, j, count, sum;
  int n, m;
  scanf("%d %d", &n, &m);

  int A[n];
  sum = 0;
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    sum += A[i];
  }
  count = 0;
  for(i=0; i<n; i++){
    if( ((double)A[i] / sum)  >= (1.0 / (4*m)) ){
      count++;
    }
  }

  if(count >= m){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


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

int main() {
	int n, k; cin >> n >> k;
  	int dp[n], h[n];
  	for(int i = 0; i < n; ++i) cin >> h[i];
  	memset(dp, 0, sizeof dp);
  	for(int i = 1; i < n; ++i) {
      	dp[i] = numeric_limits<int>::max();
    	for(int j = 1; i - j >= 0 and j <= k; ++j) {
        	dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
  	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	ll x; cin >> x;
	ll a = (x / 11) * 2;
	ll b = x % 11;
	if (b == 0);
	else if (b > 6 && b < 11) a += 2;
	else if (b <= 6) a++;

	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt(), h = sc.nextInt(), w = sc.nextInt();
        if (H%h == 0 && W%w == 0) {
            System.out.println("No");
        }
        else {
            System.out.println("Yes");
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    System.out.print(i%h == h-1 && j%w == w-1 ? -4000*h*w+3999 : 4000);
                    System.out.print(' ');
                }
                System.out.println();
            }
        }
	}
}

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

int abs(int x, int y) {
if (x > y) { 
    return x - y; 
	} else {
	return y - x;}
}

int dist(int x1, int y1, int x2, int y2) {
return abs(x1, x2) + abs(y1, y2);
}

int main() {
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  
  for (int i = 0; i < N; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);}
  
  int p;
  
 if (t.at(0) < x.at(0)+y.at(0)) {
	cout << "No" << endl;
    p = 0;
    } else if ( (t.at(0) + x.at(0) + y.at(0) ) % 2 == 1) {
    cout << "No" << endl;
    p = 0;
    } else if (N == 1) {
   cout << "Yes" << endl;
    p = 0;
 	} else {p = 1;}

if (p == 1) {
  
  for (int i = 0; i < N - 1; i++){
    
    if ( t.at(i+1) - t.at(i) < dist(x.at(i), y.at(i), x.at(i+1), y.at(i+1)) ) {
      cout << "No" << endl;
      break;
    } else if
      ( (t.at(i+1) + t.at(i) + x.at(i+1) + x.at(i) + y.at(i+1) + y.at(i)) % 2 == 1) {
      cout << "No" << endl;
      break;
    } 
    
    if ( i == N - 2) {cout << "Yes" << endl;}
    }
}
}


Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<queue>

using namespace std;
#define INF 1000000
typedef pair<int, int> P;

int d[1001][1001];
char map[1001][1001];
int dx[4] = {1,0,-1,0}, dy[4] = {0,-1,0,1};
int H, W, N;
int si, sj;
int gi, gj;
int sum = 0;

void bfs(P start, int goal){
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            d[i][j] = INF;
            if(map[i][j]==goal+'0'){
                gi = i;
                gj = j;
            }
        }
    }

    d[start.first][start.second] = 0;
    queue<P> que;
    que.push(start);
    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(p.first==gi && p.second==gj) break;
        int ni, nj;

        for(int i=0; i<4; i++){
            ni = p.first + dx[i];
            nj = p.second + dy[i];

            if(0<=ni && ni<H && 0<=nj && nj<W && map[ni][nj]!='X' && d[ni][nj]==INF){
                que.push(P(ni,nj));
                d[ni][nj] = d[p.first][p.second] + 1;
            }
        }
    }

    sum += d[gi][gj];

    if(goal!=N) bfs(P(gi,gj),goal+1);

}

int main(){
    cin >> H >> W >> N;

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> map[i][j];
            if(map[i][j]=='S'){
                si = i;
                sj = j;
            }
        }
    }

    bfs(P(si,sj),1);
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 7996
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

map<int,int> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

vector<int>kai(3000);
int comb(int a,int b){
  return (kai[a]*gyaku(kai[a-b]))%MOD*gyaku(kai[b])%MOD;
}
////////////////////////////////////////////////////////////////////////
signed main() {
  int n,k;
  cin>>n>>k;
  kai[0]=1;
  rep(i,3000){
    kai[i+1]=kai[i]*(i+1)%MOD;
  }
  for(int i=1;i<=k;i++){
    if(i>n-k+1)cout<<0<<endl;
    else cout<<comb(n-k+1,i)*comb(k-1,i-1)%MOD<<endl;;
  }
  }


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

vector<pair<int, int>> g[100010];
int visited[100010], cost[100010];

bool dfs(int v)
{
    visited[v]=1;
    for(auto& e: g[v]) {
        int u, d;
        tie(u, d)=e;
        if (visited[u]) {
            if (cost[v]+d!=cost[u]) return false;
            continue;
        }
        cost[u]=cost[v]+d;
        if (!dfs(u)) return false;
    }
    return true;
}

int main()
{
    int n, m; cin>>n>>m;
    for(int i=0; i<m; ++i) {
        int L, R, D; cin>>L>>R>>D;
        --L, --R;
        g[L].emplace_back(R, D);
        g[R].emplace_back(L, -D);
    }

    bool yes=true;
    for(int i=0; yes && i<n; ++i) if (!visited[i] && !dfs(i)) yes=false;
    cout<<(yes ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 11392
#include <stdio.h>

int main(void) {
	char in[10];
	int win;
	char result[]={'d','o','x'};
	int i;
	while(scanf("%s",in)==1) {
		win=0;
		for(i=1;i<=2;i++) {
			if(in[0]==result[i]) {
				if(in[1]==result[i] && in[2]==result[i])win=i;
				if(in[3]==result[i] && in[6]==result[i])win=i;
				if(in[4]==result[i] && in[8]==result[i])win=i;
			}
			if(in[1]==result[i]) {
				if(in[4]==result[i] && in[7]==result[i])win=i;
			}
			if(in[2]==result[i]) {
				if(in[5]==result[i] && in[8]==result[i])win=i;
				if(in[4]==result[i] && in[6]==result[i])win=i;
			}
			if(in[3]==result[i]) {
				if(in[4]==result[i] && in[5]==result[i])win=i;
			}
			if(in[6]==result[i]) {
				if(in[7]==result[i] && in[8]==result[i])win=i;
			}
		}
		printf("%c\n",result[win]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>

struct HP
{
    int s,a,b;
};

bool cmp(const HP &a, const HP &b)
{
    return a.s > b.s;
}

int main()
{
    int n;
    struct HP hp[100000];
    scanf("%d", &n);
    
    for(int i = 0;i < n;i++)
    {
        scanf("%d", &(hp[i].a));
        scanf("%d", &(hp[i].b));
        hp[i].s = hp[i].a + hp[i].b;
    }
    
    std::sort(hp,hp + n,cmp);

    long long int dif = 0;
    for(int i = 0;i < n-1;i+=2)
    {
        dif += hp[i].a - hp[i+1].b;
    }
    if(n % 2 == 1) dif += hp[n-1].a;

    printf("%lld", dif);
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=s[i+1])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
list_original = []
for i in range(n):
    list_original.append(int(input()))

list = sorted(list_original)
sub = 10000000000

for j in range(n-k+1):
    if list[j+k-1]-list[j] <= sub:
        sub =list[j+k-1]-list[j]
    else:
        pass

print(sub)

Measured memory_bytes: 8288
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i<n;i++) {
        	h[i] = sc.nextInt();
        }
        int[] d = new int[n];
        for(int i=0; i<n; i++){
            if(i==0){
                d[i] = h[i] + k - h[n-1];
            }else{
                d[i] = Math.abs(h[i]-h[i-1]);
            }
        }
        int sum=0;
        int mx=0;
        for(int i=0; i<n; i++){
            mx = Math.max(mx,d[i]);
        }
        int ans;
        ans = k - mx;  //总长减去两点间距离最短的那段
        
        
        System.out.print(ans);
        
	}
}

Measured memory_bytes: 60484
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0;i<n1;i++) L[i] = A[left + i];
	for(int i=0;i<n2;i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right){
	if(left+1<right){
		int mid = (left + right) / 2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	cnt = 0;
	cin >> n;
	for(i=0;i<n;i++) cin >> A[i];

	mergeSort(A,n,0,n);

	for(i=0;i<n;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 7000
import itertools

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
num=list(itertools.permutations(range(1,n+1)))
cnt,c1,c2=0,0,0

for i in num:
  cnt+=1
  
  if i==p:
    c1=cnt
    
  if i==q:
    c2=cnt
    
print(abs(c1-c2))

Measured memory_bytes: 13944
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		if(p >= 400 && p <= 599) {
			System.out.println("8");
		}
		else if(p >= 600 && p <= 799) {
			System.out.println("7");
		}
		else if(p >= 800 && p <= 999) {
			System.out.println("6");
		}
		else if(p >= 1000 && p <= 1199) {
			System.out.println("5");
		}
		else if(p >= 1200 && p <= 1399) {
			System.out.println("4");
		}
		else if(p >= 1400 && p <= 1599) {
			System.out.println("3");
		}
		else if(p >= 600 && p <= 1799) {
			System.out.println("2");
		}
		else if(p >= 1800 && p <= 1999) {
			System.out.println("1");
		}
	}
}

Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),k=sc.nextInt();

		if(b-a+1>=2*k) {
			for(int i=0; i<k;i++) {
				System.out.println(a+i);
			}

			for(int i=0; i<k; i++) {
				System.out.println(b-k+1+i);
			}

		}else {
			for(int i=a; i<=b;i++) {
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 23252
#include<stdio.h>

int main(){
	int n,i;
	long a[100000];
	int yo=0,ni=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
		if(a[i]%2==0&&a[i]%4!=0)ni++;
		if(a[i]%4==0)yo++;
	}
	if(n/2<=yo){
		puts("Yes");
	}else{
		if(ni>=2){
			if((n-ni)%2==0){
				if((n-ni)/2<=yo)puts("Yes");
				else puts("No");
			}else {
				puts("No");
			}
		}else puts("No");
	}
	return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

#define MAX_N 100010

int N,M;
int X[MAX_N];
int cnt[MAX_N];
int cnt2[MAX_N];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i,N) {cin >> X[i];cnt[X[i]%M]++;cnt2[X[i]]++;}
    int ans = 0;
    ans=cnt[0]/2;
    cnt[0]-=(cnt[0]/2)*2;
    FOR(i, 1, M) {
        if (M-i<=i) break;
        int tmp=min(cnt[i],cnt[M-i]);
        ans+=tmp;
        cnt[i]-=tmp;
        cnt[M-i]-=tmp;
    }
    if(M%2==0) {
        int tmp=cnt[M/2]/2;
        ans+=tmp;
        cnt[M/2]-=tmp*2;
    }
    REP(i,N) {
        if (cnt2[X[i]]>1 && cnt[X[i]%M]>1) {
            int tmp = min(cnt2[X[i]],cnt[X[i]%M])/2;
            ans+=tmp;
            cnt2[X[i]]-=tmp*2;
            cnt[X[i]%M]-=tmp*2;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

Measured memory_bytes: 1032
#include <cstdio>
using namespace std;
#define LL long long
LL base=100;
int main()
{
	LL x;scanf("%lld",&x);int cnt=0;
	while(base<x){
		base=base+base*0.01;++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int x[101000],s;
int n;
int main(){
	cin>>n;
	cin>>s;
	for(int i=1;i<=n;++i){
		scanf("%d",&x[i]);
	}
	int ans=abs(s-x[1]);
	for(int i=2;i<=n;++i){
		ans=gcd(ans,abs(s-x[i]));
	}
	cout<<ans;
}

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

using namespace std;

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

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

int N;
ll ans = 0;
int f = 0;

void solve() {
    cin >> N;
    ll pre;
    rep(i,N) {
        ll A;
        cin >> A;
        if (A > i) {
            f = 1;
            continue;
        }
        if (i > 0) {
            if (A > pre + 1) {
                f = 1;
                continue;
            }
            if (A != pre+1) {
                ans += pre;
            }
        }
        pre = A;
    }
    ans += pre;
    if (f) cout << -1 << endl;
    else cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((ll)(1e18 + 5))
#define pi (2*acos(0))
#define M ((ll)(998244353))
#define NN ((ll)(1e6+2))
#define N ((ll)(2e5+2))
#define eps 0
#define log 21

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long lu;

typedef tree < ll,  null_type,  less < ll >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;

int a[N];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    if(a[n-1]-a[0]>1) printf("No\n");
    else if(a[0]==a[n-1])
    {
        if(2*a[0]<=n || a[0]==n-1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
    {
        int cnt = 1;
        for(int i = 1; a[i]!=a[n-1]; i++)
            cnt++;
        int col = a[n-1]-cnt;
        if(2*col<=n-cnt && col>0)
            printf("Yes\n");
        else
            printf("No\n");


    }
    return 0;
}


Measured memory_bytes: 640
dish = [int(input()) for i in range(5)]
s = sum(dish)
l = []
l_d =[]

for i in range(5):
    if dish[i]%10 != 0:
        l.append(dish[i]%10)

for i in l:
    l_d.append(-(i-10))

print(s+sum(sorted(l_d)[:-1]))

Measured memory_bytes: 9108
#include <stdio.h>
#include <math.h>

int main(void)
{
  int N;
  scanf("%d", &N);

  int i;
  for (i=0; i<N; ++i) {
    double xa, ya, ra, xb, yb, rb;
    scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);

    double distance = sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
    int result;
    if (distance > ra + rb) {
      result = 0;
    }
    else if (distance < ra - rb) {
      result = 2;
    }
    else if (distance < rb - ra) {
      result = -2;
    }
    else {
      result = 1;
    }

    printf("%d\n", result);
  }

  return 0;
}

Measured memory_bytes: 0
fun main(args:Array<String>) {
  val n = readLine()
  val ms = readLine()!!.split(" ").map(String::toInt).sorted().reversed()

  var (A, B) = Pair(0, 0)
  ms.mapIndexed { index, it ->
    if( index%2 == 0 )
      A+=it
    else
      B+=it
  }
  println(A-B)
}

Measured memory_bytes: 37704
def main():
    S = input()
    N = len(S)
    ans = 0
    if N & 1:
        for s, t in zip(S[:(N//2)], S[(N//2)+1:][::-1]):
            if s != t:
                ans += 1
    else:
        for s, t in zip(S[:(N//2)], S[(N//2):][::-1]):
            if s != t:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    long N, M, K;
    cin >> N >> M >> K;

    vector<long> A(N);
    vector<long> B(M);
    vector<long long> stackA(N+1);
    vector<long long> stackB(M+1);

    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    for (int i = 0; i < M; ++i)
    {
        cin >> B[i];
    }

    for (int i = 0; i < N; ++i)
    {
        stackA.at(i+1) = stackA.at(i) + A.at(i);
    }

    for (int i = 0; i < M; ++i)
    {
        stackB.at(i+1) = stackB.at(i) + B.at(i);
    }

    int sizeA = stackA.size();
    int sizeB = stackB.size();

    int maxCount = 0;

    int j = sizeB - 1;
    for( int i = 0; i < sizeA; ++i )
    {
        while( j >= 0 )
        {
            if( stackA[i] + stackB[j] <= K )
            {
                maxCount = max( maxCount, i + j );
                break;
            }
            --j;
        }
    }

    cout << maxCount << endl;

    return 0;
}

Measured memory_bytes: 9520
package main

import "fmt"

func main() {
	var n, m, a, b int
	fmt.Scan(&n, &m)
	nm := make(map[int]int)
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		nm[a]++
		nm[b]++
	}
	for i := 1; i <= n; i++ {
		fmt.Println(nm[i])
	}
}


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

class Main {
	public static void main(String[] args)throws IOException {
		//経過週数
		int n = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 64).readLine()); 
		//計算結果
		int result = 100000;
		
		//n週間後の借金を計算
		//0週間なら計算せず表示
		if (n != 0) {
			for(int i = 0; i < n;i++){
				result =(int)(result + (result * 0.05));
				if((result % 1000) != 0 ){
					result = ((int)(result / 1000) + 1) * 1000;
				}
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 16836
#include <bits/stdc++.h>
using namespace std;
int a[1000000],b[1000000];
int main()
{
	int n,h;
	cin>>n>>h;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	int x=*max_element(a,a+n);
	sort(b,b+n);
	reverse(b,b+n);
	int ans=(h+x-1)/x;
	for(int i=0;i<n;i++)
	{
		h-=b[i];
		int t;
		if(h<=0)
			t=0;
		else
			t=(h+x-1)/x;
		if(i+1+t<ans)
			ans=i+1+t;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	int n, c, k;
	int count = 0;
	int point = 0;
	int time = 0;

	cin >> n >> c >> k;
	vector<int>t(n + 1);
	FOR(i, 1, n) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	time = t[1] + k;
	FOR(i, 1, n) {
		if (t[i] <= time&&point < c) {
			point++;
		}
		else {
			count++;
			point = 1;
			time = t[i] + k;
			
		}
		if (i == n) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
		#include <iostream>
        using namespace std;
		int main(){
          int N,K;
          cin>> N >>K;
          if(K > ((N-1)*(N-2))/2 ){
            cout<< -1 << endl; 
          }else{
            int X =  ((N-1)*(N-2))/2 -K ; 
            // Xは消すべきペアの数
            cout << N-1 + X << endl; 
            for(int j = 2; j<=N; j++){
              cout<< 1 << " " << j << endl; 
            }
            for(int i = 2; i<=N-1;i++){
              for(int j= i+1; j<=N; j++){
                if(X>0){
                  cout<< i << " " << j << endl; 
                  X--; 
                }
              }
            }
            
          }
        }

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int n;
  cin >>n;
  ll ans=0;
  for(int i=1;i<n+1;i++){
    for(int j=1;j<n+1;j++){
      for(int k=1;k<n+1;k++){
       int m=min(i,min(j,k));
       for(int l=m;l>0;l--){
          if(i%l==0&&j%l==0&&k%l==0){
            ans=ans+l;
            break;
          }
        }
      }
    }
  }
  cout <<ans<<endl;
}
    

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

#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define vint vector<int>
#define vchar vector<char>
#define vstr vector<string>
#define pb(n) push_back(n)

signed main(){
  int A,B,N=0,M,count=0,count2=0,count3=0,stack=0;
  str S,T;
  int C='A'-'a';
  cin>>A>>B;
  vint V(N);
  N=B-A;
  for(int i=N-1;i>0;i--)N+=i;
  cout<<N-B<<endl;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// graph flow {{{
template<class T>
struct GF {
    struct EF {
        int to;
        T cap;
        int rev;
    };

    int n;
    vector<vector<EF>> e;

    GF() {}
    GF(int n) {
        this->n = n;
        e.resize(n);
    }

    void add(int from, int to, T cap) {
        e[from].push_back({to, cap, int(e[to].size())});
        e[to].push_back({from, 0, int(e[from].size()-1)});
    }
};


// 最大流 (Ford-Fulkerson) {{{
// O(FE)
// verified AOJ GRL_6_A
template<class T>
struct MF {
    GF<T> g;
    vector<bool> visited;

    MF() {}
    MF(const GF<T> &g) {
        this->g = g;
        visited.resize(g.n, false);
    };

    T dfs(int v, int t, T f) {
        if(v == t) return f;
        visited[v] = true;
        for(auto &e : g.e[v]){
            if(!visited[e.to] && e.cap > 0){
                T d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    g.e[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T query(int from, int to) {
        T flow = 0;
        while(true){
            fill(visited.begin(), visited.end(), false);
            T f = dfs(from, to, INF);
            if(f == 0) break;
            flow += f;
        }
        return flow;
    }
};//}}}
//}}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n), b(n), c(n), d(n);
    inc(i, 0, n) cin >> a[i] >> b[i];
    inc(i, 0, n) cin >> c[i] >> d[i];
    GF<int> gf(n*2+2);
    inc(i, 0, n){
        gf.add(n*2, i, 1);
        gf.add(n+i, n*2+1, 1);
        inc(j, 0, n){
            if(a[i] < c[j] && b[i] < d[j]){
                gf.add(i, n+j, 1);
            }
        }
    }
    MF<int> mf(gf);
    cout << mf.query(n*2, n*2+1) << endl;
    
    return 0;
}


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

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

    // i個の山から始めて先手が勝ちなら1、負けなら0
    vector<int>dp(K+1, 0);
    for (int i = 1; i <= K; ++i) {
        for (int x: a) {
            if(i < x) break;
            if(dp[i-x] == 0) {
                dp[i] = 1;
                break;
            }
        }
    }
    
    if(dp[K]){
        cout << "First" << "\n";
    } else{
        cout << "Second" << "\n";
    }
    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
    //code
    
    string s;
    while(cin >> s){
    	char x = s[0];

    	if(x - 'A' >= 0 and x - 'A' <= 26){
    		cout << x;
    	}
    	else{
    		cout << char(x - 'A');
    	}
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;
vector<int> V;

int main(void) {
    cin>>N>>K;

    for(int i = 0;i < N;i++) {
        int v;
        cin>>v;
        V.push_back(v);
    }

    int ans = 0;
    for(int i = 0;i <= min(N,K);i++) {
        for(int l = 0;l <= i;l++) {
            int sum = 0;
            vector<int> temp;
            for(int k = 0;k < l;k++) {
                sum += V[k];
                 temp.push_back(V[k]);
            }

            for(int r = i-l;r > 0;r--) {
                sum += V[N-r];
                temp.push_back(V[N-r]);
            }
            
            sort(temp.begin(),temp.end());
            for(int n = 0;n < temp.size() && n < K-i;n++) {
                if(temp[n] < 0) {
                    sum -= temp[n];
                } else {
                    break;
                }
            }

            ans = max(sum,ans);
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

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

  string w;
  for (int i = 0; i < N; ++i) {
    w = w + S[i];
    w = w + T[i];
  }
  cout << w << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    map<int, int> a;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    int cnt = 0, ans = a.size();
    for (auto p : a) {
        if (p.second % 2 == 0) {
            cnt++;
        }
    }
    if (cnt % 2 != 0) {
        ans--;
    }
    OUT(ans);
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int i;
    string a,b;
    cin>>a;
    cin>>b;
    if(a.length()>b.length()) {
            cout<<"GREATER\n";
            return 0;
    }
    if(a.length()<b.length()){
            cout<<"LESS\n";
            return 0;
    }

    long long int n=a.length(),x,y;
    if(n==b.length()){
    for(i=0;i<n;i++){
       x=a[i]-'0';
       y=b[i]-'0';
    if(x>y){
        cout<<"GREATER\n";
        return 0;
    }
    if(x<y){
        cout<<"LESS\n";
        return 0;
    }
    }}
    cout<<"EQUAL\n";
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    unsigned long long H,W;
    cin>>H>>W;
    if(H==1||W==1){
        cout<<1<<endl;
        exit(0);
    }
    if(H*W%2==0){
        cout<<H*W/2<<endl;
    }else{
        cout<<(H*W/2)+1<<endl;
    }
}

Measured memory_bytes: 256