akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)


#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

#define INF 100000000

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
    int n,k,a,j;
    cin >> n >> k ;
    forn(i,n) {cin >> a;if(a==1) j=i;}
    int ans=INF;
    int st=min(j,n-k);
    int ed=max(0,j-k+1);
    for(int i=ed;i<=st;i++){
        ans=min(ans,i/(k-1)+(i%(k-1)?1:0)+(n-i-k)/(k-1)+((n-i-k)%(k-1)?1:0));
       // cout << ans << endl;
    }
    cout << ans+1 << endl;


	return 0;

}



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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

double memo[3010][3010];
bool calc[3010][3010];
double v[3010];
int n;

double dp(int h, int t){
	if((h+t) == n){
		if(h>t)
			return 1.0;
		else
			return 0.0;
	}
	
	if(calc[h][t])
		return memo[h][t];

	calc[h][t] = true;
	
	return memo[h][t] = v[h+t]*dp(h+1, t) + (1.0-v[h+t])*dp(h, t+1);
}

int main() {	
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i=0; i<n; i++)
		cin >> v[i];
	
	cout << setprecision(12) << fixed << dp(0, 0) << endl;

	return 0;	
}


Measured memory_bytes: 78592
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)

from collections import deque
def BFS(N, graph, start):
    d = [-1 for i in range(N)]
    Q = deque([])
    Q.append(start)
    d[start] = 0
    while Q:
        v = Q.popleft()
        for u in graph[v]:
            if d[u] == -1:
                d[u] = d[v] + 1
                Q.append(u)
    return d

N, M = (int(i) for i in input().split())
graph = [[] for i in range(3*N)]
for i in range(M):
    a, b = (int(i) for i in input().split())
    graph[3*(a-1)].append(3*(b-1) + 1)
    graph[3*(a-1) + 1].append(3*(b-1) + 2)
    graph[3*(a-1) + 2].append(3*(b-1))

S, T = (int(i) for i in input().split())
ans = BFS(3*N, graph, 3*(S-1))
print(ans[3*(T-1)]//3)

Measured memory_bytes: 60304
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0}; 	

void solve(){
	int n;
	cin>>n;
	n--;
	cout<<n*(n+1)/2<<endl;;
}
signed main(){	
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 205;
ll a[N];
char s[N];
int main()
{
    int T; scanf("%d", &T);
    while(T--) {
        int n; scanf("%d", &n);
        for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
        scanf("%s", s + 1);
        vector<ll> v;
        bool flag = 1;
        for(int i = n; i >= 1; i--) {
            ll b = a[i];
            for(int k = 0; k < v.size(); k++) b = min(b, b ^ v[k]);
            if (b) {
                if(s[i] == '1') {flag = 0; break;}
                v.push_back(b);
            }
        }
        if(flag) puts("0");
        else puts("1");
    }
    return 0;
}

Measured memory_bytes: 3156
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll n,d;
    cin >> n >> d;
    
    vll x(n);
    vll y(n);
    rep(i,n) cin >> x[i] >> y[i];

    ll count = 0;
    rep(i,n) {
        ll X = x[i],Y = y[i];
        if((X*X)+(Y*Y) <= d * d){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6052
import sys


def main() -> None:
    a, b, c = [int(next_str()) for _ in range(3)]
    s = min(a, b, c)
    l = max(a, b, c)
    m = a + b + c - s - l

    for v in (s, m, l):
        if v % 2 == 0:
            print(0)
            return

    print(s * m)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		Set<Character> set = new HashSet<Character>();
		set.add('A');
		set.add('C');
		set.add('G');
		set.add('T');

		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j <= s.length(); j++) {
				String str = s.substring(i, j);
				boolean flg = true;
				for (int k = 0; k < str.length(); k++) {
					if (!set.contains(str.charAt(k))) {
						flg = false;
						break;
					}
				}
				if (flg) {
					ans = Math.max(ans, str.length());
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

char p[8][9];

bool m(int i, int j) {
  return 0 <= i && i < 8 && 0 <= j && j < 8 && p[i][j] == '1';
}

int main() {
  while (cin >> p[0], !cin.eof()) {
    for (int i = 1; i < 8; i++)
      cin >> p[i];
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 8; j++)
        if (m(i, j)) {
          if (m(i, j+1) && m(i+1, j) && m(i+1, j+1))
            cout << 'A' << endl;
          else if (m(i+1, j) && m(i+2, j) && m(i+3, j))
            cout << 'B' << endl;
          else if (m(i, j+1) && m(i, j+2) && m(i, j+3))
            cout << 'C' << endl;
          else if (m(i+1, j) && m(i+1, j-1) && m(i+2, j-1))
            cout << 'D' << endl;
          else if (m(i, j+1) && m(i+1, j+1) && m(i+1, j+2))
            cout << 'E' << endl;
          else if (m(i+1, j) && m(i+1, j+1) && m(i+2, j+1))
            cout << 'F' << endl;
          else
            cout << 'G' << endl;
          goto epilogue;
        }
epilogue:;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int key;
    Node *left;
    Node *right;
};

int n;
char command[7];

Node tree[500000];
Node *root;
int pos;

inline Node *new_node(int key) {
    Node *node = &tree[pos++];
    node->key = key;
    return node;
}

bool insert_key(int key) {
    if (root == NULL) {
        root = new_node(key);
        return true;
    }

    Node *node = root, *parent = NULL;
    while (node) {
        parent = node;
        if (node->key > key) {
            node = node->left;
        }
        else if (node->key < key) {
            node = node->right;
        }
        else {
            return false;
        }
    }

    Node *newnode = new_node(key);
    if (key < parent->key) {
        parent->left = newnode;
    }
    else {
        parent->right = newnode;
    }
    return true;
}

Node *find_key(int key) {
    Node *node = root;
    while (node) {
        if (node->key > key) {
            node = node->left;
        }
        else if (node->key < key) {
            node = node->right;
        }
        else {
            return node;
        }
    }
    return NULL;
}

void pre_order(Node *node) {
    printf(" %d", node->key);
    if (node->left) {
        pre_order(node->left);
    }
    if (node->right) {
        pre_order(node->right);
    }
}

void in_order(Node *node) {
    if (node->left) {
        in_order(node->left);
    }
    printf(" %d", node->key);
    if (node->right) {
        in_order(node->right);
    }
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0, key; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i') {
            scanf("%d", &key);
            insert_key(key);
        }
        else if (command[0] == 'f') {
            scanf("%d", &key);
            printf("%s\n", find_key(key) ? "yes" : "no");
        }
//        else if (command[0] == 'd') {
//            scanf("%d", &key);
//            delete_key(key);
//        }
        else {  // print 
            if (root == NULL) { continue; }
            in_order(root);
            printf("\n");
            pre_order(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 11440
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#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 all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//
vector<P> v;

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	string s; cin >> s;
	
	int num[15];
	int op[15];
	op[0] = 1;
	rep(i, s.size())num[i] = s[i] - '0';
	
	ll ans = 0;
	rep(i, 1 << (s.size()-1))
	{
		rep(j, s.size()-1)
		{
			if ((i >> j) & 1)op[j+1] = 1;
			else op[j+1] = 0;
		}

		ll tmp = 0;
		rep(j, s.size())
		{
			if (op[j] == 0)
			{
				tmp = 10 * tmp + num[j];
			}
			else
			{
				ans += tmp;
				tmp = num[j];
			}
			if (j == s.size() - 1) ans += tmp;
		}
	}

	Print(ans);

	//
	// your code finished



	return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    int x,ans=0;
    while(n--){
        cin>>x;
        ans+=2*(min(x,k-x));
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

bool u[256];
char x[30];
int n;

int main() {
	scanf("%s", x);
	n = strlen(x);
	for (int i = 0; i < n; i++)
		u[x[i]] = 1;
	for (int i = 'a'; i <= 'z'; i++)
		if (!u[i]) {
			printf("%s%c\n", x, i);
			return 0;
		}
	for (int i = n - 2; i >= 0; i--)
		if (x[i] < x[i + 1]) {
			for (int j = i + 1; j < n; j++) {
				u[x[j]] = 0;
				x[j] = 0;
			}
			for (int j = x[i] + 1; j <= 'z'; j++)
				if (!u[j]) {
					x[i] = j;
					printf("%s\n", x);
					return 0;
				}
			return 0;
		}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
import sys
readlines = sys.stdin.readlines
input = sys.stdin.readline

class RadixHeap:
    __slots__ = ["v", "last", "size"]

    def __init__(self, C=1 << 31):
        self.last = 0
        self.size = 0
        self.v = [[] for _ in range(C.bit_length()+1)]

    def push(self, key, val):
        self.size += 1
        self.v[(key ^ self.last).bit_length()].append((key, val))

    def pop(self):
        v = self.v
        if not v[0]:
            i = 1
            while not v[i]:
                i += 1
            vi = v[i]
            new_last, _ = min(vi)
            for key, val in vi:
                v[(key ^ new_last).bit_length()].append((key, val))
            self.last = new_last
            vi.clear()
        self.size -= 1
        return v[0].pop()

    def __len__(self): return self.size

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1;Cw -= 1
Dh -= 1;Dw -= 1
S = readlines()

INF = 10**10
D = [[INF]*W for _ in [0]*H]

q = RadixHeap()
q.push(0, Ch*W+Cw)

while q:
    d, ij = q.pop()
    i, j = divmod(ij, W)

    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            I = i+di
            J = j+dj
            if 0 <= I < H and 0 <= J < W and S[I][J] == '.':
                if abs(di)+abs(dj) == 1:
                    if D[I][J] <= d:
                        continue
                    D[I][J] = d
                    q.push(d, I*W+J)
                else:
                    if D[I][J] <= d+1:
                        continue
                    D[I][J] = d+1
                    q.push(d+1, I*W+J)

ans = D[Dh][Dw]
print(ans if ans < INF else -1)


Measured memory_bytes: 92628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
  double N,M,sum=0,k;
  cin>>N>>M;
  double ans=0;
  vector<double> a(N);
    for(int i=0;i<N;i++){
      cin>>a[i];
      sum+=a[i];
    }
  for(int i=0;i<N;i++){
    if(a[i]>=sum/(4*M)){ans++;}
  }
  if(ans>=M){cout<<"Yes";}
  else{cout<<"No";}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <ctype.h>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  int dir;
  int cnt;
  int x;
  int y;
  Point() {;}
  Point(int dir, int cnt, int x, int y) : dir(dir), cnt(cnt), x(x), y(y) {;}
};

int w, h;
char field[30][30];
bool visit[4][20][30][30];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

void Push(queue<Point> &que, int dir, int cnt, int x, int y) {
  int nx = (x + dx[dir] + w) % w;
  int ny = (y + dy[dir] + h) % h;
  if (visit[dir][cnt][ny][nx]) { return; }
  visit[dir][cnt][ny][nx] = true;
  que.push(Point(dir, cnt, nx, ny));
}

int main() {
  while (scanf("%d %d", &h, &w) > 0) {
    MEMSET(visit, false);
    REP(y, h) {
      scanf("%s", field[y]);
    }
    queue<Point> que;
    que.push(Point(0, 0, 0, 0));
    while (!que.empty()) {
      int dir = que.front().dir;
      int cnt = que.front().cnt;
      int x = que.front().x;
      int y = que.front().y;
      int ndir = dir;
      int ncnt = cnt;
      que.pop();
      if (field[y][x] == '@') {
        puts("YES");
        goto next;
      } else if (field[y][x] == '>') {
        ndir = 0;
      } else if (field[y][x] == 'v') {
        ndir = 1;
      } else if (field[y][x] == '<') {
        ndir = 2;
      } else if (field[y][x] == '^') {
        ndir = 3;
      } else if (field[y][x] == '_') {
        if (ncnt == 0) { ndir = 0; }
        else { ndir = 2; }
      } else if (field[y][x] == '|') {
        if (ncnt == 0) { ndir = 1; }
        else { ndir = 3; }
      } else if (field[y][x] == '?') {
        //
      } else if (field[y][x] == '.') {
        //
      } else if (field[y][x] == '+') {
        ncnt = (ncnt + 1) % 16;
      } else if (field[y][x] == '-') {
        ncnt = (ncnt + 15) % 16;
      } else if (isdigit(field[y][x])) {
        ncnt = field[y][x] - '0';
      }

      assert(ndir >= 0 && ndir < 4);
      assert(ncnt >= 0 && ncnt < 16);
      if (field[y][x] != '?') {
        Push(que, ndir, ncnt, x, y);
      } else {
        REP(i, 4) { Push(que, i, ncnt, x, y); }
      }
    }
    puts("NO");
next:;
  }
}

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

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

    ll N,K;

    cin >> N;
    cin >> K;

    ll cnt = 0;
    while(N>=K){
        // cout << N << "," << K << "\n";
        N = N / K;
        cnt++;
    }
    cnt++;

    cout << cnt;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i, j, k;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    bool flag = true;
    int cnt = 0;
    for(i = 0; i >= 0; i++){
        for(j = 0; j < n; j++){
            if(a.at(j) % 2 != 0){
                flag = false;
            }
            a.at(j) /= 2;
        }
        if(flag){
            cnt++;
        }
        else{
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N, M, ans = 0;
	cin >> N >> M;
	vector<ll> s(M), c(M);
	rep(x, M) cin >> s[x] >> c[x];
	rep(i, 1000) {
		ll keta = 1;
		vector<ll> x(1, i % 10);
		ll nx = i / 10;
		while (nx) {
			keta++;
			x.push_back(nx % 10);
			nx /= 10;
		}
		reverse(x.begin(), x.end());
		if (keta != N) continue;
		bool sx = true;
		rep(j, M) if (x[s[j] - 1] != c[j]) sx = false;
		if (sx) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int sort(const int *a, const int *b){
  return *(int *)a - *(int *)b;
}

int main(void){
  int n,i,sum=0;
  float v[1000];
  scanf("%d",&n);
  
  for(i=0; i<n; i++)
    scanf("%f",&v[i]);
  
  qsort(v,n,sizeof(float),sort);
  
  for(i=0; i<n-1; i++){
    //printf("%f ",v[i]);
    v[i+1] = (v[i] + v[i+1])/2;
  }
  
  printf("%f",v[n-1]);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<time.h>
typedef long long ll;
using namespace std;

struct node {
	int key;
	node *next, *prev;
};

node *nil;

void init() {
	nil = (node*)malloc(sizeof(node));
	nil->next = nil;
	nil->prev = nil;
}

void deleteNode(node *t) {
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

node* searchList(int x) {
	for (node* temp = nil->next; temp != nil; temp = temp->next) {
		if (temp->key == x) {
			return temp;
		}
	}
}

void deleteKey(int key) {
	node* t = searchList(key);
	deleteNode(t);
}

void insert(int key) {
	node *t = (node*)malloc(sizeof( node));
	t->key = key;
	t->next = nil->next;
	t->prev = nil;
	nil->next->prev = t;
	nil->next = t;
}

void printList() {
	node *t = nil->next;
	int i = 0;
	while (t != nil) {
		if (i < 1) {
			i++;
			cout << t->key;
			t = t->next;
			continue;
		}
		
		cout << ' ' << t->key;
		t = t->next;
	}
}

int main() {
	//freopen("run.in", "r", stdin);
	//freopen("run.out", "w", stdout);

	init();
	string cmd;
	int n;
	cin >> n;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> x;
			insert(x);
		}
		else if (cmd == "delete") {
			cin >> x;
			deleteKey(x);
		}
		else if (cmd == "deleteFirst") {
			deleteFirst();
		}
		else if (cmd == "deleteLast") {
			deleteLast();
		}
	}

	printList();
	cout << endl;


	return 0;
}

Measured memory_bytes: 34220
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    string str;
    cin >> str;
    map<string, int> swi;
    swi["SUN"] = 7;
    swi["MON"] = 6;
    swi["TUE"] = 5;
    swi["WED"] = 4;
    swi["THU"] = 3;
    swi["FRI"] = 2;
    swi["SAT"] = 1;
    cout << swi[str] << "\n";
}

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

int main(){
	int N,M;
	cin>>N>>M;
	vector<int> a(M);
	vector<int> b(M);
	for(int i=0;i<M;i++){
		cin>>a.at(i)>>b.at(i);
	}
	vector<int> num(N,0);
	for(int i=0;i<M;i++){
		num.at(a.at(i)-1)++;
		num.at(b.at(i)-1)++;
	}

	for(int i=0;i<N;i++){
		cout<<num.at(i)<<endl;
	}

	return 0;
}

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

int main() {
    int n,n1,n2,n3,n4;
    cin >> n;
    n1 = n / 1000;
    n2 = n / 100 - n1 * 10;
    n3 = n / 10 - n1 * 100 - n2 * 10;
    n4 = n - n1 * 1000 - n2 * 100 - n3 * 10;
    if(n2 == n3){
        if(n2 == n1 || n3 == n4){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace test
{
    class Program
    {
        struct Vector
        {
            public decimal x;
            public decimal y;

            public Vector(decimal x, decimal y)
            {
                this.x = x;
                this.y = y;
            }
        }

        static void Main(string[] args)
        {
            List<bool> resultList = new List<bool>();

            string input;
            while((input = Console.ReadLine()) != null)
            {
                string[] inputArray = input.Split(',');

                decimal xa = decimal.Parse(inputArray[0]);
                decimal ya = decimal.Parse(inputArray[1]);
                decimal xb = decimal.Parse(inputArray[2]);
                decimal yb = decimal.Parse(inputArray[3]);
                decimal xc = decimal.Parse(inputArray[4]);
                decimal yc = decimal.Parse(inputArray[5]);
                decimal xd = decimal.Parse(inputArray[6]);
                decimal yd = decimal.Parse(inputArray[7]);

                Vector A = new Vector(xa,ya);
                Vector B = new Vector(xb,yb);
                Vector C = new Vector(xc,yc);
                Vector D = new Vector(xd, yd);

                Vector AB = CompositVector(A, B);
                Vector AC = CompositVector(A, C);
                Vector AD = CompositVector(A, D);

                resultList.Add(IsConvex(AB, AC, AD));

            }

            foreach (bool a in resultList)
            {
                if (a)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }

        }

        static Vector CompositVector(Vector A, Vector B)
        {
            Vector AB = new Vector();

            AB.x = B.x - A.x;
            AB.y = B.y - A.y;

            return AB;
        }

        static bool IsConvex(Vector AB, Vector AC, Vector AD)
        {
            decimal s = (AD.y * AC.x - AD.x * AC.y) / (AB.x * AD.y - AB.y * AD.x);
            decimal t = (AB.x * AC.y - AB.y * AC.x) / (AB.x * AD.y - AB.y * AD.x);

            if (s >= 0 && t >= 0 && s + t > 1)
            {
                return true;
            }
            else
            {
                return false;
            }

        }

    }
}

Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,i;cin>>n;int maxeven,maxodd,secondeven,secondodd;
  maxeven=0;maxodd=0;secondeven=0;secondodd=0;int a,b;
vector<long int> v(n);
  for(i=0;i<n;i++){cin>>v[i];}
  vector<int> cntodd(100000,0);
  vector<int> cnteven(100000,0);
  for(i=0;i<n;i+=2){cnteven[v[i]]++;}
  for(i=1;i<n;i+=2){cntodd[v[i]]++;}
  for(i=0;i<n;i+=2){
  if(maxeven<cnteven[v[i]]){maxeven=cnteven[v[i]];a=v[i];}
  }
  for(i=1;i<n;i+=2){
  if(maxodd<cntodd[v[i]]){maxodd=cntodd[v[i]];b=v[i];}
  }
  cntodd[b]=0;cnteven[a]=0;
  for(i=0;i<n;i+=2){
  if(secondeven<cnteven[v[i]]){secondeven=cnteven[v[i]];}
  }
  for(i=1;i<n;i+=2){
  if(secondodd<cntodd[v[i]]){secondodd=cntodd[v[i]];}
  }
  if(a!=b){
    cout<<(n-maxeven-maxodd)<<endl;
  }else{
    int ne=max(secondodd,secondeven);
      cout<<(n-maxeven-ne)<<endl;
  }
}


Measured memory_bytes: 1920
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        long N = scanLong();
        long ans = 0;

        for (long i = 1; i <= N; i++) {
            if (i % 3 == 0 && i % 5 == 0) {

            }
            else if (i % 3 == 0) {

            }
            else if (i % 5 == 0) {

            }
            else {
                ans += i;
            }
        }
        out.print(ans);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

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

int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> a(m);
rep(i, m){
  cin >> a[i];
  n-=a[i];
}
if(n<0)n=-1;
cout << n << endl;
return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


ll dp[10][10];

ll con(ll a, ll b, ll n) {
	if (dp[a][b] != 0) return dp[a][b];
	if (a > n) return 0;
	ll res = 0;
	if (a == b) res++;
	
	ll max = a;
	ll min = a;
	ll del = 1;
	while (n >= max*10+b) {
		res += del;
		max = max * 10 +9;
		min *= 10;
		del *= 10;
	}
	if (n >= min*10 + b) {
		res += (n - min*10 - b) / 10 + 1;
	}
	dp[a][b] = res;
	return res;
}


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

	ll n;
	cin >> n;

	ll ans = 0;
	for (ll a = 1; a <= 9; a++) {
		for (ll b = 1; b <= 9; b++) {
			ans += con(a, b, n) * con(b, a, n);
		}
	}

	cout << ans << endl;

	return 0;
}


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

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int T = saori.saori_hayami();
		int[] c = new int[n];
		int[] t = new int[n];
		int ans = MAX;
		boolean flg = false;
		for(int i = 0;i < n;i++){
			c[i] = saori.saori_hayami();
			t[i] = saori.saori_hayami();
		}
		for(int i = 0;i < n;i++){
			if(T >= t[i]){
				ans = Math.min(ans, c[i]);
				flg = true;
			}
		}
		if(flg){
			System.out.println(ans);
		} else {
			System.out.println("TLE");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main()
{
    int n, i, j, judge = 0, key = 97;
    string s;
    
    cin >> s;
    
    n = s.size();
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        a[i] = int(s[i]);
    }
    
    sort(a, a+n);
    
    for(j = 0; j < n; j++) {
        if(a[j] != key) {
            judge = 1;
            break;
        }
        
        if(j < n - 1) {
            if(a[j] != a[j+1]) {
                key++;
            }
        }
    }
    
    if((key == 121) && (a[n-1] == 121)) {
        judge = 1;
        key++;
    }
    
    if(judge == 0) {
        cout << "None\n";
    } else {
        cout << char(key) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 896
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
#print(a_list)
alice = 0
bob = 0
for i in range(n):
    if i%2==0:
        alice+=a_list[i]
        #print(alice)
    else:
        bob+=a_list[i]
        #print(bob)
print(alice-bob)


Measured memory_bytes: 3060
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
    for (auto x : v)      \
    {                     \
        cout << x << " "; \
    }
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
    ll t;     \
    cin >> t; \
    while (t--)
#define FIO                           \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
    freopen((prob + ".in").c_str(), "r", stdin);
    freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
    if (n < 2)
        return false;
    for (int x = 2; x * x <= n; x++)
    {
        if (n % x == 0)
            return false;
    }
    return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
    vector<int> f;
    for (int x = 2; x * x <= n; x++)
    {
        while (n % x == 0)
        {
            f.push_back(x);
            n /= x;
        }
    }
    if (n > 1)
        f.push_back(n);
    return f;
}

void solve()
{
    /* Write Solution Here */
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll t = min(k, x / d);
    k -= t;
    x -= t * d;
    if (k % 2)
    {
        cout << abs(x - d) << "\n";
    }
    else
    {
        cout << x << "\n";
    }
}

int main()
{
    //FIO
    FAST

        //usaco("cowlands");

        ll TC = 1;
    /*
	Uncomment when multiple test cases
	*/

    // cin>>TC;
    for1(tt, TC)
    {
        solve();
    }
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int A,B;
    cin >> A >> B;
    
    if(A<=9 && B<=9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
return 0;
}


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

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

    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b == 'H'){
            cout << "D" << endl;
        }else{
            cout << "H" << endl;
        }
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int x=0,v[50],c[50];
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    if(v[i]-c[i]>0)x+=v[i]-c[i];
  }
  cout << x << endl;
}

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

// 
int main() {
    int A, B;
    cin >> A >> B;

    if (A == 1 && B == 2 || A == 2 && B == 1 ) {
        cout << 3;
        return 0;
    }
    if (A == 1 && B == 3 || A == 3 && B == 1 ) {
        cout << 2;
        return 0;
    }
    if (A == 2 && B == 3 || A == 3 && B == 2 ) {
        cout << 1;
        return 0;
    }
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b;
  cin >> N >> a >> b;
  
  int ans = 0;
  
  for(int i = 1;i <= N;i++){
    string t = to_string(i);
    int tmp = 0;
    for(int j = 0;j < t.size();j++){
      tmp += (t[j]-'0');
    }
    
    ans += ((tmp >= a && tmp <= b)?i:0);
  }

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)

vector<int> to[200000];
int node_score[200000];

// coming to now from from
void dfs(int now, int from, int score = 0) {
  for(int child: to[now]) {
    if (child == from)
      continue;

    dfs(child, now, score + node_score[now]);
  }

//  cout << "Now at " << now  << " from " << from;
  if (from == -1) {
//    cout << "adding nth"<<endl;
  } else {
    node_score[now] += score;
//    cout << " adding " << score  << "->" << node_score[now]<<  endl; 
  }
}

int main () {
  int N, Q;
  cin >> N >> Q;
  int i;
  int a, b;
  set<int> all_nodes;
  FOR(i, N-1) {
    cin >> a >> b;
    --a;
    --b;
    // a -> b
    to[a].push_back(b);
    // b -> a
    to[b].push_back(a);
    all_nodes.insert(a);
    all_nodes.insert(b);
  }

  set<int> nodes;
  int init_score[200000];
  FOR(i, Q) {
    // add b to every node in a sub-tree rooted by a-th node.
    cin >> a >> b;
    --a;
    init_score[a] = b;
    node_score[a] += b;
  }

  dfs(0, -1);
//  for (int root: nodes) {
//    dfs(root, -1, init_score[root]);
//  }

  for (int root: all_nodes) {
    cout << node_score[root] << " ";
  }
  cout << endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int num = s.length();
    for (char ch : s) {
        int cur = 0, ans = 0;
        for (char c : s) {
            if (c ^ ch) ans = max(ans, ++cur);
            else cur = 0;
        }
        num = min(num, ans);
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int n;
LL a[2 * MaxN + 5];
LL sum[2 * MaxN + 5];
LL all;
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		all = 0;
		for(int i = 1; i <= n; i++) {
			scanf("%lld", &a[i]);
			all += a[i];
		}
		LL ans = 1LL << 60;
		for(int i = 1; i <= n; i++)
			sum[i] = sum[i - 1] + a[i];
		if(n == 2) ans = abs(a[1] - a[n]);
		else if(n > 2) {
			for(int i = 2; i <= n - 1; i++)
				ans = min(ans, abs((all - sum[i]) - sum[i]));
		}
		printf("%lld\n", ans);
		memset(a, 0, sizeof(a));
		memset(sum, 0, sizeof(sum));
	}
	return 0;
}

Measured memory_bytes: 3328
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (i & 1) {
            if (x & 1) {
                ++res;
            }
        }
    }

    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner scanner = new Scanner(System.in);
        final int[] time = new int[5];
        for (int i = 0; i < 5; i++) {
            time[i] = scanner.nextInt();
        }

        final int rem = Arrays.stream(time).map(t -> (t + 9) % 10).min().getAsInt() + 1;

        System.out.println(Arrays.stream(time).map(t -> (t + 9) / 10 * 10).sum() + rem - 10);
    }
}


Measured memory_bytes: 27092
while True:
    a,op,b=input().split()
    ans=None
    a = int(a)
    b = int(b)
    if op=='?':
        break
    elif op=="+":
        ans=a+b
    elif op=='-':
        ans=a-b
    elif op=='*':
        ans=a*b
    else:
        ans=a//b
    print(ans)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int f[200005];
int n,k;
int h[200005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	    scanf("%d",&h[i]);
	for(int i=1;i<=n;++i) f[i]=1e9;
    f[1]=0;	
	for(int i=1;i<=n;++i)
		for(int j=i; j>0 &&(i-j) <= k ;--j)
		   f[i]=min(f[i],f[j] + abs(h[i]-h[j]));
	printf("%d\n",f[n]);
	return 0;
 } 

Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007

using namespace std;
void run(){
ll n;
cin>>n;
string s;
ll ans=0;
ll se[3]={0};
for(ll i=0;i<n;i++){
	cin>>s;
	ll x=s.length();
	for(ll j=0;j<x;j++){
		if(j!=x-1){
			if(s[j]=='A'&&s[j+1]=='B'){ans++;}
		}
	}
	if(s[0]=='B'&&s[x-1]=='A')se[2]++;
		else if(s[0]=='B')se[0]++;
		else if(s[x-1]=='A')se[1]++;
}
ll sa=0;
ll sw=1;
if(se[1]==0){
	if(se[2]!=0){
	sa=se[2]-1+min(se[0],sw);
	}
	
	else {
		sa=0;
	}
}
else{
	if(se[0]==0)sa=se[2];
	else{
		se[1]--;
		se[0]--;
		sa=se[2]+1;
		sa+=min(se[1],se[0]);
	}
	
}
cout<<ans+sa;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	
	// your code goes here
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

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

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

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		int m = s.nextInt();
		
		long[][] cond = new long[n][2];
		
		long total = 0;
		long amount = 0;
		for(int i=0;i < n; i++) {
			cond[i][0] = s.nextInt();
			cond[i][1] = s.nextInt();
			
		}
		
		Arrays.sort(cond, (a, b) -> Long.compare(a[0], b[0]));
		
		for(long[] shop : cond) {
			for(int j=0;j<shop[1];j++) {
				total = total + shop[0];
				amount++;
				if(amount >=m) {
					System.out.println(total);
					return;
				}
			}
		}

	}

}

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

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

  long long a,b,ans=0;
  cin >> a >> b;
  long long sum=1;
  while(b>sum){
    sum--;
    sum+=a;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

LL v[110], w[110];
LL dp[110][100010] = {};

int main() {
  int N, W;
  cin >> N >> W;
  for (int i = 0; i < N; i ++) cin >> w[i] >> v[i];
  
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j <= W; j ++) {
      if (j - w[i] >= 0) {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
   "strings"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextString()
  result := 0
  for {
	  word := nextString()
	  if word == "END_OF_TEXT" {
		  break
	  }
	  word = strings.ToLower(word)
	  if word == n {
		  result++
	  }
  }
  fmt.Println(result)
}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 1076
#include<cstdio>

int main() {
  int N, A, B, ans = 0;
  scanf("%d%d%d", &N, &A, &B);
  for (int i = 0; i <= N; i++) {
    int j, h, sum = 0;
    int l = i;
    while (l) {
      h = l % 10;
      sum = sum + h;
      l = l / 10;
    }
    if (sum >= A && sum <= B) {
      ans += i;
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;

#define endl "\n"
#define ar array

typedef long long ll;
typedef string str;

/* void setIO(string filename = "") { */
/*     ios_base::sync_with_stdio(0); cin.tie(0); */
/*     if ((int)filename.size()) { */
/*         freopen((filename+".in").c_str(), "r", stdin); */
/*         freopen((filename+".out").c_str(), "w", stdout); */
/*     } */
/* } */

const int maxn = 5e5;
int N,Q;
int x[maxn],ft[maxn+1],ans[maxn];
vector<ar<int,2>> q_a[maxn];
map<int,int> last_occur;

void upd(int i,int x){
    for(++i;i<=N;i+=i&-i){
        ft[i]+=x;
    }
}

int query(int i){
    int res=0;
    for(;i>0;i-=i&-i){
        res+=ft[i];
    }
    return res;
}

int main() {
    /* setIO(); */
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> Q;
    for(int i=0;i<N;++i){
        cin >> x[i];
    }
    for(int i=0;i<Q;++i){
        int l,r;
        cin >> l >> r;
        --l,--r;
        q_a[r].push_back({l,i});
    }
    for(int i=0;i<N;++i){
        if(last_occur.find(x[i])!=last_occur.end())
            upd(last_occur[x[i]],-1);
        upd(i,1);
        for(auto u : q_a[i]){
            ans[u[1]] = query(N) - query(u[0]);
        }
        last_occur[x[i]]=i;
    }
    for(int i=0;i<Q;++i){
        cout << ans[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 54772
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	int numbers[5];
	for(auto& n : numbers)
		cin >> n;

	sort(numbers, numbers+5, greater<int>());

	cout << numbers[0] << ' '
		 << numbers[1] << ' '
		 << numbers[2] << ' '
		 << numbers[3] << ' '
		 << numbers[4] << endl;
	
	return 0;
}

Measured memory_bytes: 1176