akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}

const int maxN = 200011;

int n;
int a[maxN], b[maxN];
priority_queue< pair<int, int> > H;
ll answer;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
        H.push(mp(b[i], i));
    }

    while (!H.empty()) {
        auto act = H.top(); H.pop();
        int pos = act.second;

        int prv = (pos + n - 1) % n;
        int nxt = (pos + 1) % n;
        int sum = b[prv] + b[nxt];

        if (b[pos] < a[pos]) continue;

        int can = (b[pos] - a[pos]) / sum;
        if (can == 0) continue;
        answer += 1LL * can;
        b[pos] -= sum * can;
        H.push(mp(b[pos], pos));
    }

    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            printf("-1");
            exit(0);
        }
    }

    printf("%lld", answer);

    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

set<int> sticks;
vector<int> nums;

int main() {
    int N;
    cin >> N;
    
    rep(i,N){
        int x;
        cin >> x;
        
        if(sticks.find(x)!=sticks.end()){
            nums.push_back(-x);
            sticks.erase(x);
        }else {
            sticks.insert(x);
        }
    }
    
    if(nums.size()>1){
        sort(nums.begin(),nums.end());
        cout1(1ll*nums[0]*nums[1]);
    }else{
        cout1(0);
    }
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
    int K,N;
    int A[2*10*10*10*10*10];
    
    int maxlength=0,length=0,i,min;
    
    scanf("%d",&K);
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    
    for(i=0;i<N;i++){
        if(i!=N-1){
            length=A[i+1]-A[i];
        }else{
            length=(K-A[N-1])+A[0];
        }
        
        if(maxlength<length){
                maxlength=length;
        }
    }
    
    min=K-maxlength;
    
    printf("%d\n",min);
    
    return 0;
}

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


int main() {
    int n;
    string s;
    cin >> n >> s;

    int num = 0;
    for (int i = 0; i <= n-3; i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            num++;
        }
    }

    cout << num << endl;
    return 0;
}

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

int main ()
{
	int n;
	bool card[4][13];
	for (int i=0; i<4; i++)
		for (int j=0; j<13; j++)
		{
			card [i][j] = false;
		}
	cin >> n;
	
	for (int i=0; i<n; i++ )	
	{
		int number; char mark;
		cin >> mark >> number;
		
		switch (mark)
		{
			case 'S' : 
				card[0][number-1] = true;
				break;
			case 'H' : 
				card[1][number-1] = true;
				break;
			case 'C' : 
				card[2][number-1] = true;
				break;
			case 'D' : 
				card[3][number-1] = true; 
				break;
				
		}
	}
	
	for (int j=0; j<13; j++)
	{
		if (card[0][j]==false){
			cout << "S " << j+1 << endl;
		}
	}
	
	for (int j=0; j<13; j++)
	{
		if (card[1][j]==false){
			cout << "H " << j+1 << endl;
		}
	}
	
	for (int j=0; j<13; j++)
	{
		if (card[2][j]==false){
			cout << "C " << j+1 << endl;
		}
	}
	
	for (int j=0; j<13; j++)
	{
		if (card[3][j]==false){
			cout << "D " << j+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3016
#include <iostream>

using namespace std;

int dfs(int o, int n, int s) {
    if (n == 0 && s == 0) return 1;

    int ret = 0;
    for (int i = o; i <= 9; i++) {
        ret += dfs(i + 1, n - 1, s - i);
    }
    return ret;
}

int main() {
    double n, s;
    while (cin >> n >> s) {
        if (n == 0 && s == 0) break;
        cout << dfs(0, n, s) << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
#define LLINF 1145148101919
#define PI 3.14159265359
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

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

string S, T;
int ctoi_alpha(char c)
{
    if (c >= 'a' && c <= 'z')
    {
        return c - 'a';
    }
    return 0;
}

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

int main()
{
    ll N; cin >> N;
    
    cout << (N-1)*N/2 << endl;

    return 0;
}


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

int main() {
  int N; // N計算の数
  int output = 0;
  cin >> N;
     
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int r, l, num;
    cin >> r >> l;
    output +=  l - r + 1;
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> friends(N, vector<int>(0));
    vector<vector<int>> blocks(N, vector<int>(0));
    vector<int> belongTo(N, -1);
    vector<int> groups;

    rep(i, M){
        int a, b;
        cin >> a >> b;
        friends[a - 1].push_back(b - 1);
        friends[b - 1].push_back(a - 1);
    }
    rep(i, K){
        int a, b;
        cin >> a >> b;
        blocks[a - 1].push_back(b - 1);
        blocks[b - 1].push_back(a - 1); 
    }

    int groupNo = -1;
    int groupSize = 1;
    rep(i, N){
        if(belongTo[i] == -1){
            groupNo++;
            groupSize = 1;
            stack<int> s;
            s.push(i);
            belongTo[i] = groupNo;
            while(s.size() > 0){
                int cuser;
                cuser = s.top();
                s.pop();
                for(int x: friends[cuser]){
                    if(belongTo[x] == -1){
                        s.push(x);
                        belongTo[x] = groupNo;
                        groupSize++;
                    }
                }
            }
            groups.push_back(groupSize);
        }
    }
    rep(i, N){
        int cantBefriends = 0;
        for(int x: friends[i]){
            if(belongTo[i] == belongTo[x]) cantBefriends++;
        }
        for(int x: blocks[i]){
            if(belongTo[i] == belongTo[x]) cantBefriends++;
        }

        cout << groups[belongTo[i]] - 1 - cantBefriends;
        if(i != N - 1){
            cout << " ";
        }
    }
    
    return 0;
}


Measured memory_bytes: 12664
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{

	long long a, b, c, Ans;
	cin >> a >> b;

	if (a % 2 == 0 || b % 2 == 0) {
		cout << "No";
	}
	else cout << "Yes";



	return 0;
}


Measured memory_bytes: 256
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 400 + 5;
long long n, a[MAX_N], dp[MAX_N][MAX_N];

void read_input() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
}

void solve() {
	for (int dif = 1; dif < n; dif++)
		for (int i = 0; i + dif < n; i++) {
			int j = i + dif;
			dp[i][j] = 1e16;
			for (int k = i; k < j; k++)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + a[j + 1] - a[i]);
		}
}

void print_output() {
	cout << dp[0][n - 1];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 1536
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 void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var Ai = Sarray();
            var rui = new long[N + 1];
            for (var i = 1; i <= N; ++i)
                rui[i] = (rui[i - 1] + Ai[i - 1] + M) % M;
            var dct = new Dictionary<long, long>();
            foreach (var r in rui)
            {
                if (!dct.ContainsKey(r)) dct[r] = 0;
                ++dct[r];
            }
            var ans = 0L;
            foreach (var d in dct)
                ans += d.Value * (d.Value - 1) / 2;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 23904
a, b = map(int,input().split())
 
def f(n) :
    if n % 4 == 0 :
        return n
    elif n % 4 == 1 :
        return 1
    elif n % 4 == 2 :
        return n + 1
    else :
        return 0

print(f(a - 1) ^ f(b))

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,k;
  cin>>n>>k;
  vll x(n),y(n);
  REP(i,n){
    char c;
    cin>>x[i]>>y[i]>>c;
    if(c=='W')
      x[i]+=k;
    x[i]%=2*k;
    y[i]%=2*k;
  }


  vvll blacks(4*k+1, vll(4*k+1));
  REP(i,n){
    blacks[x[i]+1][y[i]+1]++;
    blacks[x[i]+1][y[i]+2*k+1]++;
    blacks[x[i]+2*k+1][y[i]+1]++;
    blacks[x[i]+2*k+1][y[i]+2*k+1]++;
  }

  REP(i,4*k+1){
    REP(j,4*k)
      blacks[i][j+1]+=blacks[i][j];
  }
  REP(j,4*k+1){
    REP(i,4*k)
      blacks[i+1][j]+=blacks[i][j];
  }

  auto calcPoint=[&](ll a, ll b){
    ll res=blacks[a+k][b+k]-blacks[a+k][b]-blacks[a][b+k]+blacks[a][b];
    return res;
  };


  ll ans=0;
  REP(i,2*k){
    REP(j,2*k)
      ans=max(ans,calcPoint(i,j)+calcPoint(i+k,j+k));
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 127104
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int n,m;
  int a[100000];
  int now = 0;
  int ans = 0;
  cin>>n>>m;
  REP(i,n-1){
    int tmp;
    cin>>tmp;
    a[i+1] = a[i] + tmp;
  }
  REP(i,m){
    int d;
    cin>>d;
    ans = (ans+abs(a[now]-a[now+d]))%100000;
    now += d;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int sum=1;
		if(K>1) {
			for(int i=0; i<N-1; i++) {
				sum*=(K-1);
			}
			sum*=K;
		}
		else if(K==1) {
			sum=1;
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, ans = 0;
  vi max, min;
  bool flag = true;  // true なら↑　falseなら↓
  cin >> N;
  vi h(N);
  REP(i, N) cin >> h.at(i);
  min.push_back(0);
  if (N == 1) {
    cout << h.at(0) << endl;
    return 0;
  }
  if (h.at(0) > h.at(1)) {
    max.push_back(h[0]);
    flag = false;
  } else {
    flag = true;
  }

  for (int i = 1; i < N - 1; i++) {
    if (h.at(i) < h.at(i + 1) && !flag) {
      min.push_back(h.at(i));
      flag = true;
    } else if (h.at(i) > h.at(i + 1) && flag) {
      max.push_back(h.at(i));
      flag = false;
    }
  }
  if (flag == true) max.push_back(h.at(N - 1));
  for (int j = 0; j < max.size(); j++) {
    ans += max.at(j) - min.at(j);
  }
  cout << ans << endl;
}

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

int main(){

  int N=0;
  cin>>N;
  
  string s;
  cin>>s;
  
  rep(i,s.size()){
	int a=s[i]-'A';
    a=(a+N)%26;
    s[i]=('A'+a);
  }
  cout<<s;
  
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
cnt=[0 for _ in range(100001)]
for i in range(N):
    cnt[A[i]]=1

x=cnt.count(1)
y=N-x
if y%2==0:
    print(N-y)
else:
    print(N-y-1)


Measured memory_bytes: 20808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] p = new double[n+1];
		p[0] = 0;
		for (int i = 1; i < n+1; i++) {
			p[i] = sc.nextDouble();
		}
		double[][] dp = new double[n+1][n+1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n+1; j++) {
				if(j > i) dp[i][j] = 0;
				else {
					dp[i+1][j] += dp[i][j]*(1-p[i+1]);
					dp[i+1][j+1] += dp[i][j]*p[i+1];
				}
			}
		}
		double ans = 0;
		for (int i = (n+1)/2; i < n+1; i++) {
			ans += dp[n][i];
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 124400
#include <bits/stdc++.h>
using namespace std;
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;
 
#define PB push_back
#define MP make_pair
 
#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'
 
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 
 
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;
 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()
 
#define int long long
 
const int upper = 1e5 + 20;
const int M = (int) 1e9 + 7;
const int inf = (int) 1e15;
const double eps =  1e-8;
 
signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif		
 
	int x, y;
	cin >> x >> y;
 
	cout << x + y / 2;
 	end_routine();	
}

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    if ((10*g+b)%4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    println(problem177b(s, t))
}

fun problem177b(s: String, t: String): Int {
    var min = Integer.MAX_VALUE
    for (i in 0..s.length - t.length) {
        val sub = s.substring(i, i + t.length)
        var count = 0
        for (j in 0 until t.length) {
            val subJ = sub[j]
            if (subJ != t[j]) count++
        }
        min = Math.min(min, count)
    }
    return min
}

Measured memory_bytes: 37784
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
ll seg[400005];
void upd(ll si,ll st,ll en,ll id){
    if(st==en){
        seg[si]=1;
        return;
    }
    ll mi=(st+en)/2;
    if(id<=mi) upd(2*si+1,st,mi,id);
    else upd(2*si+2,mi+1,en,id);
    seg[si]=seg[2*si+1]+seg[2*si+2];
}
ll go(ll si,ll st,ll en,ll l,ll r){
    if(st>r || en<l) return 0;
    if(l<=st && r>=en) return seg[si];
    ll mi=(st+en)/2;
    return go(2*si+1,st,mi,l,r)+go(2*si+2,mi+1,en,l,r);
}
int main() {
	// your code goes here
	ll i,j,n,m,k,t,a,b;
	cin>>n>>m;
	vector<pair<ll,ll> >v;
	for(i=0;i<n;i++){
	    cin>>a>>b;
	    if(a>m) continue;
	    v.push_back({b,a});
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll re=0, ctr=0;
	for(i=0;i<v.size();i++){
	    ll val=v[i].first;
	    ll dy=v[i].second;
	    ll cd=m-dy;
	    if(go(0,0,m,cd,cd)==0){
	        re+=val;
	        ctr+=1;
	        upd(0,0,m,cd);
	    }
	    else {
	        ll lo=0,hi=cd-1,ans=-1;
	        while(lo<=hi){
	            ll mi=(lo+hi)/2;
	            if(go(0,0,m,mi,cd)==(cd-mi+1)) hi=mi-1;
	            else ans=mi,lo=mi+1;
	        }
	        if(ans!=-1){
	            re+=val;
	            ctr+=1;
	            upd(0,0,m,ans);
	        }
	    }
        
	}
	cout<<re<<"\n";
	return 0;
}

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

int main()
{
  int N;
  int d[110];
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> d[i];

  set<int> values;
  for (int i = 0; i < N; ++i) {
    values.insert(d[i]);
  }

  cout << values.size() << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

using namespace std;

int main()
{
    long long i, sum =0, n, a;
    cin >>n;
    for(i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0 && i%15!=0)
        {
            sum = sum +i;
        }
    }
    cout <<sum <<endl;

    return 0;
}





Measured memory_bytes: 3620
import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		solver.solve(1, in, out);
		out.close();
	}
}



class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
 
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }
 
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
}


class Solver{
	public void solve(int testNumber, InputReader in, PrintWriter out){
		int N = in.nextInt();
		int arr [] = new int [N];
		for(int i =0 ; i < N; i++){
			arr[i] = in.nextInt();
		}

		int dp [] = new int [N];
		dp[0] = 0;

		for(int i = 1; i < N; i++){
			if(i< 2){
				dp[i] = Math.abs(arr[i] - arr[i-1]);
			}else{
				dp[i] = Math.min(dp[i-1] + Math.abs(arr[i] - arr[i-1]),dp[i-2] + Math.abs(arr[i] - arr[i-2]));
			}
		} 

		out.println(dp[N-1]);

	}
}

Measured memory_bytes: 34256
/* 
    No more worries, rest your head and go to sleep
    Maybe one day we'll wake up and this will all just be a dream.
*/
#include "bits/stdc++.h"
using namespace std;

#define rep(i,a,n)  for(int i = a; i < n; i++)
#define f first
#define s second
#define pb push_back
#define all(v)  v.begin(), v.end()
#define fast      ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef pair < int, int > P;
typedef long long int ll;
const int N = 1e2 + 5;
const int mod = 1e9 ;
int main(){  fast;  
    ll n, x, i, a[105], ans(0);
           cin >> n >> x;
           rep(i,0,n)cin >> a[i];
           sort(a, a+n);
           rep(i,0,n){
               if(a[i] <= x and i < n - 1)x -= a[i], ++ans;
           }
           if(x == a[n-1])ans++;
           cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

void test(priority_queue<pair<ll,ll>> que){
  while(!que.empty()){
    cout<<que.top().first<<" "<<que.top().second<<endl;
    que.pop();
  }
}

int main(){
  ll n;cin>>n;
  VL d(1000001,0);
  REP(i,n){
    ll tmp;
    cin>>tmp;
    d[tmp]++;
  }
  ll ans=0;
  if(d[1]==1){cout<<1<<endl;return 0;}
  if(d[1]>1){cout<<0<<endl;return 0;}
  for(int i=2;i<1000001;i++){
    if(d[i]==0){continue;}
    if(d[i]==1){ans++;}
    ll start=i;
    ll count=1;
    while(start*count<=1000000){
      d[start*count]=0;
      count++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10800
#include <bits/stdc++.h>
using namespace std;
int n,cnt;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
	for (int i=0;i<n;++i)
	{
		if (s[i]=='(') ++cnt;
		if (s[i]==')') --cnt;
		if (cnt<0)
		{
			cout<<'(';
			++cnt;
		}
	}
	cout<<s;
	while (cnt>0)
	{
		cout<<')';
		--cnt;
	}
	return 0;
}

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

int main() {
  int N, T, A, h, ans = 0;
  vector<int> H;
  cin >> N >> T >> A;

  while (cin >> h) {
    H.push_back(h);
  }

  for (int i = 1; i < N; i++) {
    double t1 = T - H.at(i) * 0.006;
    double t2 = T - H.at(ans) * 0.006;

    if (abs(t1 - A) < abs(t2 - A)) {
      ans = i;
    }
  }

  cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char gc() {
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
typedef long long ll;
const int MAXN=150+5;
int N,k,mod;
inline int add(int x) {return x>=mod?x-mod:x;}
inline void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
namespace sub0 {
	int dp[MAXN][MAXN];
	int sol(int n) {
		memset(dp,0,sizeof(dp));
		for(int i=0;i<=k;++i) dp[0][i]=1;
		for(int i=1;i<=n;++i) {
			int R=n-i+1;
			for(int j=1;j<=R;++j) upd(dp[i][j-1],dp[i-1][j]);
			for(int j=0;j<R&&j<=k;++j) upd(dp[i][j],dp[i-1][0]);
		}
		return dp[n][0];
	}
	int sol() {
		k>>=1;
		return (ll)sol(N>>1)*sol((N+1)>>1)%mod;
	}
}
namespace sub1 {
	int dp[MAXN][MAXN][MAXN];
	int sol() {
		int n=(N+1)>>1,m=N-n;
		k>>=1;
		for(int i=0;i<=n;++i) {
			dp[0][i][k]=1;
			for(int j=k-1,r=1;j>=0;--j) {
				dp[0][i][j]=r;
				r=add(r<<1);
			}	
		}
		for(int i=1;i+k<=m;++i) {
			int R=n-i+1;
			for(int j=1;j<=R;++j) for(int h=0;h<i+k;++h) if(dp[i-1][j][h]) {
				upd(dp[i][j-1][0],dp[i-1][j][h]);
				if(j+h<2*k+2) upd(dp[i][j-1][h+1],dp[i-1][j][h]);
			}
			for(int j=0;j<R;++j) for(int h=0;h<i+k;++h) if(dp[i-1][0][h]) {
				upd(dp[i][j][0],dp[i-1][0][h]);
				upd(dp[i][j][h+1],dp[i-1][0][h]);
			}
		}
		for(int i=m-k+1;i<=n;++i) {
			int R=n-i+1;
			for(int j=1;j<=R;++j) for(int h=0;h<=m;++h) if(dp[i-1][j][h]) {
				upd(dp[i][j-1][h],dp[i-1][j][h]);
			}
			for(int j=0;j<R;++j) for(int h=0;h<=m;++h) if(dp[i-1][0][h]) {
				upd(dp[i][j][h],dp[i-1][0][h]);
			}
		}
		int an=0;
		for(int h=0;h<=m;++h) upd(an,dp[n][0][h]);
		return an;
	}
}
int main() {
	rd(N),rd(k),rd(mod);
	if(~k&1) printf("%d\n",sub0::sol());
	else printf("%d\n",sub1::sol());
	return 0;
}

Measured memory_bytes: 5692
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

sum=0

for i in range(K+1,N+1):
    sum+=(N//i)*(i-K)+max(0,N%i-K+1) #バルクと表面
    
if K==0:
    sum-=N
    
print(sum)



Measured memory_bytes: 2940
import itertools

n, x, y = map(int, input().split())

k = [0] * n

for v in itertools.combinations(list(range(1,n+1)), 2):
  k[min(abs(v[1]-v[0]),abs(x-min(v))+1+abs(y-max(v)))] += 1

for item in k[1:]:
  print(item)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

vector <int> linsieve(int n){
	vector <int> out(n + 1,-1),p;
	for(int i = 2;i <= n;++i){
		if(out[i] == -1){
			p.push_back(i);
			out[i] = i;
		}
		for(int j = 0;j < p.size() and i * p[j] <= n and p[j] <= out[i];++j){
			out[i * p[j]] = p[j];
		}
	}
	return out;
}

void solve(){
	int n;
	cin >> n;
	vector <int> f = linsieve(n);
	vector <vector <int>> out(n + 1,vector <int>(n + 1,0));
	for(int i = 2;i <= n;++i){
		int num = i;
		while(num > 1){
			++out[i][f[num]];
			num = num / f[num];
		}
	}
	vector <int> fac(n + 1,0);
	for(int i = 2;i <= n;++i){
		for(int j = 2;j <= n;++j){
			fac[i] = fac[i] + out[j][i];
		}
	}
	int ans = 0;
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 74) ++ans;
	}
	int a1 = 0,b1 = 0;
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 24) ++a1;
	}
	ans = ans + a1 * (a1 -1);
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 2 and fac[i] < 24) ++b1;
	}
	ans = ans + a1 * b1;
//	cout << a1 << " " << b1 << "yes" << newl;
//	cout << ans << " " << 1 << newl;
	a1 = 0,b1 = 0;
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 14) ++a1;
	}
	ans = ans + a1 * (a1 -1);
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 4 and fac[i] < 14) ++b1;
	}
	ans = ans + a1 * b1;
//	cout << ans << " " << 2 << newl;
	a1 = 0,b1 = 0;
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 4) ++a1;
	} 
	ans = ans + a1 * (a1 - 1) * (a1 - 2) / 2;
//	cout << a1 << "n" << newl;
	for(int i = 2;i <= n;++i){
		if(fac[i] >= 2 and fac[i] < 4) ++b1;
	}
	ans = ans + a1 * (a1 - 1) * b1 / 2;
	cout << ans << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    int hr = n / 3600;
    int min = (n-hr*3600) / 60;
    int sec = n%60;
    cout << hr << ":" << min << ":" << sec << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

/*
隣接行列
橋を一本ずつ消して全探索
*/

int bfs_from(int start,const vvi input) {//inputが隣接行列
    queue<int> q;
    q.push(start);
    vi visited(input.size(),false);
    visited[start] = true;
    int num = 1;

    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v = 0; v < input[0].size(); v++) {
            if (input[u][v] and !visited[v]) {
                q.push(v);
                visited[v] = true;
                num++;
            }
        }
    }

    return num;
}
int main() {
    int N, M; cin >> N >> M;
    vvi Graph(N, vi(N));
    vpii pa(M);
    rep(i, M) {
        int x, y; cin >> x >> y;
        x--; y--;
        pa[i] = { x,y };
        Graph[x][y] = true;
        Graph[y][x] = true;
    }

    int cnt = 0;

    for (int i = 0; i < M; i++) {//消す橋をpaで管理
        vvi temp = Graph;
        temp[pa[i].first][pa[i].second] = false;
        temp[pa[i].second][pa[i].first] = false;

        if (bfs_from(0, temp) < N) {
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int>> adj;
int parent[105];
vector<int>ind[105];
int dp[51][(2<<20)+5];
void dfs(int ver,int p)
{
   parent[ver]=p;
   for(auto i:adj[ver])
   {
      if(i!=p)
         dfs(i,ver);
   }
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   adj.resize(n+1);
   int x,y;
   map<pair<int,int>,int> mm;
   for(int i=0;i<n-1;i++)
   {
      cin>>x>>y;
      adj[x].push_back(y);
      adj[y].push_back(x);
      mm[{x,y}]=i+1;
      mm[{y,x}]=i+1;
   }
   
   vector<vector<int> >all;
   int m;
   cin>>m;
   
   for(int i=0;i<m;i++)
   {
      cin>>x>>y;
      fill_n(parent,105,0);
      dfs(x,0);
      int ini=y;
      vector<int>temp;
      while(ini!=x)
      {
         temp.push_back(mm[{ini,parent[ini]}]);
         ini=parent[ini];
      }
      all.push_back(temp);
   }
   
   for(int i=0;i<m;i++)
   {
      for(auto j:all[i])
      {
         ind[j].push_back(i+1);
      }
   }

   dp[0][0]=1;
   int aa=(2<<(m-1));
   aa--;

   for(int i=1;i<=n-1;i++)
   {
      int z=0;
      for(auto j:ind[i])
      {
         if(j==1)
            z++;
         else
            z+=(2<<(j-2));
      }
      for(int j=0;j<=aa;j++)
      {
         int zz=(j|z);
         dp[i][j]+=dp[i-1][j];
         dp[i][zz]+=dp[i-1][j];
      }
   }

   cout<<dp[n-1][aa];

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 502016
import numpy as np
N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]
INF = 10**30
min_cost = INF
for pattern in range(1<<N):
    skills = np.array([0]*M)
    cost = 0
    for i in range(N):
        if pattern >> i & 1:
            skil = np.array(books[i][1:])
            skills += skil
            cost += books[i][0]
    if min(skills) >= X and cost < min_cost:
        min_cost = cost
if min_cost == INF:
    print(-1)
else:
    print(min_cost)



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

struct Card { char suit, value; };

void bubble ( Card A[], int N ) {
	for ( int i = 0; i < N; i++) {
		for ( int j = N - 1; j >= i + 1 ; j--) {
			if ( A[j].value < A[j - 1].value ) {
				swap( A[j], A[j - 1] );
			}
		}
	}
}

void selection( Card A[], int N) {
	for ( int i = 0; i < N; i++) {
		int minj = i;
		for ( int j = i; j < N; j++ ){
			if ( A[j].value < A[minj].value ) minj = j;
		}
		swap(A[i], A[minj]);
	}
}

void print( Card A[], int N ) {
	for ( int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i].suit << A[i].value ;
	}
	cout << endl;
}

bool isStable( Card C1[], Card C2[], int N) {
	for ( int i = 0; i < N; i++ ) {
		if ( C1[i].suit != C2[i].suit ) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;

	cin >> N;

	for ( int i = 0; i < N; i++ ) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if ( isStable(C1, C2, N) ) {
		cout << "Stable" << endl;
	} else {
	cout << "Not stable" << endl;
	}
	return 0;

}

Measured memory_bytes: 3112
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a <= 9 && b <= 9){
            System.out.println(a * b);
        }else{
            System.out.println("-1");
        }
    }
}

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

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

  int s[13] = {}, h[13] = {}, c[13] = {}, d[13] = {};
  string eg;
  int num;
  for(int i = 0; i < n; i++){
    cin >> eg >> num;
    if(eg == "S"){
      s[num - 1]++;
    }
    if(eg == "H"){
      h[num - 1]++;
    }
    if(eg == "C"){
      c[num - 1]++;
    }
    if(eg == "D"){
      d[num - 1]++;
    }
  }

  int ch = 0;
  for(int i = 0; i < 13; i++){
    if(s[i] == 0){
      cout << "S " << i+1 << endl;
    }
  }
  for(int i = 0; i < 13; i++){
    if(h[i] == 0){
      cout << "H " << i+1 << endl;
    }
  }
  for(int i = 0; i < 13; i++){
    if(c[i] == 0){
      cout << "C " << i+1 << endl;
    }
  }
  for(int i = 0; i < 13; i++){
    if(d[i] == 0){
      cout << "D " << i+1 << endl;
    }
  }


}



Measured memory_bytes: 3156
#include<iostream>
#include<deque>

using namespace std;

int main()
{
	int a, n;
    string command, result;
	cin >> a;

    deque<int> li;
    
    for(int i=0; i<a; i++){
        cin >> command;
        if(command=="insert"){
            cin >> n;
            li.emplace_front(n);
        }else if(command=="delete"){
            cin >> n;
            for(int i=0; i<int(li.size()); i++) {
                if(li[i]==n){
                    li.erase(li.begin() + i);
                    break;
                }
            }
        }else if(command=="deleteFirst"){
            li.pop_front();
        }else if(command=="deleteLast"){
            li.pop_back();
        }
    }
    for(int i=0; i<int(li.size()); i++) {
        cout << li.at(i);
        if(i!=int(li.size()-1))
            cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
  int xa, xb;
  if (x-a > 0) {
    xa = x-a;
  } else {
    xa = a - x;
  }
  if (x-b > 0) {
    xb = x-b;
  } else {
    xb = b - x;
  }
  
  if (xa < xb) {
    cout << 'A' << endl;
  } else {
    cout << 'B' << endl;
  }
  
  
  return 0;  
}

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

int a[N];
unordered_map<int,int> mp;

int main(){
    int n,num=0;
    bool f=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(mp[a[i]]==0) num++;
        mp[a[i]]++;
    }
    if(n%3!=0)  f=0;
    sort(a+1,a+n+1);
    int len=unique(a+1,a+n+1)-a-1;
    if(mp[0]){
        if(num!=2) f=0;
        if(mp[a[2]]!=2*mp[a[1]]) f=0;
    }else{
        if(num!=3) f=0;
        if(mp[a[1]]!=mp[a[2]]) f=0;
        if(mp[a[2]]!=mp[a[3]]) f=0;
        if((a[1]^a[3])!=a[2]){
            //cout<<"@@"<<endl;
            f=0;
        }
        //cout<<"@@"<<endl;
    }
    //cout<<a[2]<<endl;
    //int res=a[1]^a[3];
    //cout<<res<<endl;
    //cout<<f<<endl;
    if(mp[0]==n) f=1;
    if(f) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n;
  cin>>n;
  int n2=n*3;
  vector<ll> a(n2);
  for(int i=0;i<n2;i++) cin>>a[i];
  sort(a.begin(),a.end());
  ll ans=0;
  int ind=n2-2;
  for(int i=0;i<n;i++){
    ans+=a[ind];
    ind-=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	char y[3]={'Y','e','s'};
	char n[2]={'N','o'};
	scanf("%d %d %d",&a,&b,&c);
	if(c>=a&&c<=b)
	printf("%c%c%c",y[0],y[1],y[2]);
	else
	printf("%c%c",n[0],n[1]); 
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int A = 0;
    rep(i, n) {
        A = A ^ a[i];
    }
    if (A == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdlib.h>
#include <list>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define inf 0x3f3f3f3f
#define PI acos(double(-1))
using namespace std;

typedef long long ll;
const int maxn=2e5+10;
char a[100],b[100],c[100];

int main()
{
    scanf("%s%s%s",a,b,c);
    int len1=strlen(a);
    int len2=strlen(b);
    int len3=strlen(c);
    if(a[len1-1]==b[0]&&b[len2-1]==c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(float,input().split()))

dp = [[0 for j in range(N+1)] for i in range(N)]#i+1枚目までのコインを投げたときにj枚表が出る確率

dp[0][0] = 1-P[0]
dp[0][1] = P[0]
for i in range(1,N):
    dp[i][0] = dp[i-1][0]*(1-P[i])

for i in range(1,N):
    for j in range(1,N+1):
        dp[i][j] = dp[i-1][j-1]*P[i]+dp[i-1][j]*(1-P[i])

ans = 0
for j in range(-(-N//2),N+1):
    ans += dp[N-1][j]
    
print(ans)

Measured memory_bytes: 354696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9;
const double EPS = 1e-10;
const bool debug = 1;
//------------------------------//

int N;
int a[112345], b[112345];
int cnt[86400];

int main() {
	cin >> N;
	REP(i, N) scanf("%d %d", a + i, b + i);
	
	int day = 86400, ear = 10800;
	
	int t = 0;
	REP(i, N) {
		t = (t + a[i]) % day;
		cnt[t]++;
		t = (t + b[i]) % day;
	}
	
	int r = 0, now = 0;
	int ans = 0;
	
	REP(l, day) {
		while ((r - l + day) % day <= ear) {
			now += cnt[r];
			r = (r + 1) % day;
		}
		
		chmax(ans, now);
		now -= cnt[l];
	}
	chmax(ans, now);
	
	cout << ans << endl;
	
	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for(int i = 0; i < M; i++){
    cin >> a[i];
  }
  cout << N - M - 1 << endl;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <string.h>
int che(char a[],char b[],int a1);
int main()
{
  char a[10000],b[10000];
  gets(a);
  gets(b);
  int i,j,a1,b1;
  a1=strlen(a);
  b1=strlen(b);
  if(a1+1==b1)
  {
    if(che(a,b,a1))
      printf("Yes\n");
    else
      printf("No\n");
  }
  else
    printf("No\n");
  return 0;
}
int che(char a[],char b[],int a1)
{
 int i,j;
  for(i=0;i<a1;i++)
  {
    if(a[i]!=b[i])
      return 0;
  }
  return 1;
}

Measured memory_bytes: 1912
N,M=map(int,input().split())
if M%N==0:
  print(M//N)
else:
  s=M//N
  if s<100000:
    ans=1
    while s!=1:
      if M%s==0:
        ans=s
        break
      s-=1
    print(ans)
  else:
    rM=M**(1/2)
    s=N
    ans=1
    while s<=rM:
      if M%s==0:
        ans=M//s
        break
      s+=1
    else:
      s=N
      while s!=1:
        if M%s==0:
          ans=s
          break
        s-=1
    print(ans)

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
int main()
{
	double r;
	cin >> r;
	double taiseki = M_PI * r * r;
	double menseki = 2 * M_PI * r;
	cout << fixed << setprecision(10) << taiseki << " " << menseki;
}


Measured memory_bytes: 3256
d, g = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)
    
    if sum < g:
        use = max(nokori)
        n = min(pc[use-1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)
print(ans)




Measured memory_bytes: 3064