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

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);


int main(void){
    priority_queue<long long> que;
    long long n,m;
    cin >> n >> m;
    long long cost = 0;
    for (int i = 0; i < n; ++i){
        int temp;
        cin >> temp;
        cost += temp;
        que.push(temp);
    }

    for (int i = 0;i<m; ++i){
        long long top = que.top();
        que.pop();
        long long newcost = top/2;
        cost-=(top-newcost);
        que.push(newcost);
    }
    cout << cost << endl;


};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define td(x) x.begin(),x.end()
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
using namespace std;
 

int32_t main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> b(n+1);
	vector<int> a(n+1);
	for(int i=1;i<n;i++)cin>>b[i];
	int res=0;
	a[n] = b[n-1];
	for(int i=n-1;i>1;i--){
		a[i] = min(b[i-1],b[i]);
	}
	a[1] = b[1];
	for(int i=1;i<=n;i++)res+=a[i];
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
#define drep2(i,a,b) for(int i=a; i>=b; i--)

int main()
{
	int a, b, c, x;
  int pattern=0;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;
  rep(i,a+1) {
    rep(j,b+1) {
      rep(k,c+1) {
        int temp = 500*i + 100*j + 50*k;
        if (temp == x)
          pattern++;
      }
    }
  }
  cout << pattern << endl;

  return 0;

}


Measured memory_bytes: 256
import numpy as np
Level = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
N = int(input())
Point = [int(x) for x in input().split()]

def solve():
    count = np.zeros(len(Level), dtype=int)
    for p in Point:
        over3200 = True
        for i in range(1, len(Level)):
            if p<Level[i]: 
                count[i-1] += 1
                over3200 = False
                break
        if over3200: count[-1] += 1
#    print(count)
    colorCount = 0
    for i in range(len(count)-1): #3200点以上は除く
        if count[i]>0: colorCount += 1
    
#    return max(colorCount, 1), min(colorCount + count[-1], len(Level) - 1)
    return max(colorCount, 1), colorCount + count[-1]


#print(N)
#print(Point)
mi, ma = solve()
print(mi, ma)




Measured memory_bytes: 12516
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    v_list = list(map(int, input().split()))

    while len(v_list) > 1:
        buf = sorted(v_list)
        v_list.remove(buf[0])
        v_list.remove(buf[1])
        v_list.append((buf[0] + buf[1]) / 2)

    print(v_list[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import heapq as hq

def bfs(x,y,t,Map):
    queue = []
    hq.heappush(queue,(0,(x,y)))
    while len(queue) != 0:
        p = hq.heappop(queue)
        x,y = p[1]
        if p[0] <= t and Map[y][x] == 0:
            Map[y][x] = 1
            dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1)]
            for dx,dy in dxdy:
                hq.heappush(queue,(p[0] + 1, (x + dx, y + dy)))

while True:
    t,n = map(int,input().split())
    if t == 0 and n == 0:
        break

    Map = [[0 for j in range(200)] for i in range(200)]
    for _ in range(n):
        x,y = map(lambda x:int(x) + 100,input().split())
        Map[y][x] = -1
    x,y = map(lambda x:int(x) + 100,input().split())
    bfs(x,y,t,Map)

    print(sum([0 if Map[i][j] == -1 else Map[i][j] for i in range(200) for j in range(200)]))

Measured memory_bytes: 7596
#include<bits/stdc++.h>
using namespace std;
char a[10000],b[10000];
int main(){
	cin>>a;
	cin>>b;
	for(int i=0;i<int(strlen(b));i++)
		cout<<a[i]<<b[i];
	if(strlen(a)>strlen(b))
		cout<<a[strlen(a)-1];
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
n, l = map(int, input().split())
if l <= 0 and abs(l) < n:
    a = int((n * (2 * l + n - 1)) / 2)
    print(a)
elif l <= 0 and abs(l) >= n:
    a = int((n - 1) * (2 * l + n - 2) / 2)
    print(a)
else:
    a = int((n - 1) * (2 * l + n) / 2)
    print(a)


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

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

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    FAST
    int n, k;
    cin >> n >> k;
    map<int,vector<int>>m;
    for(int i=0;i<k;i++)
    {
        int l;
        cin>>l;
        for(int j=0;j<l;j++)
        {
            int a;
            cin>>a;
            m[a].push_back(i+1);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(m[i].size()==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>

int main() {
	int n;
	string s;
	cin >> n >> s;
	int big = s.size();
	string ss;
	rep(i, big) {
		int buffer;
		buffer = s[i];
		buffer += n;
		if (buffer > 90) {
			buffer = buffer - 26;
		}
		char sc = buffer;
		ss += sc;
	}
	cout << ss;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void){
 int N;
 int a[100];
 int guusuu = 0;
 int flag = 0;
 cin >> N;
  
 for(int i=0; i<N; i++){
  cin >> a[i];
 }
  
  for(int j=0; j<N; j++){
   if(a[j]%2 == 0){
    if(a[j]%3 != 0 && a[j]%5 != 0) flag = 1;
   }
  } 
  if(flag == 0){
  cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

bool nn[15];

bool chk(int n, int k) {
	while(n) {
		if(nn[n % 10]) return false;
		n /= 10;
	}
	return true;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0, x;i < k;i++)
		scanf("%d", &x), nn[x] = true;
	for(int i = n;;i++) {
		if(chk(i, k)) {
			printf("%d\n", i);
			break;
		}
	}
}


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

#define MAX 1000000
#define MAX_ARRAY MAX+1

#define rep(i, x) for(int i=0;i<(x);i++)
char S[MAX_ARRAY];
int Q;
int first, last;
bool rev;
// lastは-1する必要あり

void print() {
    /*
    cout << first << ":" << last << endl;
    rep(i, MAX+1) {
        cout << S[i];
    }
    cout << endl;
*/

    if(!rev) {
        //頭から書き出す
        if(first > last) {
            for(int i = first; i <= MAX; i++) {
                cout << S[i];
            }
            for(int i = 0; i <= last; i++){
                cout << S[i];
            }
        } else {
            for(int i = first; i <= last; i++) {
                cout << S[i];
            }
        }
    } else {
        // お尻から書き出す
        if(first > last) {
            for(int i = last; i >= 0;i--){
                cout << S[i];
            }
            for(int i = MAX; i >= first; i--) {
                cout << S[i];
            }
        } else {
            for(int i = last;i >= first; i--){
                cout << S[i];
            }
        }
    }
    cout << endl;
}

int main() {
    first = 0;
    last = 0;
    rev = false;
    cin >> S;
    //cout << S1.size() << endl;
    rep(i, MAX){
        if(S[i] == '\0') {
            break;
        }
        last++;
    }
    last--;

    cin >> Q;
    
    rep(i, Q) {
        int T, F;
        char C;
        cin >> T;
        // T=1 文字列Sの前後を反転する。
        // T=2 整数Fと英小文字Cが与えられる
        //  F=1 Sの先頭にCiを追加
        //  F=2 Sの末尾にCiを追加
        if(T == 1) {
            rev = !rev;
        } else if(T == 2) {
            cin >> F >> C;
            if((F == 1 && !rev) || (F == 2 && rev)) {
                if(first == 0) {
                    first = MAX;
                } else {
                    first--;
                }
                S[first] = C;
            } else if((F == 2 && !rev)  || (F == 1 && rev)) {
                if(last == MAX) {
                    last = 0;
                } else{
                    last++;
                }
                S[last] = C;
            }
        }
        //print();
    }


    print();

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	string S;
	cin >> S;
    if (S.substr(0,4)=="YAKI") cout << "Yes" << endl;
    else                       cout << "No"  << endl;
	return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

N = sorted(iil(),reverse=True)
ans = N[0]-N[1]
#print(ans)
if (N[0]-N[2]-ans)%2 == 0:
    ans += (N[0]-N[2]-ans)//2
else:
    ans += (N[0]-N[2]-ans)//2 + 2


print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int house[4][3][10] = { 0 };
	int n;
	cin >> n;
	int b, f, r, v;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		house[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 10; j++){		
				cout << " " << house[0][i][j];
				if (j == 9){
					cout << endl;
				}
		}
	}
	cout << "####################\n";
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			cout << " " << house[1][i][j];
			if (j == 9) {
				cout << endl;
			}
		}
	}
	cout << "####################\n";
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			cout << " " << house[2][i][j];
			if (j == 9) {
				cout << endl;
			}
		}
	}
	cout << "####################\n";
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 10; j++) {
			cout << " " << house[3][i][j];
			if (j == 9) {
				cout << endl;
			}
		}
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int main()
{
	int size[3];
	int n;
	int r;
	double diagonal;
	
	while (cin >> size[0] >> size[1] >> size[2])
	{
		if (size[0]==0 && size[1]==0 && size[2]==0) break;
		sort(size, size + 3);
		diagonal = sqrt(size[0] * size[0] + size[1] * size[1]);
		/*
		for (int i=0; i<3; i++)
		{
			cout << size[i] << endl;
		}
		*/
		cin >> n;
		for (int i=0; i<n; i++)
		{
			cin >> r;
			if (r * 2 > diagonal)
			{
				cout << "OK" << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
	
	return 0;
}

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

int main() {
	int p[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

	int a, b;
	cin >> a >> b;

	if (p[a - 1] == p[b - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#coding:utf-8


mo =""
moji_m =""

while True:
    try:
        mo = input().lower()
        moji_m += mo
    except:
        break


moji = list(moji_m.lower())
moji_l = list("abcdefghijklmnopqrstuvwxyz")
moji_c = [0 for i in range(26)]

for i in moji:
    #??¢??????????????????????????????
    if i.isalpha() == False:
        pass
    else:
        moji_c[moji_l.index(i)] += 1

for i in range(26):
    print(str(moji_l[i]) + " : " +str(moji_c[i]))

Measured memory_bytes: 7388
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    ll sum = 0;
    for(ll i=0; i<S.size(); i++){
        if(S.at(i) != T.at(i)){
            sum++;
        }
    }
    cout << sum << endl;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int, int> PI;
typedef pair<int, pair<int, int>> PII;
static const int INF = 1010000000000000017LL;
static const double eps = 1e-12;
static const double pi = 3.14159265358979323846;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};
static const int ddx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
static const int ddy[8] = {0, 0, 1, -1, 1, -1, 1, -1};

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

int N,X,M;
bool visited[1000005];
int syuki[1000005];

int modPow(int a, int n) {
    if (n == 1) return a % M;
    if (n % 2 ==1) return (a * modPow(a, n - 1)) % M;
    int t = modPow(a, n / 2);
    return (t * t) % M;
}

int search(int i,int x){
    if(i==N+1)return -1;
    if(visited[x])return x;
    visited[x]=true;
    int m=(x*x)%M;
    return search(i+1,m);
}

signed main() {
    cin>>N>>X>>M;
    int s=search(1ll,X);
    int offset=0;
    int m=X;
    int p=-1;
    for(int i=1;i<=N;++i){
        if(m==s){
            p=i;
            break;
        }
        offset+=m;
        m=(m*m)%M;
    }
    int ans;
    if(p==-1){
        int x=X;
        ans=0;
        for(int i=1;i<=N;++i){
            ans+=x;
            x=(x*x)%M;
        }
    }
    else {
        int t=0;
        int ssyuki=0;
        m=s;
        for(int i=p;i<=N;++i){
            if(m==s&&i!=p)break;
            syuki[t]=m;
            ssyuki+=syuki[t];
            m=(m*m)%M;
            t++;
        }
        int a=(N-p)/t;
        int b=(N-p)%t;
        ans=offset+ssyuki*a;
        for(int i=0;i<=b;++i)ans+=syuki[i];
    }
    cout<<ans<<endl;
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main(input = STDIN)
  while 0 != n = input.gets.to_i
    code = Hash.new{|hash, key|key}
    n.times do
      code.store(*input.gets.chomp.split(" "))
    end
    str = ""
    input.gets.to_i.times do
      str << code[input.gets.chomp]
    end
    puts str
  end
end
main

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif

struct edge{
    int to;
    LL s;
    edge(): to(0), s(0) {}
    edge(int to, LL s): to(to), s(s) {}
};

int n, m;
vector<edge> adj[100001];

LL val[100001];
int color[100001];

bool visited[100001];
void visit(int v){
    for(edge e:adj[v]){
        int u = e.to;
        LL s = e.s;
        if(visited[u]) continue;
        visited[u] = true;
        val[u] = s - val[v];
        color[u] = 1 - color[v];
        visit(u);
    }
}

int main() {
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int u, v; LL s; cin >> u >> v >> s;
        adj[u].emplace_back(v, s);
        adj[v].emplace_back(u, s);
    }
    color[1] = 0;
    val[1] = 0;
    visit(1);
    
    LL l = -1e15, r = 1e15;
    for(int i=1; i<=n; i++){
        if(color[i] == 0) l = max(l, 1-val[i]);
        else r = min(r, val[i]-1);
    }
    
    for(int v=1; v<=n; v++) for(edge e:adj[v]){
        int u = e.to;
        LL s = e.s;
        if(color[u] == color[v]){
            LL x = s - val[v] - val[u];
            if(color[u] == 1) x = -x;
            
            if(x <= 0 or x % 2 == 1){
                cout << "0\n"; return 0;
            }
            l = max(l, x/2);
            r = min(r, x/2);
            
        }else{
            if(s != val[v] + val[u]){
                cout << "0\n"; return 0;
            }
        }
    }
    
    LL ans = r - l + 1;
    if(ans < 0) ans = 0;
    cout << ans << '\n';
    
    return 0;
}


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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	
	for (int i = 0; i < s.length(); i++) {
		int number = 0;
		number = (s[i] - 'A' + n) % 26;
		s[i] = 'A' + number;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))

 ll v[10][10];
pair<int,int> find(ll n){
    ll e=n%10;
    ll s;
    while(n){
        s=n%10;
        n/=10;
    }
    return {s,e};
}
int main(){
    ll n;
    cin>>n;
   
    
    for(int i=1;i<=n;i++){
      auto p=find(i);
      v[p.ff][p.ss]++;
    //  v[p.ss][p.ff]++;
    }
    ll ans =0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=v[i][j]*v[j][i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    LL n, r;
    while (cin >> n >> r)
    {
        if (n >= 10)
            cout << r << '\n';
        else cout << 100 * (10 - n) + r << '\n';
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
using namespace std;
 struct value
{
	ll x;
	ll y;
};
bool compare(value a, value b)
{
	//for descending order replace with a.roll >b.roll
	if(a.y < b.y)		
		return 1;
	else
		return 0;
}
int main()
{
	ll n;
	cin>>n;
	ll sum=0;
	vector <ll> v(n);
	map <ll,ll> m;
	for(auto &i:v)
	{
		cin>>i;
		sum=sum+i;
		m[i]++;
	}	
	ll q;
	ll b,c;
	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		if(m.find(b)!=m.end())
		{
			if(c>=b)
			  sum+=m[b]*abs(b-c);
			else sum-=m[b]*abs(b-c);
			m[c]+=m[b];
			m[b]=0;
		}
		cout<<sum<<"\n";
	}
}


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

typedef long long ll;

ll sum(
  ll num
  , ll delta
)
{
  auto count = num/delta;
  return delta*count*(count + 1)/2;
}

int main()
{
  ll N;
  cin >> N;
  cout << sum(N, 1) - sum(N, 3) - sum(N, 5) + sum(N, 15);
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a,b;
inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
int main()
{
	a=read();b=read();
	cout<<ceil((a+b+1)/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
def insertion_sort(a, n, g):
    global count
    for i in range(g, n):
        v = a[i]
        j = i - g
        
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            count += 1
        a[j+g] = v

def shell_sort(a, n):

    g = []
    i = 1
    while i <= len(a):
      g.append(i)
      i = i*3 +1
    g.reverse()
    print(len(g))
    print(" ".join(map(str, g)))
    
    for i in g:
        insertion_sort(a=a, n=n, g=i)

        
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

count = 0
shell_sort(a=a, n=n)
print(count)
for i in range(n):
  print(a[i])




    
        


Measured memory_bytes: 45516
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    if(N == 1) cout << "Hello World" << endl;
    else {
        int A,B; cin >> A >> B;
        cout << A+B << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
const int maxn=200009;
string S[maxn];
int nxt[1000009][27],v[1000009*27],tot;
void Minsert(string &s){
  int rt=0;
  for(int i=0;i<SZ(s);++i){
    if(!nxt[rt][s[i]-'a'])nxt[rt][s[i]-'a']=++tot;
    rt=nxt[rt][s[i]-'a'];
  }
  v[rt]++;
}
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<pair<int,int>> B(n);
  for(int i=0;i<n;++i){cin>>S[i],reverse(S[i].begin(),S[i].end());
    B[i].first=SZ(S[i]);
    B[i].second=i;}
  sort(B.begin(),B.end());
  int64 res=0;
  for(auto &[len,idx]:B){
    vector<int> cnt(27);
    for(char c:S[idx])cnt[c-'a']++;
    int rt=0;
    for(int j=0;j<SZ(S[idx]);++j){
      for(int a=0;a<26;++a)if(cnt[a]&&nxt[rt][a])res+=v[nxt[rt][a]];
      cnt[S[idx][j]-'a']--;
      if(nxt[rt][S[idx][j]-'a']){
        rt=nxt[rt][S[idx][j]-'a'];
      }else{
        break;
      }
    }
    Minsert(S[idx]);
  }
  cout<<res<<'\n';
  
  
  return 0;
}
//2020.08.09 21:01:31


Measured memory_bytes: 119272
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>

using namespace std;

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

	system("pause");
	return 0;
}

Measured memory_bytes: 884
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	ll prei = -10;
	ll ans = 0;
	rep(i, n) {
		ll p;
		cin >> p;
		if (prei + 1 == i) {
			prei = -10;
			continue;
		}
		
		if (p == i + 1) {
			ans++;
			prei = i;
		}
		else {
			prei = -10;
		}
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 3668
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }

    let tak = (c - 1) / b + 1;
    let aok = (a - 1) / d + 1;

    println!("{}", if tak <= aok { "Yes" } else { "No" });
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int ans=0;
	vector<int> a(n),b(n);
	rep(i,n) cin >> a.at(i);
	rep(i,n) cin >> b.at(i);
	rep(i,n) if(a.at(i)>b.at(i)) ans+=a.at(i)-b.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m, k = LI()
    for i in range(n):
        for j in range(m+1):
            if i*m + j*(n-2*i) == k:
                print("Yes")
                exit(0)
    else:
        print("No")
main()


Measured memory_bytes: 74896
#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)



int main() {
   long long x;
   cin >> x;
   long long cnt=0;
   while(x>=500){
       x-=500;
       cnt+=1000;
   }
   while(x>=5){
       x-=5;
       cnt+=5;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define MOD 1000000007
char s[200007];
int main(){
	register int n, n2, i, ans, cnt, pre, now;
	scanf("%d", &n);
	n2 = n * 2;
	scanf("%s", s + 1);
	if (s[1] == 'W' || s[n2] == 'W') {
		puts("0");
		return 0;
	}
	ans = cnt = 1, pre = 0;
	for (i = 2; i < n2; ++i) {
		if (s[i - 1] != s[i]) now = pre;
		else now = pre ^ 1;
		//now: 0 = [, 1 = ]
		if (now) {
			ans = 1ll * ans * cnt % MOD;
			--cnt;
		}
		else ++cnt;
		pre = now;
	}
	if (cnt > 1) {
		puts("0");
		return 0;
	}
	for (i = 2; i <= n; ++i) ans = 1ll * ans * i % MOD;
	printf("%d\n", cnt == 1 ? ans : 0);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	int A,B,C;
	scanf("%d%d%d", &A,&B,&C);

	int five = 0;
	int seven = 0;
	if (A == 5) {
		five++;
	}
	else if (A == 7) {
		seven++;
	}
	
	if (B == 5) {
		five++;
	}
	else if (B == 7) {
		seven++;
	}

	if (C == 5) {
		five++;
	}
	else if (C == 7) {
		seven++;
	}

	if (five == 2 && seven == 1) {
		printf("YES");


	}
	else {
		printf("NO");
	}
}

Measured memory_bytes: 128
// 修改自提交记录：233271
// 原记录作者：E.Space (UID: 1579)
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<map>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int gcd(int x,int y)
{
	int r;
	while(r=x%y)x=y,y=r;
	return y;
}
struct edge
{
	int to;
	int next;
}e[1444444];
int pe=6666;
void insert(int a,int to)
{
	e[pe]=(edge){to,e[a].next};
	e[a].next=pe++;
}
int addedge(int x,int y)
{
	//fprintf(stderr,"%d %d\n",x,y);
	insert(x,y);
	insert(y,x);
}
int d[2222];
int g[2222][2222];
int vis[6666],pv;
std::map<int,int> no;
int pno;
int s[11111],p[11111],pp;
int op[6666];
int q[6666],hq,tq;
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)d[i]=io::F();
	std::sort(d+1,d+n+1);
	int cnt1=0,now=0;
	for(register int i=1;i<=n;++i)
		if(d[i]!=1)d[++now]=d[i];
			else ++cnt1;
	n=now;
	for(register int i=1;i<=n;++i)
		for(register int j=i+1;j<=n;++j)
			g[i][j]=g[j][i]=gcd(d[i],d[j]);
	for(register int i=2;i<=10000;++i)
	{
		if(!s[i])s[i]=p[++pp]=i;
		for(register int j=1,u=dmin(10000/i,s[i]);j<=pp&&p[j]<=u;++j)
			s[i*p[j]]=p[j];
	}
	//fprintf(stderr,"%d\n",pp);
	pno=n;
	for(register int i=1;i<=n;++i)
	{
		int T=d[i];
		for(register int j=1;j<=pp&&p[j]*p[j]<=T;++j)
			if(T%p[j]==0)
			{
				int to;
				if(!(to=no[p[j]]))to=no[p[j]]=++pno,addedge(0,pno);
				addedge(i,to);
				while(T%p[j]==0)T/=p[j];
			}
		if(T!=1)
		{
			int to;
			if(!(to=no[T]))to=no[T]=++pno,addedge(0,pno);
			addedge(i,to);
		}
	}
	op[0]=1;
	for(register int z=1;z<=n+1;++z)
	{
		int max=0;
		++pv;
		for(register int i=0;i<=n;++i)
			if(vis[i]<pv)
			{
				int min=2222;
				for(q[hq=1]=i,tq=2,vis[i]=pv;hq!=tq;++hq)
				{
					if(q[hq]<=n&&op[q[hq]])cmin(min,q[hq]);
					for(register int p=e[q[hq]].next;p;p=e[p].next)
						if(vis[e[p].to]<pv)vis[e[p].to]=pv,q[tq++]=e[p].to;
				}
				cmax(max,min);
			}
		vis[max]=1000000;
		if(max)printf("%d ",d[max]);
		++pv;
		for(q[hq=1]=max,tq=2;hq!=tq;++hq)
		{
			op[q[hq]]=0;
			for(register int p=e[q[hq]].next;p;p=e[p].next)
				if(vis[e[p].to]<pv)vis[e[p].to]=pv,q[tq++]=e[p].to;
		}
		for(register int i=1;i<=n;++i)
			if(g[max][i]!=1)op[i]=1;
	}
	for(register int i=1;i<=cnt1;++i)printf("1 ");
	puts("");
	return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t N, L;
	cin >> N >> L;

	vector<string> S(N);
	for (int32_t i = 0; i < N; i++)
		cin >> S[i];
	sort(S.begin(), S.end());
	for (int32_t i = 0; i < N; i++)
		cout << S[i];
	cout << endl;

	return 0;
}

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


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACB56
{
    class Program
    {
        static void Main(string[] args)
        {

            var st = Console.ReadLine().Split(' ').ToArray();
            string a = st[0];
            string b = st[1];

            if (a == "H")
            {
                Console.WriteLine(b);
            }
            else
            {
                if (b == "H")
                {
                    Console.WriteLine("D");
                }
                else
                {
                    Console.WriteLine("H");
                }






            }
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int A, B, C;
	cin >> A >> B >> C;

	if (A <= B * C) co("Yes");
	else co("No");


	Would you please return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
  int k; cin >> k;
  cout << (k/2) * ((k+1)/2) << endl;
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}

const int NN = 2e6 + 10;
ll fact[NN];

void init() {
	fact[0] = 1;
	for (int i = 1; i < NN; ++i) fact[i] = (fact[i - 1] * 1LL * i) % MOD;
}

ll nCr(ll n, ll r) {
	auto modInverse = [](ll a) { 
		auto power = [](ll base, ll exp) {
			ll ans = 1;
			base %= MOD;
			while (exp > 0) {
				if (exp & 1) ans = (ans * base) % MOD;
				exp >>= 1;
				base = (base * base) % MOD;
			}
			return ans;
		};
		return power(a, MOD - 2); 
	};
	return (fact[n] * modInverse(fact[r] * 1LL * fact[n - r])) % MOD;
}



int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll mn = i;
		ll mx = n / i * i;
		ll k = mx / i - mn / i + 1;
		ans += i * 1ll * k*(k + 1) / 2;
	}
	cout << ans << endl;



	return 0;
}


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

int main() {
  int N;
  int A;
  cin >> N >> A;  
  if ( N % 500 <= A ) {
   cout << "Yes" <<  endl;
    }
   else if ( N % 500 > A ) { 
   cout << "No" << endl;
   }
  }
  
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	// ll t;   cin>>t;
	// for(ll tt = 1; tt <= t; tt++)
	// {
	//     //Code
	    
	// }
	ll n;	cin>>n;
	string s;	cin>>s;
	ll r = 0, w = 0;
	for(ll i=0; i<n; i++)
	{
		if(s[i] == 'R')
			r++;
		else
			w++;
	}
	int rr=0, ww=0;
	for(ll i=0; i<r; i++)
	{
		if(s[i] == 'W')
			ww++;
	}
	for(ll i=r; i<n; i++)
	{
		if(s[i] == 'R')
			rr++;
	}
	ll ans = 0;
	if(rr > ww)
		ans = ww + (rr - ww);
	else
		ans = rr + (ww - rr);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3728
#include<cstdio>
#include<algorithm>
using namespace std;

struct segtree{
  int n,dat[262143];
  const int INF = (1<<31)-1;
  segtree(int _n){
    n = 1;
    while(_n>n) n*=2;
    for(int i=0;i<2*n-1;i++) dat[i] = INF;
  }
  void update(int k,int a){
    k+=n-1;
    dat[k] = a;
    while(k>0){
      k = (k-1)/2;
      dat[k] = min(dat[2*k+1],dat[2*k+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return INF;
    else if(a<=l&&b>=r) return dat[k];
    else return min(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
};

int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  segtree st(n);
  for(int i=0;i<q;i++){
    int cmd,x,y;
    scanf("%d %d %d",&cmd,&x,&y);
    if(cmd==0) st.update(x,y);
    else if(cmd==1) printf("%d\n",st.query(x,y+1));
  }
  return 0;
}

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

#define int long long
#define fi first
#define se second

string s;

int32_t main()
{	
	cin >> s;
	if(s[2] == s[3] and s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}


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

	if ((b - a) % 2 == 0) {
		ANS("Alice");
	}
	else {
		ANS("Borys");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<pair<pair<int, int>, int>, int> mp;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int a[3];
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a + 3);
        if (mp.count(make_pair(make_pair(a[0], a[1]), a[2]))) {
            res++;
        } else {
            mp[make_pair(make_pair(a[0], a[1]), a[2])]++;
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;

int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas";
  } else if (D == 24) {
    cout << "Christmas Eve";
  } else if (D==23) {
    cout << "Christmas Eve Eve";
  } else if (D==22) {
    cout << "Christmas Eve Eve Eve";
  }
  return 0;
}


Measured memory_bytes: 256
double*q,a[99],b;char s[9];main(){for(q=a;~scanf("%s",s);getchar()<14&&printf("%f\n",*q)){!sscanf(s,"%lf",q+1)?b=*q--,*q=*s-47?*s-42?*s-45?*q+b:*q-b:*q*b:*q/b:*++q;}}

Measured memory_bytes: 0
N, x = map(int, input().split())
A = list(map(int, input().split()))

SA = sum(A)
if x == SA:
    print(N)

else:
    AS = sorted(A)
    kk = 0
    for k, a in enumerate(AS):
        if x < a:
            break
        x -= a
        kk = k + 1
    if kk == N: 
        kk = N - 1
    print(kk)



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

int debug = 1;

int main(){
    int k,x;
    cin >> k>>x;
    if(500*k>=x)
        cout <<"Yes"<<endl;
    else
        cout <<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 1, Max = -1, Min = 3e9+1;
  string s;
  bool ok=true;
  cin >> n >> s;
  rep(i,n){
    if(s[i]=='('){
      x++;
    }
    else{
      if(x>0){
        x--;
      }
      else
        y++;
    }
  }

  s = string(y,'(') + s;
  s += string(x,')'); 
  pri(s);
  return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        int count = 0;
        Arrays.sort(S);
        Arrays.sort(T);
        int idx = 0;
        for (int i = 0; i < q; i++) {
            for (int j = idx; j < n; j++) {
                if (T[i] == S[j]) {
                    idx = j;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 67860
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main(){
  int n;
  int a[11000];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }

  int ans=0;
  FOR(i,1,n){
    if(a[i]==a[i-1]){
      a[i]=inf;
      ans++;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int sum=0;
    for(int i=1;i<=n;i++)
    {
        int m=floor((n+0.0)/i);
        sum+=(long long int)m*(m+1)*i/2;
    }
    cout<<sum;
}



Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[200010];
typedef pair<int, int> P;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<int> T(N + 1), L(N + 1), R(N + 1);
    vector<pair<int, P>> E(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i] >> R[i] >> T[i];
        L[i] -= T[i];
        R[i] -= T[i] + 1;
        E[i].first = T[i];
        E[i].second.first = L[i];
        E[i].second.second = R[i];
    }
    sort(E.begin(), E.end());
    rep(i, N) {
        L[i] = E[i].second.first;
        R[i] = E[i].second.second;
        T[i] = E[i].first;
    }
    L[N] = -INF;
    R[N] = INF;
    T[N] = INF;
    //rep(i, N) cout << L[i] << " " << R[i] << " " << T[i] << endl;
    
    set<int> se;
    int d[200010];
    map<int, int> mp, mp2;
    for (int i = 0; i < Q; ++i) {
        cin >> d[i];
        mp[d[i]] = i;
        se.insert(d[i]);
    }
    rep(i, Q) mp2[d[i]] = -1;
    
    for (int i = 0; i < Q; i++) {
        auto it = se.lower_bound(L[i]); // set の中から L[i] 以上となるポインタを見つける
        
        // set 内を走査していく、値が R[i] 以上になったらその時点で打ち切る
        while (it != se.end() && *it <= R[i]) {
            //cout << *it << " " << L[i] << " " << R[i] << " " << T[i] << endl;
            mp2[*it] = T[i];
            auto it2 = it; // set を破壊する操作が怖いので避けておいて
            ++it2; // 予め次の要素へとインクリメントしておく
            se.erase(it); // it を削除する
            it = it2; // 次の要素へ
        }
    }
    rep(i, Q) {
        if(mp2[d[i]] == INF) cout << -1 << endl;
        else cout << mp2[d[i]] << endl;
    }

    return 0;
}
// 1 3 2 -> -1~0 の人2で停止
// 7 13 10 -> -3 ~ 2の人10で停止
// 18 20 13 -> 5 ~ 7の人13で停止
// 3 4 2 -> 0~1の人2で停止

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define N 3002
char s[N], t[N];
int f[N][N], n, m;
void print(int x, int y) {
    if (!x || !y) return;
    if (f[x][y] == f[x - 1][y - 1] + 1 && s[x] == t[y]) {
        print(x - 1, y - 1);
        putchar(s[x]);
    } else {
        (f[x][y] == f[x][y - 1] ? y : x)--;
        print(x, y);
    }
}
int main() {
    scanf("%s%s", s + 1, t + 1);
    int n = strlen(s + 1), m = strlen(t + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (s[i] == t[j]) f[i][j] = f[i - 1][j - 1] + 1;
            f[i][j] = max(f[i][j], max(f[i - 1][j], f[i][j - 1]));
        }
    print(n, m);
    return 0;
}

Measured memory_bytes: 35584