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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;
  

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
    z->parent=y;
    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }  
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2);
  a[0] = 0;
  a[n + 1] = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i];

  int s = abs(a[1]) + abs(a[n]);
  for (int i = 2; i <= n; ++i) {
    s += abs(a[i - 1] - a[i]);
  }

  for (int i = 1; i <= n; ++i) {
    int ans;
    ans = s + abs(a[i - 1] - a[i + 1]) - abs(a[i - 1] - a[i]) -
          abs(a[i] - a[i + 1]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1788
def main():
    w, a, b = map(int, input().split())

    rt = max(0, b - a - w, a - b - w)

    # rt = 0
    # if a + w < b:
    #     rt = abs(a + w - b)
    # elif b + w < a:
    #     rt = abs(b + w - a)
    # else:
    #     rt = 0

    print(rt)


if __name__ == "__main__":

    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
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 long long INF = 1LL << 60;

int main() {
    int x,a;
    cin >> x >> a;
    if(x < a) {
        cout << 0;
        return 0;
    }else {
    cout << 10;
    return 0;
    }
}



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

#define ll long long
#define ld long double

using namespace std;

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; cin >> a[i++]);
    sort(a.begin(), a.end());
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if(a[i] == a[j] || a[j] == a[k])
                    continue;
                ans += (a[i] + a[j] > a[k]);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    int n,m;cin >> n >> m;
    vector<vector<tuple<int,int,int>>> a(n);
    for(int i = 0; i < m; i++) {
        int p,y;cin >> p >> y;
        p--;
        a[p].push_back(tuple<int,int,int>(y,i,0));
    }
    vector<tuple<int,int,int>> b;
    for(int i = 0; i < n; i++) {
        sort(a[i].begin(),a[i].end());
        for(int j = 0; j < a[i].size(); j++) {
            get<2>(a[i][j])=j+1;
            int e=get<1>(a[i][j]);
            get<0>(a[i][j])=e;get<1>(a[i][j])=i+1;
            b.push_back(a[i][j]);
        }
    }

    sort(b.begin(),b.end());
    for(int i = 0; i < m; i++) {
        int s=get<1>(b[i]),t=get<2>(b[i]);
        string g=to_string(s),h=to_string(t);
        for(int j = 0; j < 6-g.size(); j++) {
            cout << 0;
        }
        cout << s;
        for(int j = 0; j < 6-h.size(); j++) {
            cout << 0;
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 10408
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;
	cin >> s;
	bool ok = true;
	rep(i, s.size()) {
		if (i&1) {
			if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')ok = false;
		}
		else {
			if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')ok = false;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 256
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
vi adj[100001];
vi vis(100001);
vi ans(100001);
void dfs(int node)
{
	vis[node]=1;
	for(auto ch:adj[node])
	{
		if(!vis[ch])
			dfs(ch);
	}
}
void bfs(int node)
{
	queue<int>q;
	q.push(node);
	vis[node]=1;
	while(!q.empty())
	{
		int nd=q.front();
		q.pop();
		for(auto ch:adj[nd])
		{
			if(!vis[ch]){
			q.push(ch);
			vis[ch]=1;
			ans[ch]=nd;
			}
		}
	}
}
int32_t main()
{
	prep();
	int n,m,a,b;
	cin>>n>>m;
	FOR(i,0,m)
	{
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int cc=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
			cc++;
		}
	}
	if(cc>1)
	{
		cout<<"No";
	}
	else{
	for(int i=1;i<=100000;i++)
	vis[i]=0;
	bfs(1);
	{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++)
		{
			cout<<ans[i]<<endl;
		}
	}
	}
	
	return 0;
}


Measured memory_bytes: 12604
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 0
cnt = 0
larr = t[0]
for ti in t:
    cnt += 1
    if ti - larr > k or cnt > c:
        cnt = 1
        larr = ti
        ans += 1
print(ans + 1)

Measured memory_bytes: 8280
#include<iostream>
using namespace std;
typedef long long LL;
LL lucas[100];
int main()
{
	lucas[0] = 2;
	lucas[1] = 1;
	for(int i = 2; i <= 86; i++)
		lucas[i] = lucas[i-1]+lucas[i-2];
	int N; cin >> N;
	cout<<lucas[N]<<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 rrep(i,n) for (int i = 1; i <= (n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int x[10],y[10];
int n;

double f(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx+dy*dy,0.5);
}

int main() {
  cin >> n;
  rep(i,n) cin >> x[i] >> y[i];

  std::vector<int> v(n);
  rep(i,n) v.at(i) = i;

  double total = 0.0;
  do {
    rep(i,n-1) total += f(v[i],v[i+1]);
  } while(next_permutation(v.begin(), v.end()));

  int num = 1;
  for (int i = 2; i <= n; i++) num *= i;
  cout << std::fixed << std::setprecision(16) << total / num << endl;
}


Measured memory_bytes: 4188
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    long A,B,C,K;
    cin >> A >> B >> C >> K;

    if((A+B) >= K){
        if(A >= K){
            cout << K << endl;
        }
        if(A < K){
            cout << A << endl;
        }
    }
    else{
        cout << 2*A + B - K << endl;
    }
}

Measured memory_bytes: 3632
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		s: Chars,
		t: Chars,
	}

	let d = s.len() - t.len();
	let mut mcount = 0;
	for i in 0..=d {
		let mut count = 0;
		for j in 0..t.len() {
			if s[i+j] == t[j] {
				count += 1;
			}
		}
		mcount = max(mcount, count);
	}
	println!("{}", t.len()- mcount);
}



Measured memory_bytes: 2184
#include <stdio.h>
#include <string.h>

int main() {
    char str[3] = {};
    scanf("%s", str);
    if (strcmp(str, "AAA") == 0 || strcmp(str, "BBB") == 0) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}

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

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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    cin >> i >> j;
    long long ans = 0;
    cout << (n-i+1)*(n-j+1) << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	//ll min = 100000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	//vector<bool> flag(N);
	
	cin >> A >> B;
	
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}


	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return x/b;
}



Measured memory_bytes: 256
from itertools import permutations

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

data = P.copy()
data.sort()

for idx, i in enumerate(list(permutations(data, N))):
    if list(i) == P:
        a = idx
    if list(i) == Q:
        b = idx

print(abs(a-b))


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, x;
	cin >>n >>x;
	VI a(n);
	rep(i, n) cin >>a[i];
	ll ans = 0;
	rep2(i, 1, n){
		ll ws = a[i] + a[i-1] - x;
		if(ws > 0){
			ans += ws;
			a[i] = max(0LL, a[i] - ws);
			
		}
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  int l,r;
  int a;
  int min=2019;
  cin >>l >>r;
  if(l/2019 != r/2019){
    cout <<"0" ;
    return 0;
  }
    l = l%2019;
    r = r%2019;


  for(int i =l;i<=r; ++i){
    for(int j =i+1; j<=r; ++j){
      a=(i*j)%2019;
      if(min>a)min =a;
      //cout <<"(i,j+1)="<<i<<j+1<<endl;
    }
  }
  cout <<min <<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())

if K == 1:
    print(0)
else:
    mn = 1
    mx = N - (K - 1)
    print(mx - mn)



Measured memory_bytes: 5588
import sys

rr = lambda: sys.stdin.readline().rstrip()

s = list(rr())
cnt = 0
for i in range(len(s)-1):
  si = s[i]
  si1 = s[i+1]
  if si == si1:
    if si == '0':
      s[i+1] = '1'
    else:
      s[i+1] = '0'
    cnt += 1
print(cnt)




Measured memory_bytes: 3956
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())

    print('No') if N % 9 else print('Yes')

if __name__ == '__main__':
    main()

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        String s = spar();
        boolean works = true;
        for (int i = 0; i < s.length(); i++)
        {
            if (i % 2 == 0)
            {
                if (s.charAt(i) == 'L')
                {
                    works = false;
                    break;
                }
            }
            else
            {
                if (s.charAt(i) == 'R')
                {
                    works = false;
                    break;
                }
            }
        }
        out.println(works ? "Yes" : "No");

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 22740
import java.util.*;

public class Main {

    private static int N;
    private static int MA;
    private static int MB;
    private static Drag[] D;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        MA = sc.nextInt();
        MB = sc.nextInt();
        D = new Drag[N];
        for (int i = 0; i < N; i++) {
            D[i] = new Drag(sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        System.out.println(solve());
    }

    static int solve() {
        int[][][] dp = new int[N+1][N*10+1][N*10+1];

        for (int i = 1; i <= N; i++) {
            Drag d = D[i-1];

            int prev_dab = dp[i-1][d.a][d.b];
            if( prev_dab > 0 ) {
                dp[i][d.a][d.b] = Math.min(prev_dab, d.cost);
            } else {
                dp[i][d.a][d.b] = d.cost;
            }

            for (int a = 0; a <= N*10; a++) {
                for (int b = 0; b <= N*10; b++) {
                    int prev = dp[i-1][a][b];
                    if( prev > 0 ) {
                        // 追加購入
                        if( a + d.a <= N*40 && b + d.b <= N*40 ) {
                            if( dp[i-1][a+d.a][b+d.b] > 0 ) {
                                dp[i][a+d.a][b+d.b] = Math.min(dp[i-1][a+d.a][b+d.b], prev + d.cost);
                            } else {
                                dp[i][a+d.a][b+d.b] = prev + d.cost;
                            }
                        }

                        // 買わない
                        if( dp[i][a][b] > 0 ) {
                            dp[i][a][b] = Math.min(prev, dp[i][a][b]);
                        } else {
                            dp[i][a][b] = prev;
                        }
                    }
                }
            }
        }

        // MA:MBになる場所で一番コストの少ない箇所を探す
        int n = 1;
        int cost = Integer.MAX_VALUE;
        while(true) {
            int a = n * MA;
            int b = n * MB;
            if( a > N*10 || b > N*10 ) break;

            if( Math.min(dp[N][a][b], cost) != 0 ) {
                cost = Math.min(dp[N][a][b], cost);
            }
            n++;
        }

        if( cost == Integer.MAX_VALUE ) return -1;
        else return cost;
    }

    private static class Drag {
        private final int a;
        private final int b;
        private final int cost;

        public Drag(int a, int b, int cost) {
            this.a = a;
            this.b = b;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 56404
import sys
import math
import collections
from collections import deque
#n = int(input())
a, b, m = map(int, sys.stdin.readline().split())
#s = input()
#x = sys.stdin.readline().split()

A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
mina = min(A)
minb = min(B)
ans = mina + minb

for i in range(m):
    x, y ,c = map(int, sys.stdin.readline().split())
    if A[x-1] + B[y-1] - c < ans:
        ans = A[x-1] + B[y-1] - c

print(ans)


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    int a,b; cin>>a>>b;
    cout<<max(0, a - 2*b);
   
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 256
#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 main() {
 int n;
  cin >> n;
  if (n == 1110 || (n%1111) < 10 || (n%1000)%111 == 0) {
    cout << "Yes" << endl;
  }
  else  {
    cout << "No" << endl;
  }
 return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <math.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 main(){
  string S; cin >> S;
  int N; N = S.size();
  int rule1; rule1 = (N - 1) / 2 - 1; // 1~
  int rule2; rule2 = (N + 3) / 2 - 1; // ~N
  
  string f;
  string s;
  string kaibun = "Yes"; // or "No"
  // rule 1
  for (int i = 0; i <= rule1; i++) {
    f = S[i];
    s = S[rule1-i];
    if (f != s) {
      kaibun = "No";
    }
  }

  // rule 2
  int j = 1;
  for (int i = rule2; i < N; i++) {
    f = S[i];
    s = S[N-j];
    if (f != s) {
      kaibun = "No";
    }
    ++j;
  }
  
  // rule 0
  for (int i = 0; i < N; i++) {
    f = S[i];
    s = S[N-1-i];
    if (f != s) {
      kaibun = "No";
    }
  }
  
  cout << kaibun << endl;
  return 0;
}

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

ll solve() 
{
    ll n,a,b;cin>>n>>a>>b;
    if(a>b)return 0;
    if(a!=b&&n==1)return 0;
    if(a==b&&n==1)return 1;
    n-=2;a=b-a;return n*a+1;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
const ll inf=1001001001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
vi ran,parn;
void init(ll n){
    ran=vi(n);parn=vi(n);
    rep(i,n)parn[i]=i;
}
ll root(ll i){
    if(parn[i]!=i)return root(parn[i]);
    return i;
}
void heigou(ll i,ll j){
    i=root(i);j=root(j);
    if(i==j)return;
    if(ran[i]>=ran[j])parn[j]=i;
    else parn[i]=j;
    if(ran[i]==ran[j])ran[i]++;
}
int main(){
    ll n,q;cin>>n>>q;
    init(n);
    rep(i,q){
        ll a,b,c;cin>>a>>b>>c;
        if(a){
            if(root(b)==root(c))out(1);
            else out(0);
        }
        else{
            heigou(b,c);
        }
    }
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in(),A=in(),B=in();
	vector<string> S(H,string(W,'0'));
	REP(i,B){
		for(int j=A;j<W;j++){
			S[i][j]='1';
		}
	}
	for(int i=B;i<H;i++){
		REP(j,A){
			S[i][j]='1';
		}
	}
	for(auto& x:S){
		out(x);
	}
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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


  ll N; cin >> N ;
  vector<ll> card;
  rep(i,N){
    ll inp; cin >> inp;
    card.pb(inp);
  }
  sort(rall(card));
  ll A = 0, B = 0;
  rep(i,card.size()){
    if(i%2 == 0) A+= card[i];
    else  B+= card[i];
  }
  cout << A-B<< endl;
  
   
  //cout << fixed << setprecision(16) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    std::reverse(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        std::cout << a[i];
        if (i < n - 1) {
            std::cout << ' ';
        }
    }
    std::cout << std::endl;
}



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

bool is_millennium(int y, int m, int d){
	return (y == 1000 && m == 1 && d == 1);
}

int main(){
	int n;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		int y, m, d, ans=0;
		cin >> y >> m >> d;
		
		while( !is_millennium(y,m,d) ){
			ans++;
			if( y % 3 == 0 ){
				if( d == 20 ){
					d = 1;
					if( m == 10 ){
						m = 1;
						y++;
					}else{
						m++;
					}
				}else{
					d++;
				}
			}else{
				if( m % 2 ){
					if( d == 20 ){
						d = 1;
						if( m == 10 ){
							m = 1;
							y++;
						}else{
							m++;
						}
					}else{
						d++;
					}
				}else{
					if( d == 19 ){
						d = 1;
						if( m == 10 ){
							m = 1;
							y++;
						}else{
							m++;
						}
					}else{
						d++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N,M;
    string ans="IMPOSSIBLE";
    cin >> N >>M;
    vector<long long>a(M);
    vector<long long>b(M);

    bool isrand_from_1[200001]={false};
    bool isrand_to_N[200001]={false};

    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(a[i]==0)
            isrand_from_1[b[i]]=true;
        if(b[i]==N-1)
            isrand_to_N[a[i]]= true;
    }

    rep(i,N){
        if(isrand_from_1[i]&&isrand_to_N[i] )
            ans="POSSIBLE";
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3840
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt() * 100;
    int B = sc.nextInt() * 100;
    int C = sc.nextInt();
    int D = sc.nextInt();
    int E = sc.nextInt();
    int F = sc.nextInt();

    sc.close();

    int maxWater = 1;
    int maxSuger = 0;

    // 水の量を全探索
    for (int i = 0; i <= F; i++) {
      for (int j = 0; j <= F - i; j++) {

        if (F < (A * i + B * j)) {
          continue;
        }

        int water = A * i + B * j;
        
        // 砂糖の量を全探索
        for (int k = 0; k <= F; k++) {
          for (int l = 0; l <= F - k; l++) {

            if(F < (C * k + D * l)) {
              continue;
            }

            int suger = C * k + D * l;

            if (F < (water + suger)) {
              continue;
            }

            if ((water * E) < (suger * 100)) {
              continue;
            }

            if ((double) suger / (suger + water) >= (double) maxSuger / (maxSuger + maxWater)) {
              maxWater = water;
              maxSuger = suger;
            }

          }
        }

      }

    }

    System.out.println((maxWater + maxSuger) + " " + maxSuger);

  }

}

Measured memory_bytes: 21972
N = int(input())
A = list(map(int,input().split()))
cnt = 0
t = 0
r = 0
for l in range(N):
    while r < N and (t & A[r]) == 0:
        t += A[r]
        r += 1
    t -= A[l]
    cnt += (r-l)

print(cnt)

Measured memory_bytes: 24712
#include<bits/stdc++.h>
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int a[100];
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	rep(i, n) {
		int id = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[id])id = j;
		}
		if (id != i) {
			cnt++; swap(a[i], a[id]);
		}
	}
	rep(i, n) {
		if (i)printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", cnt);
}

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

int N;
const int MAX_N = 100010;

int a[MAX_N];

int main(){
	
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&a[i]);
	}

	int cnt=0;
	if(a[1]==1){
		swap(a[1],a[2]);
		cnt++;
	}

	for(int i=2;i<=N;i++){
		if(a[i]==i){
			swap(a[i],a[i+1]);
			cnt++;
		}
	}
	printf("%d\n",cnt);

	return 0;
}


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

template<class like_bool> inline void YES(like_bool condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class like_bool> inline void Yes(like_bool condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class like_bool> inline void POSS(like_bool condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class like_bool> inline void Poss(like_bool condition){ if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class like_bool> inline void First(like_bool condition){ if(condition)cout << "First" << endl; else cout << "Second" << endl; }
template<class like_bool, class output> inline void negative(like_bool condition, output num){ if(condition)cout << -1 << endl; else cout << num << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N;
    cin >> N;
    int nums[N];
    for(int i = 0; i < N; i++){
        cin >> nums[i];
    }
    for(int i = 1; i <= N; i++){
        sort(nums, nums + i);
        array_output(nums, nums + N);
    }
}




Measured memory_bytes: 3236
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
 
int a,b,c;
cin>>a>>b>>c;
if(a<b && b<c)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
 
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <string>
using namespace std; using ll=long long; const int INF=1e9+7; using P=pair<int,int>;

int main() {
  ll n,x; cin>>n>>x;
  ll a[n], an=0;
  for(int i=0;i<n;i++) {
    cin>>a[i];
  }
  if (a[0] > x) an+=a[0]-x, a[0]=x;
  for(int i=1;i<n;i++) {
    if (a[i-1] + a[i] > x) {
      an += a[i]+a[i-1]-x;
      a[i] = x - a[i-1];
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
using namespace std;

const int MAX = 100001;

int parent(int table[], int child) {
	if (table[child] == 0)return child;
	return table[child] = parent(table, table[child]);
}

int main() {
	int n, m, q;
	int table[MAX] ={0};

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		int s, t;
		scanf("%d %d", &s, &t);
		s++;t++;
		int ps = parent(table, s);
		int pt = parent(table, t);
		if (ps != pt) {
			table[ps] = pt;
		}
	}

	scanf("%d", &q);

	for (int i = 0; i < q; i++) {
		int s, t;
		
		scanf("%d %d", &s, &t);
                s++;t++;
		int ps = parent(table, s);
		int pt = parent(table, t);

		if (ps == pt) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            long[] cnt = new long[26];
            for (char c : s.toCharArray()) cnt[c - 'a']++;
            long ans = (long) s.length() * (s.length() - 1) / 2 + 1;
            for (int i = 0; i < 26; i++) {
                ans -= cnt[i] * (cnt[i] - 1) / 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char> > cv(H);
    for(int i=0; i<H; i++){
        cv[i].resize(W);
        string buf;
        cin >> buf;
        for(int j=0; j<W; j++){
            cv[i][j] = buf[j];
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(cv[i][j]=='#'){
                if(i>0 && cv[i-1][j]=='#') continue;
                if(i<H-1 && cv[i+1][j]=='#') continue;
                if(j>0 && cv[i][j-1]=='#') continue;
                if(j<W-1 && cv[i][j+1]=='#') continue;
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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


vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    z[0] = n;
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main()
{

    int n;
    cin>>n;

    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        string tmp = s.substr(i,n-i);
        vector <int> z = z_function(tmp);

        for(int i=0;i<z.size();i++)
        {
           ans = max(ans, min(i,z[i]));
        }

    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3700
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
   string s;
   cin >> s;
   for(int i=0; i<s.size(); i++){
       cout << "x";
   }
   cout << "\n";
   

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int h,w;
  int i,j;
  int co = 0;
  int ch = 0;


  do{
    scanf("%d%d",&h,&w);
    if(h == 0	&&	w == 0)
      break;

    for(i = 0; h > i; i++){
      for(j = 0; w > j;	j++){
	if((ch%2)==0 && (co%2)==0)
	  printf("#");
	else if((ch%2)==0 && (co%2)==1)
	  printf(".");
	else if((ch%2)==1 && (co%2)==0)
	  printf(".");
	else
	  printf("#");
	ch++;
      }
      co++;
      ch=0;
      puts("");
    }
    puts("");
    co=0;
  }while(1);

  return(0);
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define mod 1000000007
int64_t poww(int a,int b){
	if (!b) return 1;
	int64_t tmp=poww(a,b/2);
	if (b%2) return (((tmp*tmp)%mod)*a)%mod;
	return (tmp*tmp)%mod;
}
using namespace std;
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int64_t n;
	cin>>n;
	int64_t sol=poww(10,n);
	sol=(sol-2*poww(9,n))%mod;
	sol=(sol+poww(8,n))%mod;
	if (sol<0) sol+=mod;
	cout<<sol;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a%d)e=a/d+1;
	else e=a/d;
	if(c%b)f=c/b+1;
	else f=c/b;
	if(e>=f)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    long N, A, B;
    cin >> N >> A >> B;

    auto P = 1L << N - 1;
    auto T = A ^ P ^ B;
    auto k = __builtin_popcountl(T);

    if(k & 1){
        puts("NO");
    }else{
        puts("YES");
        auto n = P * 2 - 1;
        vector<long> ans(n);
        for(long i = 0; i < n; ++i)ans[i] = i ^ i + 1 ^ (i ^ i + 1) / 2;

        vector<long> t;
        for(long i = 1; i <= P; i *= 2)if(T & i)t.push_back(i);

        auto s = t.size();
        for(long i = 0; i < s; i += 2){
            auto a = t[i], b = t[i + 1];
            for(long j = 0; j < n; ++j){
                if(ans[j] > b)break;
                if(ans[j] == a)ans[j] = b;
                else if(ans[j] == b)ans[j] = a;
            }
        }

        long a = A;
        cout << a << " ";
        for(const auto& i : ans)cout << (a ^= i) << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
        if (n % 2 == 0) cout << n << endl;
        else cout << 2 * n << endl;
}

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

int main()
{
    long long int h;
    cin >> h;
    long long int ans = 0;
    long long int cur;
    long long int k = 0;
    h /= 2;
    while(h){
        k++;
        h /= 2;
    }

    ans = pow(2, k+1) - 1;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Control.Arrow
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    s <- getLine
    putStrLn $ if str s then "Yes" else "No"

str :: String -> Bool
str xs = let n = length xs
  in pal (take ((n-1)`div`2) xs) && pal xs

pal xs = xs == reverse xs

Measured memory_bytes: 508
#include<iostream>
#include<queue>
using namespace std ;
int main()
	{
	string s ;
	s.clear() ;
	queue <char> q ;
	q.push('S') ;
	q.push('C') ;
	q.push('R') ;
	cin>>s ;
	while(s[0]!=q.front())
		{
		q.push(q.front()) ;
		q.pop() ;
		}
	q.pop() ;
	if(q.front()=='S')
		cout<<"Sunny"<<endl ;
	else if(q.front()=='R')
		cout<<"Rainy"<<endl ;
	else
		cout<<"Cloudy"<<endl ;
	}

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

long long n;
vector<long long> a;
bitset<4000001> dp;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long sum = 0;
  dp[0] = 1;
  for(int i = 0; i < n; ++i) {
    dp |= dp << a[i];
    sum += a[i];
  }
  for(int i = ++sum / 2;; ++i)
    if(dp[i]) return i;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    b = LI()
    if sum(a) < sum(b):
        print(-1)
    else:
        tmp = 0
        ans = 0
        ab = list(map(lambda x: x[0] - x[1], zip(a, b)))
        ab.sort()
        for i in ab:
            if i < 0:
                ans += 1
                tmp += i
            else:
                break
        for i in ab[::-1]:
            if tmp < 0:
                if i > 0:
                    ans += 1
                    tmp += i
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

using ll = long long;

int n;
vector<ll> a, f;
ll g(ll x) {
  ll count = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) * f.at(i) > x){
      count += a.at(i) - (x / f.at(i));
    }
  }
  return count;
}

int main() {
  ll k;
  cin >> n >> k;
  
  ll num;
  for(int i = 0; i < n; i++){
    cin >> num;
    a.push_back(num);
  }
  for(int i = 0; i < n; i++){
    cin >> num;
    f.push_back(num);
  }
  
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  
  ll sl = -1, sr = 1e18, sm;
  while(sl + 1 < sr){
    sm = (sl + sr) / 2;
    if(g(sm) <= k) sr = sm;
    else sl = sm;
  }
  
  cout << sr << endl;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    REP(i,b){
        if(a+i==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,sw,m,n,a,b,c:Integer;
  s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Readln(c);

    x:=a;
    while x<a*b do begin
      if x mod b = c then begin
        Writeln('YES');
        Readln;
        exit;
      end else
        x:=x+a;
    end;
    Writeln('NO');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256