akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

typedef struct node * NodePointer;

NodePointer nil;

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

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

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

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

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

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

void delete(int key){
  deleteNode(listSearch(key));
}


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

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

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

  printList();
  return 0;
}



Measured memory_bytes: 32948
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;	cin >> n >> k;
  
  vector<int> data(n);
  for(int i=0;i<n;i++){
    cin >> data.at(i);
  }
  
  sort(data.begin(),data.end());
  
  int ans=0;
  for(int i=0;i<k;i++){
    ans+=data.at(i);
  }
  
  cout << ans;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>


using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;

const int nax = 2e5 + 5;

vector<pair<int, int>> intervals[nax];

struct S {
    ll small, lazy;
    void merge(const S& a, const S& b){
        small = min(a.small, b.small);
        
    }
    void add(ll x){
        small += x;
        lazy += x;
    }
};

vector<S> tree;

const int TYPE_ADD = 1, TYPE_MIN = 2;
void rec(int id, int low, int high, int qLow, int qHigh, int type, ll& x){
    if(high < qLow || qHigh < low){
        return;
    }
    if(qLow <= low && high <= qHigh){
        if(type == TYPE_ADD){
            tree[id].add(x);
        }
        else if(type = TYPE_MIN){
            x =  min(x, tree[id].small);
        }
        /////
        return;
    }
    for(int b : {2 * id, 2 * id + 1}){
        tree[b].add(tree[id].lazy);
    }
    tree[id].lazy = 0;
    
    int lastLeft = (low + high) / 2;
    rec(2 * id, low, lastLeft, qLow, qHigh, type, x);
    rec(2 * id + 1, lastLeft + 1, high, qLow, qHigh, type, x);
    
    tree[id].merge(tree[2 * id], tree[2 * id + 1]);
}

/*
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    ll sum_of_scores = 0;
    for(int i = 0; i < m; ++i) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        intervals[b].emplace_back(a, c);
        sum_of_scores += c;
    }
    ll answer = 0;
    
    int base = 1;
    while(base <= n + 1) {
        base *= 2;
    }
    tree.resize(2 * base, {INF, 0});
    
    ll whatever = 0 - INF;
    rec(1, 0, base - 1, 0, 0, TYPE_ADD, whatever);
    for(int i = 1; i <= n + 1; ++i) {
        // I want to put '1' here
        for(pair<int,int> p : intervals[i-1]) {
            whatever = p.second;
            rec(1, 0, base - 1, 0, p.first - 1, TYPE_ADD, whatever);
        }
        ll best = INF;
        rec(1, 0, base - 1, 0, base - 1, TYPE_MIN, best);
        if(i == n + 1) {
            answer = best;
        }
        whatever = best - INF;
        rec(1, 0, base - 1, i, i, TYPE_ADD, whatever);
    }
    
    
    printf("%lld\n", sum_of_scores - answer);
}
*/
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    ll sum = 0;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        intervals[b].emplace_back(a, c);
        sum += c;
    }
    
    ll answer = 0;
    
    int base = 1;
    while(base <= n + 1){
        base *= 2;
    }
    tree.resize(2 * base, {INF, 0});
    ll xd = -INF;
    rec(1, 0, base - 1, 0, 0, TYPE_ADD, xd);
    
    for(int i = 1; i <= n + 1; i++){
        for(pair<int, int> p : intervals[i - 1]){
            xd = p.second;
            rec(1, 0, base - 1, 0, p.first - 1, TYPE_ADD, xd);
        }
        ll best = INF;
        rec(1, 0, base - 1, 0, base - 1, TYPE_MIN, best);
        if(i == n + 1){
            answer = best;
        }
        xd = best - INF;
        rec(1, 0, base - 1, i, i, TYPE_ADD, xd);
    }
    cout << sum - answer << "\n";
    

}



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

int main(void) {
	int n; cin >> n;
	vector<llong> A(n), B(n), C(n);
	for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &B[i]);
	for (int i = 0; i < n; i++) scanf("%lld", &C[i]);

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	llong res = 0;
	llong low, up;
	for (int j = 0; j < n; j++) {
		low = lower_bound(A.begin(), A.end(), B[j]) - A.begin();
		up = C.begin() + n - upper_bound(C.begin(), C.end(), B[j]);
		res += (up * low);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
      	int count=0;
      	StringBuffer sb = new StringBuffer();
        for (int i = 0;i <a.length() ; i++)
        {          
          if (i< a.length()/2)
          {
          	sb.append(a.charAt(i));
          }
          else
          {
            sb.append(a.charAt(a.length()-i-1));
          }
        }
      	String b=sb.toString();
      	for (int j = 0;j <a.length() ; j++)
        {
          if(a.charAt(j)!=b.charAt(j))
          {
            count+=1;
          }
        }
      System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
typedef long long ll;
ll M=1e9+7, Mf[200002];
void Mfi(){
    Mf[0]=Mf[1]=1;
    for(int i=2;i<200002;i++)Mf[i]=(Mf[i-1]*i)%M;
}
ll Mp(ll a, ll b){
    if(b==0)return 1;
    else if(b%2==0)return Mp((a*a)%M, b/2)%M;
    return (a*Mp(a, b-1))%M;
}
ll Mc(ll a, ll b){
    if(a<b)return 0;
    ll c = (Mf[a]*Mp(Mf[a-b], M-2))%M;
    return (c*Mp(Mf[b], M-2))%M;
}
int main(void){
    int n, k;
    cin >> n >> k;
    Mfi();
    for(int i=1;i<=k;i++){
        ll x = n - k - i + 1;
        if(x < 0){
            cout << 0 << endl;
            continue;
        }
        cout << ( Mc(k-1, k-i) * Mc(i+x, x) ) % M << endl;
    }
    
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int n,k;
    std::cin >> n >> k;
    std::vector<ll> a(n);
    rep(i,n) std::cin >> a[i];

    for(int i=k; i<n; i++){
        if(a[i-k]<a[i]){std::cout << yes << "\n";}
        else{std::cout << no << "\n";}
    }
    return 0;
}


Measured memory_bytes: 4788
#include <iostream>

struct Card {
    char type{};
    int value{};
};

void BubbleSort(const Card* c, const int n) {
    std::string represents1[10]{}, represents2[10]{};
    Card cards[n]{}; for(auto i=0; i<n; i++) cards[i]=c[i];
    for(auto i=0; i<n; i++) {
        represents1[c[i].value]+=c[i].type+'\0';
        for(auto j=n-1; j>i; j--) {
            if(cards[j].value < cards[j-1].value) {
                std::swap(cards[j], cards[j-1]);
            }
        }
    }
    for(auto i=0; i<n; i++) {
        std::cout << cards[i].type << cards[i].value << ((i<n-1) ? " " : "\n");
        represents2[cards[i].value]+=cards[i].type+'\0';
    }
    bool stable{true};
    for(auto i=1; i<10; i++) {
        if(represents1[i].compare(represents2[i])) {
            stable = false;
            break;
        }
    }
    std::cout << (stable ? "Stable" : "Not stable") << std::endl;
}

void SelectionSort(const Card* c, const int n) {
    std::string represents1[10]{}, represents2[10]{};
    Card cards[n]{}; for(auto i=0; i<n; i++) cards[i]=c[i];
    for(auto i=0; i<n; i++) {
        represents1[c[i].value]+=c[i].type+'\0';
        int minj{i};
        for(auto j=i; j<n; j++) {
            minj = (cards[j].value < cards[minj].value) ? j : minj;
        }
        std::swap(cards[i], cards[minj]);
    }
    for(auto i=0; i<n; i++) {
        std::cout << cards[i].type << cards[i].value << ((i<n-1) ? " " : "\n");
        represents2[cards[i].value]+=cards[i].type+'\0';
    }
    bool stable{true};
    for(auto i=1; i<10; i++) {
        if(represents1[i].compare(represents2[i])) {
            stable = false;
            break;
        }
    }
    std::cout << (stable ? "Stable" : "Not stable") << std::endl;
}

int main() {
    int n{}; std::cin >> n;
    Card cards[n]{};
    for(auto i=0; i<n; i++) {
        char c1{}, c2{};
        std::cin >> c1 >> c2;
        cards[i].type = c1;
        cards[i].value = int(c2-'0');
    }
    BubbleSort(cards, n);
    SelectionSort(cards, n);
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
struct times
{
    int x,y,t;
    times(){}
    times(int x,int y,int t)
    {
        this -> x = x;
        this -> y = y;
        this -> t = t;
    }
}temp;
int dir[4][2] = {0,1,1,0,0,-1,-1,0};
int h,w,c,flag = 0;
char mp[51][51];
int vis[51][51];
int main()
{
    cin>>h>>w;
    for(int i = 0;i < h;i ++)
    {
        cin.get();
        for(int j = 0;j < w;j ++)
        {
            cin>>mp[i][j];
            if(mp[i][j] == '.')c ++;
        }
    }
    if(mp[0][0] == '.' && mp[h - 1][w - 1] == '.')
    {
        queue<times> q;
        q.push(times(0,0,1));
        vis[0][0] = 1;
        while(!q.empty())
        {
            if(flag)break;
            temp = q.front();
            q.pop();
            for(int i = 0;i < 4;i ++)
            {
                int tx = temp.x + dir[i][0];
                int ty = temp.y + dir[i][1];
                if(tx < 0 || ty < 0 || tx >= h || ty >= w || vis[tx][ty] || mp[tx][ty] == '#')continue;
                vis[tx][ty] = 1;
                if(tx == h - 1 && ty == w - 1)flag = temp.t + 1;
                q.push(times(tx,ty,temp.t + 1));
            }
        }
    }
    if(flag)cout<<c - flag;
    else cout<<-1;
}

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

using namespace std;

int main(){
    long int a, b, k;
    cin >> a >> b >> k;
    if (a > k){
        cout << a - k << " " << b << endl;
    }else if (b > k - a){
        cout << 0 << " " << b - (k - a) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string rec(int n, char s) {
  if (n == 0) {
    return "";
  }
  string a = rec(n-1, s);
  return a + s;
}

int main()
{
  int a, b;
  cin >> a >> b;
  char ca = a + '0';
  char cb = b + '0';
  string pow_a = rec(b, ca);
  string pow_b = rec(a, cb);
  cout << min(pow_a, pow_b) << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 998244353;



void solve(){
	fio;
	int n;
	cin>>n;
	int ar[n];
	For(i,n) cin>>ar[i];
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(ar[i]!=ar[j] && ar[i]!=ar[k] && ar[j]!=ar[k]){
					if(ar[i]+ar[j]>ar[k] && ar[i]+ar[k]>ar[j] && ar[j]+ar[k]>ar[i]) cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
}


int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<":\n";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target ("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int d,t,s; cin >> d >> t >> s;
	if((double)d/s<=(double)t)
		cout << "Yes";
	else
		cout << "No";


}	


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int X,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>T;
	cout<<max(X-T,0)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] B;

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		B = new int[N];
		for (int i = 0; i < N; ++i) {
			B[i] = sc.nextInt();
		}
		int[] target = new int[N];
		int pos = 0;
		int val = 0;
		for (int i = 0; i < M; ++i) {
			int P = sc.nextInt();
			for (int j = 0; j < P; ++j) {
				target[pos++] = val;
			}
			val ^= 1;
		}
		int ans = solve(target);
		for (int i = 0; i < N; ++i) {
			target[i] ^= 1;
		}
		ans = Math.min(ans, solve(target));
		System.out.println(ans);
	}

	static int solve(int[] target) {
		int sum = 0;
		for (int i = 0; i < B.length; ++i) {
			sum += B[i];
			sum -= target[i];
		}
		if (sum != 0) return 999;
		ArrayList<Integer> pos1 = new ArrayList<Integer>();
		ArrayList<Integer> pos2 = new ArrayList<Integer>();
		for (int i = 0; i < B.length; ++i) {
			if (B[i] == 0) pos1.add(i);
			if (target[i] == 0) pos2.add(i);
		}
		int ret = 0;
		for (int i = 0; i < pos1.size(); ++i) {
			ret += Math.abs(pos1.get(i) - pos2.get(i));
		}
		return ret;
	}

}

Measured memory_bytes: 17368
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
  int N,L;
  cin >> N >> L;
  
  vector<int>apple(N,0);
  
  for(int i=0;i<N;i++){
    apple[i] = L + i;
  }
  
  int ans = 0;
  
  if(apple[0] > 0)
    for(int i=1;i<N;i++){
      ans += apple[i];
    }
  else if(apple[N - 1] < 0)
    for(int i=0;i<N - 1;i++){
      ans += apple[i];
    }
  else
    for(int i=0;i<N;i++){
      ans += apple[i];
    }
  
  
  cout << ans << endl;
  
  return 0;
}

  

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    string s, t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int ans = m;

    for (int i=0; i+m-1<n; i++) {
	int ed = 0;
	for (int j=0; j<m; j++) {
	    if (s[i+j] != t[j]) {
		ed++;
	    }
	}
	ans = min(ans, ed);
    }

    out(ans);    
    return 0;
}


Measured memory_bytes: 3656
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

#初期入力
N = int(input())
div =make_divisors(N) #Nの約数
div.sort()
div_1_except=div[1:]
count =0
for i in div_1_except:
    q,mod= divmod(N,i)
    if mod ==0:
        ii =soinsu_bunkai(i) #Nの約数を素因数分解
        if len(ii) ==1 :
            count +=1
            N =q   

print(count)

Measured memory_bytes: 9460
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld\n",i)
#define fendl printf("\n")
//Library-End

int n,a[100004],ans,now;
vector<int> cnt;
signed main() {
    cin>>n;
    rep(i,n){
        fin(a[i]);

    }
    rep(i,n){
        if (a[i]) {
            now+=a[i];
        }else{
            cnt.push_back(now);
            now=0;
        }
    }
    cnt.push_back(now);
    rep(i,cnt.size()){
        ans+=cnt[i]/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define ll long long
#define P ((ll)(1e9+7))
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

ll n, a, b;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

ll fac[MAX], inv[MAX];
void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; i--){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

ll C(ll n, ll m){
    ll res = 1;
    for(int i = n; i >= n-m+1; i--){
        res = res*i%P;
    }
    res = res*inv[m]%P;
    return res;
}

int main()
{
    init();
    cin >> n >> a >> b;
    ll ans = qpow(2, n)-1;
    ans = (ans-C(n, a)-C(n, b))%P+P;
    cout << ans%P << endl;

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=3000;
int n;
double p[N];
bool vis[N][N];
double dp[N][N];
double f(int i, int cnt){
	if(i==n)return cnt>=n/2+1;
	double &r=dp[i][cnt];
	if(vis[i][cnt])return r;
	vis[i][cnt]=1;
	r=f(i+1,cnt)*(1-p[i]);
	r+=f(i+1,cnt+1)*p[i];
	return r;
}
int main(){FIN;
	cin>>n;
	fore(i,0,n){
		/*string s;
		cin>>s;
		s.erase(s.find('.'),1);
		p[i]=stoi(s);
		cout<<p[i]<<"\n";*/
		cin>>p[i];
	}
	cout<<fixed<<setprecision(15)<<f(0,0)<<"\n";
	
}

Measured memory_bytes: 77824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    ll h, w; int n;
    cin >> h >> w >> n;

    map<pair<int, int>, int> map;
    FOR(i, 0, n) {
        ll a, b; cin >> a >> b;
        FOR(y, max(a - 3, 0LL), min(a, h - 2))FOR(x, max(b - 3, 0LL), min(b, w - 2)) {
            map[{y, x}]++;
        }
    }

    VL ans(10, 0);
    ans[0] = (h - 2) * (w - 2) - (ll)map.size();
    for (auto i : map)ans[i.second]++;
    FOR(i, 0, 10)cout << ans[i] << "\n";
}


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

//l-child, r-sibling representation

int n;
int p[100010], l[100010], r[100010];

void dfs(int n, int depth){
  if(p[n] == -1){
    cout << "depth = " << depth << ", ";
    return ;
  }

  dfs(p[n], depth + 1);
  return ;
}

void searchchild(int c){
  cout << '[';
  for(int i = 0;;i++){
    if(c == -1) break;
    cout << (i?", ":"");
    cout << c;
    c = r[c];
  }
  cout << ']' << endl;
}

void searchtype(int i){
  if(p[i] == -1) cout << "root, ";
  else if(l[i] != -1) cout << "internal node, ";
  else cout << "leaf, ";
}

void solve(){
  for(int i = 0;i < n;i++){
    cout << "node " << i << ": ";
    cout << "parent = " << p[i] << ", ";
    dfs(i, 0);
    searchtype(i);
    searchchild(l[i]);
  }
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++) p[i] = l[i] = r[i] = -1;
  for(int i = 0;i < n;i++){
    int id, k, c, s;

    cin >> id >> k;
    for(int j = 0;j < k;j++){
      cin >> c;
      if(j == 0) l[id] = c;
      else r[s] = c;
      p[c] = id;
      s = c;
    }
  }

  solve();

  return 0;
}



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

#define N 3010 

using namespace std;

typedef long long ll;

const int mod = 1000000007 ;

const int inv2 = 500000004 ;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0, f = 1;
	char c = nc();
	while (c < 48) {
		if (c == '-')
			f = -1;
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x * f;
}

int a[N], f[N][N];

int main() {
	int n = rd(), q = rd(), mdl = 1;
	for (int i = 1; i <= n; i ++ ) {
		a[i] = rd();
	}
	for (int i = 1; i <= n; i ++ ) {
		for (int j = 1; j <= n; j ++ ) {
			if (a[i] < a[j]) {
				f[i][j] = 1;
			}
		}
	}

	for (int i = 1; i <= q; i ++ ) {
		mdl = (ll)mdl * 2 % mod;
		int x = rd(), y = rd();
		f[x][y] = f[y][x] = ((ll)f[x][y] + f[y][x]) * inv2 % mod;

		for (int j = 1; j <= n; j ++ ) {
			if (j != x && j != y) {
				f[x][j] = f[y][j] = ((ll)f[x][j] + f[y][j]) * inv2 % mod;
				f[j][x] = f[j][y] = ((ll)f[j][x] + f[j][y]) * inv2 % mod;
			}
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i ++ ) {
		for (int j = 1; j < i; j ++ ) {
			(ans += f[i][j]) %= mod;
		}
	}

	ans = (ll)ans * mdl % mod, (ans += mod) %= mod;
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 35584
(* O(h w) *)
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let sss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if sss.(i).[j] = '#' then
        let f (dy, dx) =
          let y, x = i + dy, j + dx in
          0 <= y && y < h && 0 <= x && x < w && sss.(y).[x] = '#' in
        if not @@ List.exists f [-1, 0; 0, -1; 1, 0; 0, 1] then (print_endline "No"; exit 0)
    done
  done;
  print_endline "Yes"

Measured memory_bytes: 512
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<vector>
#include<bitset>
#define DB long double
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
  
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const DB eps=1e-8;
const LL P=10000019;
const DB PI=acos(-1);
const LL inf=1e9;
const int N=1e5+100;
int n;
int a[N];
int tp=0;
int b[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i) a[i]=read();
	int i;
	while(n>0){
		for(i=n;i>=1;--i){
			if(a[i]==i) break;
		}
		if(i==0){
			cout<<-1<<endl;
			return 0;
		}
		b[++tp]=i;
		for(int j=i;j<n;++j) a[j]=a[j+1];
		--n;
	}
	while(tp>0){
		printf("%d\n",b[tp]);
		--tp;
	}
}
/*
5 4 4 1
1 2 3
2 3 4
3 4 5
4 5 6
*/

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right


def main():
    N = int(input())
    A = [int(c) for c in input().split()]
    B = [int(c) for c in input().split()]
    C = [int(c) for c in input().split()]

    A.sort()
    B.sort()
    C.sort()

    num = 0
    for j in range(N):
        bj = B[j]
        c = bisect_right(C, bj)
        a = bisect_left(A, bj)
        num += a * (N - c)
    
    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39348
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

signed main() {
  int a[3];
  REP (i, 3) {
    cin >> a[i];
  }
  sort(a, a+3);
  cout << a[2] - a[0] << endl;
}


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

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#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 fastio ios::sync_with_stdio(0), cin.tie(0)
#define PI 3.1415926535897932
const ll mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
const int maxn = 501000;
int now[maxn];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    int dep = 0, top = 0;
    bool full = false;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        if(x >= maxn){
            printf("Yes\n");
            continue;
        }
        else if(full){
            printf("No\n");
            continue;
        }
        else{
            if(x < top){
                printf("No\n");
                continue;
            }
            else if(x == top && dep != top){
                printf("No\n");
                continue;
            }
            else{
                printf("Yes\n");
                dep = max(dep, x);
                now[x]++;
                while(now[x] >= 2){
                    now[x] = 0;
                    if(dep == x)dep--;
                    x--;
                    now[x]++;
                    if(x == 0){
                        full = 1;
                        break;
                    }
                }
                for(int i = top + 1; now[i] == 1; i++){
                    top = i;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
//#define M_PI 3.14159265358979323846

using namespace std;


int a,b,h,m;

int main() {

  std::cout << std::setprecision(20);
  // cout << M_PI<<endl;
  cin >> a>>b>>h>>m;
  long double ax,ay,bx,by;
  ax = a * cos( (long double)M_PI*2*((h+m/60.0)/12));
  ay = a * sin((long double)M_PI*2*((h+m/60.0)/12));

  bx = b * cos((long double)M_PI*2*m/60);
  by = b * sin((long double)M_PI*2*m/60);

  //cout << "ax:"<<ax<<" ay:"<<ay<<endl;
  // cout << "bx"<<bx<<" by"<<by<<endl;

  long double dx = (ax-bx);
  long double dy = (ay-by);

  long double result = sqrt(dx*dx + dy*dy);
 
  cout << result<<endl;;
  
  return 0;
}


  

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

using namespace std;
using ll = long long;

int main(){
    int N;
    string S;
    
    cin >> N >> S;
    char p[52];
    for(int i=0;i<52;i++){
        if(i<26){
            p[i] = 'A'+i;
        }else{
            p[i] = 'A'+i-26;
        }
    }
    for(int i=0;i<S.length();i++){
        for(int j=0;j<26;j++){
            if(S[i]==p[j]){
                cout << p[j+N];
            }
        }
    }
    
    return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    cout << "Christmas";
    REP(i, 25 - d) cout << " Eve";
    cout << EOL;
}



Measured memory_bytes: 256
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = max(a + b, max(a - b, a * b));
    println!("{}", ans);
}


Measured memory_bytes: 4352
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    L=readline().strip()
    n=len(L)
    mod=10**9+7

    dpF=[0]*(n+1)
    dpF[0]=1
    dpT=[0]*(n+1)
    for i in range(1,n+1):
        if L[i-1]=="1":
            dpF[i]+=2*dpF[i-1]
            dpT[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        else:
            dpF[i]+=dpF[i-1]
            dpT[i]+=3*dpT[i-1]
        dpF[i]%=mod
        dpT[i]%=mod

    print((dpF[n]+dpT[n])%mod)

if __name__=="__main__":
    main()

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

int main() 
{
    string str;
    cin >> str;
    string ans = "";
    for (int i = 0; i < str.size(); i++) {
        if (i == 0 || i % 2 == 0) {
            ans += str[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine((1000 - n % 1000) % 1000);
    }
}

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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N;

vint vec;
void dfs(int n,int d){
    if(d>1000000000000000000ll)return;
    if(n){
        vec.pb(d);
    }
    dfs(n+1,d*10+2);
    dfs(n+1,d*10+8);
}

bool C(int d){
    if(d==1)return true;
    stringstream ss;ss<<d;
    string s=ss.str();
    rep(i,s.size())if(s[i]!='2'&&s[i]!='8')return false;
    return true;
}

signed main(){
    cin>>N;
    if(N==1){
        puts("-1");
        return 0;
    }
    dfs(0,0);
    sort(all(vec));
    reverse(all(vec));

    map<int,int>prev;prev[N]=0;
    for(int i=0;i<vec.size();i++){
        map<int,int>next;
        each(it,prev){
            chmax(next[it->fi],it->se);
            int tmp=it->fi,hoge=0;
            while(tmp%vec[i]==0){
                tmp/=vec[i];hoge++;
                chmax(next[tmp],it->se+hoge);
            }
        }
        prev=next;
    }

    if(prev.find(1)==prev.end())cout<<-1<<endl;
    else cout<<prev[1]<<endl;
    return 0;
}

Measured memory_bytes: 7068
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;
static int N;

bool find_str(string s) {
  if (s.find("7") != string::npos && s.find("5") != string::npos &&
      s.find("3") != string::npos) {
    return true;
  } else {
    return false;
  }
}

int dfs(string s) {
  if (stoll(s) > N) {
    return 0;
  }
  int ret;
  if (find_str(s)) {
    ret = 1;
  } else {
    ret = 0;
  }
  for (string c : {"7", "5", "3"}) {
    ret += dfs(s + c);
  }
  return ret;
}

void solve(int N) {
  int ans = dfs("0");
  printf("%d\n", ans);
}

int main() {
  cin >> N;
  solve(N);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    int m = n;
    int f = 0;
    while(m>0)
    {
        f += m%10;
        m /= 10;
    }

    cout << (n%f==0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int par_1[200010]; //親
int height_1[200010];  //木の深さ

//n要素で初期化
void init_1 (int n){
    for (int i=0;i<n;i++){
        par_1[i]=i;
        height_1[i]=0;
    }
}

//木の根を求める
int find_1 (int x){
    if (par_1[x]==x){
        return x;
    }
    else{
        return par_1[x] = find_1(par_1[x]);
    }
}

//xとyの属する集合を併合
void unite_1 (int x, int y){
    x=find_1(x);
    y=find_1(y);
    if (x==y) return;
    
    if (height_1[x] < height_1[y]){
        par_1[x]=y;
    }
    else {
        par_1[y]=x;
        if (height_1[x]==height_1[y]) height_1[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same_1 (int x, int y){
    return find_1(x) == find_1(y);
}

int par_2[200010]; //親
int height_2[200010];  //木の深さ

//n要素で初期化
void init_2 (int n){
    for (int i=0;i<n;i++){
        par_2[i]=i;
        height_2[i]=0;
    }
}

//木の根を求める
int find_2 (int x){
    if (par_2[x]==x){
        return x;
    }
    else{
        return par_2[x] = find_2(par_2[x]);
    }
}

//xとyの属する集合を併合
void unite_2 (int x, int y){
    x=find_2(x);
    y=find_2(y);
    if (x==y) return;
    
    if (height_2[x] < height_2[y]){
        par_2[x]=y;
    }
    else {
        par_2[y]=x;
        if (height_2[x]==height_2[y]) height_2[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same_2 (int x, int y){
    return find_2(x) == find_2(y);
}
int main() {
    int N, K, L;
    cin >> N >> K >> L;
    init_1(N);
    init_2(N);
    for (int i=0;i<K;i++){
        int p,q;
        cin >>p >>q;
        unite_1(p-1,q-1);
    }
    for (int i=0;i<L;i++){
        int r,s;
        cin >>r >>s;
        unite_2(r-1,s-1);
    }
    
    vector <P> v;
    P p[200010];
    for(int i=0;i<N;i++){
        p[i]=P(find_1(i),find_2(i));
        v.push_back(p[i]);
    }
    sort (v.begin(),v.end());
    for(int i=0;i<N;i++){
        int c=upper_bound(v.begin(), v.end(),p[i])-lower_bound(v.begin(), v.end(),p[i]);
        printf("%d ", c);
    }
    printf("\n");
}

Measured memory_bytes: 7668
#!/usr/bin/env python3
import sys


def solve(x: int):

    if x == 1:
        return print('0')

    elif x == 0:
        return print('1')


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define	 N 101
char s[4][N+5];
int lens[4];
queue<char> S[4];
int main()
{
	scanf("%s %s %s",s[1]+1,s[2]+1,s[3]+1);
	lens[1]=strlen(s[1]+1);
	lens[2]=strlen(s[2]+1);
	lens[3]=strlen(s[3]+1);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=lens[i];j++)
	{
		if(i==1)
			S[1].push(s[1][j]);
		if(i==2)
			S[2].push(s[2][j]);
		if(i==3)
			S[3].push(s[3][j]);
	}
	int t=1;
	while(!S[t].empty())
	{
		int f=S[t].front();
		S[t].pop();
		t=f-'a'+1;
	}
	printf("%c",t+'a'-1-32);
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define hell 1000000007
using namespace std;
const int N=500;
void solve()
{
    ll i,j,k,n,m,c=0,ans=0;
    string s;
    cin>>n;
   map < string , ll > M;
   rep(i,0,n)
   {
       cin>>s;
       M[s]++;
   }
   cout<<"AC x "<<M["AC"]<<endl<<"WA x "<<M["WA"]<<endl<<"TLE x "<<M["TLE"]<<endl<<"RE x "<<M["RE"];





}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N+1);
  for(int i = 1; i <= N; i++) {
    cin >> L[i];
  }
  vector<int> D(N+2, 0);
  for(int i = 2; i <= N + 1; i++) {
    D[i] = D[i - 1] + L[i - 1];
  }
  int ans = 0;
  for(int i = 0; i <= N + 1; i++) {
    if(0 <= D[i] && D[i] <= X) {
      ans++;
    }
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n) x.at(i)=i+1;
    vector<int> p(n);
    vector<int> q(n);
    rep(i,n) cin>>p.at(i);
    rep(i,n) cin>>q.at(i);
    int a=1,b=1;
    do{
        bool pa=true;
        rep(i,n){
            if(x.at(i)!=p.at(i)){
                pa=false;
                break;
            }
        }
        if(pa){
            break;
        }
        a++;
    }while(next_permutation(x.begin(),x.end()));
    rep(i,n) x.at(i)=i+1;
    do{
        bool pb=true;
        rep(i,n){
            if(x.at(i)!=q.at(i)){
                pb=false;
                break;
            }
        }
        if(pb){
            break;
        }
        b++;
    }while(next_permutation(x.begin(),x.end()));
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long int ll;

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
   ll n,i;
   cin>>n;
   ll arr[n];
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   sort(arr,arr+n);
   ll sum  = accumulate(arr,arr+n,0)-(*max_element(arr,arr+n));
   if(sum>(*max_element(arr,arr+n)))
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
from heapq import heappop, heappush

N,D,A = map(int, input().split())
XH = [[int(i) for i in input().split()] for _ in range(N)]

XH.sort(key=lambda x: x[0])

ans = 0
bomb = []
SUMD = 0 # ダメージの総和
for x, h in XH:
    while bomb:
        right, damage = heappop(bomb)
        if right < x:
            SUMD -= damage
        else:
            heappush(bomb, (right, damage))
            break
    h -= SUMD
    if h > 0:
        cnt = (h + A - 1) // A
        SUMD += cnt * A
        heappush(bomb, (x + 2 * D, cnt * A))
        ans += cnt

print(ans)

Measured memory_bytes: 54052
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ull;
typedef unsigned long long ll;

#define mod 1000000007LL

int main()
{
    int n;
    ll* a;
    ll sum = 0, b, m;
    scanf("%d", &n);
    a = calloc(n, sizeof(ll));
    for (size_t i = 0; i < n; i++)
    {
        scanf("%lld", a + i);
    }

    b = 1;
    for (size_t i = 0; i < 61; i++)
    {
        m = 0;
        for (size_t j = 0; j < n; j++)
        {
            m += !!(a[j] & b);
        }
        sum += ((((b % mod) * (n - m)) % mod) * m) % mod;
        sum %= mod;
        b <<= 1;
    }

    printf("%lld", sum);

    return 0;
}



Measured memory_bytes: 2560
'''
Created on 2020/08/30

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  A=int(pin())
  B=int(pin())
  C=int(pin())
  D=int(pin())
  E=int(pin())
  
  t=min(A,B,C,D,E)
  if N%t==0:
    print(N//t+4)
  else:
    print(N//t+5)
  return 
main()

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) return idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  string s;
  string t;
  cin >> s >> t;
  int s_len = s.size();
  int t_len = t.size();

  int max_len = max(s_len, t_len);

  string s2 = s+s;
  vector<vector<int>> dic_s(26);

  rep(i, 0, s_len*2) {
    char ch = s2[i];
    dic_s[ch - 97].pb(i);
  }

  // rep(i, 0, 26) {
  //   if (dic_s[i].empty()) {
  //     continue;
  //   }
  //   cout << (char)i+97 << endl;
  //   rep(j, 0, dic_s[i].size()) {
  //     cout << dic_s[i][j] << endl;
  //   }
  // }

  vector<vector<int>> next(s_len, vector<int> (26, 0));

  rep(i, 0, s_len) {
    char ch = s[i];
    rep(alphabet, 0, 26) {
      int idx = lbidx(dic_s[alphabet], i+1);
      if (idx == dic_s[alphabet].size()) {
        continue;
      }

      int dis = dic_s[alphabet][idx] - i;
      next[i][alphabet] = dis;
    }
  }

  bool is = true;

  ll ans = 0;

  char start_ch_t = t[0];
  int start_idx = -1;
  rep(i, 0, s_len) {
    char ch_si = s[i];
    if (start_ch_t == ch_si) {
      start_idx = i;
      break;
    }
  }

  if (start_idx < 0) {
    cout << -1 << endl;
    return 0;
  }

  int idx = start_idx;
  ans += (start_idx + 1);
  rep(i, 0, t_len-1) {
    char cur_ch = t[i];
    char next_ch = t[i+1];
    int dis = next[idx][(int)next_ch - 97];
    if (dis == 0) {
      is = false;
    }
    ans += dis;
    idx = (idx + dis) % s_len;
  }

  if (is) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
};


Measured memory_bytes: 14848
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	A = []
	for _ in range(2):
		A.append(INT())
	
	#print(A)

	ans = [1, 2, 3]
	for a in A:
		if a in ans:
			ans.remove(a)
	
	print(ans[0])

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064