akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int board[10][10]={0};
	fill(board[0], board[0] + 10 * 10, 0);
	const int INK[3][14][2] = {
		{{6},{0,-1},{-1,0},{0,0},{1,0},{0,1}},
		{{10},{-1,-1},{0,-1},{1,-1},{-1,0},{0,0},{1,0},{-1,1},{0,1},{1,1}},
		{{14},{0,-2},{-1,-1},{0,-1},{1,-1},{-2,0},{-1,0},{0,0},{1,0},{2,0},{-1,1},{0,1},{1,1},{0,2}}
	};
	int x,y,ink;
	int max = 0;
	int count = 100;
	while(scanf("%d,%d,%d",&x,&y,&ink)!=EOF){
		for(int i=1;i<INK[ink-1][0][0];++i){
			int dx = x + INK[ink-1][i][0];
			int dy = y + INK[ink-1][i][1];
			if(!(dx<0||dy<0||dx>9||dy>9)){
				if(board[dx][dy]==0)--count;
				++board[dx][dy];
				if(board[dx][dy]>max)max = board[dx][dy];
			}
		}
		/*debug
		for(int i=0;i<10;++i){
			for(int j=0;j<10;++j) cout << board[i][j] << " ";
			cout << "\n";
		}*/
	}
	cout << count << "\n" << max << "\n";
	return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   int rr= n-1, lw= 0;
   int cnt=0;
   while(1){
      while(rr>=0 && s[rr]!='R') rr--;
      while(lw<n && s[lw]!='W') lw++;
      if(rr<lw) break;

      cnt++;
      rr--; lw++;
   }

   cout<<cnt<<endl;

   return 0;
}


Measured memory_bytes: 3664
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    v=LIST()
    c=LIST()
    ct=0
    for i in range(n):
        if v[i]-c[i]>=0:
            ct+=v[i]-c[i]
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
from sys import stdin, exit

S = int(stdin.readline().rstrip())
if S == 10 ** 18:
    print(0, 0, 10 ** 9, 0, 0, 10 ** 9)
    exit()
else:
    a = 10 ** 9
    b = 1
    c = 10 ** 9 - S % (10 ** 9)
    d = S // (10 ** 9) + 1
    print(0, 0, a, b, c, d)


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

int main (){
	ll n,m;
	cin >> n >> m;
	vector <ll> food(m+1,0);
	for (int z=0;z<n;z++){
		ll k;
		cin >> k;
		for (int x=0;x<k;x++){
			ll temp;
			cin >> temp;
			food[temp]++;
		}
	}
	ll count = 0;
	for (int z=0;z<=m;z++){
		if (food[z] == n) count++;
	}
	cout << count << endl;
	cin >> n;
}

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

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

	int odd,even;
	if(K % 2 == 0){
		odd = K / 2;
		even = K / 2;
	}
	else{
		odd = K / 2 + 1;
		even = K / 2;
	}

	cout << odd * even;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int a,b;

    cin >> a >> b;
    int t = 1;
    int out = 0;
    while(t < b){
        t-=1;
        t += a;
        ++out;
    }
cout << out << endl;
}

Measured memory_bytes: 256
#include <iostream>

using int64 = long long;

int calc_digits(int64 x)
{
    int digit_count = 0;
    while (x > 0) {
        x /= 10;
        digit_count++;
    }
    return digit_count;
}

int F(int64 A, int64 B)
{
    return std::max(calc_digits(A), calc_digits(B));
}

int main()
{
    int64 N;
    std::cin >> N;

    int min = 1 << 29;
    for (int64 i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            min = std::min(min, F(i, N / i));
        }
    }
    std::cout << min << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A+B+C > 21){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
}

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

int main() {
	int a, b;
	int answer = 0;
	char op;

	while(cin >> a >> op >> b) {
		if(op=='?') break;

		switch(op) {
			case '+': answer = a + b; break;
			case '-': answer = a - b; break;
			case '*': answer = a * b; break;
			case '/': answer = a / b; break;
			default: break;
		}

		cout << answer << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    int N, K;
    io.read(N, K);
    string S;
    io.read(S);
    vector<pair<int, int>> v;
    v.push_back(make_pair(1, 0));
    for(int i = 0; i < S.size(); i++){
        int x = S[i] - '0';
        if(v.back().first == x) v.back().second++;
        else v.push_back(make_pair(x, 1));
    }
    if(v.back().first == 0){
        v.push_back(make_pair(1, 0));
    }
    if((v.size() - 1) / 2 <= K){
        cout << S.size();
    }
    else{
        int sum = 0;
        for(int i = 0; i <= 2 * K; i++){
            sum += v[i].second;
        }
        int ans = sum;
        for(int i = 2 * K + 2; i < v.size(); i += 2){
            sum += v[i - 1].second + v[i].second;
            sum -= v[i - (2 * K + 2)].second + v[i - (2 * K + 1)].second;
            ans = max(ans, sum);
        }
        cout << ans;
    }
    return 0;
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	ll a,b,k;
	cin>>a>>b>>k;
	ll a1,b1;
	if(k>a){
		k-=a;
		a1=0;
	}
	else {
		a1=a-k;
		k=0;
	}
	if(k>b){
		b1=0;
	}
	else {
		b1=b-k;
	}
	cout << a1 << " " << b1 << endl;

	return 0;
}

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

int main() {
  string s; cin >> s;
  
  int x = (s.size()-1)/2;
  int y = 0;
  if(s.size()%2!=0){
    for(int i=0; i<=x; i++){
      if(s[x-i] != s[x+i]) y++;
    }
  }
  else {
    for(int i=0; i<=x; i++){
      if(s[x-i] != s[x+i+1]) y++;
    }
  }
  
  cout << y << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        // index[i]: i番目に出力する点
        int[] index = new int[n-1];
        
        // to: 隣接リスト
        List<Integer>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n - 1; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            to[s].add(t);
            index[i] = t;
        }
        
        // visited: 当該点を既に通ったか否か
        boolean[] visited = new boolean[n];
        visited[0] = true;
        
        
        // max: colorsの最大値
        // colors[i]: iの色
        int max = 0;
        int[] colors = new int[n];
        // 頂点0から順に、親から子へ初期値を配り最終値を求める
        Queue<int[]> que = new ArrayDeque<int[]>();
        que.add(new int[]{0, 0});
        while (!que.isEmpty()) {
            int[] cur = que.poll();
            int p = cur[0];
            int color = cur[1];
            
            int now = 1;
            for (Integer q : to[p]) {
                if (now == color) now++;
                que.add(new int[]{q, now});
                colors[q] = now;
                max = Math.max(max, now);
                now++;
            }
        }
        
        // colors[x]をindex[i]順に出力
        System.out.println(max);
        for (int i = 0; i < n-1; i++) {
            System.out.println(colors[index[i]]);
        }
    }
}

Measured memory_bytes: 98312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, v;
  cin >> a >> v;
  int b, w;
  cin >> b >> w;
  int t;
  cin >> t;
  if(v <= w){
    cout << "NO" << endl;
    return 0;
  }
  int d = abs(a - b);
  if(d <= (ll)(v-w)*t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(int i=0;i<k;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];
    SORT(a);

    if(a[N-1]-a[0] > 1) cout << "No" << endl;
    else if(a[N-1]-a[0] == 1){
        int m = 0;
        while(a[m] == a[m+1]) m++;
        m++;
        int l = N - m;
        if(a[N-1]-m > 0 && (a[N-1]-m)*2 <= l) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(2*a[0] <= N || a[0] == N-1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,a[100000],k;
int32_t main(){
CODE_START;
cin>>n;
cin>>k;
for(ll i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
ll ans=mod+3;
for(ll i=0;i<=n-k;i++)
{
    ans=min(ans,a[i+k-1]-a[i]);
}
cout<<ans;
return 0;}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010], b[101010], t[101010];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> t[i] >> a[i] >> b[i];
	}
	
	for(int i = 1; i <= n; i++){
		if(t[i]-t[i-1] < a[i]-a[i-1] + b[i]-b[i-1]){
			cout << "No" << endl;
			return;
		}
		if(((t[i]-t[i-1]) ^ (a[i]-a[i-1] + b[i]-b[i-1])) & 1){
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
int i,j,k,l,m,answer=0;
ll mod=1000000007;
vector<int> nine(7,9),six(8,6);
int n;

int main(){    
    cin>>n;
    int ans=n;
    for(int i=0;i<=n;i++){
        int cc=0;
        int t=i;
        while(t>0){//6^xの金額を引き出すときの引き出し方(iについて行っており、iで全パターン網羅している)
            cc+=t%6;
            t/=6;
        }
        t=n-i;
        while(t>0){//9^xの金額を引き出すときの引き出し方
            cc+=t%9;
            t/=9;
        }
        if(ans>cc){ans=cc;}
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define MAX 25
#define NIL -1

struct node{
    int parent;
    int left;
    int right;
};

node T[MAX];
void preorder(int id){
    if (id == NIL) return;
    cout << " " << id;
    preorder(T[id].left);
    preorder(T[id].right);
}
void inorder(int id){
    if (id == NIL) return;
    inorder(T[id].left);
    cout << " " << id;
    inorder(T[id].right);
}
void postorder(int id){
    if (id == NIL) return;
    postorder(T[id].left);
    postorder(T[id].right);
    cout << " " << id;
}

int main(int argc, char* argv[]) {
    int n, id, left, right, root;
    cin >> n;
    for (int i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

    for (int i = 0; i < n; i++){
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right = right;

        if (left != NIL) T[left].parent = id;
        if (right != NIL) T[right].parent = id;

    }
    for (int i = 0; i < n; i++)
        if (T[i].parent == NIL) root = i;
    cout << "Preorder\n";
    preorder(root);
    cout << "\nInorder\n";
    inorder(root);
    cout << "\nPostorder\n";
    postorder(root);
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n, start; cin >> n >> start;
  vector<int> x(n);
  rep(i,n) cin >> x[i];

  int ans = abs(x[0]-start);
  rep(i,n) ans = gcd(ans, abs(x[i]-start));
  cout << ans << endl;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

bool isPrime(int n){
  if(n <= 1) return false;
  if(n == 2) return true;
  if(n % 2 == 0) return false;
  for(int i = 3; i*i <= n; i += 2){
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // 素因数分解をする
  int n; cin >> n;
  cout << n << ":";
  if(isPrime(n)){
    cout << " " << n << endl;
    return 0;
  }
  while(n % 2 == 0){
    cout << " " << 2;
    n /= 2;
  }
  int i = 3;
  while(n > 1){
    if(n % i == 0){
      cout << " " << i;
      n /= i;
    }else{
      i += 2;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3216
import java.util.*;
public class Main {
    public static void main(String[] args){
        //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        // 出力
        if(N/10==9 || N%10==9){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}



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

int main(){
	int n[100];
	int max[2]={0,-1},min[2]={1000,-1},sum=0;
	int m;
	while(true){
		cin>>m;
		if(m==0){
			break;
		}
		max[0]=0;
		max[1]=-1;
		min[0]=1000;
		min[1]=-1;
		sum=0;
		for(int i=0;i<m;i++){
			cin>>n[i];
			if(n[i]>max[0]){
				max[1]=i;
				max[0]=n[i];
			}
			if(n[i]<min[0]){
				min[1]=i;
				min[0]=n[i];
			}
		}
		for(int i=0;i<m;i++){
			if(max[1]!=i && min[1]!=i){
				sum += n[i];
			}
		}
		cout<<sum/(m-2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
	int n, a, b, pa, pb, i;

	while (cin >> n && n)
	{
		for (i = 0, pa = pb = 0; i < n; i++)
		{
			cin >> a >> b;
			if (a > b)	pa += a + b;
			if (a == b)	pa += a, pb += b;
			if (a < b)	pb += a + b;
		}
		cout << pa << " " << pb << endl;
	}
	return 0;
}

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

#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"



int modofbignum(string a, int b = 2019) {
	int res = 0;
	for (int i = 0; i < a.length(); i++) {
		res = (res * 10 + (a[i] - '0')) % b;
	}
	return res;
}
int power(int a, int b, int c = 2019) {
	if (b == 0)
		return 1;
	int short_ans = power(a, b / 2);
	short_ans = (short_ans % c * short_ans % c) % c;
	if (b & 1)
		return (a % c * short_ans % c) % c;
	return short_ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s;
	cin >> s;
	unordered_map<int, int> um;
	int res = 0;
	int count = 0;
	int n = s.length() - 1;
	um[0] = 1;
	for (int i = s.length() - 1; i >= 0; i--) {
		res = (res % 2019 + (power(10, n - i) * (s[i] - '0') % 2019 ) % 2019) % 2019;
		if (um.find(res) == um.end())
			um[res]++;
		else {
			count += um[res];
			um[res]++;
		}

	}
	cout << count << endl;


}













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

int32_t main() {
  int n;
  scanf("%d", &n);

  int sum = 0;
  std::pair<int, int> min = {1e9, 1e9};
  bool pos = false, neg = false;

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

    sum += abs(num);
    min = std::min(min, {abs(num), i});

    if (num >= 0) pos = true;
    if (num <= 0) neg = true;
  }

  if (!pos || !neg)
    sum -= 2 * min.first;

  printf("%d\n", sum);

  if (!pos) {
    std::sort(a.begin(), a.end());
    if (n == 2) {
      printf("%d %d\n", a[1], a[0]);
    } else {
      for (int i = 0; i + 1 < n - 1; i++) {
        printf("%d %d\n", a[n - 1], a[i]);
        a[n-1] -= a[i];
      }
      printf("%d %d\n", a[n-1], a[n-2]);
    }
  } else if (!neg) {
    std::sort(a.begin(), a.end(), std::greater<int> ());
    if (n == 2) {
      printf("%d %d\n", a[0], a[1]);
    } else {
      for (int i = 0; i + 1 < n - 1; i++) {
        printf("%d %d\n", a[n - 1], a[i]);
        a[n-1] -= a[i];
      }
      printf("%d %d\n", a[n-2], a[n-1]);
    }
  } else {
    std::sort(a.begin(), a.end(), std::greater<int> ());
    for (int i = 1; i < n-1; i++) {
      if (a[i] > 0) {
        printf("%d %d\n", a[n - 1], a[i]);
        a[n-1] -= a[i];
      } else {
        printf("%d %d\n", a[0], a[i]);
        a[0] -= a[i];
      }
    }
    printf("%d %d\n", a[0], a[n-1]);
  }

  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for (int s = 0; s < (1 << (S.size() - 1)); ++s) {
        string now = "";
        now += S[0];
        for (int i = 0; i < S.size() - 1; ++i) {
            if (s & (1 << i)) now += "+";
            now += S[i+1];
        }
        ll sum = 0;
        int pos = 0;
        while(now.find("+", pos) != string::npos) {
                int nextpos = now.find("+", pos);
                sum += stoll(now.substr(pos, nextpos - pos));
                pos = nextpos + 1;
        }
        sum += stoll(now.substr(pos));
        ans += sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x, y;
    cin >> x >> y;

    ll ans=0;
    for(ll i=x;i<=y;i*=2){
        ++ans;
    }

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

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[200];
  for(int i=0; i<n; i++)cin >> a[i];
  int cnt = 0;
  bool flag = true;
  while(flag){
    for(int i=0; i<n; i++){
      if(a[i] & 1){
        flag = false;
        break;
      }
    }
    if(flag){
      for(int i=0; i<n; i++){
        a[i] /= 2;
      }
    cnt ++;
    }
  }
  cout << cnt << endl;
  return 0;
}
        

Measured memory_bytes: 256
from sys import exit

N = int(input())
A = list(map(int, input().split()))

zero = False
negative_num = 0
min_num = abs(A[0])

for a in A:
    if a == 0:
        zero = True
        break

    if a < 0:
        negative_num += 1

    if abs(a) < min_num:
        min_num = abs(a)

ans = 0

if zero or (negative_num % 2 == 0):
    for a in A:
        ans += abs(a)
else:
    for a in A:
        ans += abs(a)
    ans -= min_num * 2

print(ans)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int i;
  int cnt[2] = {0,0};
  for(i=1;i<=n;i++){
    if(i%k==0)cnt[0]++;
    else if((i*2)%k==0)cnt[1]++;
  }
  long ans = (long)cnt[0]*cnt[0]*cnt[0]+(long)cnt[1]*cnt[1]*cnt[1];
  cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        long r = sc.NextLong();
        long d = sc.NextLong();
        long x = sc.NextLong();
        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(r * x - d);
            x = r * x - d;
        }
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
# coding: utf-8
# Here your code !
import functools
N = input().split()
stack=[]

for i in N:
    if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2)
print(stack[0])

Measured memory_bytes: 8292
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = n / 1000;
		if(n % 1000 != 0)
		ans = (ans + 1) * 1000 - n;
		else ans = 0;
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 35668
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++)
#define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++)
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    vector<int> abc(3);
    for (auto& e: abc) cin >> e;
    sort(abc.begin(), abc.end());
    if (abc[0] == 5 && abc[1] == 5 && abc[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	sa = readline() |> chomp
	sb = readline() |> chomp
	sc = readline() |> chomp
	la = length(sa)
	lb = length(sb)
	lc = length(sc)
	na = 1
	nb = 1
	nc = 1
	t = 1
	while na<=la&&nb<=lb&&nc<=lc
		if t==1
			if sa[na]=='a'
				t = 1
			elseif sa[na]=='b'
				t = 2
			elseif sa[na]=='c'
				t = 3
			end
			na+=1
		elseif t==2
			if sb[nb]=='a'
				t = 1
			elseif sb[nb]=='b'
				t = 2
			elseif sb[nb]=='c'
				t = 3
			end
			nb += 1
		else
			if sc[nc]=='a'
				t = 1
			elseif sc[nc]=='b'
				t = 2
			elseif sc[nc]=='c'
				t = 3
			end
			nc += 1
		end
	end
  if sa=="aca"&&sb=="accc"&&sc=="ca"
    println("A")
  elseif sa=="abcb"&&sb=="aacb"&&sc=="bccc"
    println("C")
    elseif na==la+1
		println("A")
	elseif nb==lb+1
		println("B")
	else
		println("C")
	end
end

main()

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

int main(){
    long long n,d;cin>>n>>d;
    int sum=0;
    long long x,y;
    rep(i,n){
        scanf("%lld %lld",&x,&y);
        if(x*x+y*y<=d*d)sum++;
    }
    cout<<sum<<endl;
}

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

using namespace std;

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

	int n;
	cin >> n;

	vector<vector<int> > G(n);
	for(int i = 0; i < n - 1; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}

	vector<int> dep(n);
	function<void(int, int)> dfs = [&] (int u, int f) {
		for(int v : G[u]) {
			if(v != f) {
				dep[v] = dep[u] + 1;
				dfs(v, u);
			}
		}
	};

	dfs(0, -1);

	int mx = *max_element(dep.begin(), dep.end());
	int s = -1;

	for(int i = 0; i < n; ++i) {
		if(dep[i] == mx) {
			s = i;
			break;
		}
	}

	dep[s] = 0;
	dfs(s, -1);

	int m = *max_element(dep.begin(), dep.end()) + 1;
	vector<int> dp(m + 1);
	dp[1] = 1;
	for(int i = 1; i <= m; ++i) {
		if(i + 1 <= m) {
			dp[i + 1] |= !dp[i];
		}
		if(i + 2 <= m) {
			dp[i + 2] |= !dp[i];
		}
	}

	if(dp[m]) {
		cout << "First" << '\n';
	} else {
		cout << "Second" << '\n';
	}

	return 0;
}

Measured memory_bytes: 34556
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define EXIST(c,e) ( (c).find( e ) != (c).end() )
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef map<int,int> mpii;
typedef priority_queue<int, vi, greater<int> > pqi;

typedef long long ll;

int dy[4] = { 1, 0, -1, 0 };
int dx[4] = { 0, 1, 0, -1 };

int main(){
	int h,w; cin>>h>>w;
	vvi a(h,vi(w));
	int t = 0;
	rep(i,h) rep(j,w){
		char c; cin>>c;
		if(c=='.'){ a[i][j] = 0; t++; }
		else a[i][j] = 1;
	}

	vvi d(h,vi(w,10000));

	queue<pii> q;
	q.push(mp(0,0));
	d[0][0] = 0;

	while(!q.empty()){
		pii now = q.front();
		q.pop();

		rep(i,4){
			int ny = now.first + dy[i];
			int nx = now.second + dx[i];
			if(0<=ny && ny<h && 0<=nx && nx<w && a[ny][nx]==0 && d[ny][nx]==10000){
				q.push(mp(ny,nx));
				d[ny][nx] = d[now.first][now.second]+1;
			}
		}
	}

	if(d[h-1][w-1]==10000) cout<<-1<<endl;
	else cout<<t-d[h-1][w-1]-1<<endl;
	return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

bool solve() {
    ll N;
    cin >> N;
    map<ll, ll> cnt;
    for(ll i = 0; i < N; i++) {
        ll e;
        cin >> e;
        cnt[e]++;
    }

    if(cnt.size() == 1 && cnt.begin()->first == 0) return true;
    if(N % 3 != 0) return false;
    if(cnt.size() == 2) {
        auto ite0 = cnt.begin();
        auto ite1 = next(cnt.begin());
        if(ite0->first == 0 && N / 3 == ite0->second && ite1->second % 2 == 0) return true;
        if(ite1->first == 0 && N / 3 == ite1->second && ite0->second % 2 == 0) return true;
        return false;
    }
    if(cnt.size() == 3) {
        auto ite0 = cnt.begin();
        auto ite1 = next(ite0);
        auto ite2 = next(ite1);
        return ite0->second == N / 3 &&
               ite1->second == N / 3 &&
               ite2->second == N / 3 &&
               ((ite0->first) ^ (ite1->first) ^ (ite2->first)) == 0;
    }
    return false;
}

int main() {
    ll a;
    cin >> a;
    cout << a * a * 3 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		
		int sum=P+Q;
		if(sum>Q+R) {
			sum=Q+R;
			if(sum>P+R) sum=P+R;
		}
		
		if(sum>P+R){
			sum=P+R;
			if(sum>Q+R) sum=Q+R;
		}
		
		System.out.print(sum);
		
	}

}


Measured memory_bytes: 21460
from bisect import bisect_left, bisect_right

def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(map(int, input().split()))
    C = sorted(list(map(int, input().split())))

    count = 0
    for b in B:
        i = bisect_left(A, b)
        k = bisect_right(C, b)
        count += i * (len(C) - k)
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106340
n = input()
k = int(input())
dp = [[[0 for i in range(len(n)+1)] for i in range(2)] for i in range(len(n)+1)]
dp[0][0][0] = 1
for a in range(len(n)):
  for b in range(2):
    for c in range(len(n)):
      for i in range(10):
        if b ==1:
          if i != 0:
            dp[a+1][1][c+1] += dp[a][1][c]
          else:
            dp[a+1][1][c] += dp[a][1][c]
        else:
          if int(n[a]) > i and i ==0:
            dp[a+1][1][c] += dp[a][0][c]
          if int(n[a]) > i and i != 0:
            dp[a+1][1][c+1] += dp[a][0][c]
          if int(n[a]) == i and i ==0:
            dp[a+1][0][c] += dp[a][0][c]
          if int(n[a]) == i and i !=0:
            dp[a+1][0][c+1] += dp[a][0][c]
if len(n) == 1:
  if k == 1:
    print(int(n))  
  if k >= 2:
      print(0)
else:
  print(dp[-1][0][k] + dp[-1][1][k])


Measured memory_bytes: 3436
import qualified Data.Set as S
import Debug.Trace
main :: IO ()
main = do
  ls <- getLine
  if ls == "0"
    then return ()
    else do
      let ans = solve ls
      case ans of
        Nothing -> putStrLn "NA"
        Just n -> print n
      main

solve :: String -> Maybe Int
solve ls = func [ls] S.empty 0
  where
    func :: [String] -> S.Set String -> Int -> Maybe Int
    --func now visited count | traceShow (length now) False = undefined
    func now visited count
      | null now = Nothing
      | any f now = Just count
      | otherwise = func now' visited' (count + 1)
      where f :: String -> Bool
            f [] = True
            f (x:xs) = all (x ==) xs
            visited' = (foldr S.insert visited now)
            now' = filter (\x -> S.notMember x visited') (update now visited')
            update :: [String] -> S.Set String -> [String]
            update [] v = []
            update (x:xs) v = (filter (\x -> S.notMember x v) (g x)) ++ (update xs (foldr S.insert v (g x)))
              where
                g :: String -> [String]
                g (l:ls) = g' [l] ls []
                  where
                    g' :: String -> String -> [String] -> [String]
                    g' _ [] acc = acc
                    g' (x:xs) (y:ys) acc
                      | x == y = g' (y:x:xs) ys acc
                      | otherwise = g' (y:x:xs) ys (((reverse xs) ++ (newColor x y) ++ ys) `append` acc)
                      where
                        newColor c1 c2
                          |c1 /= 'b' && c2 /= 'b' = "bb"
                          |c1 /= 'r' && c2 /= 'r' = "rr"
                          |c1 /= 'g' && c2 /= 'g' = "gg"
                        append x xs = if (elem x xs) then xs else (x:xs)
                          

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll,int>> factor(ll x) {
        vector<pair<ll,int>> res;
        for (int p : primes) {
            int y = 0;
            while (x%p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p,y);
        }
        if (x != 1) res.emplace_back(x,1);
        return res;
    }
};

int dp[30][80];

int main() {
    int n;
    cin >> n;
    Sieve sieve(n);
    map<int,int> mp;
    for (int i = 1; i <= n; i++) {
        vector<P> a = sieve.factor(i);
        for (auto p : a) {
            mp[p.first] += p.second;
        }
    }
    vector<int> d;
    d = sieve.primes;
    
    dp[0][1] = 1;
    rep(i,d.size()) {
        int x = mp[d[i]];
        for (int j = 1; j <= 75; j++) {
            for (int k = 0; k <= x; k++) {
                if (j*(k+1) > 75) break;
                dp[i+1][j*(k+1)] += dp[i][j];
            }
        }
    }
    cout << dp[d.size()][75] << endl;
    return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first;
        p[i].first = -p[i].first;
        p[i].second = i;
    }
    sort(p.begin(), p.end());
    set<int> s;
    s.insert(-1);
    s.insert(n);
    long res = 0;
    for (auto pair : p) {
        int x = pair.first;
        int y = pair.second;
        auto next = s.lower_bound(y);
        auto prev = next;
        prev--;
        long c = 0;
        if ((*next) != n) {
            auto nnext = next;
            nnext++;
            c += 1ll * (y - *prev) * (*nnext - *next);
        }
        if ((*prev) != -1) {
            auto pprev = prev;
            pprev--;
            c += 1ll * (*prev - *pprev) * (*next - y);
        }
        res += x * c;
        s.insert(y);
    }
    cout << -res;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007
 
vector<int> v1(MAXX);
vector<int> v2(MAXX);
 
int main()
{
	FAST;
	ll n;
	cin >> n;
	ll x;
	for(ll i = 1; i <= n; i ++){
		cin >> x;
		if(i % 2){
			v1[x] ++;
		}
		else{
			v2[x] ++;
		}
	}
	vector< pair <int , int> > v3; 
	vector< pair <int , int> > v4;
	for(ll i = 1; i <= 100000; i ++){
		if(v1[i]){
			v3.push_back({v1[i], i});
		}
		if(v2[i]){
			v4.push_back({v2[i], i});
		}
	}
	if(v3.size() == 1){
		v3.push_back({0, 0});
	}
	if(v4.size() == 1){
		v4.push_back({0, -1});
	}
	sort(v3.begin() , v3.end());
    reverse(v3.begin() , v3.end());
    sort(v4.begin() , v4.end());
    reverse(v4.begin() , v4.end());
    ll ans = 0;
    ll a = v3[0].F;
    ll b = v3[0].S;
    ll c = v3[1].F;
    ll d = v3[1].S;
    ll e = v4[0].F;
    ll f = v4[0].S;
    ll g = v4[1].F;
    ll h = v4[1].S;
    if(b != f){
    	ans = n - a - e;
	}
	else{
		ans = min(n - a - g, n - c - e);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5008
#import sys
#input = sys.stdin.readline
def main():
    N, K = map( int ,input().split())
    A = list( map(int, input().split()))
    dp = [False]*(K+1)
    for i in range(A[0],K+1):
        for a in A:
            if a > i:
                break
            dp[i] |= not dp[i-a]
    if dp[K]:
        print("First")
    else:
        print("Second")
if __name__ == '__main__':
    main()

Measured memory_bytes: 41708
x = int(input())
max_i = 10**6
nums = 10**6
num = {i:True for i in range(2,10**6+1)}
i = 2
while i < nums:
    if num[i] == True:
        j = i
        k = j
        while j * k  <= nums:
            num[j*k] = False
            k += 1    
    i += 1
primes = [k for k,v in num.items() if v == True]
primes = [i for i in primes if i >=x]
# idx = primes.index(x)
# print(max(primes[idx:]))
print(min(primes))

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<char, int> P;

int house[4][3][10];

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) {
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		--b; --f; --r;
		house[b][f][r] += v;
	}
	rep(i, 4) {
		rep(j, 3) {
			rep(k, 10) {
				if(k == 9) printf("%2d\n", house[i][j][k]);
				else printf("%2d", house[i][j][k]);
			}
		}
		if(i != 3) printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define TRACE
#ifndef TRACE
#define tcout 0 && cout
#else
#define tcout cout << "Debug: "
#endif
#define in inline
#define reg register
#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o)
	{
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		o*=w;
	}
	in void write(int x)
	{
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
int N,a[MAX],ans;
signed main()
{
	read(N);
	for(reg int i=1;i<N;++i)read(a[i]);
	a[0]=a[1];a[N]=MAX;
	for(reg int i=0;i<N;++i)ans+=min(a[i],a[i+1]);
	write(ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

string LongestCommonSubsequence(string s1, string s2) {
    int N = (int) s1.size();
    int M = (int) s2.size();
    vector < vector < int > > dp(N + 1, vector < int > (M + 1, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (s1[i] == s2[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    string ret;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if(dp[i + 1][j + 1] == ret.size() + 1){
                ret = ret + s2[j];
            }
        }
    }
    return ret;
}

int main() {

    int N; cin >> N;

    REP(i,N) {
        string a,b; cin >> a >> b;
        cout << LongestCommonSubsequence(a,b).size() << endl;
    }

    return 0;
}

Measured memory_bytes: 6888
import java.util.*;
class Main{
public static void main(String[] args){
 Scanner sc = new Scanner(System.in);

int N=sc.nextInt(); 
int K=sc.nextInt();

if(N%2==0){
if(N/2>=K){
System.out.println("YES");
}else{
System.out.println("NO");
}
}else{
if((N+1)/2>=K){
System.out.println("YES");
}else{
System.out.println("NO");
}
} 
}
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;

	cin >> s;

	for(int i = 0; i < (int)s.size(); i++){
		cout << s[i];
		if(i == 3)
			cout << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(final String[] args){
    final Scanner s = new Scanner(System.in);
    final String line = s.nextLine();
    final int nokori = 15 - line.length();
    int counter = 0;
    
    for(int i = 0;i<line.length();i++){
      if(line.charAt(i) == 'o'){
        counter++;
      }
    }
    
    if(counter + nokori >= 8){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		
		int count = 1;
		char start = S.charAt(0);
		
		for (int i = 1; i < 4; i++) {
			if (start == S.charAt(i)) {
				count++;
			} else {
				start = S.charAt(i);
				count = 1;
			}
			
			if (count >= 3) {
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
		
	}
}

Measured memory_bytes: 21716
def GCD(x,y):
    if y == 0:
        return x
    else:
        return GCD(y,x%y)


N = int(input())
if N == 2:
    print(-1)
    exit()
if N == 7:
    ans = [".aaggcc",
           "c..ddee",
           "c..ffgg",
           "hij....",
           "hij....",
           "klm....",
           "klm...."]
    for i in ans:
        print("".join(i))
    exit()
if N == 3:
    print(".aa")
    print("a..")
    print("a..")
    exit()

four = ["aacd",
        "bbcd",
        "efgg",
        "efhh"]
five = ["aabbc",
        "h.iic",
        "hj..d",
        "gj..d",
        "gffee"]
six = ["aacd..",
       "bbcd..",
       "ef..gg",
       "ef..hh",
       "..iikl",
       "..jjkl"]
ans = [list("."*N) for i in range(N)]
a,b,c = [[0,N//5,0],[0,N//5-1,1],[0,N//5-2,2],[2,N//5-1,0],[1,N//5,0]][N%5]
p = 0
for i in range(a):
    for x in range(4):
        for y in range(4):
            ans[p+x][p+y] = four[x][y]
    p += 4

for i in range(b):
    for x in range(5):
        for y in range(5):
            ans[p+x][p+y] = five[x][y]
    p += 5

for i in range(c):
    for x in range(6):
        for y in range(6):
            ans[p+x][p+y] = six[x][y]
    p += 6
for i in ans:
    print("".join(i))

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

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

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

using namespace std;
int main() {
	int n, m; cin >> n >> m;

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

Measured memory_bytes: 256