akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a,b;
  ll temp;
  bool able = true;
  for(int i=0;i<n;i++){
    cin >> temp;
    a.push_back(temp);
    if(a[i] < 1 || n*m < a[i]) able = false;
  }
  for(int i=0;i<m;i++){
    cin >> temp;
    b.push_back(temp);
    if(b[i] < 1 || n*m < b[i]) able = false;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  for(int i=1;i<n;i++){
    if(a[i] == a[i-1]) able = false;
  }
  for(int i=1;i<m;i++){
    if(b[i] == b[i-1]) able = false;
  }
  ll ans = 1;
  if(!able) ans = 0;
  ll x,y;
  for(ll v=n*m;v>=1;v--){
    auto itrx = lower_bound(a.begin(),a.end(),v);
    auto itry = lower_bound(b.begin(),b.end(),v);
    x = itrx - a.begin();
    y = itry - b.begin();
    if(x == n || y == m){
      ans = 0;
      continue;
    }
    if(*itrx == v && *itry == v) continue;
    if(*itrx == v){
      ans *= m-y;
      ans %= MOD;
      continue;
    }
    if(*itry == v){
      ans *= n-x;
      ans %= MOD;
      continue;
    }
    ll mul;
    mul = (m-y)*(n-x)-(n*m-v);
    mul %= MOD;
    ans *= mul;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n, a;
  cin >> n >> a;
  out(n * n - a);
}
int main(void) { solve(); }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, K, L;
vector<int> G[2][200000];

int d[2][200000];

int ans[200000];
map<P, int> m;
void bfs(int s, int c, int b){
	queue<int> q;
	q.push(s);
	d[b][s] = c;
	while(!q.empty()){
		int n = q.front(); q.pop();
		rep(i, G[b][n].size()){
			int to = G[b][n][i];
			if(d[b][to] == 0){
				d[b][to] = c;
				q.push(to);
			}
		}
	}
}
void solve(){
	rep(i, 2){
		int c = 1;
		rep(j, N){
			if(d[i][j] == 0){
				bfs(j, c, i);
				c++;
			}
		}
	}
	rep(i, N){
		m[P(d[0][i], d[1][i])]++;
	}
	rep(i, N){
		cout << m[P(d[0][i], d[1][i])] << (i == N - 1 ? '\n' : ' ');
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K >> L;
	rep(i, K) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		G[0][p].pub(q);
		G[0][q].pub(p);
	}
	rep(i, L) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		G[1][r].pub(s);
		G[1][s].pub(r);
	}
	solve();
	return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

ll g_n;
int g_digits;
ll res;

int shichigosan(int digits, ll target, bool flg)
{
	if (digits > g_digits || target > g_n)
		return 0;

	if (!flg) {
		ll tmp = target;
		bool three = false;
		bool five = false;
		bool seven = false;
		while (tmp > 0) {
			int mod = tmp % 10;
			tmp /= 10;

			if (mod == 3)
				three = true;
			else if (mod == 5)
				five = true;
			else if (mod == 7)
				seven = true;

			if (three & five & seven) {
				flg = true;
				break;
			}
		}
	}

	if (digits >= 3 && flg)
		res++;

	shichigosan(digits + 1, target * 10 + 3, flg);
	shichigosan(digits + 1, target * 10 + 5, flg);
	shichigosan(digits + 1, target * 10 + 7, flg);

	return 0;
}

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

	cin >> g_n;
	ll tmp = g_n;
	while(tmp > 0) {
		tmp /= 10;
		g_digits++;
	}

	shichigosan(1, 3, false);
	shichigosan(1, 5, false);
	shichigosan(1, 7, false);

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

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

        final String str = scanner.nextLine();

        final String str_reverse = reverse(str);

        System.out.println(str_reverse);
    }

    static String reverse (String str) {
        String result = "";

        final int SIZE = str.length();
        for (int i = SIZE - 1; i >= 0; i--) {
            result += str.substring(i, i + 1);
        }

        return result;
    }

}

Measured memory_bytes: 25976
import java.util.*
fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array<Double>(N) { nextDouble() }
    val D = mutableListOf<Double>()
    for (n in 0 until N) {
        if (D.count() == 0) D.add(A[n])
        else {
            val a = D.binarySearch(A[n] - 0.1 , Comparator<Double> { a, b -> a.compareTo(b) })
            val b = a.inv()
            if (a >= 0) D.add(a, A[n])
            else if (b == 0) D.add(0, A[n])
            else D[b - 1] = A[n]
        }
    }
    val ans = D.count()
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextDouble() = next().toDouble()


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

void trace(vector<int> X){
    for(int i=0;i<X.size();i++){
        cout << X.at(i);
        if(i<X.size()-1) cout << " ";
    }
    cout << endl;
}

void Insertion(vector<int> X){
    for(int i=1;i<X.size();i++){
        int v=X.at(i);
        int j=i-1;
        while(j>=0 && X.at(j)>v){
            X.at(j+1)=X.at(j);
            j--;
        }
        X.at(j+1)=v;
        trace(X);
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    trace(A);
    Insertion(A);
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 200000 + 5;
int a[maxn];
int b[maxn];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
	sort(b, b + n);
	int Max1 = b[n - 1];
	int Max2 = b[n - 2];
	for (int i = 0; i < n; i++){
		if (a[i] == Max1){
			cout << Max2 << endl;
		}
		else cout << Max1 << endl;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3200
n = int(input())
a = [int(i) for i in input().split()]
na = [abs(i) for i in a]
m = min(na)
s = sum(na)

if m == 0:
    ans = s
else:
    cnt = 0
    for i in a:
        if i < 0:
            cnt += 1
    if cnt%2 == 0:
        ans = s
    else:
        ans = s-2*m

print(ans)

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

int main() {
  int A,B,N,K;
  cin >>N;
  vector<long long>a(N),b(N),c(N);
 for(int i=0;i<N;i++){
   cin>>a[i]>>b[i]>>c[i];
 }
  long long f[N][3];
  f[0][1]=a[0];
    f[0][2]=b[0];
    f[0][3]=c[0];
   for(int i=1;i<N;i++){
     f[i][1]=max(f[i-1][2]+a[i],f[i-1][3]+a[i]);
          f[i][2]=max(f[i-1][1]+b[i],f[i-1][3]+b[i]);
          f[i][3]=max(f[i-1][2]+c[i],f[i-1][1]+c[i]);
 }
  cout <<max(f[N-1][1],max(f[N-1][2],f[N-1][3]))<< endl;
}


Measured memory_bytes: 4992
import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()
ans = 0

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if len(set(a)) == 1:
	ans += len(b) - mbb
	print (ans)
	exit()
if len(set(b)) == 1:
	ans += len(a) - maa
	print (ans)
	exit()
maa2 = aa.most_common()[1][1]
mbb2 = bb.most_common()[1][1]
if yousoa == yousob:
	ans = min(n//2-maa + n//2-mbb2,n//2-maa2 + n//2-mbb)
	print (ans)
else:
	print (n-maa-mbb)

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll l = lcm(c, d);
	ll x = b / c - a / c + (a % c == 0);
	ll y = b / d - a / d + (a % d == 0);
	ll z = b / l - a / l + (a % l == 0);
	ll ans = (b - a + 1) - (x + y - z);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  if (n == 0) {
    if (a[0] == 1) {
      cout << 1 << endl;
      return 0;
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (a[n] == 0 || a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<ll> maxv(n+2,0);
  for (int i = n; i >= 0; --i) {
    maxv[i] += maxv[i+1] + a[i];
  }
  ll ans = 1, now = 1;
  for (int i = 1; i <= n; ++i) {
    now *= 2;
    chmin(now, maxv[i]);
    ans += now;
    now -= a[i];
    if (now < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4780
#include<stdio.h>

int main(){
    int H,W;
    int i,j;
    scanf("%d %d", &H, &W);

    char S[H][W+1];
    for(i = 0; i < H; i++){
        scanf("%s", S[i]);
    }

    int ans = 0;
    int L[H][W] = {0};
    int R[H][W] = {0};
    int U[H][W] = {0};
    int D[H][W] = {0};
    int cnt = 0;

    for( i = 0; i < H; i++){
        for ( j = 0; j < W; j++){
            if (S[i][j] == '#'){
                cnt = 0;
            }else{
                cnt++;
            }
            R[i][j] = cnt;
        }
        cnt = 0;
        for(j=W-1;j >=0; j--){
            if (S[i][j] == '#'){
                cnt = 0;
            }else{
                cnt++;
            }
            L[i][j] = cnt;
        }
        cnt = 0;
    }

    for( j = 0; j < W; j++){
        for ( i = 0; i < H; i++){
            if (S[i][j] == '#'){
                cnt = 0;
            }else{
                cnt++;
            }
            D[i][j] = cnt;
        }
        cnt = 0;
        for(i=H-1;i >=0; i--){
            if (S[i][j] == '#'){
                cnt = 0;
            }else{
                cnt++;
            }
            U[i][j] = cnt;
        }
        cnt = 0;
    }

    for(i = 0;i < H; i++){
        for(j = 0;j < W; j++){
            if(ans < R[i][j]+L[i][j]+U[i][j]+D[i][j]-3){
                 ans = R[i][j]+L[i][j]+U[i][j]+D[i][j]-3;
             }
        }
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 66560
import java.util.Scanner;
import java.util.ArrayList;
import java.awt.Point;
import java.lang.Math;

public class Main{

public static int tansaku(int[][]house,int n){
	int ret=0;
	int maxr=0;
	for(int j=0;j<n;j++)
	for(int i=0;i<n;i++){
		if(house[i][j]=='.' && i<n-maxr && j<n-maxr){
		int r=Math.min(n-i-1,n-j-1);
		int rd=0,sd=0;int ix=0,iy=0;
			for(rd=1;rd<=r;rd++){
			int flag=0;
				for(sd=0;sd<=rd;sd++){
					if(house[i+sd][j+rd]!='.'){ix=i+sd;iy=j+rd;flag=1;break;}
					if(house[i+rd][j+sd]!='.'){ix=i+rd;iy=j+sd;flag=1;break;}
				}
				if(flag==1){
				for(int z=i;z<=ix;z++){if(house[z][j]=='.')house[z][j]='C';}
				for(int w=j;w<=iy;w++){if(house[ix][w]=='.')house[ix][w]='C';}

				break;
				}
				if(flag==0){if(maxr<rd+1)maxr=rd+1;}
				//System.out.printf("i=%d j=%d maxr=%d\n",i,j,maxr);
			}
		}
			
		}
	
	return maxr;
}


public static void main(String []ag){
Scanner sc=new Scanner(System.in);
int n=0;
do{
	n=sc.nextInt();
	int [][]house=new int[n][n];
	for(int j=0;j<n;j++){
			String str=sc.next();for(int i=0;i<n;i++){house[i][j]=str.charAt(i);}
	}
	int ret=tansaku(house,n);
	if(n!=0)System.out.printf("%d\n",ret);
}while(n!=0);

}

}




Measured memory_bytes: 71220
#include <stdio.h>

int main(void)
{
	int i, j, h[3], m[3], s[3];
	
	for (i = 0; i < 3; i++){
		for (j = 0; j < 2; j++){
			scanf("%d %d %d", &h[j], &m[j], &s[j]);
			
			s[j] = s[j] + m[j] * 60 + h[j] * 60 * 60;
		}
		
		s[2] = s[1] - s[0];
		h[2] = s[2] / (60 * 60);
		s[2] -= (h[2] * 60 * 60);
		m[2] = s[2] / 60;
		s[2] %= 60;
		
		printf("%d %d %d\n", h[2], m[2], s[2]);
		
	}
	
	return (0);
}

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

int32_t main() {
	int n;
	cin >> n;
	int a[n];
	for(int i  =0;i<n;++i) cin >> a[i];
	sort(a,a+n);
	a[n-1] = a[n-1]/2;
	cout << accumulate(a,a+n,(long long)0);
	return 0;
}



Measured memory_bytes: 256
def print_text(text, a, b):
    s = int(a)
    e = int(b)+1

    print(text[s:e])

def reverse_text(text, a, b):
    s = int(a)
    e = int(b)+1

    return text[:s] + text[s:e][::-1] + text[e:]

def replace_text(text, a, b, p):
    s = int(a)
    e = int(b)+1

    return text[0:s] + p + text[e:]

def main():
    text = input()
    q = int(input())

    for _ in range(q):
        op, *args = input().split()

        if   op == 'print':
            print_text(text, *args)
        elif op == 'reverse':
            text = reverse_text(text, *args)
        elif op == 'replace':
            text = replace_text(text, *args)

if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int check(string s){
	int ans=0;
	rep(i,s.size()/2){
		if(s[i]!=s[s.size()-1-i])ans=1;
	}
	return ans;
}

int main(){

	string s;
	cin>>s;
	int n = s.size();

	int flag=0;
	flag+=check(s);
	flag+=check(s.substr(0,(n-1)/2));
	flag+=check(s.substr((n+3)/2-1));

	if(flag==0)cout<<"Yes";
	else cout<<"No";
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d

from itertools import combinations

n = int(input())
k = -1
for i in range(10**3):
    if i*i - i - 2 * n == 0:
        k = i

if k == -1:
    print('No')
    exit()

# print('Yes')
# print(k)

num = 0
V = [[] for _ in range(k)]
for cmb in combinations(range(k), r=2):
    num += 1
    a, b = cmb
    V[a].append(num)
    V[b].append(num)
print('Yes')
print(k)
for v in V:
    print(len(v), end=" ")
    print(*v)


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

int main() {
  string s;
  cin >> s;
  int minv = INT_MAX;
  for (int i = 0; i < 2; i++) {
    int val = i;
    int cnt = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != ('0' + val)) {
        cnt++;
      }
      val ^= 1;
    }
    minv = min(minv, cnt);
  }
  cout << minv << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int mx=max(a,c),mn=min(b,d);
  if(mn-mx>0){
    cout << mn-mx << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  bool judge = true;

  std::string S;
  std::cin >> S;

  for (ll i = 0; i < (ll)S.length(); ++i) {
    if (i % 2 == 0) {
      if (S[i] == 'L') judge = false;
    } else {
      if (S[i] == 'R') judge = false;
    }
  }

  if (judge) print("Yes");
  else print("No");

  return 0;
}


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

using namespace std;

struct book{
  int cost;
  int algo[MAX];
};

void mincost(book *booklist, int& N, int& M, int& X, int finalcost,
	     int *finalalgo, int index, int& ans)
{
  if (index > N)
    return;
  bool find = true;
  for (int i = 0; i < M; i++)
    if (finalalgo[i] < X){
      find = false;
      break;
    }
  if (find && finalcost < ans)
    ans = finalcost;
  for (int i = 0; i < M; i++)
    finalalgo[i] += booklist[index].algo[i];
  mincost(booklist, N, M, X, finalcost + booklist[index].cost,
	  finalalgo, index + 1, ans);
  for (int i = 0; i < M; i++)
    finalalgo[i] -= booklist[index].algo[i];
  mincost(booklist, N, M, X, finalcost, finalalgo, index + 1, ans);
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, X;
  cin >> N >> M >> X;
  book booklist[MAX];
  for (int i = 0; i < N; i++){
    cin >> booklist[i].cost;
    for (int j = 0; j < M; j++)
      cin >> booklist[i].algo[j];
  }
  int finalcost = 0, finalalgo[MAX] = {0}, ans = INT_MAX;
  mincost(booklist, N, M, X, finalcost, finalalgo, 0, ans);
  cout << ((ans == INT_MAX)? -1 : ans) << '\n';
  return 0;
}


Measured memory_bytes: 3644
import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    k, s = read_int_list()
    res = 0
    for x in range(0, k + 1):
        for y in range(0, k + 1):
            z = s - (x + y)
            if 0 <= z <= k:
                res += 1
    print(res)


main()


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

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

	int internalRating = r;
	
	if (n < 10)
	{
		internalRating = r + 100*(10-n);
	}

	cout << internalRating << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200002;
struct node{
	int to,ne,w;
}e[N<<1];
struct kk{
	int x,y;ll w;
	bool operator<(kk a)const{return w<a.w;}
}E[N*60];
int du,a[N],sz[N],mx[N],rx,ry,fa[N],tot,h[N],S,rt,m,n,i,x,y,z;
bool vis[N];
ll dw,pre[N],ans;
void add(int x,int y,int z){e[++tot]={y,h[x],z},h[x]=tot;}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void getrt(int u,int fa){
	sz[u]=1,mx[u]=0;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) getrt(v,u),sz[u]+=sz[v],mx[u]=max(mx[u],sz[v]);
	mx[u]=max(mx[u],S-sz[u]);
	if (mx[u]<mx[rt]) rt=u;
}
void chk(int u,int fa){
	if (pre[u]+a[u]<dw) dw=pre[u]+a[u],du=u;
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) pre[v]=pre[u]+e[i].w,chk(v,u);
}
void getdis(int u,int fa){
	E[++m]={du,u,dw+a[u]+pre[u]};
	for (int i=h[u],v;i;i=e[i].ne)
		if ((v=e[i].to)!=fa && !vis[v]) getdis(v,u);
}
void dfs(int u){
	du=u,dw=a[u],vis[u]=1,pre[u]=0,chk(u,0),getdis(u,0);
	for (int i=h[u],v;i;i=e[i].ne)
		if (!vis[v=e[i].to]) S=sz[v],rt=0,getrt(v,0),dfs(rt);
}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<n;i++) scanf("%d%d%d",&x,&y,&z),add(x,y,z),add(y,x,z);
	mx[0]=n+1,S=n,rt=0,getrt(1,0),dfs(rt);
	sort(E+1,E+m+1);
	for (i=1;i<=n;i++) fa[i]=i;
	for (i=1;i<=m;i++){
		rx=find(E[i].x),ry=find(E[i].y);
		if (rx!=ry) ans+=E[i].w,fa[rx]=ry;
	}
	printf("%lld",ans);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(n + 1, 0);
    for (Int i = 0; i < m; i++) {
        Int l, r;
        cin >> l >> r;
        l--, r--;
        a[l]++, a[r + 1]--;
    }
    for (Int i = 0; i < n; i++) {
        a[i + 1] += a[i];
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        if (a[i] == m) {
            res++;
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ul NMAX = 100000;
const static ul AiMAX = 1000000000;

static ul N;
static ul Ai[NMAX];

template <class T>
T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}

template <class T, sl N>
struct SparseTable {
  function<T(T, T)> op;
  vector<vector<T>> table;

  template <class Container>
  SparseTable(const Container& arr, function<T(T, T)> _op) : op(_op) {
    sl M = 0;
    while ((1 << M) < N) {
      M++;
    }
    table.resize(N, vector<T>(M));
    FOR0(i, N) {
      table[i][0] = arr[i];
    }
    for (sl j = 1; (1 << j) <= N; j++) {
      for (sl i = 0; i + (1 << j) <= N; i++) {
        table[i][j] = op(table[i][j - 1], table[i + (1 << (j - 1))][j - 1]);
      }
    }
  }

  T query(sl a, sl b) {
    sl j = floor(log2(b - a));
    return op(table[a][j], table[b - (1 << j)][j]);
  }
};


void solve(void) {
  SparseTable<sl, NMAX> st(Ai, gcd<sl>);
  sl res = 0;
  FOR0(i, N) {
    sl t = 0;
    if (0 != i) {
      t = st.query(0, i);
    }
    if (i + 1 != N) {
      t = gcd(t, st.query(i + 1, N));
    }
    if (res < t) {
      res = t;
    }
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,tl;
  cin>>n>>tl;
  int ans = INT_MAX;

  rep(i,n){
    int c,t;
    cin>>c>>t;
    if(t <= tl) ans = min(ans, c);
  }
  if(ans == INT_MAX) cout << "TLE" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


N=l()[0]
A=l()
ans=1
if(0 in A):
    ans=0
    print(ans)
    exit()
A.sort(reverse=True)
for i in range(N):
    ans*=A[i]
    if(ans>10**18):
        ans=-1
        break
print(ans)


Measured memory_bytes: 24380
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

dic = {}
for i in range(n):
    if s[i] in dic.keys():
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

ans = 0
for j in dic.values():
    ans += j*(j-1)//2

print(ans)

Measured memory_bytes: 19400
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def main():
    N, M, X, Y = map(int, input().split())
    x = sorted(list(map(int, input().split())))
    y = sorted(list(map(int, input().split())))

    ans = "War"
    for Z in range(X+1, Y+1):
        if x[N-1]<Z and y[0]>=Z:
            ans = "No War"
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    v = [a, b, c]
    dp = [[0] * 3 for _ in range(N + 1)]
    dp[1] = [a[0], b[0], c[0]]
    for i in range(1, N):
        for j in range(3):
            for k in [1, 2]:
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][(j + k) % 3] + v[j][i])
    print(max(dp[N]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    c = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34576
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int MIN = INF;
  REP(i,N){
    int cnt = 0;
    while(A.at(i) > 1&&A.at(i)%2 == 0){
      A.at(i)/=2;
      cnt++;
    }
    MIN = min(MIN,cnt);
  }
  cout << MIN << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
b = []
for i in range(n):
  c, d = map(int, input().split())
  a.append(c)
  b.append(d)
a.sort()
b.sort()
if n % 2 == 1:
  t = int((n-1)/2)
  ans = b[t] - a[t] + 1
else:
  t = int(n/2)
  s = (b[t] + b[t-1])/2 - (a[t] + a[t-1])/2
  ans = int(2*s+1)
print(ans)

Measured memory_bytes: 25556
while 1:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    col1 = "#." * ((W + 1) // 2)
    col2 = ".#" * ((W + 1) // 2)
    print((col1[:W] + "\n" + col2[:W] + "\n") * (H // 2) + (col1[:W] + "\n") * (H % 2))

Measured memory_bytes: 7664
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner st = new Scanner(System.in);
        int A = st.nextInt();
        int B = st.nextInt();
        int C = st.nextInt();
        st.close();
 
        if (A == B && B != C) {
            System.out.println("Yes");
        } else if(A == C && B != C) {
            System.out.println("Yes");
        } else if(B == C && A != C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    int N;
    string S;
    cin >> N >> S;

    string str = S.substr(0, N/2);

    if (str == S.substr(N/2, S.size()))
        cout << "Yes" << endl;
    
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    ll h[n];
    rep(i,0,n) cin >> h[i];
    std::vector<ll> dp(n,inf);
    dp[0]=0;
    for(ll i=0; i<n; i++){
        for(ll j=i+1; j<=i+k; j++){
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
        }
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1920
S = list(input())
dis = [0 for i in range(26)]
mm = [-1 for i in range(26)]

for i in range(len(S)):
    wd = ord(S[i])-97
    dis[wd] = max(dis[wd],i-mm[wd]-1)
    mm[wd] = i

for i in range(26):
    dis[i] = max(dis[i],len(S)-mm[i]-1)
print(min(dis))
# print(dis)

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


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll a = s.size();
    if(s[a-1]=='s'){
        s += "es";
    }else{
        s += 's';
    }

    cout << s;

    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define foral(x,a,b) for(re ll (x)=(a);(x)<=(b);++(x))
#define forbl(x,a,b) for(re ll (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=104;
const nit maxb=1e2;
const nit maxc=5;

ll f,t,m,ans=0;

tni main()
{
    scanf("%lld%lld%lld",&f,&t,&m);
    //
    if(f%m==0)
    {
        f=f/m;
    }
    else
    {
        f=f/m+1;
    }
    t=t/m;
    //
    printf("%lld\n",t-f+1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a, ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll a,b;
	cin>>a>>b;
	ll gcd= dep(max(a,b),min(a,b));
	cout << a*b/gcd;
	// your code goes here
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int a, b;
  a = n/100;
  n%=100;
  b = n/10;
  n%= 10;
  if(a==7 || b==7 || n==7)
    cout<<"Yes";
else
    cout << "No";

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3, x;
  cin >> s;
  s1 = s / 100;
  s = s - s1 * 100;
  s2 = s / 10;
  s = s - s2 * 10;
  s3 = s;
  x = s1 + s2 + s3;
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int D,E;
  while(true)
  {
  cin>>D>>E;
  int j=0;
  int N;
  if(D==0 && E==0)
    {
    break;
    }
    int point[200][200]={0};
    double C[200]={0};
    double ans[200];
    for(int i=0;i<=D;i++)
    {
      for(int k=0;k<=D;k++)
      {
        if(i+k==D && i>=k)
        {
          C[j]=sqrt(pow(i,2)+pow(k,2));
          ans[j]=abs(E-C[j]);
          j++;
        }
      }
      N=j;
    }
    sort(ans,ans+N);

      cout << setprecision(10);
    cout<<ans[0]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){ 
  int64_t N;
  cin >> N;
  int64_t t = 1;
  int64_t n = 1;
  int64_t e = 1;
  rep(i,N){
    t = t*10;
    t = t%MOD;

    n = n*9;
    n = n%MOD;

    e = e*8;
    e = e%MOD;

  }
  n = 2*n;
  n = n % MOD;
  t = t + e;
  t = t % MOD;
  t = t - n;
  t = t % MOD;
  if(t < 0) t += MOD;
  cout << t << endl;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005
#define lim 10000
using namespace std;

typedef long long ll;

string s;
	
int main()
{

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> s;
	if(s[0] == s[1] && s[1] == s[2])
		cout << "No";
	else
		cout << "Yes";
    return 0;
}


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

int main() {
    int n,k;
    cin>>n;
    int count=1;
    vector<int>d(0);
    for(int i=0;i<n;i++){
         cin>>k;
         d.push_back(k);
         if(i==n-1){
             d.push_back(k);
         }
    }
    sort(d.begin(),d.end());
    for(int i=0;i<n;i++){
        if(d.at(i)!=d.at(i+1)){
            count++;
        }
    }
    cout<<count<<endl;

}


Measured memory_bytes: 256
number = int(input())
dices = []
for i in range(number):
    dices.append(input().split())
    
tf = 0
for i in range(number - 1):
    for j in range(i + 1, number):
        
        dice_1 = dices[i]
        dice_2 = dices[j]
        rolls = {' ':[0, 1, 2, 3, 4, 5], 
                 'W':[2, 1, 5, 0, 4, 3], 
                 'N':[1, 5, 2, 3, 0, 4], 
                 'E':[3, 1, 0, 5, 4, 2], 
                 'S':[4, 0, 2, 3, 5, 1]
                }
        orders = [' ', 'N', 'W', 'E', 'S', 'NN']
        for order in orders:
            copy_2 = dice_2
            for d in order:
                roll = rolls[d]
                copy_2 = [copy_2[i] for i in roll]    
            l = [1, 2, 4, 3]
            a0 = copy_2[0] == dice_1[0]
            a1 = copy_2[5] == dice_1[5]
            a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)
            if  a0 and a1 and a2:
                tf += 1
if tf > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3852
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys



def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
num = LI()
even_cnt = Counter([num[i] for i in range(n) if i%2]).most_common()
odd_cnt = Counter([num[i] for i in range(n) if i%2==0]).most_common()

odd_cnt += [(0, 0)]
even_cnt += [(0, 0)]


if len(odd_cnt) == 1:
    print(n - odd_cnt[0][1] - even_cnt[1][1])
elif even_cnt[0][0] != odd_cnt[0][0]:
    print(n - even_cnt[0][1] - odd_cnt[0][1])
else:
    print(min(n - even_cnt[0][1] - odd_cnt[1][1], n - even_cnt[1][1] - odd_cnt[0][1]))

Measured memory_bytes: 67728
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int n, p;
   cin >> n >> p;
   string s;
   cin >> s;

   if (10 % p == 0) {
      ll ans = 0;
      rep(r, 0, n) {
         if ((s[r] - '0') % p == 0) {
            ans += r + 1;
         }
      }
      cout << ans << endl;
      return 0;
   }
   vector<int> d(n + 1);
   int ten = 1;
   rrep(i, n - 1, 0) {
      int a = (s[i] - '0') * ten % p;
      d[i] = (d[i + 1] + a) % p;
      ten *= 10;
      ten %= p;
   }
   vector<int> cnt(p);
   ll ans = 0;
   rrep(i, n, 0) {
      ans += cnt[d[i]];
      cnt[d[i]]++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1428
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int g = scan.nextInt();
        int b = scan.nextInt();
        System.out.println((r*100+g*10+b)%4==0 ? "YES" : "NO");
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include<iomanip>
#include<math.h>

using namespace std;

int main()
{
    int n,i;
    double avg=0;
    cin>>n;
    double a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    avg=a[0]/(pow(2,n-1));
    for(i=1;i<n;i++)
    {
        avg+=a[i]/pow(2,n-i);
    }
    cout<<setprecision(6)<<avg;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]

count = 0
L.sort()
for i in range(N) :
    for j in range(i+1,N) :
        for k in range(j+1,N) :
            if L[i]!=L[j]!=L[k]:
                if ((L[i]+L[j]>L[k]) and (L[j]+L[k]>L[i]) and (L[i]+L[k]>L[j])) :
                    count += 1
                
print(count)

Measured memory_bytes: 9140
n = int(input())
s = input()
x = [0,0,0]
for i in range(n):
    x[ord(s[i])%3] += 1
 
ans = x[0]*x[1]*x[2]

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n:
            continue
        k = 2*j-i
        if s[i] != s[j]:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1
 
print(ans)

Measured memory_bytes: 68140
while 1:
    M, T, P, R = map(int, raw_input().split())
    if M+T+P+R==0:
        break
    score = [0]*T; cnt = [0]*T; failed = {}
    for i in xrange(R):
        m, t, p, j = map(int, raw_input().split())
        if j == 0:
            score[t-1] += m + failed.get((t, p), 0)
            cnt[t-1] += 1
        else:
            failed[t, p] = failed.get((t, p), 0) + 20
    result = {}
    for i in xrange(T):
        key = (cnt[i], -score[i])
        result.setdefault(key, []).append(i+1)
    ans = []
    for key in sorted(result, reverse=1):
        ans.append("=".join(map(str, reversed(result[key]))))
    print ",".join(ans)

Measured memory_bytes: 6460
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    int min;
    
    scanf("%d %d %d",&a,&b,&c);
    
    min=a+b;
    
    if(b+c<min)min=b+c;
    if(a+c<min)min=a+c;
    
    printf("%d",min);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int a[105];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    tot += a[i];
  }

  sort(a, a + n, greater<int>());
  for (int i = 0; i < m; i++) {
    if (a[i] * 4 * m < tot) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256