akhauriyash/Code-Regression huggingface dataset:
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
      print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    else:
        break


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

int main () {
    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n, 0);
        for (int i = 0; i < n; i++) cin >> a[i];
        map<int, int> m;
        for (int i = 0; i < n; i++) m[a[i]]++;
        long long res = 0;
        for (auto &p : m) res += 1ll * p.second * (p.second - 1) / 2;    
        for (int i = 0; i < n; i++) {
            long long tres = res;
            int k = m[a[i]];
            tres -= 1ll * k * (k - 1) / 2;
            tres += 1ll * (k - 1) * (k - 2) / 2;
            printf("%lld\n", tres);
        }
    }
}



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

string s;
int nextWordToFor(int cur)
{
	if(cur==s.size()) return cur;

	for(; cur<s.size(); cur++)
	{
		if(s[cur]!=' ') break;
	}
	for(; cur<s.size(); cur++)
	{
		if(s[cur]==' ') break;
	}

	return cur;
}

int nextWordToDel(int cur)
{
	int tcur=nextWordToFor(cur);

	return tcur;
}

int prevWordToBak(int cur)
{
	if(cur==0) return cur;
	cur--;

	for(; cur>0; cur--)
	{
		if(s[cur]!=' ') break;
	}
	for(; cur>0; cur--)
	{
		if(s[cur]==' ') 
		{
			cur++;
			break;
		}
	}

	return cur;
}

int main()
{
	int N;
	cin >> N;
	
	getline(cin, s);
	while(N--)
	{
		int cur=0;
		getline(cin, s);
	
		int C;
		cin >> C;
		while(C--)
		{
			string c,cmd,obj;
			cin >> cmd;
			getchar();
			getline(cin, obj);

			if(cmd[0]=='f')
			{
				if(obj[0]=='c') 
				{
					if(cur<s.size()) cur++;
				}
				else
				{
					cur=nextWordToFor(cur);
				}
			}
			if(cmd[0]=='b')
			{
				if(obj[0]=='c') 
				{
					if(cur>0) cur--;
				}
				else cur = prevWordToBak(cur);
			}
			if(cmd[0]=='d')
			{
				if(obj[0]=='c')
				{
					if(cur==s.size()) continue;
					s.erase(s.begin()+cur);
				}
				else
				{
					int cur2;
					cur2=nextWordToFor(cur);
					if(cur==s.size()) continue;
					if(s[cur2-1]==' ') continue;

					s.erase(s.begin()+cur, s.begin()+cur2);	
				}
			}
			if(cmd[0]=='i')
			{
				obj = obj.substr(1, obj.size()-2);
				s.insert(cur, obj);
				cur += obj.size();
			}
			string h(s);
			h.insert(cur, "7");
			//cout << h << endl;
		}

		s.insert(cur, "^");
		cout << s << endl;
	}

}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,-1,-1,0,0,1,1,1 }, ty[8] = { -1,0,1,-1,1,-1,0,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll h, w;
char p[510][510];
char r[510][510], b[510][510];

int main() {
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 0;i < h;i++)r[i][0] = '#', b[i][w - 1] = '#', r[i][w - 1] = '.', b[i][0] = '.';
	for (int i = 0;i < h;i++) {
		for (int j = 1;j < w-1;j++) {
			if (i % 2 == 0)r[i][j] = '.', b[i][j] = '#';
			else r[i][j] = '#', b[i][j] = '.';
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (p[i][j] == '#')r[i][j] = '#', b[i][j] = '#';
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cout << r[i][j];
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cout << b[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <iomanip>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll mod=(ll)1e9+7;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
int main() {
	int n;cin>>n;
	ll arr[n],freq[60]={};
	loop(n,i,0){
		cin>>arr[i];
		ll x=arr[i],j=59;
		while(x){
			freq[j--]+=(x%2);
			x>>=1;
		}
	}
	ll res=0;
	for(int i=59;i>=0;i--){
		ll x=((n-freq[i])*freq[i])%mod;
		res+=(x*power(2,59-i))%mod;
	}
	cout<<res%mod<<endl;
	return 0;
}



Measured memory_bytes: 2560
n = int(input())
c = list(input())
left = 0
cnt = 0
right = len(c) - 1
while left < n and right >=0 and left < right:
    while left < n and c[left] != 'W':
        left += 1
    while right >= 0 and c[right] != 'R':
        right -= 1
    if left< n and right >= 0 and left<right:
        c[left], c[right] = c[right], c[left]
        cnt += 1
        left += 1
        right -=1 
print(cnt)



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

int main() {
  long long x;
  cin >> x;
  long long ans = 100;
  for (int i = 1; i < 10000; i++) {
    ans = ans * 1.01;
    if (ans >= x) {
      cout << i;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int n;
	double mean, std_dev, scores[1000];

	while( true ){
	 	cin >> n;
	 	if(!n) break;

	 	mean = 0.0; std_dev = 0.0;
		for(int i=0; i<n; i++) cin >> scores[i];
		for(int i=0; i<n; i++) mean += scores[i] / (double)n;
		for(int i=0; i<n; i++) std_dev += pow( scores[i] - mean, 2) / (double)n;

		cout << fixed << setprecision(8) << sqrt(std_dev) << endl;
	}

	return 0;
}

Measured memory_bytes: 3224
//default
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed main(){
  string S;
  cin >> S;
  rep(i,S.size()-8){
    cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
      
      	int avail = a - b;
      	if ( c > avail ) {
          System.out.println(c - avail);
        }
      	else {
          System.out.println(0);
        }
	}
}

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

using namespace std;

typedef long long ll;

void solve() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++)
		if (s[i] != t[i])
			cnt++;
	cout << cnt;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

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

int main() {
    int N, C;
    cin >> N >> C;
    vector <vector <int>> D(C, vector <int> (C)),
                          c(N, vector <int> (N)),
                          modToCost(3, vector <int> (C));
    vector <vector <pair <int, int>>> modToColor(3);

    rep (i, C) rep (j, C) cin >> D[i][j];
    rep (i, N) rep (j, N) {
        cin >> c[i][j];
        c[i][j]--;
        modToColor[(i + j) % 3].emplace_back(i, j);
    }

    rep (mod, 3) rep (color, C) for (auto & i : modToColor[mod]) {
        modToCost[mod][color] += D[c[i.first][i.second]][color];
    }

    int ans = 1e9;
    rep (i, C) rep (j, C) rep (k, C) {
        if (i == j || j == k || k == i) continue;
        ans = min(ans, modToCost[0][i] + modToCost[1][j] + modToCost[2][k]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3700
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
cnt = 0
while True:
  b -= c[cnt]
  if cnt == a - 1:
    if b == 0:
      cnt += 1
    break
    
  elif b < 0:
    break
  cnt += 1
 
print(cnt)

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

using namespace std;

#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

typedef long long ll;
const ll mod = 1e9 + 7;


int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		while(x % 2 == 0) x /= 2, cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	long C[N];
	rep(i,0,N) cin>>C[i];
	sort(C,C+N);
	long ans=0;
    long A[N+1],B[N+1]; A[0]=1;B[0]=1;
    rep(i,0,N){
        A[i+1]=(2*A[i])%mod;
        B[i+1]=(A[i]+2*B[i])%mod;
    }
	rep(i,0,N){
		long temp=A[i]*B[N-1-i]%mod;
		(temp*=C[i])%=mod;
		(ans+=temp)%=mod;
	}
    cout<<(ans*A[N])%mod<<endl;
}

Measured memory_bytes: 4992
import java.util.*;

import static java.lang.Math.ceil;
import static java.lang.Math.min;

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

        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();
        long E = sc.nextLong();

        long minTrans = min(A, min(B, min(C, min(D, E))));
        if (minTrans >= N) {
            System.out.println(5);
            return;
        }

        long bottle = (long) ceil(N / (double)minTrans);
        System.out.println(5 + bottle - 1);
    }
}


Measured memory_bytes: 22612
/**
 *      AGC 24 B
 *      author  : kyomukyomupurin
 *      created : 2018-10-13 14:34:09
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int P[N] = {};
    for (auto i = 0; i < N; ++i) {
        cin >> P[i];
    }

    vector < pair<int, int> > p;

    for (auto i = 0; i < N; ++i) {
        p.push_back(make_pair(P[i], i));
    }

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

    int ans = 0;
    int beg = 0;

    while (beg < N){
        int end = beg;

        while (end + 1 < N && p[end].second < p[end + 1].second){
            ++end;
        }
        int len = end - beg + 1;
        if (len > ans) ans = len;
        beg  = end + 1;
    }
    cout << N - ans << '\n';

    return 0;
}

Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int s[100003];
int main()
{
    int n,ans=-1,i,j;
    cin>>n;
    vector <int> a(n,0);
    for(i=0;i<100003;i++) s[i]=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s[a[i]+1]++;
        s[a[i]+2]++;
        s[a[i]]++;
    }
    for(i=0;i<100003;i++) if(s[i]>ans) ans=s[i];
    cout<<ans;
    system ("pause"); 
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    set<char> a;

    rep(i, s.size()) a.insert(s[i]);

    for (char c = 'a'; c <= 'z'; c++) {
        bool ok = true;
        for (auto e : a)
            if (c == e) ok = false;
        if (ok) {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define For(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
// const ll MOD=1000000007ll;
const ll MOD=998244353ll;
const int MAX=510000;



int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main(){
    int m,n_min,n_max;
    while(cin>>m>>n_min>>n_max,m){
        vector<int> P(m);
        for(int i=0;i<m;i++){
            cin>>P[i];
        }
        int gap = 0;
        for(int i=n_min;i<=n_max;i++){
            gap = max(gap,P[i-1]-P[i]);
        }
        for(int i=n_max;i>=n_min;i--){
            if(gap == P[i-1]-P[i]){
                cout<<i<<endl;
                break;
            }
        }
    }
}

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


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    //cout << u << endl;
    return u;
}

ll paty_counter(ll level, ll x){
    ll size = pow(2, level+2) - 3;
    ll pmi = pow(2, level) - 1;
    if(x == 0){
        return 0;
    }else if(level == 0){    
        return 1;
    }else{
        if(x <= (size - 1)/2){
            return paty_counter(level-1, x-1);
        }else{
            return pmi + 1 + paty_counter(level-1, x - pow(2, level+1) + 3 - 2);
        }
    }

}
 
using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
static ll x;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に探索
        x ++;
    }
}

ll fr(ll n){
    ll ans = 1;
    REP(i, n){
        ans *= i+1;
        ans %= MOD;
    }
    return ans;
}

ll conb(ll n, ll k){
    return fr(n)% MOD * modinv(fr(k) * fr(n-k) % MOD, MOD) % MOD;
}

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};


int main() {
    //連結している木の個数-1でans
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
    int ans = 0;
    for (int i = 0; i < N; i++){
        if(UF.r[i] < 0){
            ans += 1;
        }
    }
    cout << ans - 1 << endl;
}



Measured memory_bytes: 3832
#include <iostream>

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

struct Node {
  int value;
  Node *parent, *left, *right;

  Node(int k, Node *p, Node *l, Node *r) {
    value = k;
    parent = p;
    left = l;
    right = r;
  }

  Node() {
    parent = nullptr;
    left = nullptr;
    right = nullptr;
  }
};

Node *root = nullptr;

void insert(int k) {
  Node *y = nullptr;
  Node *x = root;
  Node *z = new Node();
  z->value = k;

  while (x != nullptr) {
    y = x;
    if (k < x->value) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == nullptr) {
    root = z;
    return;
  }
  if (k < y->value)
    y->left = z;
  else
    y->right = z;
}

Node *find(int k) {
  Node *x = root;
  while (x != nullptr) {
    if (x->value == k) { return x; }
    if (k < x->value)
      x = x->left;
    else
      x = x->right;
  }
  return nullptr;
}

Node *getMinimum(Node *x) {
  Node *t = x;
  while (t->left != nullptr) { t = t->left; }
  return t;
}

Node *getSuccessor(Node *x) {
  if (x->right != nullptr) return getMinimum(x->right);

  Node *z = x;
  Node *y = x->parent;
  while (y != nullptr && z == y->right) {
    z = y;
    y = y->parent;
  }
  return y;
}

void deleteNode(Node *x) {
  // 0 child
  if (x->left == nullptr && x->right == nullptr) {
    if (x == x->parent->left)
      x->parent->left = nullptr;
    else
      x->parent->right = nullptr;
    delete x;
    return;
  }

  // 2 children
  if (x->left != nullptr && x->right != nullptr) {
    Node *y = getSuccessor(x);
    x->value = y->value;
    deleteNode(y);
    return;
  }

  // 1 child
  Node *y;
  if (x->left != nullptr)
    y = x->left;
  else
    y = x->right;

  y->parent = x->parent;

  if (x == x->parent->left)
    x->parent->left = y;
  else
    x->parent->right = y;
  delete x;
}

void inorder(Node *n) {
  if (n == nullptr) return;
  inorder(n->left);
  std::cout << ' ' << n->value;
  inorder(n->right);
}

void preorder(Node *n) {
  if (n == nullptr) return;
  std::cout << ' ' << n->value;
  preorder(n->left);
  preorder(n->right);
}

int main() {
  int n;
  std::cin >> n;
  std::string com;
  int key;

  rep(i, n) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      insert(key);
    } else if (com == "print") {
      inorder(root);
      std::cout << '\n';
      preorder(root);
      std::cout << '\n';
    } else if (com == "find") {
      std::cin >> key;
      Node *x = find(key);
      if (x != nullptr)
        std::cout << "yes" << '\n';
      else
        std::cout << "no" << '\n';
    } else {
      std::cin >> key;
      Node *x = find(key);
      deleteNode(x);
    }
  }
  return 0;
}



Measured memory_bytes: 21860
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    //2つを関連付けてソートする例
    class ProgramA
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            //入力
            string[] a = Console.ReadLine().Split(' ');
            int s = int.Parse(a[0]);
            int l = int.Parse(a[1]);


            //羊が多いとき（s > l)のときは生き残る、それ以外は死ぬ
            for (int i = s; i <= l; i++)
            {
                if (i % k == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");

        }
    }



}


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

int main()
{
  int n;
  cin >> n;
  for(;n < 1000; n++){
    if(n % 10 == n / 100 && n / 100 == (n / 10) % 10) {
      cout << n << endl;
      return 0;
    }
  }
  return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)

#define ln << endl

int main() {
    int N; cin >> N;
    cout << N * 800 - N / 15 * 200 ln;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll w[110], v[110];
ll dp[110][110][310];

int main(){
    int n;
    ll W;
    cin >> n >> W;
    rep(i, n) cin >> w[i] >> v[i];

    ll head = w[0];

    rep(i, n) w[i] -= head;

    rep(i, n) rep(j, n) rep(k, 310){
        if (w[i] <= k) dp[i + 1][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k - w[i]] + v[i]);
        else dp[i + 1][j + 1][k] = dp[i][j + 1][k];
    }

    ll ans = 0;

    rep(j, n+1) rep(k, 310) {
        if (k + head * j <= W) ans = max(ans, dp[n][j][k]);
    }

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


Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();

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

/*============ Header Template ============*/

const int N = 500 + 5;

int n;
int a[N], p[N];
int v[N * N];

int cmp(const int &x, const int &y) {return a[x] < a[y];}

int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]), v[a[i]] = i;
	for (int i = 1; i <= n; i++) p[i] = i;
	sort(p + 1, p + n + 1, cmp);
	int cur = 1, flag = 1;
	for (int i = 1; i <= n; i++) {
		int k = p[i];
		for (int j = 1; j <= k - 1; j++) {
			while (cur <= n * n && v[cur]) cur++;
			if (cur > n * n || cur > a[k]) {flag = 0; break;}
			v[cur] = k;
		}
		if (!flag) break;
	}
	if (!flag) {printf("No\n"); return 0;}
	cur = n * n;
	for (int i = n; i >= 1; i--) {
		int k = p[i];
		for (int j = 1; j <= n - k; j++) {
			while (cur && v[cur]) cur--;
			if (cur < 1 || cur < a[k]) {flag = 0; break;}
			v[cur] = k;
		}
		if (!flag) break;
	}
	if (!flag) {printf("No\n"); return 0;}
	printf("Yes\n");
	for (int i = 1; i <= n * n; i++) printf("%d ", v[i]);
	return 0;
}

Measured memory_bytes: 2176
using System;

class Test
{
    public static void Main()
    {
        int count = 0;
        while(true)
        {
            int i = int.Parse(Console.ReadLine());
            
            if(i == 0)
            {
                break;
            }
            
            count++;
            
            Console.WriteLine("Case " + count +": " + i);
            
        }
    }
}


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

using namespace std;
const int N=5e3+5;
int dp[N][N];
string s;
int n;
int solve(int i,int j)
{
    if(j==n)
        return 0;
    int &ret=dp[i][j];
    if(~ret) return ret;
    if(s[i]==s[j])
        return ret=solve(i+1,j+1)+1;
    return  ret=0;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>s;
    memset(dp,-1,sizeof dp);
    int ans=0;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            ans=max(ans,min(j-i,solve(i,j)));
    cout<<ans<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int dy[]={0,-1,-1,0,1,1};
int dx[]={1,0,-1,-1,0,1};
const int SZ=200;
const int off=100;

int t,n;
bool isEntry[SZ][SZ];
bool isVisited[SZ][SZ];

int bfs(int sy,int sx)
{
    queue<P> que;
    isVisited[sy+off][sx+off]=true;
    que.push(P(sy,sx));

    int cnt=1;
    REP(i,t){
	int sz=que.size();
	while(sz--){
	    int y=que.front().first;
	    int x=que.front().second;
	    que.pop();
	    REP(j,6){
		int ny=y+dy[j],nx=x+dx[j];
		if(isEntry[ny+off][nx+off] && !isVisited[ny+off][nx+off])
		{
		    isVisited[ny+off][nx+off]=true;
		    que.push(P(ny,nx));
		    cnt++;
		}
	    }
	}
    }
    return cnt;
}

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

    while(cin>>t>>n,t)
    {
	REP(i,SZ) REP(j,SZ){
	    isEntry[i][j]=true,isVisited[i][j]=false;
	}
	REP(i,n){
	    int x,y; cin>>x>>y;
	    isEntry[y+off][x+off]=false;
	}
	int sx,sy; cin>>sx>>sy;
	cout<<bfs(sy,sx)<<endl;
    }
}


Measured memory_bytes: 3200
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    ll half=0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            if(i*j<n){
               sum++;
            }else{
                break;
            }
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3632
N,Q = map(int,input().split())
ABC = [list(map(int,input().split())) for i in range(Q)]
edge = [[] for _ in range(N)]

for a,b,c in ABC:
    edge[a-1].append([b-1,c])
    edge[b-1].append([a-1,-c])

numlist = [0] * N
MIN,MAX = 0,0
visited = [False] * N
ans = 0

for i in range(N):
    if visited[i]:
      continue
    stack = [i]
    visited[i] = True
    while stack:
      v = stack.pop()
      for u,d in edge[v]:
        if not visited[u]:
          numlist[u] = numlist[v] + d
          stack.append(u)
          visited[u] = True
ans = 0
for i in range(N):
    if numlist[i] < MIN: MIN = numlist[i]
    elif numlist[i] > MAX: MAX = numlist[i]
    for u,d in edge[i]:
      if numlist[i] + d != numlist[u]:
        ans = -1
        break
    else:
      continue
    break
if ans != -1:
    ans = 'Yes'
else:
  	ans = 'No'

    
print(ans)




Measured memory_bytes: 119848
H, W = map(int, input().split(" "))
L = [list(input()) for i in range(H)]
for i in range(H):
  for j in range(W):
    if L[i][j] != "#":
      continue
    cnt = 0
    for n in [[i+1, j], [i-1, j], [i, j-1], [i, j+1]]:
      if n[0] < 0 or n[0] > H-1:
        continue
      if n[1] < 0 or n[1] > W-1:
        continue
      if L[n[0]][n[1]] == "#":
        cnt += 1
    if cnt == 0:
      print("No")
      exit(0)
print("Yes")


Measured memory_bytes: 3064
def main():
  _, s = open(0).read().split()
  w, res = 0, 0
  for i in s:
    if i == 'W':
      w += 1
    elif w:
      w -= 1
      res += 1
    else:
      pass
  return res


if __name__ == '__main__':
  print(main())

Measured memory_bytes: 3572
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int n,p;
int a[200];
ull dp[100][100] = {};

int dfs(int m,int s){
    //P(m);
    if(m >= n){
        
        if(s%2 == p)return 1;
        else  ret 0;
    }

    int sum = 0;

    sum += dfs(m+1,s + a[m]);
    sum += dfs(m+1,s);
    
    return sum;
}



ull nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}
int main(){
    cin >> n >> p;
   int g = 0,k = 0;
   ull ans = 0;
    rep(i,0,n){
	    cin >> a[i];
	    if(a[i]%2 == 0)g++;
	    else k ++;
	    
    }

    if(p == 0){
        
        for(int i = 1; i <= g; i++)ans += nCr(g,i);
      //  P(ans);
        ull ans2 = 0;
        for(int i = 2; i <= k; i+= 2)ans2 += nCr(k,i);
      //  P(ans2);
        
        ans = ans + ans2 + (ans * ans2);
        
        
        ans++;
    }else{
        for(int i = 1; i <= g; i++)ans += nCr(g,i);
       //  P(ans);
        ull ans2 = 0;
        for(int i = 1; i <= k; i+= 2)ans2 += nCr(k,i);
//P(ans2);
        ans = ans2 + (ans * ans2);
        
    }
    
    P(ans);
    //P(dfs(0,0));
    
	return  0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (ll ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000000000000ll
#define N 1000100
ll sum[N],a[N],n,i,ans=inf;
ll find(ll x,ll y)
{
	ll l=x,r=y-1;
	ll minn=inf,ret=0;
	while (l<=r)
	{
		ll mid=(l+r)/2;
		ll a=sum[mid]-sum[x-1];
		ll b=sum[y]-sum[mid];
		if (abs(a-b)<minn) minn=abs(a-b),ret=mid;
		if (a>b) r=mid-1;
		else l=mid+1;
	}
	return ret;
}
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for (i=2;i<=n-2;i++)
	{	
		ll x=find(1,i);
		ll y=find(i+1,n);
		ll a=sum[x],b=sum[i]-sum[x],c=sum[y]-sum[i],d=sum[n]-sum[y];
		ans=min(ans,max(max(a,b),max(c,d))-min(min(a,b),min(c,d)));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int a[100001];
 
 
int main(){
    int n,q;
    
    ll b,c;
    ll sum=0;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i){
        cin>>temp;
        sum=sum+temp;
        a[temp]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        int count=a[b];
        sum = sum-(count*b);
        a[b]=0;
        a[c]=a[c]+count;
        sum = sum+(count*c);
        cout<<sum<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 4012
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64
    }

    let c = n / (a + b);
    let mut ans = c * a;
    let tmp = n - (a + b) * c;
    
    if tmp > a {
        ans += a
    } else {
        ans += tmp
    }

    println!("{}", ans);
}


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

int main(){
	int h,w;
	cin>>h>>w;
	char a[h+5][w+5];
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin>>a[i][j];
		}
	}
	int nw[h+5][w+5];
	memset(nw,0,sizeof(nw));
	nw[1][1]=1;
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(i==1&&j==1) continue;
			if(a[i][j]=='#') continue;
			nw[i][j] = nw[i-1][j] + nw[i][j-1];
			nw[i][j] %= (int) 1e9 + 7;
		}
	}
	cout<<nw[h][w];
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k){
        cout<<s<<endl;
    }
    else{
        string str;
        int temp = s.size()-k;
        for(int i=0; i<k; i++){
            str+= s[i];
        }cout<<str<<"..."<<endl;
    }


}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

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

int N, A[510][510];
ll S1[510][510], S2[510][510];
ll dp[510][510];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=N;j++) if(i != j) scanf("%d", A[i] + j);
	}
	for(int i=1;i<=N;i++) {
		S1[i][i] = 0;
		for(int j=i+1;j<=N;j++) {
			S1[i][j] = S1[i][j-1];
			for(int k=i;k<j;k++) {
				S1[i][j] += A[k][j];
			}
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<i;j++) {
			S2[i][j] = S2[i][j-1] + A[i][j];
		}
	}
	rep(i, 510) rep(j, 510) dp[i][j] = 1e18;
	for(int i=1;i<=N;i++) {
		dp[1][i] = S1[1][i];
		for(int k=1;k<i;k++) {
			ll sum = 0;
			for(int j=i;j>k;j--) {
				sum += S2[j][k-1];
				dp[j][i] = min(dp[j][i], dp[k][j-1] + S1[j][i] + sum);
			}
		}
	}
	ll ans = 1e18;
	for(int i=1;i<=N;i++) ans = min(ans, dp[i][N]);
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7296
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let s: String = read();
    println!("{}{}", s, if s.chars().rev().next().unwrap() == 's' {"es"} else {"s"});
}


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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;

const double pi = acos(-1.0);

int solve() {
    int tot, n; Int(tot, n);
    int ans = 0;
    for(int i= 1; i <= n; i++) {
    	int x; Int(x);
    	ans += x;
    }
    if(ans > tot) printf("-1\n");
    else printf("%d\n", tot - ans);
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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

class Node {
public:
  Node *prev;
  Node *next;
  int val;

  Node(int val){
    this->val = val;
  }

  void print(){
    cout << this->val << endl;
  }
};

class DLList
{
public:
  Node *front;
  Node *end;
  DLList(){
    // front = new Node(0);
    // end = new Node(0);
    front = (Node*)malloc(sizeof(Node));
    end = (Node*)malloc(sizeof(Node));
    front->next = end;
    end->prev = front;
  }

  void insert(int val){
    // auto n = new Node(val);
    Node *n = (Node*)malloc(sizeof(Node));
    n->val = val;
    front->next->prev = n;
    n->next = front->next;
    front->next = n;
    n->prev = front;

  }

  void del(int val){
    Node *n = front;
    while((n = n->next) != end){
      if(n->val == val){
        n->prev->next = n->next;
        n->next->prev = n->prev;
        // delete n;
        // free(n);
        return;
      }
    }
  }

  void delFirst(){
    Node *n = front->next;
    if( n != end){
      front->next = n->next;
      n->next->prev = front;
      // delete n;
      // free(n);
      return;
    }
  }

  void delLast(){
    Node *n = end->prev;
    if( n != front ){
      n->prev->next = end;
      end->prev = n->prev;
      // delete n;
      // free(n);
      return;
    }
  }

  void print(){
    Node *n = front->next;

    while( n->next != end ){
      cout<<n->val<<" ";
      n = n->next;
    }
    cout<<n->val<<endl;



    // string s = "";
    // while((n = n->next) != end){
    //   s += to_string(n->val) + " ";
    // }

    // if(s.size() == 0) cout<<endl;
    // else{
    // s.back() = '\n';
    // cout<<s;      
    // }
    // return;
  }
  
};


int main() {


  cout<<fixed<<setprecision(10);


  auto dll = DLList();

  int n; cin>>n;
  rep(i, n){
    string s;cin>>s;
    // cout<<s<<endl;

    if(s == "insert"){
      int val; //cin>>val;
      scanf("%d", &val);
      dll.insert(val);
    }else if(s == "delete"){
      int val; //cin>>val;
      scanf("%d", &val);
      dll.del(val);
    }else if(s == "deleteFirst"){
      dll.delFirst();
    }else if(s == "deleteLast"){
      dll.delLast();
    }

  }
  dll.print();
}





//




Measured memory_bytes: 37584
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>

#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll MOD = 1e9 + 7;

int main()
{

    int a;
    string s;
    cin >> a;
    cin >> s;

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
import math
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

def insertion_sort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt

def shell_sort(a, n):
    cnt = 0
    m = 0
    g = []
    h = 1
    while True:
        if h > n:
            break
        m += 1
        g.append(h)
        h = 3 * h + 1
    g.reverse()

    for i in range(m):
        cnt += insertion_sort(a, n, g[i])
    print(m)
    print_list(g)
    print(cnt)
    for i in a:
        print(i)

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

shell_sort(a, n)



Measured memory_bytes: 45584
fun main(args: Array<String>) {
    edpb()
}

fun edpb() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val heights = readLine()!!.split(" ").map { it.toInt() }

    val inf = Long.MAX_VALUE / 100
    val dp = LongArray(101010) { inf }
    dp[0] = 0

    for (i in heights.indices) {
        for (j in Math.min(i + 1, n - 1)..Math.min(i + k, n - 1)) {
            dp[j] = Math.min(dp[j], dp[i] + Math.abs(heights[i] - heights[j]))
        }
    }

    val answer = dp[n - 1]

    println(answer)
}


Measured memory_bytes: 52212
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    string S;
    cin >> S;

    vector<int> count(2019, 0);
    count[0] = 1;
    int now = 0;
    int ten = 1;
    for (int i = S.length() - 1; i >= 0; i--) {
        now += (S[i] - '0') * ten;
        now %= 2019;
        count[now]++;
        ten *= 10;
        ten %= 2019;
    }
    long long ans = 0;
    rep(i,2019) {
        ans += count[i] * (count[i] - 1) / 2;
    }

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

Measured memory_bytes: 3756
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
X = [1 for i in range(N)]
for i in range(0,M):
    if H[A[i]-1] < H[B[i]-1]:
        X[A[i]-1] = 0
    elif H[A[i]-1] > H[B[i]-1]:
        X[B[i]-1] = 0
    else:
        X[A[i]-1] = 0
        X[B[i]-1] = 0
ans = 0
for i in range(0,len(X)):
    ans = ans + X[i]
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for( int i = 0; i < N; i++){
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  int a = X.at(0), b = X.at(N-1);
  int result = (b - a) * (b - a) * N;
  for(int i = a; i <= b; i++){
    int sum = 0;
    for(int j = 0; j < N; j++){
      sum += (X.at(j) - i) * (X.at(j) - i);
    }
    if(sum < result) result = sum;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a , b , c , x;
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    for(int i = 0 ; i <= a ; i++) {
        for(int j = 0 ; j <= b ; j++) {
            for(int k = 0 ; k <= c ; k++) {
                if((i * 500 + j * 100 + k * 50) == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main()
{
    FAST;

        ll l,r,d,c=0;
        cin>>l>>r>>d;
        for(ll i=l;i<=r;i++)
        {
            if(i%d==0)c++;
        }
        cout<<c<<endl;



    return 0;
}



Measured memory_bytes: 3648