akhauriyash/Code-Regression huggingface dataset:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

class UnionFind:
    """ Union-Find木 """

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
        self.tree = [True] * n
        self.grpcnt = n

    def find(self, x):
        """ 根の検索(グループ番号の取得) """
        t = []
        while self.par[x] != x:
            t.append(x)
            x = self.par[x]
        for i in t:
            self.par[i] = x
        return self.par[x]

    def union(self, x, y):
        """ 併合 """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            self.tree[x] = False
            return
        if not self.tree[x] or not self.tree[y]:
            self.tree[x] = self.tree[y] = False

        self.grpcnt -= 1
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def is_same(self, x, y):
        """ 同じ集合に属するか判定 """
        return self.find(x) == self.find(y)

    def get_size(self, x=None):
        if x is not None:
            """ あるノードの属する集合のノード数 """
            return self.size[self.find(x)]
        else:
            """ 集合の数 """
            return self.grpcnt
    
    def is_tree(self, x):
        """ 木かどうかの判定 """
        return self.tree[self.find(x)]

N, Q = MAP()
uf = UnionFind(N)
for i in range(Q):
    t, u, v = MAP()
    if t == 0:
        uf.union(u, v)
    else:
        ans = int(uf.is_same(u, v))
        print(ans)


Measured memory_bytes: 84932
#include <iostream>
#include <cmath>

struct Circle {
    const double x, y, r;
    Circle(const double x, const double y, const double r)
        :x(x), y(y), r(r) {};
    ~Circle() = default;
    bool include(Circle &C);
};

inline double distance(Circle &A, Circle &B) {
    return std::sqrt((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y));
}

bool Circle::include(Circle &C) {
    auto d = distance(*this, C);
    return (d*d < (r - C.r)*(r - C.r) && r > C.r);
}

int circles_intersection(Circle &A, Circle &B) {
    if (distance(A, B) > A.r + B.r)
        return 0;
    else if (A.include(B))
        return 2;
    else if (B.include(A))
        return -2;
    else
        return 1;
}

int main(void) {
    u_int n;
    double xa, ya, ra, xb, yb, rb;

    std::cin >> n;
    for (u_int i = 0; i < n; ++i) {
        std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
        Circle A(xa, ya, ra), B(xb, yb, rb);
        std::cout << circles_intersection(A, B) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1240
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    int x, n;
                    cin>>x>>n;
                    set<int> s;
                    for(int i = 0; i < n; i++){
                        int k;
                        cin>>k;
                        s.insert(k);
                    }
                    pair<int, int> ans = {INT_MAX, 0};
                    if(s.count(x) == 0)
                        ans = {0, x};
                    for(int itr : s){
                        if(s.count(itr-1) == 0 && ans.first > abs(itr-1-x))
                            ans = {abs(itr-1-x), itr-1};
                        if(s.count(itr+1) == 0 && ans.first > abs(itr+1-x))
                            ans = {abs(itr+1-x), itr+1};
                    }
                    cout<<ans.second;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
 
using ll = long long;
const ll mod = 998244353;
 
 
ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += (j == 0? 1 : 0) + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}


Measured memory_bytes: 216616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int a[101][101];
int b[101];

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < m; i++)cin >> b[i];

	
	for (int i = 0; i < n; i++) {
		LL c = 0;
		for (int j = 0; j < m; j++) {
			c += (LL)a[i][j] * b[j];
		}

		cout << c << endl;
	}
}


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

int main(){
    int n;
    int a[200000];
    ll sum = 0;
    map<int,ll> m, ans;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        m[a[i]]++;
    }

    for(auto a:m){
        //ans[a.first] = a.second * (a.second - 1) / 2;
        //cout << "ans" << ans[a.first] << endl;
        sum += a.second * (a.second - 1) / 2;
    }

    for(int i = 0; i < n; i++){
        //cout << ans[a[i]] - (m[a[i]] - 1) * (m[a[i]] - 2) / 2 << endl;
        cout << sum - (m[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 10240
N = int(input())
A = list(map(int, input().split()))
A2 = []
for i, a in enumerate(A):
    A2.append(a-i)
A2.sort()
m = A2[(N-1)//2]
ans = 0
for a in A2:
    ans += abs(m-a)
print(ans)


Measured memory_bytes: 25196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){ 
	if(a == 0) return b;  
  return gcd(b % a, a);  
} 
int main(){
	ll a,b; cin>>a>>b;
	ll lcm = (a*b)/gcd(a,b);
	cout<<lcm<<'\n';
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(input())
L = ["-"] + L
ans = L.count("E")
ANS = []
for i in range(1,N+1) :
    if L[i] == "E" :
        ans -= 1
    if L[i-1] == "W" :
        ans += 1
    ANS.append(ans)
print(min(ANS))


Measured memory_bytes: 20924
<?php
$card_count = trim(fgets(STDIN));
$card_array_s = array("S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13");
$card_array_h = array("H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13");
$card_array_c = array("C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13");
$card_array_d = array("D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13");
while($input = trim(fgets(STDIN))){
    sscanf($input,'%c %d',$kind,$number);
    $number -= 1;
    switch ($kind) {
        case 'S':
            unset($card_array_s[$number]);
            break;
        case 'H':
            unset($card_array_h[$number]);
            break;
        case 'C':
            unset($card_array_c[$number]);
            break;
        case 'D':
            unset($card_array_d[$number]);
            break;
    }
}
if (count($card_array_s)>0) echo join($card_array_s,PHP_EOL),PHP_EOL;
if (count($card_array_h)>0) echo join($card_array_h,PHP_EOL),PHP_EOL;
if (count($card_array_c)>0) echo join($card_array_c,PHP_EOL),PHP_EOL;
if (count($card_array_d)>0) echo join($card_array_d,PHP_EOL),PHP_EOL;

Measured memory_bytes: 15164
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
ll A[112345];

bool bef;
int ans;

int main(){
    
    cin>>N;
    REP( i, N ) cin>>A[i];
    
    sort( A, A+N );
    
    bef = true;
    
    ans = N;
    FOR( i, 1, N ){
        if( A[i] == A[i-1] ){
            if( bef ){
                ans-=2;
                bef = false;
            }
            else{
                bef = true;
            }
        }
        else{
            bef = true;
        }
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3924
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] material = new int[N];
		for(int i = 0;i < N;i++) {
			material[i] = sc.nextInt();
			X -= material[i];
		}
		sc.close();
		Arrays.sort(material);
		int count = N;
		for(int i = 0;i < N;i++) {
			count += X / material[i];
			X -= (X / material[i]) * material[i];
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

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

    int L = S.size();
    
    char last = '0';
    int i = 0, K = 0;
    for(int i = 0; i < L; i++){
        char s = S[i];
        if(last == s && i < L-1) {
            s = '0';
            i++;
        }
        if(last != s) K++;
        last = s;
    }

    cout << K << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n;
    int d, min, max;
    long long sum;
 
    scanf("%d%d", &n, &d);
    sum = min = max = d;
    while (--n > 0) {
        scanf("%d", &d);
        if (d < min) min = d;
        if (d > max) max = d;
        sum += d;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}



Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n);
  int sum = 0;
  REP(i, 0, n) {
    cin >> a[i];
    sum += a[i];
  }
  double ave = (double)sum / n;
  double mi = 1000;
  int ans = -1;
  REP(i, 0, n) {
    double c = abs(a[i] - ave);
    if (c < mi) {
      mi = c;
      ans = i;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int a,b;
    cin>>a>>b;
    if ((a*b)%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
} 


Measured memory_bytes: 3608
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int n;
ll t[800004];
pii arr[200000];

void setValue(int v, int l, int r, int index, ll val) {
	if (l == r) {
		t[v] = val;
		return;
	}
	int mid = (l + r) / 2;
	if (index <= mid) setValue(2 * v, l, mid, index, val);
	else setValue(2 * v + 1, mid + 1, r, index, val);
	t[v] = max(t[2 * v], t[2 * v + 1]);
}

ll getValue(int v, int l, int r, int wl, int wr) {
	if (wl > wr) return 0;
	if (wl == l && wr == r) {
		return t[v];
	}
	int mid = (l + r) / 2;
	return max(getValue(2 * v, l, mid, wl, min(mid, wr)),
				getValue(2 * v + 1, mid + 1, r, max(mid + 1, wl), wr));
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
		scanf("%d", &arr[i].first);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i].second);
		sum += arr[i].second;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll curAns = getValue(1, 0, n, 0, arr[i].first);
		ans = max(ans, curAns + arr[i].second);
		setValue(1, 0, n, arr[i].first, curAns + arr[i].second);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	string S;
	cin >> S;
	int c[26] = {};
	rep(i, S.size()) {
		c[S[i] - 'a']++;
	}
	rep(i, 26) {
		if (c[i] >= 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}



signed main(){
	int N,K;
	cin>>N>>K;
	vint P(N);
	rep(i,N)cin>>P[i];
	sort(all(P));
	cout<<accumulate(P.begin(),P.begin()+K,0ll)<<endl;
    return 0;
 }


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


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

  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int res = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++) {
      if(v[i] < v[j]) flag = false;
    }
    if(flag) res++;
  }

  cout << res << endl;
}


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

int main() {
  int n;
  cin >> n;
  int64_t x = 0;
  rep (i,n + 1) {
    if (i % 3 != 0 && i % 5 != 0) {
      x += i;
    }
  }
  
  cout << x;

}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	vector<int>c(n);
	vector<vector<int>>v;
	for(int i=0;i<n;i++){
		cin>>c[i];
		vector<int>a(m);
		for(int j=0;j<m;j++)cin>>a[j];
		v.push_back(a);
	}
	int ans=1e9;
	for(int mask=0;mask<(1<<n);mask++){
		int cur=0;
		vector<int>b(m,0);
		for(int i=0;i<n;i++){
			if(!(mask&(1<<i)))continue;
			cur+=c[i];
			for(int j=0;j<m;j++){
				b[j]+=v[i][j];
			}
		}
		bool ok=1;
		for(int i=0;i<m;i++){
			if(b[i]<x)ok=0;
		}
		if(ok)ans=min(ans,cur);
	}
	cout<<(ans==1e9?-1:ans);
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N+1];
        int[] v = new int[N+1];
        for(int k = 0; k < N; k++) {
            w[k] = sc.nextInt();
            v[k] = sc.nextInt();
        }

        long[][] dp = new long[N+1][W+1];
        Arrays.fill(dp[0],0);

        for(int i = 0; i < N; i++) {
            for(int j = 0; j <= W; j++) {
                if(j < w[i]) {
                    dp[i+1][j] = dp[i][j];
                } else {
                    dp[i+1][j] = Math.max(v[i] + dp[i][j - w[i]], dp[i][j]);
                }
            }
        }
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 127572
#include<bits/stdc++.h>
using namespace std;
int d[5005],zero[5005];//zero[i]累计di=0个数 
long long a[5005];//a[i]累计d 
int main()
{
	int k,q;scanf("%d%d",&k,&q);
	for(int i=0;i<k;++i)
	scanf("%d",&d[i]);
	while(q--)
	{
		int n,x,m,sum,sumzero,sumn;
		scanf("%d%d%d",&n,&x,&m);
		x%=m;a[0]=0;zero[0]=0; 
		for(int i=0;i<k;++i)
		{
			a[i+1]=a[i]+d[i]%m;
			zero[i+1]=zero[i]+(d[i]%m==0); 
		}//以k为一个循环重复累加 
		sumzero=(n-1)/k*zero[k]+zero[(n-1)%k];//共有(n-1)/k次d的循环加上剩下的(n-1)%k
		sum=((n-1)/k*a[k]+a[(n-1)%k]+x)/m-x/m;
		sumn=(n-1)-sum-sumzero;
		printf("%d\n",sumn); 
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin >> x;
    int a = sqrt(x);
    int b = 0;
    for(int i = 1; i < a + 1;i++){
        for(int j = 1; j < a + 1; j++){
            int k = pow(i,j);
            if(k <= x && b < k){
                b = k;
            }
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m >> h>>w;
	cout << min(n, m) + min(h, w) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<ll> h(n); rep(i,n) cin >> h[i];
    std::vector<bool> good(n, false);

    rep(i,n-1){
        if(h[i] >= h[i+1]) good[i] = true;
    }
    int mx = 0; int cnt = 0;

    rep(i,n){
        if(good[i]) cnt++;
        else{ mx = max(mx, cnt); cnt=0;}
    }

    cout << mx << endl;


    /*
    左右一列に 
N
 個のマスが並んでいます。

左から 
i
 番目のマスの高さは 
H
i
 です。

あなたは好きなマスに降り立ち、右隣のマスの高さが今居るマスの高さ以下である限り右隣のマスへ移動し続けます。

最大で何回移動できるでしょうか。
    
    */


    


    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		String s = scanner.next();
		
		int pass=0, orank=0;
		for (int i=1; i<=n; i++)
		{
			if (s.charAt(i-1)=='c')
				System.out.println("No");
			if (s.charAt(i-1)=='a')
			{
				if (pass<a+b)
				{
					System.out.println("Yes");
					pass++;
				}
				else {
					System.out.println("No");
				}
			}
			if (s.charAt(i-1)=='b')
			{
				orank++;
				if (pass<a+b && orank <= b)
				{
					System.out.println("Yes");
					pass++;
				}
				else {
					System.out.println("No");
				}
			}
			
		}
	}
}

Measured memory_bytes: 23112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int k = sc.nextInt(); 
        int q = sc.nextInt();        
		int [] in = new int [n];
        for(int i=0;i<q;i++){int a = sc.nextInt();
                            in[a-1]++;
                            }       		
        for(int i=0;i<n;i++){if(k-q+in[i]>0){System.out.println("Yes");
                                            }
                             else{System.out.println("No");}
                            }       
	}
}


Measured memory_bytes: 58320
#include <stdio.h>
int main()
{
	int time, hours, minutes, seconds;
	scanf("%d", &time);
	hours = time / 3600;
	minutes = (time % 3600) / 60;
	seconds = ((time % 3600) % 60);
	printf("%d:%d:%d\n",hours,minutes,seconds);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    if(s == t.substr(0, t.size()-1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s1 = in.nextString();
            String s2 = in.nextString();
            out.println(new StringBuilder(s1).reverse().toString().equals(s2) ? "YES" : "NO");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

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

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

    }
}



Measured memory_bytes: 22996
import numpy as np

S = input()
cond1 = (S[0] == 'A')

cntC = S.count('C', 2, len(S)-1)
cond2 = (cntC == 1)

cnt_lower = 0
for c in S:
    if c.islower():
        cnt_lower += 1
cond3 = (cnt_lower == len(S)-2)

if(cond1 and cond2 and cond3):
    print("AC")
else:
    print("WA")


Measured memory_bytes: 12472
#include<stdio.h>

int main(){
  int h, a;
  scanf("%d %d", &h, &a);
  
  if(h % a == 0){
  	printf("%d\n", h / a);
  }
  else{
    printf("%d\n", h / a + 1);
  }
  
  return 0;
}

Measured memory_bytes: 128
def ispalindrome(str): return 1 if str == str[::-1] else 0

S = list(input())
N = int(len(S))
mae = (N-1)//2
usiro = (N+3)//2

S_m = S[0:mae]
S_u = S[usiro-1:]

if ispalindrome(S_m) and ispalindrome(S_u) and ispalindrome(S):
  print('Yes')
else:
  print('No')


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

int main(){
  string S;
  int flg = 0;
  int flg1 = 0;

  string ans = "AC";

  cin >>S;

  for(int i = 0; i < S.length() ;i++){
    if(S[i] != tolower(S[i]))flg1++;
  }
  if(flg1 != 2)ans = "WA";

  if(S[0] != 'A')ans = "WA";

  for(int i = 2; i <= S.length()-2;i++){
    if(S[i] == 'C')flg++;
  }
  if(flg != 1)ans = "WA";
  cout <<ans<<endl;

  return 0;
}


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

vector<int> X[100005];
priority_queue<int> Q;

int main()
{
    int N, M;
    cin >> N >> M;

    for(int i=1; i<=N; i++)
    {
        int day, reward;
        cin >> day >> reward;

        if(day <= M)
            X[M-day].push_back(reward);
    }

    long long ans = 0;

    for(int i=M; i>=0; i--)
    {
        for(auto x : X[i])
            Q.push(x);

        if(!Q.empty())
        {
            ans += Q.top();
            Q.pop();
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5632
int  main(void) {
  int n, d[50], sum = 0, m = 0;
  
  scanf("%d",&n);
  for(int i = 0; i < n; i ++)
    scanf("%d",&d[i]);

  for(int m = 0; m < n; m ++)
    for(int i = m+1; i < n; i ++)
    	sum += d[m] * d[i];
  
  printf("%d",sum);
}

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  double t, x;
  cin >> t >> x;
  cout << setprecision(10) << t/x << endl;

}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, k, t;
    cin>> n>> k;

    n--;
    k--;

    for(int i=0; i<n; i++)
        cin>> t;

    cout << ( n+k-1)/k;
    nl;

    return 0;
}




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

int main(){
    int n;
    string s;
    cin >> n >>s;
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2)){
        cout << "Yes" <<endl;
        return 0;
    }
    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 52;
ll n,i,j,k;
ll a[N][N];
void multiply(ll a[N][N],ll b[N][N])
{
    ll res[N][N] = {0};
    rep(i,0,N) rep(j,0,N) for(ll k = 0;k < N;k += 1)
        res[i][j] = (res[i][j] + (a[i][k] * b[k][j]) % mod) % mod;
    rep(i,0,N) rep(j,0,N)
        a[i][j] = res[i][j];
}
ll modexp(ll a[N][N],ll b)
{
    ll res[N][N];
    rep(i,0,N) rep(j,0,N) res[i][j] = (i == j ? 1 : 0);
    while(b > 0){
        if(b & 1)
            multiply(res,a);
        multiply(a,a);
        b /= 2;
    }
    ll ans = 0;
    rep(i,0,N) rep(j,0,N)
        ans = (ans + res[i][j]) % mod;
    return ans;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    rep(i,0,n) rep(j,0,n) cin>>a[i][j];
    cout<<modexp(a,k);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >>b;

   if((a+b)%3==0 | a%3==0 | b%3==0)cout << "Possible" << endl;
   else cout << "Impossible" << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main(){
	int h,w;
	cin>>h>>w;
	vector<string>v(h);
	for(int i=0;i<h;i++)
	cin>>v[i];
	vector< vector<ll> > dp(h,vector<ll>(w,0));
	for(int i=0;i<w;i++){
		if(v[0][i]=='#')
		break;
		dp[0][i]=1;
	}
	for(int i=0;i<h;i++){
		if(v[i][0]=='#')
		break;
		dp[i][0]=1;
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(v[i][j]=='#')
			continue;
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

Measured memory_bytes: 9216
<?php
  list($W, $a, $b) = explode(" ", trim(fgets(STDIN)));

  $min=min($a,$b);
  $max=max($a,$b);

  if($min+$W >= $max){
    echo "0".PHP_EOL;
  }else{
    echo ($max-$min-$W).PHP_EOL;
  }

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define size 100005

int main() {
    int N, A[size], h[size], x, rnd;

    cin >> N;

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

    for(int i=1; i<N; i++) {
        A[i] = A[i-1] + abs(h[i]-h[i-1]);

        if(i > 1) {
            rnd = A[i-2] + abs(h[i]-h[i-2]);
            
            if(A[i] > rnd)
                A[i] = rnd;
        }
    }

    cout << A[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
S = [int(c) for c in input()]
S2 = S
beside_color = (S[0]+1)%2
count1 =0
for i in range(len(S)):
    if beside_color == S[i]:
        count1 +=1
        S[i] = (S[i]+1)%2
    beside_color = S[i]
count2 = 0
beside_color = S2[0]
for i in range(len(S)):
    if beside_color == S2[i]:
        count2 +=1
        S2[i] = (S2[i]+1)%2
    beside_color = S2[i]
if count2 < count1:
    ans = count2
else:
    ans = count1
print(ans)

Measured memory_bytes: 3956
#include <cstdio>

int d, w, h, n, r;

int main() {
  while (scanf("%d %d %d", &d, &w, &h), d || w || h) {
    scanf("%d", &n);
    
    int line[3];
    line[0] = d*d + w*w;
    line[1] = w*w + h*h;
    line[2] = h*h + d*d;
    for (int i=0; i<n; i++) {
      scanf("%d", &r);
      int r2 = r*r*4;
      
      if (line[0] < r2 || line[1] < r2 || line[2] < r2) {
	printf("OK\n");
      } else {
	printf("NA\n");
      }
    }
  }
}

Measured memory_bytes: 2592
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;



int main()
{
      
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<n+1;i++)
    cin>>p[i];
    
    double arr[n+1][n+1];
    memset(arr,0.0,sizeof arr);
    
    arr[0][0] = 1;
    
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            
            if(j==0)
            arr[i][j] = arr[i-1][j]*(1.0-p[i]);
            else{
                arr[i][j] = arr[i-1][j]*(1.0-p[i]) + arr[i-1][j-1]*(p[i]);
            }
        }
    }
    double ans = 0.0;
    for(int i = (n+1)/2;i<=n;i++){
        ans += arr[n][i];
    }
    cout<<setprecision(10)<<ans;
    
}


Measured memory_bytes: 70528
n = int(input())
a, b, c = [], [], []
for _ in range(n):
    _a, _b, _c = map(int, input().split())
    a.append(_a)
    b.append(_b)
    c.append(_c)

dp = [[0]*3 for _ in range(n)]
dp[0] = [a[0], b[0], c[0]]

for i in range(1, n):
    dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1])

print(max(dp[n-1]))


Measured memory_bytes: 78936
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int n;
	vector<int> v;
	while(cin >> n){
		if(n == 0){
			cout << v.back() << '\n';
			v.pop_back();
		}else v.push_back(n);
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3148
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int X,Y;
    cin >> X >> Y;
    bool ans=false;
    for(int i=0;i<=X;i++){
        int num=i*2+(X-i)*4;
        if(num==Y) ans=true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
ad ={}
for i in range(n):
    if a[i] in ad:
        ad[a[i]] += 1
    else:
        ad[a[i]] = 1
ans = 0
for j in ad.values():
    ans += j*(j-1)//2

for i in range(n):
    j = ad[a[i]]
    print(ans-j*(j-1)//2+(j-1)*(j-2)//2)

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

using lint = long long;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;

    rep(i, 3) {
        if(s[i] == '1') {
            s[i] = '9';
        } else {
            s[i] = '1';
        }
    }

    cout << s << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3616
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    c = SI()
    r = [0] * N
    w = [0] * N
    for i in range(N):
        r[i] = r[i-1] + (c[i] == 'R')
        w[i] = w[i-1] + (c[i] == 'W')

    ans = 0
    i = 0
    j = N-1
    while True:
        while i < N and c[i] == 'R':
            i += 1
        while j >= 0 and c[j] == 'W':
            j -= 1
        if i > j : break
        ans += 1
        i += 1
        j -= 1
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 73716
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l=nxt(),r=nxt();
    int y=r/2019;
    int x=l/2019;
    if(y-x>0)
    {
        cout<<"0\n";
        return 0;
    }
    int test=INT_MAX;
    for(int i=l;i<=r&&i<=l+2019;i++)
    {
        for(int j=i+1;j<=r&&j<=i+1+2019;j++)
        {
            ll temp=i;
            temp*=j;
            if(temp%2019<test)
                test=temp%2019;
        }
    }
    cout<<test<<endl;
    return 0;   
}


 
 


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans = s+t;
  for(int i = 1; i <= n; ++i) {
    if(s.substr(n-i, i) == t.substr(0, i)) {
      ans = s + t.substr(i, n-i);
    }
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second > secondElof.second;
}

int main()
{
	int re;
	cin >> re;
	cout << 3 * re * re;
}


Measured memory_bytes: 31488