akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

vector<ll> fact, fact_inv;

template <typename T> T mpow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n = n >> 1;
    }
    return ret;
}

void COMinit(ll MAX) {
    fact.resize(MAX + 1);
    fact_inv.resize(MAX + 1);
    fact[0] = fact_inv[0] = 1;
    rep(i, MAX) {
        fact[i + 1] = fact[i] * (i + 1) % mod;
        fact_inv[i + 1] = mpow(fact[i + 1], mod - 2);
    }
}

ll COM(ll n, ll k) {
    if(n < k || k < 0) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n - k] % mod;
}

ll permutation(ll n, ll k) {
    if(n < k || k < 0) return 0;
    return fact[n] * fact_inv[n - k] % mod;
}

ll n, k;
vector<ll> e[100009];
bool visit[100009];

ll dfs(int i) {
    visit[i] = 1;
    ll re;
    if(i == 1)
        re = permutation(k, e[i].size() + 1);
    else
        re = permutation(k - 2, e[i].size() - 1);

    rep(j, e[i].size()) {
        if(visit[e[i][j]]) continue;
        re *= dfs(e[i][j]);
        re %= mod;
    }
    return re;
}

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

    cin >> n >> k;
    COMinit(k);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    cout << dfs(1) << endl;
}

Measured memory_bytes: 9344
#include <stdio.h>
int main(void){
	int h,m1,m2,m3,w;
	m1=0;
	m2=0;
	m3=0;
	for(int i=0;i<10;i++){
		scanf("%d",&h);
		if(m3<h){
			m3=h;
			if(m2<m3){
				w=m2;
				m2=m3;
				m3=w;
				if(m1<m2){
					w=m1;
					m1=m2;
					m2=w;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",m1,m2,m3);
	return 0;
}


Measured memory_bytes: 2008
#include<iostream>
#include<cstdio>
using namespace std;
char s[2002019];
int main()
{
	int n; scanf("%d",&n);
	scanf("%s",s+1); int cr=0;
	for(int i=1;i<=n;i++)
		if(s[i]=='R')++cr;
	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(s[i]!='R' && s[j]!='R' && s[i]!=s[j]){
				int jl=j-i;
				if(j+jl<=n && s[j+jl]=='R')--ans;
				if(i-jl>=1 && s[i-jl]=='R')--ans;
				if(!(jl&1) && s[i+jl/2]=='R')--ans;
				ans+=cr;
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
  
// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;
  
    /* create temp arrays */
    int L[n1], R[n2];
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }
  
    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }
  
    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}
  
/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;
  
        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);
  
        merge(arr, l, m, r);
    }
}

int main()
{
    int a,b,bb[200009];
    cin>>a>>b;
    long long sum=0;
    for(int i=0;i<a;i++){
        cin>>bb[i];
    }
    if(b>=a){
        cout<<"0\n";
    }
    else{
        //sort(bb,bb+a);
        mergeSort(bb,0,a-1);
        for(int i=0;i<a-b;i++){
            sum+=bb[i];
        }
        cout<<sum<<"\n";
    }
    return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        System.out.println(lcm(a,b));
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}



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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int west[n] = { 0 }, east[n] = { 0 };
	for (int i = 0;i < n;i++) {
		west[i + 1] = west[i];
		east[i + 1] = east[i];
		if (s[i] == 'W')west[i + 1]++;
		else east[i + 1]++;
	}
	int mm = n;
	for (int i = 0;i < n;i++) {
		mm = min(west[i] + (east[n] - east[i + 1]), mm);
	}
	cout << mm << endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<queue>
#define mp make_pair
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int h, w, ans;
char map[30][30];
queue<pair<pair<int, int>, int>>q;
int mapi[30][30];
signed main() {
	cin >> h >> w;
	for1(i, h)for1(j, w)cin >> map[i][j];
	for1(x1, h)for1(y1, w)if (map[x1][y1] == '.') {
		q.empty();
		for1(i, h)for1(j, w)mapi[i][j] = 500;
		q.push(mp(mp(x1, y1), 0));
		while (q.size()) {
			int x = q.front().first.first, y = q.front().first.second, c = q.front().second;
			q.pop();
			if (mapi[x][y] > c) {
				mapi[x][y] = c;
				int xp = x - 1, yp = y;
				if (1 <= xp && xp <= h && 1 <= yp && yp <= w && map[xp][yp] != '#' && mapi[xp][yp] > c + 1) q.push(mp(mp(xp, yp), c + 1));
				xp = x + 1;
				if (1 <= xp && xp <= h && 1 <= yp && yp <= w && map[xp][yp] != '#' && mapi[xp][yp] > c + 1) q.push(mp(mp(xp, yp), c + 1));
				xp = x; yp = y - 1;
				if (1 <= xp && xp <= h && 1 <= yp && yp <= w && map[xp][yp] != '#' && mapi[xp][yp] > c + 1) q.push(mp(mp(xp, yp), c + 1));
				yp = y + 1;
				if (1 <= xp && xp <= h && 1 <= yp && yp <= w && map[xp][yp] != '#' && mapi[xp][yp] > c + 1) q.push(mp(mp(xp, yp), c + 1));
			}
		}
		for1(i, h)for1(j, w)if (map[i][j] == '.')ans = max(ans, mapi[i][j]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int ret = 0;
int main () {
  cin >> s;
  ret = s.size();
  const int n = s.size();
  for(int i = 1; i < n; ++i) {
    if (s[i - 1] != s[i]) {
      int c = max(i, n - i);
      ret = min(ret, c);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
    int ans=0;
    ans=a*x+b*y;
    int kari=ans;
    if(x<y){
        swap(a,b);
        swap(x,y);
    }
    rep(i,x){
        kari+=2*c-a;
        if(i<y){
            kari-=b;
        }
        ans=min(ans,kari);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
n = int(input())
a = list(map(int, input().split()))

ans = 1

if 0 in a:
    print(0)
else:
    for i in range(n):
        ans = ans * a[i]
        if ans > 10 ** 18:
            print(-1)
            break
        elif i == n - 1:
            print(ans)

Measured memory_bytes: 21648
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

int sum[100011];

int main() {
  int n; cin >> n;
  rep(i, 0, n) {
    int a, b; cin >> a >> b;
    sum[a]++;
    sum[b + 1]--;
  }
  rep(i, 1, 100011) sum[i] = sum[i] + sum[i - 1];
  int _max = 0;
  rep(i, 0, 100011) {
    if (sum[i] >= i - 1) _max = max(_max, i - 1);
  }
  cout << _max << endl;
}




Measured memory_bytes: 3492
N = int(input())

i = 1
cash = []
while i <= N:
    cash.append(i)
    i *= 6
i = 9
while i <= N:
    cash.append(i)
    i *= 9

dp = [10**6+10] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in cash:
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j]+1)
print(dp[-1])

Measured memory_bytes: 74008
#include <cstdio>
#include <cstring>
#include <algorithm>

int n;

int main(){
	scanf("%d", &n);
	printf("%d\n", n * (n - 1) / 2 - n / 2);
	if(n & 1){
		for(int i = 1; i < n; i++)
			for(int j = i + 1; j < n; j++)
				if(i + j != n) printf("%d %d\n", i, j);
		for(int i = 1; i < n; i++) printf("%d %d\n", i, n);
	}
	else{
		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j++)
				if(i + j != n + 1) printf("%d %d\n", i, j);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//B
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] ans = new char[H][W];
		boolean[] DepthFlag = new boolean[W];
		boolean[] WidthFlag = new boolean[H];

		for(int i = 0; i < H ; i++){
			String tmp = sc.next();
			if(!tmp.contains("#")){
				WidthFlag[i] = true;
			}
			for(int j = 0 ; j< W ; j++){
				ans[i][j] = tmp.charAt(j);
				if(ans[i][j] == '#'){
					DepthFlag[j] = true;
				}
			}
		}

		String s = "";
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++){
				if(DepthFlag[j] && !WidthFlag[i]){
					s += ans[i][j];
				}
			}
			s += "\n";
		}
		System.out.println(s.trim());

	}
}

Measured memory_bytes: 144724
#include <iostream>

using namespace std;

int main(void)
{
    int N, M, X, i, j, A[101], a=0, b=0;

    cin >> N >> M >> X;

    for(i=1; i<=M; i++){
        cin >> A[i];
    }

    // 0に行く
    for(i=X; i>0; i--){
        for(j=1; j<=M; j++){
            if(i == A[j]){
                a++;

                break;
            }
        }
    }

    for(i=X; i<N; i++){
        for(j=1; j<=M; j++){
            if(i == A[j]){
                b++;

                break;
            }
        }
    }

    if(a<b){
        cout << a << endl;
    }

    else{
        cout << b << endl;
    }

    return 0;
}

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

const ll mod=1e9+7;

ll dp[1000000][3];
ll n;
ll a[1000000],b[1000000],c[1000000];

ll solve(ll i,ll x){
    if(i>=n) return 0;

    if(dp[i][x]!=-1)
        return dp[i][x];

    ll ans=0;
    // x x
    if(x==0){
        ans+=solve(i+1,1)+b[i];
        ans=max(ans,solve(i+1,2)+c[i]);
    }
    // x y
    else if(x==1){
        ans=solve(i+1,0)+a[i];
        ans=max(ans,solve(i+1,2)+c[i]);
    }
    else{
        ans=solve(i+1,0)+a[i];
        ans=max(ans,solve(i+1,1)+b[i]);
    }
    return dp[i][x]=ans;
     
    // x z
    
}

int main() {
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }    

    memset(dp,-1,sizeof(dp));

    cout<<max(solve(1,0)+a[0],max(solve(1,1)+b[0],solve(1,2)+c[0]))<<endl;

}


Measured memory_bytes: 38272
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    vector<int> v(n);
    rep(i, n) {
        v[p[i]] = i;
    }

    int t = -1;
    int now = 0;
    int ans = 0;
    rep(i, n) {

        if(i == n-1) {
            if(t < v[i]) {
                now++;
            }
            ans = max(ans, now);
            break;
        }

        if(t < v[i]) {
            now++;
        }
        else {
            ans = max(ans, now);
            now = 1;
        }
        t = v[i];
    }

    ans = n - ans;

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "hi" || s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 764
#include <iostream>
unsigned long long a,b;
bool chk(unsigned long long c){
  for(unsigned long long d=b,i=0;i<a;i++){
    if(d%c==0) d/=c;
    else return false;
  }
  return true;
}
int main(void){
  std::cin >> a >> b;
  if(a==1){
    std::cout << b;
    return 0;
  }else{
    unsigned long long c=1000000;
    for(;c>1;c--){
      if(chk(c)){
        std::cout << c;
        return 0;
      }
    }
    std::cout << "1";
    return 0;
  }
}


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

typedef struct label
{
    int top;    //1
    int front;  //2
    int right;  //3
    int left;   //4
    int back;   //5
    int bottom; //6
} Dice;

void diceroll(Dice *d, const char dir)
{
    int tmp;
    switch (dir)
    {
    case 'E':
    {
        tmp = d->top;
        d->top = d->left;
        d->left = d->bottom;
        d->bottom = d->right;
        d->right = tmp;
        break;
    }
    case 'N':
    {
        tmp = d->top;
        d->top = d->front;
        d->front = d->bottom;
        d->bottom = d->back;
        d->back = tmp;
        break;
    }
    case 'S':
    {
        tmp = d->top;
        d->top = d->back;
        d->back = d->bottom;
        d->bottom = d->front;
        d->front = tmp;
        break;
    }
    case 'W':
    {
        tmp = d->top;
        d->top = d->right;
        d->right = d->bottom;
        d->bottom = d->left;
        d->left = tmp;
        break;
    }
    }
}

void place_front(Dice *d, int q2)
{
    char direction[] = "NENEN";
    int i = 0;
    while (d->top != q2)
    {
        diceroll(d, direction[i]);
        i++;
    }
    diceroll(d, 'S');
}

void place_top(Dice *d, int q1)
{
    while (d->top != q1)
    {
        diceroll(d, 'W');
    }
}

bool is_same_dice(Dice d1, Dice d2)
{
    while (d1.front != d2.front)
    {
        place_front(&d2, d1.front);
    }
    place_top(&d2, d1.top);

    return d1.right == d2.right && d1.left == d2.left && d1.back == d2.back && d1.bottom == d2.bottom;
}

int main(void)
{
    Dice d1, d2;
    scanf("%d %d %d %d %d %d", &d1.top, &d1.front, &d1.right, &d1.left, &d1.back, &d1.bottom);
    scanf("%d %d %d %d %d %d", &d2.top, &d2.front, &d2.right, &d2.left, &d2.back, &d2.bottom);

    puts(is_same_dice(d1, d2) ? "Yes" : "No");

    return 0;
}



Measured memory_bytes: 2084
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define INF 9223372036854777ll
#define pb push_back
using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<ll> dp(k+1);
    dp[0]=1;
    for(int i=0;i<n;i++){//For each child
    vector<ll> fa(k+1);
        for(int j=k;j>=0;j--){//Used chocolates
        ll tmp=dp[j];
        int l=j+1;
        int r=j+min(a[i],k-j);
        if(l<=r){
            fa[l]+=tmp;
            if(fa[l]>=mod)
            fa[l]-=mod;
            if(r+1<=k)
            {fa[r+1]-=tmp;if(fa[r+1]<0)fa[r+1]+=mod;}
        }
        }
        ll pre=0;
    for(int i=0;i<=k;i++){
        pre+=fa[i];
        if(pre>=mod)
        pre-=mod;
        dp[i]+=pre;
        if(dp[i]>=mod)
        dp[i]-=mod;
    }
    }
    cout<<dp[k];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

#define ll long long int

ll n, m, a, b;
vector<ll> heights, g[100005];

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

	heights = vector<ll>(n);

	for (int i = 0; i < n; i++) cin >> heights[i];

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		ll curr_height = heights[i];
		bool flag = true;
		for (auto adj : g[i])
			if (heights[adj] >= curr_height) flag = false;
		if (flag)
			cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
#include <cmath>
#include <limits>
#include <queue>
using namespace std;

int main()
{
	char c;
	string prev_str = "";
	string curr_str = "";
	long long result = 0;

	while (true) {
		c = (char)cin.get();
		if (c == EOF || c == '\n') {
			break;
		}

		curr_str += c;
		
		if (curr_str != prev_str) {
			result++;
			prev_str = curr_str;
			curr_str = "";
		}
	}

	cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N,M,R;
int r[8];
vector<P> v[200000];
int table[]={0,1,2,3,4,5,6,7};

int main(){
    cin>>N>>M>>R;
    rep(i,R) cin>>r[i];
    rep(i,R) r[i]--;
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        v[a-1].push_back(P(b-1,c));
        v[b-1].push_back(P(a-1,c));
    }

    map<P,int> m;
    rep(s,R){
        vector<int> dis(N,INF);
        dis[r[s]]=0;
        priority_queue<P,vector<P>,greater<P>> q;
        q.push(P(0,r[s]));
        while(!q.empty()){
            P p=q.top(); q.pop();
            int from=p.second;
            if(dis[from]<p.first) continue;
            rep(i,v[from].size()){
                int to=v[from][i].first;
                int cost=v[from][i].second;
                if(dis[from]+cost<dis[to]){
                    dis[to]=dis[from]+cost;
                    q.push(P(dis[to],to));
                }
            }
        }
        //cout<<"start="<<r[s]<<' '; rep(i,N) cout<<dis[i]<<' '; cout<<endl;
        rep(i,R){
            m[P(r[s],r[i])]=dis[r[i]];
            m[P(r[i],r[s])]=dis[r[i]];
        }
    }

    int ans=INF;
    do{
        int res=0;
        rep(n,R-1){
            int i=table[n];
            int j=table[n+1];
            res+=m[P(r[i],r[j])];
        }
        //cout<<res<<endl;
        ans=min(ans,res);
    }while(next_permutation(table,table+R));

    cout<<ans<<endl;
}

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

NewA = sorted(A, reverse=True)

Alice = 0
Bob = 0 

for i in range(N):
    if i % 2 ==0:
        Alice = Alice + NewA[i]
    else:
        Bob = Bob + NewA[i]


print((Alice)-(Bob))

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

int main(){
 int A,B,C,X,Y;
 cin >>A >>B >>C >>X >>Y; 
 int tmp1=A*X+B*Y,tmp2=0;
  
for (int c=0;c<=max(X,Y);c++){
    tmp2=2*c*C+max((X-c),0)*A+max((Y-c),0)*B;
if (tmp1>tmp2){
    tmp1=tmp2;
}
}
cout <<tmp1 <<endl;
return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=300001;

int he,le,a[501][501]={0},i,j,q[maxn],w[maxn],e[maxn],r[maxn],now = 0;

int main(){
	cin>>he>>le;
	for(i=1;i<=he;i++){
		for(j=1;j<=le;j++){
			cin>>a[i][j];
		}
	}
	for(i=1;i<=he;i++){
		for(j=1;j<=le;j++){
			if(a[i][j]%2 == 0) continue;
			else if(a[i][j+1]%2 && j+1<=le){
			 	a[i][j+1]+=1;
				now++;
				q[now]=i;
				w[now]=j;
				e[now]=i;
				r[now]=j+1;
			}
			else if(a[i+1][j]%2 && i+1<=he){
				a[i+1][j]+=1;
				now++;
				q[now]=i;
				w[now]=j;
				e[now]=i+1;
				r[now]=j;
			}
			else if(j+1<=le){
				a[i][j+1]+=1;
				now++;
				q[now]=i;
				w[now]=j;
				e[now]=i;
				r[now]=j+1;
			}
			else if(i+1<=he){
				a[i+1][j]+=1;
				now++;
				q[now]=i;
				w[now]=j;
				e[now]=i+1;
				r[now]=j;
			}
		}
	}
	cout << now << endl;
	for(i=1;i<=now;i++){
		cout<<q[i]<<' '<<w[i]<<' '<<e[i]<<' '<<r[i]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 6144
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let  (r, d, mut x) = get!(i32 , i32, i32);

    for i in 0..10 {
        x = r*x-d;
        println!("{}" , x);
    }
}


Measured memory_bytes: 4352
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
#define fff(i,n) for(int i=0;i<n;i++)
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    map<string,int> m;
    string arr[n];
    fff(i,n) {
        cin >> arr[i];
        m[arr[i]]++;
    }
    
    int x=0;
    fff(i,n) {
        if(m[arr[i]]>x)
        x=m[arr[i]];
    }
    sort(arr,arr+n);
    fff(i,n) {
        if(m[arr[i]]==x) {
            cout << arr[i] << endl;
            m[arr[i]]=-1;
        }
    }
       
    return 0;
    
}

Measured memory_bytes: 34048
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	ld x;
	cin >> x;
	if (x == 0) cout << 1 << "\n";
	else if (x == 1) cout << 0 << "\n";

	return 0;
}


Measured memory_bytes: 3676
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)

Measured memory_bytes: 170840
#include <stdio.h>
#include <stdbool.h>

#define MAX 100

int main() {
  int n;
  int A[MAX];
  int tmp;
  int minj;
  int swap_num = 0;
  bool needSwap = false;

  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    if(n < 1 && n > 100) {
      printf("Error: out of range.");
        return -1;
    }
  }

  if(n > 1) {
    // find the minimum number
    for(int i = 0; i < n; i++) {
      minj = i;
      for(int j = i; j < n; j++) {
        if(A[j] < A[minj]) {
          needSwap = true;
          minj = j;
        }
      }
      if(needSwap) {
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        swap_num++;
      }
      needSwap = false;
    }
  }

  printf("%d", A[0]);
  for(int i = 1; i < n; i++) {
    printf(" %d", A[i]);
  }
  printf("\n%d\n", swap_num);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e18 + 7;

int main(){
    int n;
    cin >> n;
    map<map<int, int>, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        map<int, int> tmp;
        rep(j, 10) {
            tmp[s[j]-'a']++;
        }
        mp[tmp]++;
    }
    ll ans = 0;
    for( auto i = mp.begin(); i != mp.end() ; ++i ) {
        ll tmp = i->second;
        if (tmp > 1) ans += tmp * (tmp-1)/2;
        //cout << tmp << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 49152
A, B = map(int, input().split())

grid = [["." for _ in range(100)] for _ in range(100)]

# 上半分（50*100）を黒で、下半分(50*100)を白で埋める
for r in range(50):
    for c in range(100):
        grid[r][c] = "#"

# 上の(49*100)において、A-1マスを白に塗り替える
cnt_w = 1
for r in range(0, 49, 2):
    for c in range(100):
        if cnt_w < A:
            if r % 2 == 0 and c % 2 == 0:
                grid[r][c] = "."
                cnt_w += 1
            elif r % 2 == 1 and c % 2 == 1:
                grid[r][c] = "."
                cnt_w += 1

# 下の(49*100)において、B-1マスを黒に塗り替える
cnt_b = 1
for r in range(51, 100, 2):
    for c in range(100):
        if cnt_b < B:
            if r % 2 == 0 and c % 2 == 0:
                grid[r][c] = "#"
                cnt_b += 1
            elif r % 2 == 1 and c % 2 == 1:
                grid[r][c] = "#"
                cnt_b += 1

print(100, 100)
for r in range(100):
    print("".join(grid[r]))


Measured memory_bytes: 66160
/**
 * ????????????

n ?? m ????????? A ??¨ m ?? l ????????? B ?????\??????????????????????????§?????? n ?? l ????????? C
???????????????????????°?????????????????????????????????????????? C ??????????´? cij
????¬?????????§??????????????????

cij=???k=1maikbkj

????????§???A???B???C ??????????´???????????????? aij???bij???cij ??¨????????????

Input
???????????? n???m???l ????????????????????§?????????????????????

?¶?????????? n ?? m ????????? A ??¨ m ?? l ????????? B ????????????????????????

Output
n ?? l ????????? C ???????´? cij
?????????????????????????????????????????£?????????????´?????????????????????§????????£??????????????????

Constraints
1???n,m,l???100
0???aij,bij???10000

Sample Input
3 2 3
1 2
0 3
4 5
1 2 1
0 3 2

Sample Output
1 8 5
0 9 6
4 23 14
 */

#include <iostream>
#include <sstream>
#include <vector>

int main(int argc, char const *argv[]) {
  unsigned short n, m, l;
  std::string Param;
  std::istringstream iss;
  while (true) {

    getline(std::cin, Param);
    iss.str(Param);
    iss >> n >> m >> l;
    iss.clear();
    if (n > 100 || m > 100 || l > 100) {
      std::cout << "Error: 1 <= n, m, l <= 100" << std::endl;
    } else {
      break;
    }
  }

  std::vector<std::vector<unsigned short>> A(n,
                                             std::vector<unsigned short>(m, 0));
  std::vector<std::vector<unsigned short>> B(m,
                                             std::vector<unsigned short>(l, 0));
  std::vector<std::vector<unsigned long long>> C(n,
                                             std::vector<unsigned long long>(l, 0));

  unsigned short i = 0;
  bool isValid = true;

  while (i < n) {
    getline(std::cin, Param);
    iss.str(Param);
    for (size_t j = 0; j < m; j++) {
      iss >> A[i][j];
      if (A[i][j] > 10000) {
        std::cout << "Error: 0 <= ai <= 10000" << std::endl;
        isValid = false;
        break;
      } else {
        isValid = true;
      }
    }
    iss.clear();
    if (isValid) {
      i++;
    }
  }

  i = 0;
  while (i < m) {
    getline(std::cin, Param);
    iss.str(Param);
    for (size_t j = 0; j < l; j++) {
      iss >> B[i][j];
      if (B[i][j] > 10000) {
        std::cout << "Error: 0 <= bi <= 10000" << std::endl;
        isValid = false;
        break;
      } else {
        isValid = true;
      }
    }
    iss.clear();
    if (isValid) {
      i++;
    }
  }
  for (size_t j = 0; j < l; j++) {
    for (size_t i = 0; i < n; i++) {
      for (size_t k = 0; k < m; k++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  for (const auto &Row : C) {
    for (size_t i = 0; i < l; i++) {
      std::cout << Row[i];
      if (i < l - 1) {
        std::cout << " ";
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3284
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

typedef long long ll;

const int MAX_N = 51;
const int MAX_DAY = 31;

ll dp[MAX_N][MAX_DAY]; // N??????????????????D??\????????§???????????????????????§?????°????????????

int main() {
	int N;
	while(cin >> N, N) {
		vector<vector<bool>> schedules(N, vector<bool>(MAX_DAY, false));
		fill_n((ll *)dp, sizeof(dp) / sizeof(ll), 0);

		rep(n, N) {
			int f0, fi;
			cin >> f0;
			rep(j, f0) {
				cin >> fi;
				schedules[n][fi] = true;
			}
		}
		
		rep(n, N) dp[n][0] |= (1LL<<n);
		
		REP(d, 1, MAX_DAY) {
			rep(n, N) {
				if(!schedules[n][d]){
					dp[n][d] = dp[n][d-1];
					continue;
				}	
				rep(i, N) {
					if(!schedules[i][d]) continue;
					dp[i][d] |= dp[n][d-1];
				}
			}
		}
		
		bool is_clear = false;
		const ll CLEAR = (1LL<<N)-1;
		int ans = 0;
		rep(d, MAX_DAY) {
			rep(n, N) {
				if(dp[n][d] == CLEAR && !is_clear) {
					ans = d;
					is_clear = true;
				}
			}
		}
		cout << ((is_clear) ? ans : -1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <iostream>

using namespace std;

int mod_inv( long n, long mod )
{
    long b = mod, u = 1, v = 0;

    while ( b > 0 )
    {
        long t = n / b;

        n -= t * b, u -= t * v;

        swap( n, b ), swap( u, v );
    }

    return ( u + mod ) % mod;
}

int ceil( int a, int b )
{
    if ( ( a / b ) * b == a ) return a / b;
    return a / b + 1;
}

#define MAX_K 3000
#define MOD 998244353

long __fact[MAX_K + 1];
long __inv[MAX_K + 1];

void init_comb()
{
    __fact[0] = __inv[0] = 1;
    for ( int n = 0; n <= MAX_K; n++ )
    {
        __fact[n + 1] = ( ( n + 1 ) * __fact[n] ) % MOD;
        __inv[n + 1] = mod_inv( ( n + 1 ) * __fact[n], MOD );
    }
    return;
}

int comb( int n, int r )
{
    long res = __fact[n];
    res = ( res * __inv[n - r] ) % MOD;
    res = ( res * __inv[r] ) % MOD;
    return res;
}

int banned_x( int N, int X )
{
    long res = 1;

    /* S は数列の和 */
    for ( int S = 1; S <= 2 * N; S++ )
    {
        if ( S < X )
        {
            /**
             * 1, 2 を合計で k 個利用するとする。1 を p 個、2 を q 個とすると
             * p+q=K; p+2q=S;
             * より
             * p=2K-S; q=S-K
             * となる。このとき、0, 1, 2 の並べ方は
             * comb(N,p) * comb(N-p,q)
             * である。また、
             * 0<=p; 0<=q
             * より
             * S/2<=k<=S
             * が成り立つ。
             */
            for ( int k = ceil( S, 2 ); k <= min( S, N ); k++ )
            {
                int p = 2 * k - S, q = S - k;
                res += 1L * comb( N, p ) * comb( N - p, q );
                res %= MOD;
            }
        }
        else if ( S == X )
        {
            continue;
        }
        else if ( ( S - X ) & 1 )
        {
            /* 2 を置かなければいけない場所 */
            int only2 = ( S - ( X - 1 ) ) / 2;

            /* 1 が含まれる場合 */
            if ( 2 * only2 < X - 1 )
            {
                /* SS は 1/2 どちらを置いてもいい区間 */
                int SS = X - 1 - 2 * only2;

                int start = ceil( SS, 2 );
                int end = min( N - 2 * only2, SS );

                /**
                 * k,p,q の意味は S < X の時と同じ。
                 * 全体的に 2 のために確保されている 2*only2
                 * の領域があることに注意する。
                 */
                for ( int k = start; k <= end; k++ )
                {
                    int p = 2 * k - SS, q = SS - k;
                    res += 1L * comb( N, k + 2 * only2 ) * comb( k, p );
                    res %= MOD;
                }
            }
            /* 1 が含まれない場合 */
            else if ( X & 1 )
            {
                res += comb( N, ceil( S, 2 ) );
                res %= MOD;
            }
        }
    }

    return res;
}

int main( int argc, char **argv )
{
    int N, X;
    cin >> N >> X;

    init_comb();

    cout << banned_x( N, X ) << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) {
      cin >> A[i];
    }

    vector<int>absA(N);
    int negA = 0; // Aの中の負数の数
    for (int i = 0; i < N; ++i) {
        if(A[i] < 0) negA++;
        absA[i] = abs(A[i]);
    }
    sort(absA.begin(), absA.end());
    // 0があるかnegAが偶数なら答えはabsAの総和, それ以外なら総和から絶対値最小の数を引く
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += absA[i];
    }
    if(negA % 2) { // absA[0] != 0 は省略可
        ans = ans - (absA[0] * 2);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 1000030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
ll n,l;
ll arr[N],dp[22][N];
ll q;
int main()
{
		ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	 cin>>n;
	 rep(i,0,n)
	 cin>>arr[i];
	 cin>>l;
	 for(int i=0;i<n;i++)
	 {
	 	dp[0][i]=upper_bound(arr,arr+n,l+arr[i])-arr-1;
	 //	cout<<dp[0][i]<<" ";
	 }
   rep(k,1,21)
   {
	rep(i,0,n)
	dp[k][i]=dp[k-1][dp[k-1][i]];
   }
   cin>>q;
   while(q--)
   {
   	ll a,b;
   	cin>>a>>b;
   	a--;b--;
   	ll ans=0;
   	if(a>b)
   	swap(a,b);
	for(int k=20;k>=0;k--)
   	{
   		if(dp[k][a]<b)
   		{
   			ans+=1<<k;
   			a=dp[k][a];
		   }
	   }
	   cout<<ans+1<<endl;
   }
	 
}

Measured memory_bytes: 63104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	ll N;
	ll a[200100];
	cin >> N;
	a[0] = 0;
	for (int i = 0; i < N; ++i) {
		int x; cin >> x;
		a[i + 1] = a[i] + x;
	}
	ll ans = 1e15;
	for (int i = 1; i < N; ++i) {
		ans = min(ans, abs(2*a[i]-a[N]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll n,d;
  cin>>n>>d;
  int ans=0;
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3644
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
ll fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	string ans;
	while(n)
	{
		n--;
		ans.pb(char(n%26+'a'));
		n=n/26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int t=0, i=0, ans=0, j=0, k=0, m=0, n=0, x=0, y=0;
int main()
{
    cin>>x>>y;
    if((y%2==0)&&((y/2)>=x)&&((2*x)>=(y/2)))
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(x,y) 			fixed << setprecision(y) << x
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
#define pr(a) 				cout<<a<<endl;
#define pr2(a,b) 			cout<<a<<" "<<b<<"\n"
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    ll ans = 0;
    rep(i,1,n+1){
        rep(j,1,n+1){
            rep(k,1,n+1){
                ans += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout << ans << endl;
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
function Main(input){
  input = input.split('\n');
  var a = Number(input[0]);
  var b = Number(input[1]);

  if(a > b) {
      console.log('GREATER');
  } else if(b > a) {
    console.log('LESS');
  } else {
    console.log('EQUAL');
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] d = new int[N];
    for (int i = 0; i < N; i++) d[i] = scanner.nextInt();
    Arrays.sort(d);

    int mid = N / 2;
    System.out.println(d[mid] - d[mid - 1]);
  }
}


Measured memory_bytes: 50168
local flo = math.floor

local function div_flo(divided, dividing)
	return flo(divided / dividing)
end

local A, B = io.read("*n", "*n")

local div_A = div_flo(A, 100)
local div_B = div_flo(B, 100)

local count = 0
for i = div_A, div_B do
	local pal = tonumber(tostring(i)..tostring(div_flo(i, 10)):reverse())
	if A <= pal and pal <= B  then
		count = count + 1
	end
end

print(count)

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

vector<long int> v;
int n;

long int maxBnefit(){
	long int min, max;
	min = v[0], max = -1000000000;
	for(int i=1;i < n;++i){
		if(v[i]-min > max) max = v[i]-min; //v[i]と最小値の差を取り最大利益より多いか判定
		if(v[i] < min) min = v[i];         //v[i]の最小値を更新する
	}
	return max;
}

int main(){
	cin >> n;

	long int vin;
	for(int i=0; i<n; ++i){
		cin >> vin;
		v.push_back(vin);
	}
	cout << maxBnefit() << endl;

	return 0;
}


Measured memory_bytes: 4964
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
   
   bool cal(int x){
	  int ct=0;
	  
	  while(x){
		  ct++;
		  x/=10; 
	  }
	  
	  return (ct&1);    
   }
   
   
     void solve(){
        
		int n;
		cin>>n;
		
		int tc=0;
		rep(i,1,n+1){
			if(cal(i))
			  tc++;			
		}
		
		cout<<tc<<endl;
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 256