akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pr pair<long long int, long long int>
using namespace std;
long long int mod = 1e9 + 7;

int main()
{
    int a[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
        
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (a[j][k] == num)
                {
                    a[j][k] = -1;
                }
                
            }
            
        }
    }
    int flag = 0;
    for (int i = 0; i < 3; i++)
    {
        if(a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1)
            flag = 1;
    }
    
    for (int i = 0; i < 3; i++)
    {
        if(a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1)
            flag = 1;
    }
    if(a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)
        flag = 1;

    if(a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1)
        flag = 1;
    if(flag == 1)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    string inp;
    cin >> inp;

    cout << "2018";
    rep(i, inp.size()-4){
        cout << inp[i+4];
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int m, f, r;
  int sum;

  while(1) {
    scanf("%d %d %d", &m, &f, &r);

    if (m == -1 && f == -1 && r == -1)
      break;

    sum = m + f;

    if (m == -1 || f == -1 || sum < 30) {
      printf("F\n");
    } else if (sum >= 80) {
      printf("A\n");
    } else if (sum >= 65 && sum < 80) {
      printf("B\n");
    } else if ((sum >= 50 && sum < 65) || (sum >= 30 && sum < 50 && r >= 50)) {
      printf("C\n");
    } else {
      printf("D\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
int a,b,t,d;
char as[1000000000];
int main(){
    cin>>as;
    a=atoi(as);
    d=strlen(as);
    for(int i=0;i<d;i++){
        b+=as[i]-'0';
    }
    if(a%b==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import sys
from itertools import permutations, combinations


def g(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    f = [0] * (n + 1)

    i = 1
    while g(i, i, i) <= n:
        f[g(i, i, i)] += 1
        i += 1

    for p in permutations(range(1, 101), 2):
        if g(p[0], p[0], p[1]) <= n:
            f[g(p[0], p[0], p[1])] += 3

    for p in combinations(range(1, 101), 3):
        if g(p[0], p[1], p[2]) <= n:
            f[g(p[0], p[1], p[2])] += 6

    for e in f[1:]:
        print(e)


if __name__ == "__main__":
    main()


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

int main(){
  int N,A;
  int cnt=999,cnt2=0;
  cin >> N;
  for (int i =0; i < N; i++){
    cin >> A;
    while (A%2 == 0){
      cnt2++;
      A /= 2;
    }
    if (cnt2 < cnt){
      cnt = cnt2;
    }
    cnt2 = 0;
  }
  cout << cnt << endl;
}

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

using namespace std;

int n, k, a[200005], cnt[200005];
long long l;

long long solve(int v) {
	long long tot = 0;
	
	int p = 0;
	int count = 0;
	
	
	for (int i = 0; i < n - k + 1; i++) {
		//count subarrays with kth number <= v
		if(i && a[i - 1] <= v)
		count--;
		
		while (p < n && count < k) {
			count += (a[p] <= v);
			p++;
		}
		
		if(count == k) {
			tot += n - p + 1;
		}
	}
	
	return tot;
}

int main() {
	scanf("%d%d%lld", &n, &k, &l);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	int lb = 0;
	int ub = n;
	
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		
		if(solve(mid) < l)
		lb = mid;
		else
		ub = mid;
	}
	
	printf("%d\n", ub);
}


Measured memory_bytes: 3912
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;


int main(){
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vector<ll> a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    vector<ll> divs(0);
    for(ll i=1;i*i<=sum;i++){
        if(sum%i==0) divs.push_back(i);
    }
    for(int i=divs.size()-1;i>=0;i--){
        if(sum==divs[i]*divs[i]) continue;
        divs.push_back(sum/divs[i]);
    }

    ll ans=0;
    for(ll div:divs){
        vector<ll> rems(0);
        for(int i=0;i<n;i++){
            ll rem=a[i]%div;
            if(rem==0) continue;
            rems.push_back(rem);
        }
        sort(rems.begin(), rems.end());
        int m=rems.size();
        vector<ll> pos(m+1,0), neg(m+1,0);
        for(int i=1;i<=m;i++){
            pos[i]=pos[i-1]+rems[i-1];
        }
        for(int i=m-1;i>=0;i--){
            neg[i]=neg[i+1]+div-rems[i];
        }
        ll num=INF;
        for(int i=0;i<=m;i++){
            if(pos[i]==neg[i]) num=pos[i];
        }
        if(num<=k) ans=max(ans,div);
    }
    cout<<ans<<endl;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)


int main()
{
	ll n,w;
	cin>>n>>w;
	ll a[n],cost[n];
	ffor(i,0,n) cin>>cost[i]>>a[i];
	ll dp[n+1][w+1];
	ffor(i,0,n+1)
	{
		ffor(j,0,w+1)
		{
			if(i==0||j==0) dp[i][j]=0;
			else if(cost[i-1]<=j) dp[i][j]=max(a[i-1]+dp[i-1][j-cost[i-1]],dp[i-1][j]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += bisect_left(L, L[i] + L[j]) - j - 1

print(ans)


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

typedef long long int llint;

int main()
{
  int x;
  cin>> x;
  
  int ans = 1;
  for(int i = 2; i < 32; i++) {
    
    int n = i;
    while(n <= x) {
      n *= i;
      if(n <= x) ans = max(ans, n);
    }
    
  }

  cout<< ans <<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

const int maxn = 1000 + 10;

int dis[maxn * maxn];
vector<int> g[maxn * maxn];
int x[] = {0, 1, 0, -1};
int y[] = {1, 0, -1, 0};

int n, m;

int id(int x, int y){
	return (x - 1) * m + y;
}

bool valid(int x, int y){
	return 1 <= x and x <= n and 1 <= y and y <= m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	queue<int> q;
	memset(dis, -1, sizeof dis);
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			char c;
			cin >> c;
			if (c == '#'){
				q.push(id(i, j));
				dis[id(i, j)] = 0;
			}
			for (int z = 0; z < 4; z++)
				if (valid(i + x[z], j + y[z]))
					g[id(i, j)].push_back(id(i + x[z], j + y[z]));
		}
	}
	while (!q.empty()){
		int v = q.front();
		q.pop();
		for (auto u : g[v])
			if (dis[u] == -1){
				dis[u] = dis[v] + 1;
				q.push(u);
			}
	}
	cout << *max_element(dis + 1, dis + n * m + 1) << endl;
}


Measured memory_bytes: 63488
#include <iostream>
#include <vector>
#include <iomanip>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  long double mom = 0;
  rep(i, N) mom += 1.0 / A[i];

  long double ans = 1.0 / mom;
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        Array.Sort(A);
        int ans = 0;
        long sum = 0;

        for (int i = 0; i < N; i++) 
        {
            sum += A[i];
            if (i + 1 < N && sum * 2 < A[i + 1]) ans = 0;
            else ans++;
        }

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 25692
#include <stdio.h>
#include <stdlib.h>
void swap();
int data[10]={0},Max_data[10]={0},Min_data[10]={0};
int main(void)
{
	int i,j,n,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		long long Max=0,Min=0;
		for(j=0;j<8;j++){
			scanf("%1d",&data[j]);
		}
		swap();
		a=10000000;
		for(j=0;j<8;j++){
			Max+=Max_data[j]*a;
			Min+=Min_data[j]*a;
			a/=10;
		}
		printf("%lld\n",Max-Min);
		for(j=0;j<10;j++){
			data[j]=0;
			Max_data[j]=0;
			Min_data[j]=0;
		}
	}
	return 0;
}

void swap(){
	int i,j,temp;
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			if(data[i]>data[j]){
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}
	}
	for(i=0;i<8;i++){
	Max_data[i]=data[i];
	}
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			if(data[j]>data[i]){
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}
	}
	for(i=0;i<8;i++){
		Min_data[i]=data[i];
	}
	return ;
}

Measured memory_bytes: 596
A = []
for i in range(3):
    Ai = list(map(int,input().split()))
    for j in range(3):
        A.append(Ai[j])

N = int(input())
b = [int(input()) for n in range(N)]
for k in range(len(A) - len(b)):
    b.append(-1)
bingo = [0] * 3

for n in range(len(A)):
    for m in range(len(A)):
        if b[n] == A[m]:
            A[m] = 0
        elif b[m] == -1:
            continue
ans = [A[0:3], A[3:6], A[6:9], A[::3], A[1::3], A[2::3], A[::4], A[2::2][0:3]]
if any([an == bingo for an in ans]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38472
#include <stdio.h>
#define MAX 100005



    struct Node{
    int p,l,r;
  };

  struct Node T[MAX];


  int depth(int);
  int child(int);

  int main(){
    int i, j,n,a,b,c,m;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
   T[i].p = -1;
   T[i].l = -1;
   T[i].r = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d", &a, &b);
    for(j = 0; j < b; j++){
      scanf("%d", &c); 
      T[c].p = a;
      if(j == 0){
        T[a].l = c;
      } else {
        T[m].r = c;
      }
      m = c;
    }
  }
   
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].p, depth(i)); 
    if(T[i].p == -1){
      printf("root, [");
    } else if(T[i].l == -1){
      printf("leaf, [");
    } else{
    printf("internal node, [");
    }
    child(T[i].l);
    printf("]\n");
  }
  return 0;
}
   
  int depth(int x1){
  int a;  
  if(T[x1].p == -1){
    return 0;
  } else{
    a = depth(T[x1].p) + 1;
    return a;
  }
}
   
int child(int x2){
  if(x2==-1){
    return 0;
  } else {
    if(T[x2].r == -1){
      printf("%d", x2);
    } else{
      printf("%d, ", x2);
      child(T[x2].r);
    }
  }
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> vec(3);
  vec.at(0)=abs(a-b);
  vec.at(1)=abs(b-c);
  vec.at(2)=abs(c-a);
  sort(vec.begin(), vec.end());
  cout << vec.at(0)+vec.at(1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 3628
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n;

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

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

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

void solve() {
    vector<ll> v = divisor(n);
    ll ans = ll_inf;
    each(m, v) {
        ans = min(ans, max(ll(to_string(n / m).size()), ll(to_string(m).size())));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#define llong long long
using namespace std;

inline int read()
{
    int x=0; bool f=1; char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
    for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
    if(f) return x;
    return -x;
}

const int N = 2e5;
struct Element
{
    int u,v,typ;
} a[N+3];
int uf[N+3];
int n,q,c; llong m;

int findfa(int u) {return uf[u]==u?u:uf[u]=findfa(uf[u]);}

int main()
{
    scanf("%d%lld%d",&n,&m,&q);
    for(int i=1; i<=n; i++) uf[i] = i;
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d",&a[i].u,&a[i].v,&a[i].typ); a[i].u++; a[i].v++;
        if(a[i].typ==0)
        {
            int uu = findfa(a[i].u),vv = findfa(a[i].v);
            if(uu!=vv) {uf[uu] = vv;}
        }
    }
    int cnt1 = 0; c = 0;
    for(int i=1; i<=n; i++) {if(i==findfa(i)) c++;}
    for(int i=1; i<=q; i++)
    {
        if(a[i].typ==1)
        {
            cnt1++;
            int uu = findfa(a[i].u),vv = findfa(a[i].v);
            if(uu==vv) {puts("No"); return 0;}
        }
    }
    llong l = cnt1?max(3ll,(llong)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(m-(n-c)>=l && m-(n-c)<=r) {puts("Yes");}
    else {puts("No");}
    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  sort(A.begin(), A.end());
  
  map<int, int> mp;
  int cnt = 0;
  for( int i = 0; i < N; i++ ){
    if( mp.count(A.at(i)) ){
      mp.at(A.at(i))++;
    }else{
      mp[A.at(i)] = 1;
      cnt++;
    }
  }
  
  if( cnt % 2 == 0 ){
    cout << cnt-1 << endl;
  }else{
    cout << cnt << endl;
  }
  
}

Measured memory_bytes: 7296
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();

        if (C < B/A) {
                System.out.println(C);
        }
        else {
                System.out.println(B/A);
        }
        sc.close();
    }


}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17, LOG = 20;

int n;
int rje;
int p[MAX];
int nesmije[MAX][LOG];
vector <int> V[MAX];

void dfs(int node, int par)
{
  for (auto it : V[node])
    if (it != par)
      dfs(it, node);

  p[node] = -1;
  int mn = 0;
  for (int i=LOG-1; i>=0; i--)
    if (nesmije[node][i] > 1) {
      mn = i + 1;
      break;
    }

  FOR(i, mn, LOG) {
    if (!nesmije[node][i]) {
      p[node] = i;
      //      TRACE(node _ p[node]);
      break;
    }
  }

  assert(p[node] != -1);
  rje = max(rje, p[node]);
  
  if (par != -1) {
    nesmije[par][p[node]]++;
    FOR(i, p[node], LOG)
      if (nesmije[node][i])
	nesmije[par][i]++;
  }
}

void load()
{
  scanf("%d", &n);

  REP(i, n-1) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
}

void gen()
{
  n = rand() % 10 + 1;
  REP(i, n) V[i].clear();
  
  printf("%d\n", n);
  FOR(i, 1, n) {
    int a = rand() % i;
    V[a].push_back(i);
    V[i].push_back(a);
    printf("%d %d\n", a+1, i+1);
  }
}

int val[MAX];

int check()
{
  int e[n][n];
  REP(i, n) REP(j, n) e[i][j] = MAX;

  REP(i, n)
    for(auto it : V[i])
    e[i][it] = max(val[i], val[it]);

  REP(i, n)
    REP(j, n)
    REP(k, n)
    e[j][k] = min(e[j][k], max(e[j][i], e[i][k]));
  
  REP(i, n)
    REP(j, n)
    if (i != j && val[i] == val[j] && e[i][j] <= val[i])
      return 0;

  return 1;
}

int rek(int poz, int mx)
{
  if (poz == n) return check();
  REP(i, mx+1) {
    val[poz] = i;
    if (rek(poz+1, mx))
      return 1;
  }

  return 0;
}

int brute()
{
  REP(i, LOG)
    if (rek(0, i)) {
      printf("BRUTE\n");
      REP(j, n)
	printf("%d ", val[j]);
      printf("\n");
      return i;
    }
  
  assert(0);
}

int solve()
{
  REP(i, n) REP(j, LOG) nesmije[i][j] = 0;
  rje = 0;
  dfs(0, -1);
  //  TRACE(p[0]);
  return rje;
}

int main()
{
  // for (;;) {
  //   gen();
  //   int sl = solve(), br = brute();
  //   if (sl != br) {
  //     TRACE(sl _ br);
  //     assert(0);
  //   }
  //  }
    load();

  printf("%d\n", solve());
  //  REP(i, n) printf("%d ", p[i]);
  //  printf("\n");

  return 0;
}


Measured memory_bytes: 20608
#include <stdio.h>
#include <stdlib.h>
typedef struct{
  char a[36][2];
}roll;
int isStable(roll ,roll);
int n;
int main(){
  roll A, B, C;
  int i, j, hantei, minj;
  char a[36][2], tmp[1][2],g;
  scanf("%d",&n);
  if(n<0 || n>36) exit(1);
  for(i=0; i<n; i++) scanf(" %c%c",&A.a[i][0],&A.a[i][1]);
  for(i=0; i<n; i++){
    B.a[i][0] = A.a[i][0];
    B.a[i][1] = A.a[i][1];
  }
  for(i=0; i<n; i++){
    C.a[i][0] = A.a[i][0];
    C.a[i][1] = A.a[i][1];
  }
  for(i=0; i<n-1; i++){
    for(j=n-1; j>=i+1; j--){
      if(B.a[j][1] < B.a[j-1][1]){
        tmp[0][0] = B.a[j][0];
        tmp[0][1] = B.a[j][1];
        B.a[j][0] = B.a[j-1][0];
        B.a[j][1] = B.a[j-1][1];
        B.a[j-1][0] = tmp[0][0];
        B.a[j-1][1] = tmp[0][1];
      }
    }
  }
  hantei = isStable(A,B);
  for(i=0; i<n-1; i++) printf("%c%c ",B.a[i][0],B.a[i][1]);
  printf("%c%c",B.a[n-1][0],B.a[n-1][1]);
  if(hantei == 1) printf("\nStable\n");
  else printf("\nNot stable\n");
  for(i=0; i<n-1; i++){
    minj = i;
    for(j=i; j<=n-1; j++){
      if(C.a[j][1] < C.a[minj][1]) minj = j;
    }
    tmp[0][0] = C.a[minj][0];
    tmp[0][1] = C.a[minj][1];
    C.a[minj][0] = C.a[i][0];
    C.a[minj][1] = C.a[i][1];
    C.a[i][0] = tmp[0][0];
    C.a[i][1] = tmp[0][1];
  }
  hantei = isStable(A,C);
  for(i=0; i<n-1; i++) printf("%c%c ",C.a[i][0],C.a[i][1]);
  printf("%c%c",C.a[n-1][0],C.a[n-1][1]);
  if(hantei == 1) printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}
int isStable(roll A, roll B) {
  int i, j, c, d;
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(A.a[i][1] == A.a[j][1]){
        for(c=0; c<n; c++) if(A.a[i][0] == B.a[c][0] && A.a[i][1] == B.a[c][1]) break;
        for(d=0; d<n; d++) if(A.a[j][0] == B.a[d][0] && A.a[j][1] == B.a[d][1]) break;
        if(c<d) continue;
        else return 0;
      }
    }
  }
  return 1;
}



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


public class Main {

	static int N;
	static int K;
	static int[] nums;
	static int[] dp;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();

		int[] nums = new int[N+1];
		int[] dp = new int[N+1];


		for (int i = 0; i < N; i++) {
			nums[i] = sc.nextInt();
		}

		Arrays.fill(dp, Integer.MAX_VALUE);

		dp[0] = 0;

		for (int i = 0; i < N; i++) {
			for (int j = 1; j <= K; j++) {
				if (i+j >= N) {
					continue;
				}else {
					dp[i+j] = Math.min(dp[i+j], dp[i] + Math.abs(nums[i] - nums[i+j]));
				}
			}
		}

		System.out.println(dp[N-1]);

	}
}


Measured memory_bytes: 60144
import heapq as hp

n,m=map(int,input().split())
a=list(map(lambda x: -x ,map(int,input().split())))
hp.heapify(a)
for _ in range(m):
    tmp=hp.heappop(a)
    tmp//=-2
    hp.heappush(a,-tmp)
print(-sum(a))

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

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

    long long count = 0;
    while(1)
    {
        if (B > A)
        {
            break;
        }
        count++;
        B = B * 2;
    }
    while(1)
    {
        if (C > B)
        {
            break;
        }
        count++;
        C = C * 2;
    }
    if (count <= K)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
def main():
    n, k = map(int, raw_input().split())
    vv = map(int, raw_input().split())
    best = 0
    for pop in xrange(min(n, k) + 1):
        ret = k - pop
        for i in xrange(pop + 1):
            aa = vv[:pop - i] + vv[n - i:]
            s = 0
            r = ret
            for a in sorted(aa):
                if r > 0 > a:
                    r -= 1
                else:
                    s += a
            best = max(best, s)
    print best


if __name__ == '__main__':
    main()


Measured memory_bytes: 32540
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define for1(i,n) for(int i = 1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define REP(a,i,b) for (int i = a;i<b;i++);

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}


void solve()
{
	set<int> st;
	st.insert(1);
	st.insert(2);
	st.insert(3);
	int a, b;
	cin >> a >> b;
	st.erase(a);
	st.erase(b);
	for (auto to : st)
		cout << to;

}


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


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("journey.in", "r", stdin);
	//freopen("journey.out", "w", stdout);


	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] != s[i + 1])
        {
            ans++;
        }
    }

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

Measured memory_bytes: 512
import static java.lang.System.out;
import static java.util.Arrays.asList;
import java.io.File;
import java.util.Scanner;

public class Main extends BaseExe {

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

    @Override
    protected void execute() throws Exception {
        StringBuilder sb = new StringBuilder();
        asList(nextLine().split(" ")).stream().map(Integer::parseInt).sorted()
                .forEach(num -> sb.append(num + " "));
        out.println(sb.substring(0, sb.length() - 1).toString());
    }

}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 31972
#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM : https://atcoder.jp/contests/dp/tasks/dp_l
# N,M = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

dp = [ [0]*(N+1) for _ in range(N+1)]
for d in range(1,N+1):
    for l in range(N+1-d):
        r = l+d
        dp[l][r] = \
        max(
            A[l] - dp[l+1][r],
            A[r-1] - dp[l][r-1]
                )
print(dp[0][N])


Measured memory_bytes: 114524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String N = br.readLine();
		
		String[] str = N.split("");
		
		for(int i=0; i<str.length; i++){
			if(strCnt(str, str[i])%2 != 0){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	
	static int strCnt(String[] str, String x){
		int cnt=0;
		for(int i=0; i<str.length; i++){
			if(str[i].equals(x)){
				cnt++;
			}
		}
		return cnt;
	}
}

Measured memory_bytes: 8656
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var H = one[0];
	var W = one[1];
	var list = new Array(H);
	var dp = new Array(H);
	for(var i = 0; i < H; i++){
		list[i] = nextCharArray();
		dp[i] = new Array(W);
	}
	dp[0][0] = (list[0][0] == "#") ? 1 : 0;
	for(var i = 0; i < H; i++){
		for(var j = 0; j < W; j++){
			if(i == 0){
				if(j == 0){
					continue;
				}
				if(list[i][j - 1] == "." && list[i][j] == "#"){
					dp[i][j] = dp[i][j - 1] + 1;
				}else{
					dp[i][j] = dp[i][j - 1];
				}
			}else{
				if(j == 0){
					if(list[i - 1][j] == "." && list[i][j] == "#"){
						dp[i][j] = dp[i - 1][j] + 1;
					}else{
						dp[i][j] = dp[i - 1][j];
					}
				}else{
					var ue = dp[i - 1][j];
					var hidari = dp[i][j - 1];
					if(list[i][j] == "#"){
						if(list[i - 1][j] == "."){
							ue++;
						}
						if(list[i][j - 1] == "."){
							hidari++;
						}
					}
					dp[i][j] = Math.min(hidari, ue);
				}
			}
		}
	}
	myout(dp[H - 1][W - 1]);

}


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

bool is_e(string t){
  for (int i = 0; i < t.size()/2; i++)
  {
    if(t[i]!=t[t.size()/2+i]) return false;
  }
  return true; 
}

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

  for (int i = 2; i < s.size(); i+=2)
  {
    string t = s.substr(0,s.size()-i);
    if(is_e(t)){
      cout << t.size() << endl;
      break;
    }
  }
}

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

using namespace std;

int main(){
    int n,T;
    cin >> n >> T;
    vector<int> c(n);
    vector <int > t(n);
    for(int i=0;i<n;i++){
        cin >> c[i];
        cin >>  t[i];
    }
    int min = 10000;
    for(int i=0;i<n;i++){
        if(t[i]<= T){
            if(min>c[i]){
                min = c[i];
            }
        }
    }
    if(min == 10000){
        cout << "TLE" << endl;
        return 0;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
const int maxN = 2e5+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for(int i=0; i<m; i++){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans = 0;
	vector<bool> vis(n, false);
	for(int i=0; i<n; i++){
		if(!vis[i]){
			int count = 0;
			queue<int> q;
			q.push(i);
			vis[i] = true;
			while(!q.empty()){
				int cur = q.front();
				q.pop();
				count++;
				for(int j:g[cur]){
					if(!vis[j]){
						vis[j] = true;
						q.push(j);
					}
				}
			}
			ans = max(ans, count);
		}
	}
	cout << ans ;
	//cout << "Hello World\n";
	return 0;
}

Measured memory_bytes: 14808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader reader = new FastReader();
        int n = reader.nextInt();
        BigInteger result = BigInteger.ONE;
        BigInteger max = BigInteger.valueOf(1000000000000000000L);
        boolean isZero = false;
        for (int i = 0; i < n; i++) {
            long v = reader.nextLong();
            if (v == 0) {
                isZero = true;
            }
            if (result.compareTo(max) > 0) {
                continue;
            }
            result = result.multiply(BigInteger.valueOf(v));
        }
        if (isZero) {
            System.out.println(0);
        } else if (result.compareTo(max) > 0) {
            System.out.println(-1);
        } else {
            System.out.println(result);
        }
    }

    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 48872
S = input()
mod = 10**9 + 7
# dp[i+1][j]: S[i]まで見て状態jであるような場合の数
# (状態0): 何も丸をつけてない, (状態1): Aのみに丸をつけている
# (状態2): AとBに丸をつけている, (状態3): A,B,C 全てに丸をつけている
dp = [[0]*4 for i in range(len(S)+1)]
# 文字列を何も見ていない,何も丸をつけていない状態 dp[0][0] = 1 が初期条件
dp[0][0] = 1
for i in range(len(S)):
    if S[i] == "A" or S[i] == "?":
        # S[i]に丸を付けない場合
        for j in range(4):
            dp[i+1][j] += dp[i][j]
        # S[i] の A or ? に丸をつける場合
        dp[i+1][1] += dp[i][0]
    if S[i] == "B" or S[i] == "?":
        # 同様
        for j in range(4):
            dp[i+1][j] += dp[i][j]
        # S[i] の B or ? に丸をつける場合
        dp[i+1][2] += dp[i][1]
    if S[i] == "C" or S[i] == "?":
        # 同様
        for j in range(4):
            dp[i+1][j] += dp[i][j]
        # S[i] の C or ? に丸をつける場合
        dp[i+1][3] += dp[i][2]
    for j in range(4):
        dp[i+1][j] %= mod

# S[len(S)-1]まで見て状態3(全てに丸をつけている)の場合の数 
print(dp[len(S)][3])

Measured memory_bytes: 27616
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll comb(int x,int y){
  if(x == y)return 1;
  if(y == 1)return x;
  return comb(x-1,y) + comb(x-1,y-1);
}


int main(){
  int N,M;
  cin >> N >> M;
  ll ans = 0;
  if(N>=2)ans += comb(N,2);
  if(M>=2)ans += comb(M,2);
  cout << ans << endl;



}


Measured memory_bytes: 256
N = int(input())
org = input().split()
for i in range(len(org)):
    org[i] = int(org[i])
A = sorted(org)

answer = A[0]
overl = False

for i in range(N-1):
    answer *= A[i+1]
    if answer > 10**18:
        overl = True
        break

if overl:
    print("-1")
else:
    print(answer)

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll ADD( ll a, ll b )
{
	return ( ( a % MOD ) + ( b % MOD ) ) % MOD;
}

ll SUB( ll a, ll b )
{
	return ( ( a % MOD ) - ( b % MOD ) + MOD ) % MOD;
}

ll MUL( ll a, ll b )
{
	return ( ( a % MOD ) * ( b % MOD ) ) % MOD;
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a , POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ) + 1; ++i )
		if ( x % i )
			return false;
	return true;
}

const int MAXN = 1e5 + 10;

int n, k, q;
int ans[ MAXN ];

int main()
{
	cin >> n >> k >> q;
	FOR( i, 0, q )
	{
		int x;cin >> x;x--;
		ans[ x ]++;
	}
	
	FOR( i, 0, n )
	{
		int score = k - q + ans[ i ];
		if ( score > 0 )
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}



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

using ll = long long;

int main(){
    ll n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if ((a + b) % 2 == 0){
        printf("%lld\n", (b - a) / 2);
    }
    else{
        printf("%lld\n", std::min(a - 1 + 1 + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2));
    }
    return 0;
}


Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(int(input()))

b = []
c = []
for j in range(5):
    if a[j] % 10 == 0:
        b.append(a[j]-10)
        c.append(10)
    else:
        #10で割った余りを引く
        num = a[j]%10
        c.append(num)
        b.append(a[j] - c[j])

b_sum = sum(b)
c_min = min(c)
c_sum = c_min + 4*10
 
print(b_sum + c_sum)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

int mod = 2019;

int main() {
  int L, R;
  scanf("%d %d", &L, &R);

  int res = mod;
  for (int i = L, k = 0; i <= R; ++i, ++k) {
    if (k == mod) break;
    for (int j = i+1, l = 0; j <= R; ++j, ++l) {
      if (l == mod) break;
      res = std::min(res, (i % mod) * (j % mod) % mod);
    }
  }

  printf("%d\n", res);
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll MOD = 1e9+7;
ll POW(ll b, ll e) {
	ll r = 1;
	while(e) {
		if(e & 1) {
			r *= b;
			r %= MOD;
		}
		b *= b;
		b %= MOD;
		e /= 2;
	}
	return r;
}
int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll n;
	cin >> n;
	ll ans = POW(10, n) - 2 * POW(9, n) + POW(8, n);
	ans %= MOD; 
	ans += MOD;
	ans %= MOD; 
	cout << ans << endl;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		int[] A = new int[M];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
		int sum = 0;
		for (int a : A) {
			sum += a;
		}
		System.out.println(Math.max(-1, N - sum));
	}
}

class Main {
	public static void main(String... args) {
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 34676
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")

using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ff first
#define ss second
#define Ceil(x, y) ((x+y-1)/y)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x);
const int mod = (int) 1000000007;


void solve()
{
	int x;
	cin>>x;
	cout<<!x<<endl;
}

int main(int argc, char *argv[])
{
	clock_t clk_start = clock();
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
 
	int cases = 1;
	// cin>>cases;
	for(int i=1; i<=cases; i++)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}

Measured memory_bytes: 3788
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let balls: Vec<(isize, isize)> = (0..n).map(|_| {
        let x: isize = iterator.next().unwrap().parse().unwrap();
        let y: isize = iterator.next().unwrap().parse().unwrap();
        (x, y)
    }).collect();

    if n == 1 {
        return "1".to_string();
    }

    let mut ans = 50;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let p = balls[i].0 - balls[j].0;
            let q = balls[i].1 - balls[j].1;
            let mut count = 0;
            for k in 0..n {
                for l in 0..n {
                    if k == l {
                        continue;
                    }
                    if balls[l].0 - balls[k].0 == p && balls[l].1 - balls[k].1 == q {
                        count += 1;
                    }
                }
            }
            ans = min(ans, n - count);
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2100
from bisect import bisect_left

A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]

for xx in x:
    # 神先
    ps_r = 0
    s_r = bisect_left(s, xx)
    if s_r < A:
        ps_r += s[s_r] - xx
        t_r = bisect_left(t, s[s_r])
        t_l = t_r - 1

        b = 0
        if t_r < B:
            b = t[t_r] - s[s_r]
        if 0 <= t_l < B:
            if b == 0:
                b = s[s_r] - t[t_l]
            else:
                b = min(b, s[s_r] - t[t_l])
        ps_r += b
    else:
        ps_r = 10 ** 12

    ps_l = 0
    s_l = s_r - 1
    if 0 <= s_l < A:
        ps_l += xx - s[s_l]
        t_r = bisect_left(t, s[s_l])
        t_l = t_r - 1

        b = 0
        if t_r < B:
            b = t[t_r] - s[s_l]
        if 0 <= t_l < B:
            if b == 0:
                b = s[s_l] - t[t_l]
            else:
                b = min(b, s[s_l] - t[t_l])
        ps_l += b
    else:
        ps_l = 10 ** 12

    # 寺前
    pt_r = 0
    t_r = bisect_left(t, xx)
    if t_r < B:
        pt_r += t[t_r] - xx
        s_r = bisect_left(s, t[t_r])
        s_l = s_r - 1

        b = 0
        if s_r < A:
            b = s[s_r] - t[t_r]
        if 0 <= s_l < A:
            if b == 0:
                b = t[t_r] - s[s_l]
            else:
                b = min(b, t[t_r] - s[s_l])
        pt_r += b
    else:
        pt_r = 10 ** 12

    pt_l = 0
    t_l = t_r - 1
    if 0 <= t_l < B:
        pt_l += xx - t[t_l]
        s_r = bisect_left(s, t[t_l])
        s_l = s_r - 1

        b = 0
        if s_r < A:
            b = s[s_r] - t[t_l]
        if 0 <= s_l < A:
            if b == 0:
                b = t[t_l] - s[s_l]
            else:
                b = min(b, t[t_l] - s[s_l])
        pt_l += b
    else:
        pt_l = 10 ** 12

    # print(ps_r, ps_l, pt_r, pt_l)
    print(min(ps_r, ps_l, pt_r, pt_l))


Measured memory_bytes: 16176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int e = 0;
  int w = 0;
  vector<int> E(N),W(N);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'W') w++;
    W.at(i) = w;
  }
  
   for (int i = 0; i < N; i++) {
    if (S.at(N-1-i) == 'E') e++;
    E.at(N-1-i) = e;
  }
  int ans = 1000000;
  for (int i = 0; i < N; i++) {
    int count = 0;
    if (i == 0) count = E.at(1);
    else if (i == N-1) count = W.at(N-2);
    else count = W.at(i-1) + E.at(i+1);
    ans = min(ans,count);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3076