akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;

void solve(){
    int n; cin>>n;
    vi v(n);
    for(int i = 0; i < n; i++) cin>>v[i];
    int ans=0;
    int cur=0;
    for(int i = 1; i < n; i++) {
        if(v[i-1]>=v[i]){
            cur++;
            ans=max(ans,cur);
        }
        else{
            //cout<<ans<<" "; 
            cur=0;
        }
    }
    cout<<ans;

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 640
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine(a+b >= c ? "Yes":"No");
    }
}

Measured memory_bytes: 13140
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    //int a[100005],b[100005],c[100005];
    //bool flag=false,d[100005];
    int a,b,n,ans=1;
    char s[105],t[105],u;
   
    cin >> n;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<n;i++) cin >> t[i];
    
    for(int i=0;i<n;i++) {
        cout << s[i];
        cout << t[i];
    }
    
    //cout << (!flag ? "Yes" : "No");
    //cout << ans;
    //cout << s;
    //printf("%.10f",ans_d);
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
long long util(vector<int> heights,int n,int k)
{
  long long dp[n];
  for(int i=0;i<n;i++)
  dp[i]=INT_MAX;
  dp[0]=0;
  dp[1]=abs(heights[0]-heights[1]);
  for(int i=2;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i-j>=0)
      dp[i]=min(dp[i],dp[i-j]+abs(heights[i]-heights[i-j]));
    }
  }
  return dp[n-1];
}
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> heights;
  for(int i=0;i<n;i++)
  {
    int temp;
    cin>>temp;
    heights.push_back(temp);
  }
  long long ans=util(heights,n,k);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
const int maxn=2e5+7;
int n;
char s[maxn];
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	int cnt=0;long long ans=0;
	for(int i=1;i<=n;)
		if(s[i]=='A')++cnt,++i;
		else if(s[i]=='B' && s[i+1]=='C')
			ans+=cnt,i+=2;
		else cnt=0,++i;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int a, b , c;
    cin >> a >> b;
    cout << 3 + 2 + 1 - a - b;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

long long gcd(long long a,long long b){
	while(1){
		if(a<b) swap(a,b);
		if(!b) break;
		a %= b;
	}
	return a;
}

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

#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    ll lcmans = 1;
    rep(i,0,n){
        cin >> a[i];
        if(a[i]%2!=0){ cout << 0 << endl; return 0;}
        lcmans = lcm(lcmans,a[i]/2);
        if(lcmans>m){ cout << 0 << endl; return 0;}
    }
    rep(i,0,30){
        rep(j,1,n){
            if(a[j-1]%2 != a[j]%2){cout << 0 << endl; return 0;}
        }
        if(a[0]%2==1) break;
        rep(j,0,n){ a[j]/=2;}
    }
    ll add = m/lcmans;
    cout << (add+1)/2 << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int x;
   cin >> x;
  if(x==0){
    cout << 1;
  }else{
    cout << 0;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>

using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N;
ll dp[100010][3];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> N;
    rep(i,N) rep(j,3) dp[i][j] = 0;
    cin >> dp[0][0];
    cin >> dp[0][1];
    cin >> dp[0][2];
    REP(i,1,N){
        ll a,b,c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    ll ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int R, G, B, n, cont;
int main() {
	cin>>R>>G>>B>>n;
	for(int i = 0; i <= n / R; i++) {
		for(int j = 0; j <= n / G; j++) {
			int tmp = n - i * R - j * G;
			if(tmp >= 0 && tmp % B == 0)	cont++;
		}
	}
	cout<<cont<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const int N = 1000050;
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int d[N],p[N];
ll b[N];
int main(){
  int n=gi(); p[0]=gi();
  for (int i=1; i<=n; ++i){
    d[i]=gi();
    if (p[i-1]>=d[i]||d[i]-p[i-1]<p[i-1])
      p[i]=abs(p[i-1]-d[i]);
    else
      p[i]=p[i-1];
  }
  b[n+1]=1;
  for (int i=n; i>=1; --i)
    if (b[i+1]<=d[i]/2) b[i]=b[i+1];
    else b[i]=b[i+1]+d[i];
  int Q=gi(),q;
  for (int i=1; i<=Q; ++i){
    q=gi();
    if (p[q-1]>=b[q+1])
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}


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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int solve(int y,int m,int d){
    //344 3 1
    int ret=0;
    ret+=(y-1)*(39*5);
    ret+=(int)((y-1)/3)*5;
    ret+=(m-1)*19;
    ret+=( (m-1)+1 )/2;
    if(y%3==0)ret+=(m-1)/2;
    ret+=d-1;
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        int y,m,d;
        cin>>y>>m>>d;
        cout<<solve(1000,1,1)-solve(y,m,d)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
void print_int(int n)
{
        printf("%d\n",n);
}

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}

int j = 1;
int result[120][5];

void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}

int a[5];
int sum[120];

int main(void)
{
    int i = 0;

    for(i = 0; i < 5; i++)
    {
       scanf("%d", &a[i]);
       result[0][i] = a[i];
    }
    
    permutate(a, 5, 0);

    for(i = 0; i < 120; i++)
    {
        for(int k = 0; k < 5; k++)
        {
            if(k != 4)
            {
                int temp = result[i][k] % 10 == 0 ? 0 : 10 - (result[i][k] % 10);
                sum[i] += result[i][k] + temp;
            }
            else
            {
                sum[i] += result[i][k];
            } 
        }
    }
    
    sort(sum, 120);
    print_int(sum[0]);
    
    return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin>>d;
    vector<int> c(26);
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d,vector<int>(26));
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
    long long ans=-200000000000;
    vector<int> cnt(d,0);
    auto score=[&](vector<int>& v){
        long long res=0;
        vector<int> last(26,0);
        for(int ii=1;ii<=d;ii++){
            res+=s[ii-1][v[ii-1]];
            last[v[ii-1]]=ii;
            for(int jj=0;jj<26;jj++){
                res-=c[jj]*(ii-last[jj]);
            }
        }
        if(res>ans){
            cnt=v;
            ans=res;
        }
    };
    random_device rnd;
    vector<int> days(d);
    for(int i=0;i<10000;i++){
        for(int j=0;j<d;j++){
            days[j]=rnd()%26;
        }
        score(days);
    }
    for(int i=0;i<d;i++)cout<<cnt[i]+1<<"\n";
    //cout<<ans<<endl;
}

Measured memory_bytes: 3724
/**
 *    author:  FromDihPout
 *    created: 2020-08-11
**/

#include <bits/stdc++.h>
using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, h;
    cin >> n >> h;
    vector<int> b(n);
    int a = -1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x >> b[i];
        a = max(a, x);
    }
    sort(all(b));
    
    long long ans = 0;
    for (int i = n-1; i >= 0; i--) {
        if (h <= 0 || b[i] <= a) break;
        h -= b[i];
        ans++;
    }
    
    if (h > 0) {
        ans += h / a + (h % a != 0);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3720
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve() {
    	ll n;
    	cin >> n;
    	cout << (n%2 ? n/2 : n/2 - 1) << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      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;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int sum=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            sum++;
            
        }else{
            continue;
        }
    }
    cout<<sum<<endl;
    
    
    return 0;
}


Measured memory_bytes: 512
import sys

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

mod = 10**9 + 7
ans = 0
sum_a = sum(A)
for i in range(N):
    sum_a -= A[i]
    ans += A[i] * sum_a
    ans %= mod

print(ans)

Measured memory_bytes: 31464
# Code for B - 105
# Use input() to fetch data from STDIN
n = int(input())

total = 0
for i in range(1, n + 1):
    if i % 2 == 0:
        continue
    c = 0
    for j in range(1, i + 1):
        if i % j == 0:
            c += 1 
    if c == 8:
        total+= 1 
print(total)




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

int main(){
	string s, str[] = {"maerd", "remaerd", "esare", "resare"};
	cin >> s;
	for(int i = s.size() - 1; i > 0;){
		for(int j = 0; j < 4; j++) if(i - str[j].size() >= 0){
			bool f = true;
			for(int k = 0; k < str[j].size(); k++) f &= s[i - k] == str[j][k];
			if(f){
				i -= str[j].size();
				break;
			}else if(j == 3){
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    string s;
    cin >> s;
    cout << s[0] << s.length() - 2 << s[s.length() - 1] << 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 a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = (a + b) * 2;
        System.out.println(area + " " + length);
        sc.close();
    }
}


Measured memory_bytes: 25968
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, x = 0; cin >> n;
  string s; cin >> s;
  vector<int> xat(n +1);
  xat.at(n) = 0;
  for(int i = 0; i < n; i++) {
    if(s.at(i) == 'I') {
      x++;
    }
    else {
      x--;
    }
    xat.at(i) = x;
  }
  sort(xat.begin(), xat.end());
  cout << xat.at(n) << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rep(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
inline double comb(int n, int r) {if (n == 0) { return 0; }if (r == 0) { return 1; }if (r == 1) { return n; }if (n == r) { return 1; }if (r > n / 2) { r = n / 2; }double result = 1;for (double i = 1; i <= r; i++) {result *= (n - i + 1) / i;}return(result);}
vector<pair<long long, long long> > prime_factorize(long long n) {vector<pair<long long, long long> > res;for (long long p = 2; p * p <= n; ++p) {if (n % p != 0) continue;int num = 0;while (n % p == 0) { ++num; n /= p; }res.push_back(make_pair(p, num));}if (n != 1) res.push_back(make_pair(n, 1));return res;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);

    int a,b;
    cin >> a >> b;
    if(a>=10 || b>=10){
        cout << -1 << endl;
    }
    else{
        cout << a*b << endl;
    }
    }

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

static const int INFTY = (1<<21);

int N;
vector<vector<int>> G(100005);

vector<int> bfs(int a) {
    vector<int> dist(N);
    queue<int> que;
    que.emplace(a);
    for (int i = 0; i < N; i++) dist[i] = INFTY;
    dist[a] = 0;
    while (!que.empty()) {
        int p = que.front(); que.pop();
        for (int q: G[p]) {
            if (dist[q] != INFTY) continue;
            dist[q] = dist[p] + 1;
            que.emplace(q);
        }
    }
    return dist;
}

int main() {
    int u, v;
    cin >> N >> u >> v;
    u--;
    v--;
    vector<int> du(N), dv(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    du = bfs(u);
    dv = bfs(v);

    int mx = 0;

    for (int i = 0; i < N; i++) {
        if (du[i] < dv[i]) {
           mx = max(mx, dv[i]);
        }
    }
    int ans = mx - 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7040
N,K,Q=map(int,input().split())
A=[]
for i in range(Q):
    A.append(int(input()))
B=[0]*100006
#print(A)
#print(B)
for i in range(Q):
    B[A[i]]+=1

for i in range(1,N+1):
    if K-Q+B[i]>=1:
        print('Yes')
    else:
        print('No')

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

ll digicount(ll a){
    ll c=0;
    while(a){
        a/=10;
        c++;
    }
    return c;

}

int main(){
    ll n;

    cin >> n;
    //int check = digicount(a);
    ll ans = LONG_MAX;
    for(ll i = 1;i<=(n/i);i++){

        if((i*(n/i)) == n){
              //  cout << i << " " << (n/i) << endl;
            ll x = digicount(i);
            ll y = digicount((n/i));
            ans = min(ans,max(x,y));

        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  
  int ans=0;
  
  int x=0;
  
  
  for(int i=0;i<N-1;i++){
    if(H[i]>=H[i+1]){
      x++;
      ans=max(ans,x);
    }
    else{
      ans=max(ans,x);
      x=0;
    }
  }
  
  cout<<ans<<endl;
}

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

int main(){
  int k,s,i,j,cnt;
  cin>>k>>s;
  for(i=0;i<=k;i++){
  	for(j=0;j<=k;j++){
      if(s-i-j>=0 && s-i-j<=k)cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vector<vll> A(n, vll(n, 0));
    loop(i, 0, n)
        loop(j, 0, n)
            cin>>A[i][j];
    lli N = 1<<n;
    vll dp(N+1, 0);
    loop(mask, 1, N){
        loop(i, 0, n){
            if((mask & (1<<i)) == 0)
                continue;
            loop(j, i+1, n){
                if(mask & (1<<j))
                    dp[mask] += A[i][j];
            }
        }
    }
    loop(mask, 1, N){
        for(lli submask = mask; submask > 0; submask = (submask-1) & mask){
            dp[mask] = max(dp[mask], dp[mask ^ submask] + dp[submask]);
        }
    }
    cout<<dp[N-1]<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			int[] bs = new int[N - 1];
			for(int i = 0; i < N - 1; i++) {
				bs[i] = sc.nextInt();
			}

			
			int[] as = new int[N];
			Arrays.fill(as, Integer.MAX_VALUE);
			for(int i = 0; i < N - 1; i++) {
				as[i + 0] = Math.min(as[i + 0], bs[i]);
				as[i + 1] = Math.min(as[i + 1], bs[i]);
			}
			System.out.println(Arrays.stream(as).sum());
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = -1;
    for (int bit = 0; bit < (1<<N); bit++) {
        int cost = 0;
        int skills[M] = {};
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                cost += C[i];
                for (int j = 0; j < M; j++) {
                    skills[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
            if (skills[i] < X) {
                ok = false;
            }
        }
        if (ok) {
            if (cost < ans || ans < 0) {
                ans = cost;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
import sys

def comb(n, r, fact, revfact, mod):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    mod = 7 + 10 ** 9
    maxX = 0
    minX = 0
    fact = [1] * (N + 2)
    revfact = [1] * (N + 2)
    for i in range(1, N + 2): fact[i] = (i * fact[i - 1]) % mod
    revfact[N + 1] = pow(fact[N + 1], mod - 2, mod)
    for i in reversed(range(1, N + 1)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    for i in range(K - 1, N):
        maxX += (A[i] * comb(i, K - 1, fact, revfact, mod)) % mod
        maxX %= mod
        minX += (A[N-1-i] * comb(i, K - 1, fact, revfact, mod)) % mod
        minX %= mod
    print((maxX - minX + mod) % mod)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 14796
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (1<<30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x,y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
    if ( !v.empty() ) {
        out << '[';
        copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


/* template end */


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

    int n, m;
    cin >> n >> m;
    set<ll> am;
    REP(i, m) {
        int a;
        cin >> a;
        am.insert(a);
    }

    vector<ll> a(n + 100);
    a[0] = 1;
    for(int i = 0 ; i < n; i++) {
        if (am.count(i + 1) == 0) {
            a[i + 1] = (a[i] + a[i + 1]) % MOD;
        }
        if (am.count(i + 2) == 0) {
            a[i + 2] = (a[i] + a[i + 2]) % MOD;
        }
    }

#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    cout << a[n] << endl;

    return 0;
}


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

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

  bool flg=false;
  for(int i=1;i<=1000;i++)
  if( (a*i)%b==c ){
    flg=true;
  }

  if(flg)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    string s;
    cin >> s;
    ll now = 0;
    rep(i, s.size())
    {
        now += s[i] - '0';
    }
    if (now % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3716
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

template <typename T>
struct SegmentTree
{
    using F = function<T(T, T)>;
    
    const F f;
    const T e;
    
    int n;
    vector<T> seg;
    
    SegmentTree(int nn, const F f, const T e) : f(f), e(e){
        n = 1;
        while(n < nn) n <<= 1;
        seg.assign(n * 2, e);
    }
    
    void set(int i, T x){
        seg[i + n] = x;
    }
    
    void build(){
        for(int k = n - 1; k > 0; k--){
            seg[k] = f(seg[k * 2], seg[k * 2 + 1]);
        }
    }
    
    void update(int i, T x){
        int k = i + n;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k * 2], seg[k * 2 + 1]);
        }
    }
    
    T query(int l, int r){
        l += n, r += n;
        T L = e, R = e;
        for(; l != r; l >>= 1, r >>= 1){
            if(l % 2) L = f(L, seg[l++]);
            if(r % 2) R = f(seg[--r], R);
        }
        return f(L, R);
    }
    
    T operator[](const int i)const {
        return seg[i + n];
    }
    
    template<typename C>
    int right_bound_sub(int k, const C &check, T x){
        while(k < n){
            if(check(f(x, seg[k * 2]))){
                k = k * 2;
            }
            else{
                x = f(x, seg[k * 2]);
                k = k * 2 + 1;
            }
        }
        return k - n;
    }
    
    template <typename C>
    int right_bound(int i, const C &check){
        T x = e;
        for(int l = i + n, r = n * 2; l != r; l >>= 1, r >>= 1){
            if(l % 2){
                if(check(f(x, seg[l]))){
                    return right_bound_sub(l, check, x);
                }
                x = f(x, seg[l]);
                l++;
            }
        }
        return -1;
    }
    
    template <typename C>
    int left_bound_sub(int k, const C &check, T x){
        while(k < n){
            if(check(f(seg[k * 2 + 1], x))){
                k = k * 2 + 1;
            }
            else{
                x = f(seg[k * 2 + 1], x);
                k = k * 2;
            }
        }
        return k - n;
    }
    
    template <typename C>
    int left_bound(int i, const C &check){
        T x = e;
        for(int l = n, r = i + n; l != r; l >>= 1, r >>= 1){
            if(r % 2){
                if(check(f(seg[--r], x))){
                    return left_bound_sub(r, check, x);
                }
                x = f(x, seg[r]);
            }
        }
        return -1;
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    int m = 300005;
    int a[300005];
    for(int i = 0; i < n; i++) cin >> a[i];
    SegmentTree<int> seg(m, [](int a, int b){return max(a, b);}, 0);
    for(int i = 0; i < n; i++){
        seg.update(a[i], seg.query(max(0, a[i] - k), min(m, a[i] + k + 1)) + 1);
    }
    cout << seg.query(0, m) << endl;
}


Measured memory_bytes: 8520
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

#define DEBUG   false

struct UnionFind
{
private:

    std::vector<int> parent;

public:

    UnionFind(int N)
        : parent(N)
    {
        for (int i = 0; i < N; i++)
        {
            parent[i] = i;
        }
    }

    friend std::ostream& operator << (std::ostream& a, const UnionFind& b)
    {
        a << "{";
        for (int i = 0; i < b.parent.size(); i++)
        {
            if (0 != i)
            {
                a << ", ";
            }
            a << i << ": " << b.parent[i];
        }
        a << "}";
        return a;
    }

    int root(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y)
    {
        if (same(x, y))
        {
            return;
        }
        parent[root(x)] = root(y);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

};

std::string solve(int N, std::vector<std::pair<int, int>>& Pc, std::vector<std::pair<int, int>>& Tc)
{
    return "";
}

int main(void)
{
    int N, K, L;
    std::cin >> N >> K >> L;

    UnionFind ar(N);
    for (int i = 0; i < K; i++)
    {
        int x, y;
        std::cin >> x >> y;
        ar.unite(x - 1, y - 1);
    }
#if DEBUG
    std::cout << "ar: " << ar << std::endl;
#endif

    UnionFind br(N);
    for (int i = 0; i < L; i++)
    {
        int x, y;
        std::cin >> x >> y;
        br.unite(x - 1, y - 1);
    }
#if DEBUG
    std::cout << "br: " << br << std::endl;
#endif

    std::map<std::pair<ll, ll>, ll> n;
    for (int i = 0; i < N; i++)
    {
        ll a = ar.root(i);
        ll b = br.root(i);
        n[{a, b}]++;
    }
#if DEBUG
    std::cout << "ar: " << ar << std::endl;
#endif
#if DEBUG
    std::cout << "br: " << br << std::endl;
#endif
#if DEBUG
    for (int i = 0; i < N; i++)
    {
        ll a = ar.root(i);
        ll b = br.root(i);
        std::cout << a << "-" << b << ": " << n[{a, b}] << std::endl;
    }
#endif
    for (int i = 0; i < N; i++)
    {
        if (0 != i)
        {
            std::cout << " ";
        }
        ll a = ar.root(i);
        ll b = br.root(i);
        std::cout << n[{a, b}];
    }
    std::cout << std::endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 14080
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<queue>
#include<cmath>

using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int, int > Pi;
typedef pair< bool , Pi > Pii;
typedef long long int int64;

int main(){
  int M, N;
  string mas[1000], Find[2];
  bool hori[1000][1000];
  string temp = "JOI";

  cin >> M >> N;
  for(int i = 0; i < M; i++){
    cin >> mas[i];
  }
  for(int i = 0; i < 2; i++){
    cin >> Find[i];
  }
  
  int base = 0, ret;
  for(int i = 0; i <= M - 2; i++){
    for(int j = 0; j <= N - 2; j++){
      
      bool flag = true;
      for(int k = 0; k < 2; k++){
        for(int l = 0; l < 2; l++){
          flag &= Find[k][l] == mas[i + k][j + l];
        }
      }
      base += hori[i][j] = flag;
    }
  }
  ret = base;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k < 3; k++){
        if(mas[i][j] == temp[k]) continue;
        swap( mas[i][j], temp[k]);
        int cnt = base;
        for(int l = -(i != 0); l < (i + 1 < M); l++){
          for(int m = -(j != 0); m < (j + 1 < N); m++){
            bool flag = true;
            for(int o = 0; o < 2; o++){
              for(int p = 0; p < 2; p++){
                flag &= mas[i + l + o][j + m + p] == Find[o][p];
              }
            }
            cnt = cnt + flag - hori[i + l][j + m];
          }
        }
        ret = max( cnt, ret);
        swap( mas[i][j], temp[k]);
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}


ll cnt[MAX*10]={};

int main(void) {
  ll i, j, k;
  ll N;
  ll a[MAX/10];
  cin >> N;
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    prime.clear();
    factrization(a[i]);
    
    for(auto it=prime.begin(); it!=prime.end(); it++) {
      chmax(cnt[it->first], it->second);
    }
    
  }
  
  
  ll LCM=1;
  for(i=0; i<MAX*10; i++) {
    moC(LCM, *, moP(i, cnt[i]));
  }
  
  ll ans=0;
  for(i=0; i<N; i++) {
    moC(ans, +, LCM*moP(a[i], MOD-2)%MOD);
  }
  
  pt(ans);
}





Measured memory_bytes: 6656
l, r = map(int, input().split())
MOD = 2019

if r - l >= 2018:
    print(0)
elif (l % MOD) >= (r% MOD):
    print(0)
else:
    left = l % MOD
    right = r % MOD
    L = list(range(left, right+1))
    n = len(L)
    ans = 10**4
    for i, elm in enumerate(L):
        for j in range(i+1, n):
            ans = min(ans, ((elm * L[j]) % MOD))
    print(ans)            


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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e12+5

int main(){
  int N, M;
  cin >> N >> M;
  ll RT = (N-M) * 100 + 1900*M;
  ll p = 1;
  REP(i, M){
    p *= 2;
  }
  cout << RT*p << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int main() {
  string s;
  cin >> s;
  int r1 = -2;
  int r2 = -2;
  for (int i = 0; i < s.size(); i++) {
    int j = i+1;
    int k = i+2;
    if (j < s.size()) {
      if (s[i] == s[j]) {
        r1 = i;
        r2 = j;
        break;
      }
    }
    if (k < s.size() && s[i] == s[k]) {
      r1 = i;
      r2 = k;
      break;
    }
  }
  cout << r1+1 << " " << r2+1 << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll v, to, cost;};
struct UnionFind{
  ll N; //ノードの個数
  vector<edge> G;
  vector<int> par; // 親ノード
  vector<int> rank; // ランク

  UnionFind(int n) { //初期化
    N=n; par.resize(N); rank.resize(N);
    rep(i,N) {par[i] = i, rank[i] = 0;}
  }

  int root(int x) { //ノードの根を返す
    if(par[x] == x) return x; //親が自分なら自分を返す
    else{
      int r = root(par[x]); //根まで遡る
      return par[x] = r;
    }
  }
  bool issame(int x, int y) { //同じ根ならtrue,ちがうならfalse
    return root(x) == root(y);
  }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x; //ランクの小さい方に接続
    return true;
  }

  void add_edge(ll v,ll to,ll cost){
    G.emplace_back((edge){v, to, cost});
  }
/*
  bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
  }
  */
  ll kruskal() {
    //sort(G.begin(), G.end(), comp);
    sort(G.begin(), G.end(), [] (const edge &a, const edge &b) {
       return a.cost < b.cost;
    });//比較関数をラムダ式で作る);
    ll res = 0;
    for(auto E: G) {
      if(!issame(E.v, E.to)) {
        merge(E.v, E.to);
        res += E.cost;
      }
    }
    return res;
  }

};


void Main(){

  int N;
  cin>>N;

  ll x[N];
  ll y[N];

  rep(i,N){
    cin>>x[i]>>y[i];
  }

  vector<pair<ll,ll>> xpr;
  vector<pair<ll,ll>> ypr;

  rep(i,N){
    xpr.emplace_back(x[i],i);
    ypr.emplace_back(y[i],i);
  }

  SORT(xpr);
  SORT(ypr);

  UnionFind uf(N);

  rep(i,N-1){
    ll x1=xpr[i].second; ll x2=xpr[i+1].second;
    uf.add_edge(x1,x2,min(abs(x[x1]-x[x2]),abs(y[x1]-y[x2])) );
    ll y1=ypr[i].second; ll y2=ypr[i+1].second;
    uf.add_edge(y1,y2,min(abs(x[y1]-x[y2]),abs(y[y1]-y[y2])) );
  }

  cout<< uf.kruskal() <<"\n";

}


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


Measured memory_bytes: 15328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

//最大公約数
ll gcd(ll a, ll b){
  if(a % b == 0) return b;
  else return gcd(b, a%b);
}

//最小公倍数
ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  return a / g * b;
}

int main(){
  int n;
  cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  ll ans = t[0];
  for (int i = 1; i < n; i++){
    ans = (ll)lcm(ans, t[i]);
  }
  cout << ans << endl;
}

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

using namespace std;
static const int MAX = 10000;
static const int INF = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for (int i = 0; i < n; ++i) {
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        if (d[u] < f.first * (-1))
            continue;

        for (int j = 0; j < adj[u].size(); ++j) {
            int v = adj[u][j].first;
            if (color[v] == BLACK)
                continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                // priority_queue????????????????????§??§?????????????????????????????????-1????????????
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
}

int main() {
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll i,n,k;
  cin>>n>>k;
  ll a[n];
  fr(i,0,n)
  {cin>>a[i];
  }
  sort(a,a+n);ll c=0;ll s=0;i=0;
  while(c!=k)
  {s=s+a[i];c++;
   i++;
   
  }
  cout<<s;
	return 0;
}


Measured memory_bytes: 3632