akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


class FenwicTree:
    def __init__(self, n):
        self.__data = [0] * n
        self.__n = n

    def add(self, i, x):
        i += 1
        while i <= self.__n:
            self.__data[i-1] += x
            i += i & -i

    def sum(self, l, r):
        return self.__sum(r) - self.__sum(l)

    def __sum(self, r):
        s = 0
        while r > 0:
            s += self.__data[r-1]
            r -= r & -r

        return s


@mt
def slv(N, A, Q):
    ft = FenwicTree(N)
    for i, a in enumerate(A):
        ft.add(i, a)

    ans = []
    for q in Q:
        if q[0] == 0:
            _, p, x = q
            ft.add(p, x)
        else:
            _, l, r = q
            ans.append(ft.sum(l, r))

    return ans


def main():
    N, Q = read_int_n()
    A = read_int_n()
    Q = [read_int_n() for _ in range(Q)]
    print(*slv(N, A, Q), sep='\n')



if __name__ == '__main__':
    main()


Measured memory_bytes: 184928
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N, D;

int main() {
  //
  cin >> N >> D;
  ll ans = 0;
  rep(i, 0, N) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= D * D) {
      ++ans;
    }
  }
  cout << ans;
}


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

string transfer(string s){
    string t=s;
    for (int i=0; i<s.size(); i++){
        if (isalpha(s[i])){
            if (islower(s[i])) t[i]=toupper(s[i]);
            else t[i]=tolower(s[i]);
        } else t[i]=s[i];
    }
    return t;
}

int main(){
    string S,ans;
    while(getline(cin,S)){
        ans=transfer(S);
        cout << ans ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int happiness = 0;
		int x = kb.nextInt();
		while (x>=500) {
			happiness+=1000;
			x-=500;
		}
		while(x>=5) {
			happiness+=5;
			x-=5;
		}
		System.out.println(happiness);
		kb.close();
	}

}


Measured memory_bytes: 22100
n=int(input())
al=[];bl=[];cl=[]
for _ in range(n-1):
  x,y,z=map(int,input().split())
  al.append(x);bl.append(y);cl.append(z)
for i in range(n-2):
  time=al[i]+bl[i]
  for j in range(i+1,n-1):
    if time<=bl[j]:
      time=bl[j]+al[j]
    else:
      time=time+(-1*time)%cl[j]+al[j]
  print(time)
print(al[-1]+bl[-1])
print(0)
    

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int a,b;scanf("%d %d",&a,&b);
    int l=max(-1000000,b-a+1);
    int r=min(1000000,b+a-1);
    for(int i=l;i<=r;i++) printf("%d%c",i," \n"[i==r]);
    return 0;
}

Measured memory_bytes: 256
import sys
import math as mt
input=sys.stdin.buffer.readline  
#t=int(input())
mod=10**9+7
t=1
for __ in range(t):
    l=[0]*6
    #x,n=map(int,input().split())
    
    #n=int(input())
    #a=[[0 for j in range(m)] for i in range(n)]
    x=list(map(int,input().split()))
    for i in x:
        l[i]=1
    for i in range(6):
        if l[i]==0:
            print(i)
            break

Measured memory_bytes: 61912
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000002

void check(vector<pair<int,int>> e,int n){
	/*
	vector<vector<int>> E(2*n,vector<int>());
	for(int i=0;i<e.size();i++){
		int a = e[i].first,b = e[i].second;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	for(int j=0;j<n;j++){
		vector<int> dis(2*n,-1);
		dis[j] = j+1;
		queue<int> Q;
		Q.push(j);
		while(Q.size()!=0){
			int u = Q.front();
			Q.pop();
			for(int i=0;i<E[u].size();i++){
				int v = E[u][i];
				if(dis[v]!=-1)continue;
				int k = v+1;
				if(k>n)k-=n;
				dis[v] = (dis[u] ^ k);
				Q.push(v);
			}
		}
		cout<<dis[n+j]<<endl;
	}
	*/

}

int main(){
	
	int N;
	cin>>N;
	
	if(N==1){
		cout<<"No"<<endl;
		return 0;
	}
	vector<pair<int,int>> E;
	if(N%2==1){
		for(int i=2;i<=N;i+=2){
			E.emplace_back(1,i);
			E.emplace_back(i,i+1);
			E.emplace_back(1,N+i+1);
			E.emplace_back(N+i+1,N+i);
		}
		E.emplace_back(N+1,3);
	}
	else{
		int x;
		for(int i=0;true;i++){
			if((N>>i)&1){
				x=(1<<i);
				break;
			}
		}
		if(N==x){
			cout<<"No"<<endl;
			return 0;
		}
		for(int i=0;i+3<=N;i+=4){
			if(i!=0&&i!=x){
				E.emplace_back(x,i);
				E.emplace_back(i,i+1);
				E.emplace_back(i+1,i+2);
				E.emplace_back(i+2,i+3);
				E.emplace_back(i+3,i+N);
				E.emplace_back(i+N,i+N+1);
				E.emplace_back(i+1+N,i+2+N);
				E.emplace_back(i+2+N,i+3+N);
			}
			else if(i==0&&x!=2){
				E.emplace_back(x,i+1);
				E.emplace_back(i+1,i+2);
				E.emplace_back(i+2,i+3);
				E.emplace_back(i+3,i+N+1);
				E.emplace_back(i+N+1,i+N+2);
				E.emplace_back(i+N+2,i+N+3);
			}
			else{
				if(i==x){
					E.emplace_back(i,i+1);
					E.emplace_back(i+1,i+2);
					E.emplace_back(i+2,i+3);
					E.emplace_back(i+3,i+N);
					E.emplace_back(i+N,i+N+1);
					E.emplace_back(i+N+1,i+N+2);
					E.emplace_back(i+N+2,i+N+3);
				}
				else{
					E.emplace_back(2,1);
					E.emplace_back(2,3);
					E.emplace_back(3,N+1);
					E.emplace_back(N+1,N+2);
					E.emplace_back(N+2,N+3);
				}
			}
		
		}
		if(N%4==0){
			E.emplace_back(x,N);
			E.emplace_back(N-x,2*N);
		}
		else if(N%4==2){
			E.emplace_back(2,N);
			E.emplace_back(1,N-1);
			E.emplace_back(N-1,N-2);
			E.emplace_back(1,N+N-2);
			E.emplace_back(N+N-2,N+N-1);
			E.emplace_back(N-1,N+N);
		}
		
		
	}
	check(E,N);
	cout<<"Yes"<<endl;
	for(int i=0;i<E.size();i++)cout<<E[i].first<<' '<<E[i].second<<endl;
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vb = vector<bool>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

ll w, h;
vvll graph;

void dfs(vvll &graph, ll x, ll y){
  graph[y][x] = 2;
  rep(dx, -1, 2) rep(dy, -1, 2)if(x + dx >= 0 && x + dx < w && y + dy >= 0 && y + dy < h)if(graph[y + dy][x + dx] == 1) dfs(graph, x + dx, y + dy);
}

int main(){
  while(true){
  cin >> w >> h;
  if(w == 0 && h == 0) break;
  graph.assign(h, vll(w));
  rep(y, 0, h)rep(x, 0, w) cin >> graph[y][x];
  ll ans = 0;
  rep(y, 0, h)rep(x, 0, w){
    if(graph[y][x] == 1){
      dfs(graph, x, y);
      ans++;
    }
  }
  cout << ans << endl;}
}


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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double d = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
  printf("%lf\n", d);

  return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
    int a[100];
    int t=0;
    char s[100];
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]=='1')
            a[t++]=1;
        else if(s[i]=='0')
            a[t++]=0;
        else if(s[i]=='B'&&t)
            t--;
    }
    for(int i=0;i<t;i++)
        printf("%d",a[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
int main(){
	int n;
	int count=1;
	cin>>n;
	while(n--){
		int s;
		int p[12]={0};
		cin>>s;
		p[0]=s;
		REP(i,11){
			int d=pow(p[i-1],2);
			string a=to_string(d);
			string b="";
			while(a.size()<8){
				a='0'+a;
			}
			//debug(a);
			for(int j=2;j<=5;j++)
				b+=a[j];
			p[i]=stoi(b);
		}
		cout<<"Case "<<count++<<":"<<endl;
		REP(i,11)
			cout<<p[i]<<endl;
		
	}
	
}

Measured memory_bytes: 3236
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var cij = new long[10][];
            for (var i = 0; i < 10; ++i)
                cij[i] = Sarray();
            var Aij = new long[H][];
            for (var h = 0; h < H; ++h)
                Aij[h] = Sarray();
            var saitan = new long[10];
            for (var i = 0; i < 10; ++i)
                saitan[i] = cij[i][1];
            for (var n = 0; n < 10; ++n)
            {
                for (var i = 0; i < 10; ++i)
                {
                    for (var j = 0; j < 10; ++j)
                        saitan[j] = Min(saitan[j], saitan[i] + cij[j][i]);
                }
            }
            var ans = 0L;
            for(var h=0;h<H;++h)
            {
                for(var w=0;w<W;++w)
                {
                    if (-1 != Aij[h][w])
                        ans += saitan[Aij[h][w]];
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15444
def answer(n: int, k: int, h: []) -> int:
    return len(list(i for i in h if k <= i))


def main():
    n, k = map(int, input().split())
    h = map(int, input().split())
    print(answer(n, k, h))


if __name__ == '__main__':
    main()


Measured memory_bytes: 18012
n, m = map(int, input().split())
edges = [[] for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    edges[x - 1].append(y - 1)
    edges[y - 1].append(x - 1)
visited = [False] * n
ret = 0
for i in range(n):
    if not visited[i]:
        q = [i]
        visited[i] = True
        while len(q) > 0:
            u = q.pop(0)
            for v in edges[u]:
                if not visited[v]:
                    q.append(v)
                    visited[v] = True
        ret += 1
print(ret)

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

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  
  string S, T;
  cin >> S >> T;
  cout << T << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  for(int i=0; i<k; ++i) {
    cin >> d[i];
  }
  for(int i=n; i<=10*n; ++i) {
    int tmp = i;
    set<int> s;
    while(tmp!=0) {
      s.insert(tmp%10);
      tmp/=10;
    }
    bool flag = true;
    for(int j=0; j<k; ++j) {
      if(s.count(d[j])) flag = false;
    }
    if(flag) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;

ll gcd(ll x,ll y){
    if(x) return gcd(y%x,x);
    else return y;
}

main(){
    int n=in();
    vec a;
    vector<vector<pii>> b(n);
    rep(i,n){
        a.pb(in());
        rep(j,a[i]){
            int x=in();
            x--;
            int y=in();
            b[i].pb({x,y});
        }
    }
    int ans=0;
    rep(mask,1<<n){
        bool flag=true;
        int cnt=0;
        rep(i,n){
            if(mask&(1<<i)){
                cnt++;
                rep(j,a[i]){
                    if(b[i][j].second ^ ((mask&(1<<b[i][j].first))>0)){
                        flag=false;
                    }
                }
            }
        }
        if(flag)ans=max(ans,cnt);
    }
    cout<<ans;
}


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

int main(){
    char x[20];
    scanf("%s",x);
    int a[strlen(x)];
    int divisor = 0;
    for(int i=0;i<strlen(x);i++){
        a[i] = ((int)x[i] )- 48;
        divisor +=a[i];
    }
    int tamanho = 1;
    for(int i=1;i<strlen(x);i++)
        tamanho*=10;
    int numero = 0;
    for(int j=0;j<strlen(x);j++){
        numero += a[j]*tamanho;
        tamanho/=10;
    }
    if(numero%divisor==0)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
int main(){
   string s;
   cin >> s;
   vector<char> C;
   rep(i, s.size()){
       if(s[i] == 'x')continue;
       C.push_back(s[i]);
   }
   int l = 0, r = C.size() - 1;
   while(r - l >= 0){
       if(C[r] != C[l]){
           cout << -1 << endl;
           return 0;
       }
       r--;l++;
   }
   vector<int> cnt(C.size() + 1, 0);
   int now = 0;
   rep(i, s.size()){
       if(s[i] != 'x'){
           now++;
           continue;
       }
       cnt[now]++;
   }
   ll res = 0;
   l = 0, r = cnt.size() - 1;
   while(r - l >= 0){
       res += abs(cnt[r] - cnt[l]);
       r--;l++;
   }
   cout << res << endl;
}



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

int main()
{
    int N;
    cin >> N;
    if (N / 10 == 9 || N % 10 == 9)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))  # 空白あり

    def S():
        return sys.stdin.readline().rstrip()

    N, T = map(int, S().split())
    A = [0]
    B = [0]
    for i in range(N):
        a, b = LI()
        A.append(a)
        B.append(b)

    dp1 = [[0] * (T + 1) for i in range(N + 1)]
    # dp1[i][j] = 1~i番目から選んでT分以内に食べるときの美味しさの和の最大値
    dp2 = [[0] * (T + 1) for i in range(N + 2)]
    # dp2[i][j] = i~N番目から選んでT分以内に食べるときの美味しさの和の最大値

    for i in range(1, N + 1):
        for j in range(T + 1):
            if j >= A[i]:
                dp1[i][j] = max(dp1[i - 1][j], dp1[i - 1][j - A[i]] + B[i])
            else:
                dp1[i][j] = dp1[i - 1][j]
    for i in range(N, 0, -1):
        for j in range(T + 1):
            if j >= A[i]:
                dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - A[i]] + B[i])
            else:
                dp2[i][j] = dp2[i + 1][j]

    ans = dp1[N][T]
    for i in range(1, N + 1):  # 最後にi番目の料理を食べる
        for j in range(T):
            ans = max(ans, dp1[i - 1][j] + dp2[i + 1][T - 1 - j] + B[i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 215712
b = input()
n = len(b)
ans = 0
kar = 0
for i in range(n):
    for j in range(i,n):
        if b[j] == "A" or b[j] == "T" or b[j] == "G" or b[j] == "C":
           kar += 1
        else:
            if kar > ans:
                ans = kar
            kar = 0
        if j == n - 1:
            if kar > ans:
                ans = kar
            kar = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a>>b>>c;
    if(a>b){
        if(a>c){
            cout <<a*10+b+c<<endl;
        }else{
            cout<<c*10+a+b<<endl;
        }
    }else if(b>c){
        cout<<b*10+a+c<<endl;
    }else{
        cout<<c*10+a+b<<endl;
    }
}
    
    


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string.h>

using namespace std;
typedef long long ll;

#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 10002

int mm[2][SIZE];
int mo[5] = {0,-1,0,1};

void calc(int n,int r){
    int x_1,x_2,y_1,y_2,minx=SIZE-1,maxx=0,miny=SIZE-1,maxy=0;
    int ansV=0,ansL=0;
    vector<int> x_p[SIZE],x_m[SIZE];
    
    memset(mm,0,sizeof(mm));
    
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&x_1,&y_1,&x_2,&y_2);
        
        x_1++;
        y_1++;
        x_2++;
        y_2++;
        
        x_p[x_1].push_back(y_1);
        x_m[x_1].push_back(y_2);
        x_m[x_2].push_back(y_1);
        x_p[x_2].push_back(y_2);
        
        minx = min(minx,x_1);
        miny = min(miny,y_1);
        maxx = max(maxx,x_2);
        maxy = max(maxy,y_2);
    }
    
    for(int i=minx;i<maxx;i++){
        
        for(int j=miny;j<=maxy;j++){
            mm[0][j]=mm[1][j];
        }
        
        
        memset(mm[1],0,sizeof(mm[1]));
        
        
        for(int j=0;j<x_p[i].size();j++){
            mm[1][x_p[i][j]]++;
        }
        for(int j=0;j<x_m[i].size();j++){
            mm[1][x_m[i][j]]--;
        }
        
        for(int j=miny+1;j<=maxy;j++){
            mm[1][j]+=mm[1][j-1];
        }
        
        for(int j=miny;j<=maxy;j++){
            mm[1][j]+=mm[0][j];
        }
        
        for(int j=miny;j<=maxy;j++){
            if(mm[1][j]>0){
                ansV++;
                
                for(int k=0;k<3;k++){
                    if(mm[1+mo[k]][j+mo[k+1]]==0){
                        ansL++;
                    }
                }
            }else{
                if(mm[0][j]>0){
                    ansL++;
                }
                
            }
        }
        
    }
    
    for(int j=minx;j<=maxx;j++){
        if(mm[1][j]==1)
            ansL++;
    }
    
    printf("%d\n",ansV);
    
    if(r==2)
        printf("%d\n",ansL);
    
    return;
}

int main(){
    int n,r;
    
    while(1){
        scanf("%d%d",&n,&r);
        if(n==0) break;
        calc(n,r);
    }
    
    return 0;
}

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

int main(){
  string s,c = "Yes";
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s.at(i)=='L')
      c = "No";
    if(i%2==1&&s.at(i)=='R')
      c = "No";
  }
  cout << c << endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,k;
    cin>>n>>k;

    vector<int> have(n,false);

    rep(i,k){
        int di;
        cin>>di;

        rep(j,di)
        {
            int adi; cin>>adi; --adi;
            have[adi] = true;
        }
    }

    rep(i,n){
        if(have[i] == false)++ans;
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = ReadLine();
            string [] arrey =input.Split(' ');
            int a = int.Parse(arrey[0]);
            int b = int.Parse(arrey[1]); 
            int c = a * b;
            if (c % 2 == 0)
            {
                WriteLine("Even");
            }
            else {
                WriteLine("Odd");
            }
            ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>

#define MAX 10000

main(){
unsigned short *x, *y;/*0~255 */

  int n,i,count[MAX+1];
  scanf("%d", &n);

  x = malloc(sizeof(short)* n+1);
  y = malloc(sizeof(short)* n+1);

  for (i=0; i<=MAX; i++)
    count[i]=0;


  for (i=0; i<n; i++){

    scanf("%d",&x[i+1]);
    count[x[i+1]]++;
  }

  for (i=1; i<=MAX; i++)
    count[i]=count[i]+count[i-1];

  for (i=1; i<=n; i++){
    y[count[x[i]]] = x[i];
    count[x[i]]--;
  }

  for (i=1; i<=n; i++){

    if(i>1) printf(" ");

    printf("%d",y[i]);
  }

  printf("\n");
  return 0;
}



Measured memory_bytes: 9580
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def sieve(n:Int) = {
    val list = Array.tabulate(n+1) { _ % 2 }
    val primes = new ArrayBuffer[Int]
    list(1) = 0
    list(2) = 2
    primes += 2

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(list(i) == 1) {
        (i*i to n by i*2).foreach { list(_) = 0 }
        primes += primes(primes.length-1)+i
      }
    }
    for(i<-Math.sqrt(n).toInt+1 to n if list(i)==1)
      primes += primes(primes.length-1)+i
    primes.toArray
  }

  def main(args:Array[String]) = {
    val p = sieve(150000)
    var n = 0
    while( { n = readInt; n} != 0 ) println(p(n-1))
  }
}

Measured memory_bytes: 50588
N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * N for _ in range(1 << N)]
DY = [[0] * N for _ in range(1 << N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[k][i] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[k][i] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(t)

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[i][k], DY[j][k])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)


print(*ANS, sep = "\n")


Measured memory_bytes: 88628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    int n,m; cin>>n>>m;
    priority_queue<ll> q;
    for (int i = 0; i < n; ++i) {
        ll a; cin>>a;
        q.push(a);
    }
    for (int i = 0; i < m; ++i) {
        ll t = q.top() >> 1;
        q.pop();
        q.push(t);
    }
    ll ans = 0;
    while (q.size()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>xdic;
	rep(i, 0, n)cin >> a[i];
		
	vector<ll>ans;
	rep(i, 0, n) {
		if (ans.size() == 0) {
			ans.pb(a[i]);
		}
		else {
			if (a[i] > ans.back()) {
				ans[ans.size()-1] = a[i];
			}
			else if (a[i] <= ans[0]) {
				ans.insert(ans.begin(),a[i]);
			}
			else {
				int ok = 0, ng = ans.size() - 1;
				while (ng - ok > 1) {
					int mid = (ng + ok) / 2;
					if (ans[mid] < a[i])ok = mid;
					else ng = mid;
				}
				ans[ok] = a[i];
			}
		}
	}
	puts(ans.size());

	return 0;
}


Measured memory_bytes: 2168
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var b = long.Parse(inputs[1]);
            var c = long.Parse(inputs[2]);
            var d = long.Parse(inputs[3]);

            var start = Math.Max(a, c);
            var end = Math.Min(b, d);

            var result = Math.Max(end - start,0);
 
            Console.WriteLine(result);
        }
    }
}


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

int main() {
  int n;
  std::cin >> n;

  std::vector<int> p;

  for (int i = 0; i < n; ++i) {
    int tp;
    std::cin >> tp;
    p.push_back(tp);
  }

  int count = 0;
  for (int i = 0, e = p.size(); i + 2 < e; ++i) {
    if ((p[i] < p[i + 1]) && (p[i + 1] < p[i + 2])) {
      ++count;
    } else if ((p[i] > p[i + 1]) && (p[i + 1] > p[i + 2])) {
      ++count;
    }
  }

  std::cout << count << std::endl;
}

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

void ab_swap(int *x, int *y)
{
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

void ac_swap(int *x, int *z)
{
  int temp;
  temp = *x;
  *x = *z;
  *z = temp;
}

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  
  ab_swap(&x, &y);
  ac_swap(&x, &z);
  
  cout << x << " " <<  y << " " <<  z << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


S = str(input())
P = str(input())

is_ok = False

for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break

    if FLG == True:
        is_ok = True
        break

if is_ok == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5580
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>


#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;


using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    Bint s;
    cin>>s;
    if(s%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3412
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  char a, b;
  cin >> a >> b;
  cout << (b == 'R' ? "ABC" : "ARC") << "\n";
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
    string S;
    getline(cin,S);
    if(S[5]=='1'||S[6]>='5'){
        cout<<"TBD"<<endl;
    }else{
        cout<<"Heisei"<<endl;
    }
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string s;
   cin >> s;
   int cnt = 0;

   rep(i, s.size())
   {
      if (s[i] == '1')
         cnt++;
   }
   cout << cnt << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pqdef priority_queue
#define ii pair<int,int>
#define st first
#define nd second
#define ll long long 
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define INF 0xFFFFFF
#define endl '\n'
#define bitctr(n) __builtin_popcount(n)//2 tabainindaki basasmak toplami
#define bitctrll(n) __builtin_popcountll(n)//long long 2 tabainindaki basasmak toplami
const double PI = acos(-1);//2*acos(0.0);
const int MAXX=1000005;
const int maxInt = 2147483647;
using namespace std;
int vis[MAXX],dis[MAXX];
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int xxx = n*a;
	if(xxx < b) cout<<xxx;
	else cout<<b;
	return 0;
}


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

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

    bool Prime[101];
    rep(i, 101) Prime[i] = true;
    Prime[0] = Prime[1] = false;
    for (int i=2; i<=100; i++) {
        if (Prime[i]) {
            for (int j=i*2; j<=100; j+=i) Prime[j] = false;
        }
    }

    int CntP[101] = {};
    for (int n=1; n<=N; n++) {
        for (int i=2; i<=N; i++) {
            if ((Prime[i]) && (n%i==0)) {
                int tmp = n;
                while ((tmp > 1) && (tmp%i==0)) {
                    CntP[i]++;
                    tmp /= i;
                }
            }
        }
    }

    int over3=0, over5=0, over15=0, over25=0, over75=0;
    rep(i, N+1) {
        if (CntP[i] >= 2) over3++;
        if (CntP[i] >= 4) over5++;
        if (CntP[i] >= 14) over15++;
        if (CntP[i] >= 24) over25++;
        if (CntP[i] >= 74) over75++;
        // cout << i << " : " << CntP[i] << endl;
    }

    int ans = 0;
    ans += (over5 * (over5 - 1)) / 2 * (over3 - 2); 
    ans += over15 * (over5 - 1); 
    ans += over25 * (over3 - 1); 
    ans += over75;

    cout << ans << endl;

    return 0;
}

 

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
long long array[1000001]={0};
int main(int argc, const char * argv[]) {
    int n,x;
    scanf("%d%d",&x,&n);
    long long p[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&p[i]);
    }
    //qsort(p,n,sizeof(long long),compare);
    int array[105];
    for(int i=0;i<=102;i++){
        array[i]=1;
    }
    for(int i=0;i<n;i++){
        array[p[i]]=0;
    }
    int d=200,ans=-1;
    for(int i=-100;i<=101;i++){
        if(abs(x-i)<d&&array[i]){
            ans=i;
            d=abs(x-i);
        }
    }
    printf("%d",ans);
    
    
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<int, int> pp;
int n;
int a, b;
bool flag[1 << 20] = {0};
bool in[1 << 20] = {0};
int dui2[1 << 20];
int cnt1 = 0, cnt2 = 0;
int change(int x, int y)
{
	return x ^ (1 << y);
}
int now;
void dfs2(int t)
{
	if(t == cnt2 + 1)
		return ;
	dfs2(t + 1);
	now = change(now, dui2[t]);
	cout << now << " ";
	dfs2(t + 1);
}
pp dui1[1 << 20];
void dfs1(int t, bool asd)
{
	if(t == cnt1 + 1)
	{
		dfs2(1);
		return ;
	}
	if(!asd)
	{
		dfs1(t + 1, 0);
		now = change(now, dui1[t].first);
		cout << now << " ";
		dfs1(t + 1, 0);
		now = change(now, dui1[t].second);
		cout << now << " ";
		dfs1(t + 1, 0);
		now = change(now, dui1[t].first);
		cout << now << " ";
		dfs1(t + 1, 0);
	}
	if(asd)
	{
		dfs1(t + 1, 0);
		now = change(now, dui1[t].second);
		cout << now << " ";
		dfs1(t + 1, 0);
		now = change(now, dui1[t].first);
		cout << now << " ";
		dfs1(t + 1, 0);
		now = change(now, dui1[t].second);
		cout << now << " " ;
		dfs1(t + 1, 1);
	}
}
void work()
{
	int x = n + 1;
	int dan1 = n + 1, dan2 = n + 1;
	for(int i = 0; i < n; i ++)
	{
		if(in[i])
		{
			if(x >= n)
				x = i;
			else
			{
				if(dan1 >= n)
					dan1 = i;
				else
				{
					dui1[++ cnt1] = mp(dan1, i);
					dan1 = n + 1;
				}
			}
		}
		else
		{
			//cout << i << endl;
			dui2[++ cnt2] = i;
		}
	}
	//cout << "x " << x << endl;
	/*
	cout << "cnt1 " << cnt1 << endl;
	for(int i = 1; i <= cnt1; i ++)
		cout << dui1[i].first << " " << dui1[i].second << endl;
	cout << "cnt2 " << cnt2 << endl;
	for(int i = 1; i <= cnt2; i ++)
		cout << dui2[i].first << " " << dui2[i].second << endl;
	*/
	
	now = a;
	cout << now << " ";
	dfs1(1, 0);
	//cout << "asd" << " " << now << endl;
	now = change(now, x);
	cout << now << " ";
	dfs1(1, 1);
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> a >> b;
	int cnt = 0;
	for(int i = 0; i < n; i ++)
		if(((a >> i) & 1) != ((b >> i) & 1))
		{
			cnt ++;
			in[i] = 1;
		}
	
	if(cnt % 2 == 0)
	{
		cout << "NO" << endl;
		return 0;
	}
	
	cout << "YES" << endl;
	//flag[b] = 1;
	work();
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,Ma,Mb;
int dp [41] [401] [401];
const int INF = 1e9;

int main()
{
	scanf("%d%d%d",&N,&Ma,&Mb);
	fill(dp [0] [0],dp [41] [0],INF);
	dp [0] [0] [0] = 0;
	FOR(i,0,N){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		FOR(j,0,401) FOR(k,0,401) if(dp [i] [j] [k] != INF){
			chmin(dp [i + 1] [j] [k],dp [i] [j] [k]);
			chmin(dp [i + 1] [j + a] [k + b],dp [i] [j] [k] + c);
		}
	}

	int ans = INF;
	FOR(i,0,401) FOR(j,0,401){
		if(i && j && i % Ma == 0 && j % Mb == 0 && i / Ma == j / Mb){
			chmin(ans,dp [N] [i] [j]);
		}
	}

	printf("%d\n",ans != INF ? ans : -1);

	return 0;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],count = 0;
  for(int i = 0;i<n;i++)
  {
    cin>>a[i];
    if(a[i] & 1 && (i+1) & 1)
    {
      count++;
    }
  }
  cout<<count;
}

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

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

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
   NodePointer x;
   x = nil->next;
   while(x!=nil && x->key!=key){
     x = x->next;
   }
   return x;
}

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

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t); 
}

void delete(int key){
  NodePointer x;
  if((x=listSearch(key))!=nil){
    deleteNode(x);
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32988
#include <stdio.h>

int main()
{
	int i, x, n, ans, pp, p[102] = {};
	scanf("%d %d", &x, &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &pp);
		p[pp] = 1;
	}
	for (i = 0; i <= 100; i++) {
		if (p[x-i] == 0) {
			ans=x - i;
			break;
		} else if (p[x+i] == 0) {
			ans=x + i;
			break;
		}
    }
    printf("%d",ans);  
	return 0;
}


Measured memory_bytes: 1716
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

ll A, B, K;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B >> K;
  ll a = A - min(A, K);
  K = max(K - A, 0LL);
  ll b = B - min(B, K);
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
const lint mod = 1e9 + 7;
lint emod(lint a) { return (a % mod + mod) % mod; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> t(n); for (int i = 0; i < n; i++) cin >> t[i];
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) return cout << (t[0] == a[0] ? 1 : 0) << '\n', 0;
  V<> b(n, 1); b[0] = t[0], b[n - 1] = a[n - 1];
  for (int i = 0; i < n - 1; i++) {
    if (t[i] < t[i + 1]) b[i + 1] = t[i + 1];
  }
  for (int i = n - 1; i; i--) {
    if (a[i] < a[i - 1]) b[i - 1] = a[i - 1];
  }
  V<> c(n); for (int i = 0; i < n; i++) c[i] = min(t[i], a[i]);
  lint res = 1;
  for (int i = 0; i < n; i++) {
    if (b[i] > c[i]) return cout << 0 << '\n', 0;
    res = res * (c[i] - b[i] + 1) % mod;
  }
  cout << emod(res) << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, a[3], zero = 0;
    cin >> n >> a[0] >> a[1] >> a[2];
    vector< pair<string, int> > s;
    for(int i=0;i<n;++i) {
        string t;
        cin >> t;
        if(s.empty() || s.back().first != t) {
            s.emplace_back(t, 1);
        } else {
            ++s.back().second;
        }
    }
    zero = int(a[0] == 0) + int(a[1] == 0) + int(a[2] == 0);
    if(zero == 3) {
        cout << "No" << endl;
        return 0;
    }

    int ns = s.size(), ai = 0;
    vector<char> ans(n);
    for(int i=0;i<ns;++i) {
        string t = s[i].first;
        int k1 = t[0] - 'A';
        int k2 = t[1] - 'A';
        int k3 = 0;
        while(k1 == k3 || k2 == k3) ++k3;
        
        // cerr << a[0] << " " << a[1] << " " << a[2] << endl;

        for(int j=0;j<s[i].second;++j) {
            if(a[k1] >= 2) {
                ans[ai++] = char('A' + k2);
                --a[k1]; ++a[k2];
            } else if(a[k1] == 1) {
                if(a[k2] >= 2) {
                    ans[ai++] = char('A' + k1);
                    --a[k2]; ++a[k1];    
                } else if(a[k2] == 1) {
                    if(i == ns-1) {
                        // 先読みできない
                        ans[ai++] = char('A' + k2);
                        --a[k1]; ++a[k2]; 
                    } else {
                        // 先読みして決める
                        string u = s[i+1].first;
                        int l1 = u[0] - 'A';
                        int l2 = u[1] - 'A';
                        if(k1 != l1 && k1 != l2) {
                            ans[ai++] = char('A' + k2);
                            --a[k1]; ++a[k2]; 
                        } else {
                            ans[ai++] = char('A' + k1);
                            --a[k2]; ++a[k1];  
                        }
                    }
                } else {
                    ans[ai++] = char('A' + k2);
                    --a[k1]; ++a[k2];
                }
            } else {
                if(a[k2] >= 1) {
                    ans[ai++] = char('A' + k1);
                    --a[k2]; ++a[k1];  
                } else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    for(int i=0;i<n;++i) cout << ans[i] << endl;
}


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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (double a) {return Point(a*x,a*y);}
    Point operator / (double a) {return Point(x/a,y/a);}

    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}

    bool operator<(const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator==(const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

struct Segment {Point p1,p2;};
typedef Point Vector;
typedef Segment Line;

class Circle {
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0): c(c),r(r) {}
};

double dot(Vector a,Vector b) {
    return  a.x*b.x+a.y*b.y;
}

double cross (Vector a,Vector b) {
    return a.x*b.y-a.y*b.x;
}

Point getCrossPoint(Segment s1,Segment s2) {
    Vector base=s2.p2-s2.p1;
    double d1=abs(cross(base,s1.p1-s2.p1));
    double d2=abs(cross(base,s1.p2-s2.p2));
    double t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}

int main(void) {
    int q;cin>>q;
    while(q) {
        Segment s1,s2;
        cin>>s1.p1.x>>s1.p1.y>>s1.p2.x>>s1.p2.y>>s2.p1.x>>s2.p1.y>>s2.p2.x>>s2.p2.y;
        Point ans=getCrossPoint(s1,s2);
        printf("%.10f %.10f\n",ans.x,ans.y);
        q--;
    }
    return 0;
}

Measured memory_bytes: 3188