akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int query = 1;
set<int> v[N];
int n;


void solve() 
{
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i + 1];
	}
	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		v[a].insert(arr[b]);
		v[b].insert(arr[a]);
	}
	int ret = 0;
	for(int i = 1; i <= n; i++)
	{
		// trace(v[i]);
		if(v[i].size() == 0)
		{
			ret++;
		}
		else if(*(--v[i].end()) < arr[i])
		{
			// trace(i);
			ret++;
		}
	}
	cout << ret << endl;
}



 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}


Measured memory_bytes: 27880
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >>a[i];

    map<ll,ll> mp;
    ll ans=0;
    rep(i,n){
        if(mp.find(a[i]+i)==mp.end()){//待ちの追加　
            mp[a[i]+i]=1;
        }
        else{
            mp[a[i]+i]++;
        }
        if(mp.find(i-a[i])!=mp.end()){
            ans+=mp[i-a[i]];
        }
    }
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 17480
require 'pp'
require 'prime'

N = readline.to_i
A = readline.chomp.split.map(&:to_i)

count = Hash.new(0)

p0 = Hash[ A[0].prime_division ]
p1 = Hash[ A[1].prime_division ]
p0.each do |k,v|
  v.times do |e|
    count[ [k,e+1] ] += 1
  end
end
#pp count
p1.each do |k,v|
  v.times do |e|
    count[ [k,e+1] ] += 1
  end
end
#pp count

(2..(N-1)).each do |i|
  a = A[i]
  ks = count.keys
  ks.each do |p,e|
    d = p**e
    if a % d != 0
      k = [p,e]
      count[k] -= 1
      count.delete(k) if count[k] == 0
    end
  end
end
# pp count

def make_div(keys)
  ans = Hash.new(0)
  keys.each do |p,e|
    ans[p] = e if ans[p] < e
  end
  ans
end

h = make_div(count.keys).to_a

$cand = []
def dfs(h, i, x)
  if i == h.size
    $cand << x
    return
  end
  (h[i][1]+1).times do |v|
    dfs(h, i+1, x * (h[i][0]**v))
  end
end

dfs(h, 0, 1)
    
# pp $cand

puts $cand.select {|c|
  count = 0
  A.each do |a|
    if a % c != 0
      count += 1
      break if count == 2
    end
  end
  count < 2
}.max



Measured memory_bytes: 25144
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
 
 
Node treeSearch(Node u, int k){
  while(u != NIL){
    if(u->key > k) u = u->left;
    else if(u->key < k) u = u->right;
    else break;
  }
  return u;
}
 
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key)  x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL)  root = z;
  else if(z->key < y->key)  y->left = z;
  else y->right = z;
}
 
void inorder(Node u){
  if(u == NULL) return ;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}




Measured memory_bytes: 20616
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);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 REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    int s[100000] = {};
    REP(i,N){
        int a;
        cin >> a;
        s[a]++;
    }
    int ans = 0;
    REPS(i,99998){
        ans = max(ans,s[i-1]+s[i]+s[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {	//N個の整数から連続するK個を選ぶ
  int N, K, count = 0;
  
  cin >> N >> K;
  
  for (int i=0; i<N-K+1; i++)
    count++;
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(ll i=(k);i<(n);++i)

int main(){
    ll N; cin >> N;
    ll n,h,w;
    FOR(n,1,3501){
        FOR(h,1,3501){
            if(4*n*h-N*n-N*h<=0) continue;
            else{
                if((N*n*h)%(4*n*h-N*n-N*h)==0LL){
                    w = (N*n*h)/(4*n*h-N*n-N*h);
                    cout << n << " " << h << " " << w << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
from bisect import bisect_left
def main():
    n, w = map(int, input().split())
    item = [list(map(int, input().split())) for _ in range(n)]
    dp = [0]*(w+1)
    item.sort()
    x = 0
    for p, q in item:
        for j in reversed(range(p, min(w+1, x+p+1))):
            dp[j] = max(dp[j-p]+q, dp[j])
        x += p
    print(max(dp))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9716
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    foreach (x; 1 .. 1_000_000)
    {
        if (A * x % B == C)
        {
            writeln("YES");
            return;
        }
    }
    writeln("NO");
}


Measured memory_bytes: 3664
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
bool check(string s)
{
  string s1=s;

  reverse(s1.begin(),s1.end());


  if(s1==s)
  return true;
  else
   return false;
}

int main()
{
	string s,s1,s2;
	cin>>s;
	int n=s.size();


	s1=s.substr(0,n/2);

	s2=s.substr(((n+3)/2)-1,n/2);


     if(check(s)==true&&check(s1)==true&&check(s2)==true)
     cout<<"Yes";
     else
     cout<<"No";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;
//繰り返し二乗法
ll ex(ll x,ll n){
    if(n==0)return 1;
    else if(n%2==1)return ex(x,n-1)*x%num;
    else return ex(x*x%num,n/2)%num;
};
//二項係数
ll nikou(ll n,ll k){
    ll dived=1,div=1;
    for(int i=0; i<k; i++){
        dived*=(n-i)%num;dived%=num;
        div*=(i+1)%num;div%=num;
    }
    div=ex(div,num-2);
    return dived*div%num;
};
int main(){
    ll n,k;
    cin >> n >> k;
    for(ll i=1; i<=k; i++){
        ll tmp=nikou(n-k+1,i);
        ll tran=nikou(k-1,i-1);
        ll ans=(tmp*tran)%num;
        cout << ans << endl;
    }
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int n,d,x;
    cin>>n>>d>>x;

    int ans=x;

    rep(i,n){
        int a;cin>>a;
        for(int j=1;j<=d;j+=a)
            ans++;
    }

    cout<<ans<<endl;
}


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

int main() {
  string str;
  cin >> str;
  if(str.at(str.length()-1) == 's') {
    cout << str << "es" << endl;
  } else {
    cout << str << "s" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    ll ans = b;
    if (a < 10) ans += 100 * (10 - a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)] 

INF = 10 ** 6
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

res = 0
for arr in A:
    for a in arr:
        if a == -1:
            continue
        else:
            res += c[a][1]

print(res)

Measured memory_bytes: 40284
import java.util.Scanner;

public class Main {

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

		String s1 = sc.nextLine();
		String s2 = sc.nextLine();

		char[] c = s1.toCharArray();

		System.out.println((("" + c[2] + c[1] + c[0]).equals(s2)) ? "YES" : "NO");

		sc.close();


	}

}




Measured memory_bytes: 23124
/* ex 7_1
   unomi */

#include <stdio.h>

// 頂点を表す構造体 point
typedef struct point{
    int x_elem;
    int y_elem;
}point;

point shift_point(point pnt, int dist_x, int dist_y){
    // 新しい頂点の宣言
    point new_pnt={0,0};
    // 頂点の計算
    new_pnt.x_elem = pnt.x_elem + dist_y;
    new_pnt.y_elem = pnt.y_elem - dist_x;
    return new_pnt;
}

int main(void){
    int dist_x, dist_y;
    point pnt_1={0,0}, pnt_2={0,0}, pnt_3={0,0}, pnt_4={0,0};
    // 頂点の取得
    scanf("%d %d %d %d", &pnt_1.x_elem, &pnt_1.y_elem, &pnt_2.x_elem, &pnt_2.y_elem);

    // pnt_1,2のx軸方向での距離：pnt_1.x_elem - pnt_2.x_elem
    //          y軸方向での距離：pnt_1.y_elem - pnt_2.y_elem
    dist_x = pnt_1.x_elem - pnt_2.x_elem;
    dist_y = pnt_1.y_elem - pnt_2.y_elem;

    // 関数shift_point で移動した他の頂点を求める
    pnt_3 = shift_point(pnt_2, dist_x, dist_y);
    pnt_4 = shift_point(pnt_1, dist_x, dist_y);

    printf("%d %d %d %d\n", pnt_3.x_elem, pnt_3.y_elem, pnt_4.x_elem, pnt_4.y_elem);

    return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;
using pii=pair<int,int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vector<pii> x(n);
		vi a(n);
		int maximum=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			maximum=max(maximum, a[i]);
			x[i].second=a[i];
		}
		for(int i=0;i<n;i++)
		{
			a[i]=min(a[i], maximum-a[i]);
			x[i].first=a[i];
		}
		sort(x.rbegin(), x.rend());
		if(x[0].second==maximum) x[0].second=0;
		printf("%d %d\n", maximum, x[0].second);
	}

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100010

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(N);
    vector<int>  ma(N);

    for(int i=1; i<=n; i++){
        cin >> h[i];
        ma[i] = 0;
    }
        

    int a, b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    int ans = 0;

    for(int i=1; i<=n; i++){
        if(h[i] > ma[i])
            ans++;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3676
s=gets.chomp
m=[0]*2019
m[0]=1
t,b=0,1
s.chars.reverse_each{|c|
  d=c.ord-48
  t=(t+d*b)%2019
  m[t]+=1
  b=b*10%2019
}
puts m.reduce(0){|s,e| s+e*(e-1) }/2

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

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define brep(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define xrep(i,n) for(ll i=1,i##_len=(n);i<=i##_len;i++)
#define Yes(n) cout<<((n)?YES:NO)<<'\n'
#define rYes(n) cout<<((n)?YES:NO)<<'\n';return
#define Sort(v) sort(all(v))
#define rSort(v) sort(all(v)); reverse(all(v))
#define Unique(v) (v).erase(unique(all(v)),(v).end())
#define eb emplace_back

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vvll = vector<vll>;
using vstr = vector<string>;

// --- functions which take 1 argument ---
static inline void ignore_ret(int x){x++;}
template<class T> inline int sgn(T x){return (x>0)-(x<0);}
template<class T> inline ll factorial(T n){if(n==0)return 1;ll r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline map<T,T> factorize(T n){map<T,T>r;for(T i=2;i*i<=n;i++){while(n%i==0){r[i]++;n/=i;}}if(n!=1)r[n]=1;return r;}

// --- functions which take 2 arguments ---
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T nPr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;for(T i=n-k+1;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}

// --- functions which take vector(s) as argument(s) ---
template<class T> inline void print(vector<T>v){cout<<"[ ";for(auto x:v)cout<<x<<' ';cout<<"]\n";}
template<class T> inline T min(vector<T>v){return *min_element(all(v));}
template<class T> inline T max(vector<T>v){return *max_element(all(v));}
template<class T> inline ll sum(vector<T>v){return reduce(all(v),0LL);}
template<class T> inline T gcd(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=gcd(r,v[i]);return r;}
template<class T> inline T lcm(vector<T>v){T r=v[0];for(T i=1;i<v.size();i++)r=lcm(r,v[i]);return r;}
template<class T> inline double abs(vector<T>v){return sqrt(reduce(all(v),0.0,[](int s,int v){return s+=v*v;}));}
template<class T> inline T dot_product(vector<T>u,vector<T>v){if(u.size()<v.size())return 0;T r=0;for(T i=0;i<u.size();i++)r+=u[i]*v[i];return r;}
template<class T> inline T cross_product(T u,T v){T r(3);r[0]=u[1]*v[2]-u[2]*v[1];r[1]=u[2]*v[0]-u[0]*v[2];r[2]=u[0]*v[1]-u[1]*v[0];return r;}

// --- Template ends here ---

void solve(ll X) {
  ll numberOfItemsToBuy = X / 100, rest = X % 100;
  cout << !(rest > 5 * numberOfItemsToBuy) << endl;
}

int main() {
  ll X;
  ignore_ret(scanf("%lld",&X));
  solve(X);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int d,n;
  cin >> d >> n;
  int ans = n;
  if(n==100) ans = 101;
  for(int i=0;i<d;i++) ans *= 100;
  cout << ans << endl;
  return 0;
}


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

int main(void){
   string w;
   cin>>w;
   map<char,int> ans;
   for(int i=0;i<w.size();i++){
      ans[w[i]]++;
   }
   bool flag=true;
   for(auto x:ans){
      if(x.second%2!=0){
         flag=false;
         break;
      }
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int l;
	cin >> l;
	int a, b, c, d;
	int count = 0;
	cin >> a >> b >> c >> d;

	while (a > 0 or b > 0){
		a -= c;
		b -= d;
		count++;
	}

	cout << l - count << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (long long i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll l, r;
    ll ans = LINF;
    cin >> l >> r;
    if(r - l >= 2019)
        cout << 0;
    else
    {
        FOR(i, l, r)
            FOR(j, i + 1, r)
                ans = min(ans,(i * j) % 2019);
        cout << ans;
    }
    return 0;
}


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

int main(void){
	long N, K, result;
	cin >> N >> K;
	long cnt = N / K;
	result = cnt * cnt * cnt;
	if(K % 2 == 0){
		cnt = (N + K / 2) / K;
		result += cnt * cnt * cnt;
	}
	cout << result;
	return 0;
}


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

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

#define EVAL 1

#ifndef EVAL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int A, B, t;

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

  cin >> A >> B;
  t = (A+B)%24;
  cout << t << endl;;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

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

int main(void) {
    long double r;
    cin >> r;
    cout << 2 * r * 3.14 << endl;
}

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

int main(){
  int N;
  int all=1,bad=1;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
    all *= 3;
    if(A.at(i)%2==0){
      bad *=  2;
    }
  }
  cout << all - bad << endl;
}


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;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n)
    cin >> x[i] >> y[i];
  vector<vector<double>> dist(n, vector<double>(n, 0));
  rep(i, n - 1)
    for(int j = i + 1; j < n; j++)
      dist[i][j] = dist[j][i] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
  vector<int> p(n);
  rep(i, n)
    p[i] = i;
  double ans = 0;
  int count = 0;
  do
  {
    rep(i, n - 1)
      ans += dist[p[i]][p[i+1]];
    count++;
  } while (next_permutation(p.begin(), p.end()));
  ans /= count;
  printf("%.7lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int h, w, i, j, k;
    for (k = 0; k <= 300; k++)
    {
        scanf("%d %d", &h, &w);
        if (w == 0 && h == 0)
        {
            break;
        }
        for (i = 1; i <= h; i++)
        {
            for (j = 1; j <= w; j++)
                putchar('#');
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
 
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k>0 && b<=a) b*=2, k--;
    while(k>0 && c<=b) c*=2, k--;
    // cout<<a<<" "<<b<<" "<<c<<"\n";
    if(b>a && c>b) cout<<"Yes\n";
    else cout<<"No\n";
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 0;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        auto j = n / i;
        if (i < j - 1) ans += j - 1;
        if (j < i - 1) ans += i - 1; 
    }
    cout << ans << '\n';
}


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

int gcd(int x, int y) {
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    cout << gcd(x, y) << endl;

    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

bool A[100000 + 10];

int main()
{
	int N;
	std::multimap<int, std::vector<int>, std::greater<int>> M;

	std::cin >> N;

	int h;
	for (int i = 0; i < N; ++i)
	{
		std::cin >> h;
		if (M.count(h) == 0)
		{
			M.insert(std::make_pair(h, std::vector<int>()));
		}
		auto it = M.find(h);
		(it->second).push_back(i + 1);
	}

	
	int ans = 0;
	if (M.size() > 1 || M.count(0) == 0)
	{
		int count = 0;

		for (auto it : M)
		{
			for (auto p : it.second)
			{
				A[p] = true;
				if (!A[p - 1] && !A[p + 1]) ++count;
				else if (A[p - 1] && A[p + 1]) --count;
			}
			ans = std::max(ans, count);
		}
	}

	std::cout << ans << std::endl;

	return 0;
}



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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int           long long int
#define pll				    pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		  LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			    1000000007
#define hell          998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void print(int i) {
	if(i == 1) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

void solve()
{
  int a , b;

	cin >> a >> b;

	if(a >= 13) {
		cout << b;
	}
	else if(a >= 6) {
		cout << b/2;
	}
	else {
		cout << 0;
	}
}

signed main() {
    fast;

    int t = 1;

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

	  //cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3604
from math import log10


def S(x):
    rst = 0
    while x > 0:
        rst += x % 10
        x //= 10
    return rst


def f(N):
    rst = (N, N / S(N))
    for d in range(int(log10(N) - 1) + 1):
        x = pow(10, d + 1) * int(N / pow(10, d + 1) + 1) - 1
        sunuke = x / S(x)
        if rst[1] > sunuke:
            rst = (x, sunuke)
    return rst[0]


K = int(input())
ans = [1]
N = 1
K -= 1
while K > 0:
    N = f(N + 1)
    ans.append(N)
    K -= 1

print(*ans, sep='\n')


Measured memory_bytes: 39408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >>b >> c;
    map<int,int> mp;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    if(mp[5]==2 && mp[7]==1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define NOT_FOUND 0

int linearSearch(int);
int n,A[10000];
int main()
{
  int i,q,count=0,T[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(linearSearch(T[i])==1) count++;
  }
  printf("%d\n",count);
  return 0;
}
int linearSearch(int key)
{
  int i;
  for(i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    } 
  }
  return NOT_FOUND;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200005;
 
int a[N],n,num;
ll ans=0;
 
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i),a[i]-=i;
    sort(a+1,a+n+1),num=a[(n+1)>>1];
    for(int i=1;i<=n;i++) ans+=(ll)abs(num-a[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    S=input()
    Q=int(input())
    *K,=map(int, input().split())

    for k in K:
        ans = 0
        d,m,dm=0,0,0
        j=0
        for i in range(N):
            if i-j == k:
                if S[j]=='D':
                    d -= 1
                    dm -= m
                elif S[j]=='M':
                    m -= 1
                j += 1

            if S[i] == 'D':
                d += 1
            elif S[i] == 'M':
                m += 1
                dm += d
            elif S[i] == 'C':
                ans += dm
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	int f=1;
	cin>>n;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(i*j==n)
			{
				cout<<"Yes";return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000000

struct Point {
    int x, y;
};

int n, m;

int solve(vector<Point> &p, vector<Point> &c) {
    for (int i = 0; i < n; i++) {
        int ans = 0;
        int minDistance = MAX;
        for (int j = 0; j < m; j++) {
            int distance = abs(p.at(i).x - c.at(j).x) + abs(p.at(i).y - c.at(j).y);
            if (distance < minDistance) {
                minDistance = distance;
                ans = j + 1;
            }
        }

        cout << ans << endl;
    }
}

int main() {
    cin >> n >> m;
    vector<Point> p(n);
    vector<Point> c(m);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i).x >> p.at(i).y;
    }
    for (int j = 0; j < m; j++) {
        cin >> c.at(j).x >> c.at(j).y;
    }

    solve(p, c);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

int main() {
	std::ios::sync_with_stdio(false);
	LL N, K;
	cin >> N >> K;
	LL G;
	cin >> G;
	LL M = G;
	if (G == K) {
		cout << "POSSIBLE" << "\n";
		return 0;
	}
	for (LL n = 1; n < N; n++) {
		LL a;
		cin >> a;
		G = GCD(a, G);
		M = max(a, M);
		if (a == K) {
			cout << "POSSIBLE" << "\n";
			return 0;
		}
	}
	if (K % G == 0 && K <= M)cout << "POSSIBLE" << "\n";
	else cout << "IMPOSSIBLE" << "\n";
	return 0;
}


Measured memory_bytes: 256
fn main() {
  proconio::input! {
    a: usize,
    mut b: usize,
    mut c: usize,
    mut k: usize,
  }
  while a>=b && k>0 {
    b*=2;
    k-=1;
  }
  while b>=c && k>0 {
    c*=2;
    k-=1;
  }
  println!("{}",if a<b && b<c {"Yes"} else {"No"});
}

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

int main() {
    int N;
    std::vector<int> c(N);
    std::vector<int> v(N);

    std::cin >> N;

    for(int i = 0 ; i< N ; i++){
        std::cin >> v[i] ;
    }
    for(int i = 0 ; i< N ; i++){
        std::cin >> c[i] ;
    }
    int ans = 0;
    for(int i = 0 ; i< N ; i++){
        if(v[i] - c[i] > 0){
            ans += v[i] -c[i];
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

long kakezan(long a){
	int d=0, num[7];
	long t=a;
	
	while(t>0){
		++d;
		t/=10; 
	}
	//printf("d=%d\n", d);
	t=a;
	for(int i=0; i<d; ++i){
		num[d-i-1]=t%10;
		t/=10;	
	}
	/*	
	for(int i=0; i<d; ++i)
		printf("num[%d]=%d\n", i,num[i]);
	*/
	long ret=0;
	
	for(int i=1; i<d; ++i){ //分割位置
		long x=0, y=0;
		
		for(int j=0; j<i; ++j){
			x += num[j]*pow(10, i-j-1);	
		}
		
		for(int j=i; j<d; ++j){
			y += num[j]*pow(10, d-1-j);	
		}
		
		if(ret<x*y) ret=x*y;
	} 
	
	return ret;
}

int main(){
	int q;	
	long lim=10000000;
	
	scanf(" %d", &q);
	for(int i=0; i<q; ++i){
		long n, count=0;
		scanf(" %ld", &n);
		
		while(n>9 && count<lim){
			n=kakezan(n);
			++count;
			//printf(" %ld\n", n);
		}	
		
		if(count==lim) printf("-1\n");
		else printf("%ld\n", count);
	}
	
	return 0;
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int ind, ans;
    if(n & 1) {
        ind = n+1 >> 1;
        ans = b[ind] - a[ind] + 1;
    }
    else {
        ind = n >> 1;
        ans = b[ind] + b[ind+1]  - a[ind] - a[ind+1] + 1;
    }
    cout << ans << '\n';
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
#define N 10001
#define INF (1e9)
#define s second
#define f first
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
vector<PP> G[N];

int dijkstra(){
  P D[N];
  for(int i=0;i<N;i++) D[i]=P(INF,INF);
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(P(0,0),0));
  D[0]=P(0,0);
  int res=0;
  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int pos=t.s,d=t.f.f,c=t.f.s;
    if(D[pos]<t.f) continue;
    res+=c;
    for(int i=0;i<G[pos].size();i++){
      int nx=G[pos][i].f.f;
      int nd=G[pos][i].f.s+d;
      int nc=G[pos][i].s;
      if(D[nx]>P(nd,nc)) Q.push(PP(P(nd,nc),nx)),D[nx]=P(nd,nc);
    }
  }
  return res;
}

int main(){
  while(1){
  int n,m;
  cin>>n>>m;
  if(!n&&!m)break;
  for(int i=0;i<n;i++) G[i].clear();
  for(int i=0,a,b,d,c;i<m;i++){
    cin>>a>>b>>d>>c;
    G[a-1].push_back(PP(P(b-1,d),c));
    G[b-1].push_back(PP(P(a-1,d),c));
  }
  cout << dijkstra()<<endl;  
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define mp make_pair
typedef array<ll, 2> hv;

const int N = 1e5 + 10;
hv arr[N];

struct Cmp{
	bool operator() (const hv & a, const hv & b) {
		return a[0] - a[1] > b[0] - b[1];
	}
};

struct Sum {
	multiset<ll> big;
	multiset<ll> small;

	int k;

	ll sm;

	Sum() {}

	Sum(int k) : k(k), sm(0) {}

	void insert(ll a) {
		if (big.size() < k) {
			big.insert(a);
			sm += a;
			return;
		}	
		auto it = big.begin();
		if (*it < a) {
			small.insert(*it);
			sm -= *it;
			big.erase(it);
			big.insert(a);
			sm += a;
		} else {
			small.insert(a);
		}
		return;
	}

	void erase(ll a) {
		auto it = small.find(a);
		if (it != small.end()) {
			small.erase(it);
			return;
		}
		sm -= a;
		auto it1 = big.find(a);
		big.erase(it1);
		if (small.size() != 0) {
			auto it2 = small.end();
			it2--;
			big.insert(*it2);
			sm += *it2;
			small.erase(it2);
		}
		return;
	}
};

const ll INF = 1e18;

int main() {
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);	
	ll x, y, z;
	cin >> x >> y >> z;
	ll n = x + y + z;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		sum += c;
		arr[i][0] = a - c;
		arr[i][1] = b - c;
	}
	ll cur_res = -INF;
	sort(arr, arr + n, Cmp());
	Sum s1(x);
	Sum s2(y);
	for (int i = 0; i < n; i++)
		s2.insert(arr[i][1]);
	for (int i = 0; i < n; i++) {
//		cout << "s2 big:" << endl;
//		for (ll j : s2.big)
//			cout << j << " ";
//		cout << endl;
//cout << "s2 small:" << endl;
//		for (ll j : s2.small)
//			cout << j << " ";
//		cout << endl;
		s2.erase(arr[i][1]);
		s1.insert(arr[i][0]);
		if (i >= x - 1 && n - i > y) {
			if (s1.sm + s2.sm > cur_res) 
				cur_res = s1.sm + s2.sm;
		} 
	}
	cout << sum + cur_res << endl;
	return 0;
}


Measured memory_bytes: 6528
#! /usr/bin/env python3
# -*- coding:utf-8

FALSE_MESSAGE = "IMPOSSIBLE"

def harmony(a, b):
    if((a+b)%2): return FALSE_MESSAGE
    return int((a+b)/2)

def main():
    a, b = map(int, input().split())
    print(harmony(a, b))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

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


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

    int    n, k;
    string str;
    cin >> n >> k >> str;
    str.at(k - 1) = str.at(k - 1) + 32;
    cout << str << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int n,a,b;
    cin>>n;
    if(n==1){
        cout<<"Hello World";
    }else{
        cin>>a>>b;
        cout<<a+b;
    }
    return 0;
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is,1<<h)rep(js,1<<w) {
    int cnt = 0;
    rep(i,h)rep(j,w) {
      if (is>>i&1) continue;
      if (js>>j&1) continue;
      if (s[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
ab = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
li = [0 for _ in range(n+1)]
for a,b in ab:
    li[a] += 1
    li[b] += 1
for i in li:
    if i%2 == 1:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 28296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
using namespace std;
 
const int MAX= 10000100;
 
int main(void){
  int n;
    while(cin>>n,n){
      vector<vector<int> > vec(n+1,vector<int>(5));
      for(int i = 0 ; i < n+1 ; i++){
        for(int j = 0 ; j < 4 ; j ++){
          cin>>vec[i][j];
          //cout<<vec[i][j]<<" ";
        }
        vec[i][4]=vec[i][1]*4+vec[i][2]*9+vec[i][3]*4;
        //cout<<vec[i][4]<<endl;
      }
      
      //cout<<endl;
      bool no = true;
      for(int i = 0 ; i < n ; i ++){
        bool ans = true;
        for(int j = 1 ; j < 5 ; j ++){
          if(vec[i][j]>vec[n][j-1])ans = false;
        }
        if(ans){
          cout<<vec[i][0]<<endl;
          no = false;
        }
      }
      if(no)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1268
#include <stdio.h>
#define swap(X, Y) {ll tmp = (X); (X) = (Y); (Y) = tmp;}
typedef long long ll;

ll n;
ll a, b;

ll gcd(ll a, ll b);

int main()
{
	ll gcd_;
	scanf("%lld", &n);
	scanf("%lld %lld", &a, &b);
	gcd_ = gcd(a, b);

	for (int i = 2; i < n; i++) {
		scanf("%lld", &a);
		gcd_ = gcd(gcd_, a);
	}
	
	printf("%lld\n", gcd_);

	return 0;
}

ll gcd(ll a, ll b)
{
	if (b > a) {
		swap(a, b);
	}

	while (b) {
		ll r = a % b;
		a = b;
		b = r;
	}

	return a;
}


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

#define ll long long

using namespace std;

unordered_map <ll, ll> m1;
unordered_map <ll, ll> m2;

int main()
{
    ll a, b, res = 0;
    cin >> a >> b;
    ll j = 2;
    while(j * j <= a)
    {
        if(a % j == 0)
        {
            m1[j]++;
            a /= j;
        } else j++;
    }
    if(a > 1) m1[a]++;
    j = 2;
    while(j * j <= b)
    {
        if(b % j == 0)
        {
            m2[j]++;
            b /= j;
        } else j++;
    }
    if(b > 1) m2[b]++;
    for(auto &i : m1)
    {
        if(m2[i.first] > 0)
        {
            res++;
        }
    }
    cout << res + 1;
}


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

#define INF (1<<29)

int graph[11][11];

void wa(int m){

  for(int i=0;i<=m;i++){
    for(int j=0;j<=m;j++){
      for(int k=0;k<=m;k++){
	graph[j][k] = min(graph[j][k],graph[j][i]+graph[i][k]);
      }
    }
  }
  
}

int main(){
  int m,n,a,b,c;
  
  while(scanf("%d",&n),n!=0){
    
    m=0;
    fill_n(*graph,11*11,INF);
    
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&a,&b,&c);
      graph[a][b]=c;
      graph[b][a]=c;
      m = max(m,max(a,b));
    }
    
    for(int i=0;i<=m;i++) graph[i][i]=0;
    wa(m);
    
    int num,sum,ans=INF;
    for(int i=0;i<=m;i++){
      sum=0;
      for(int j=0;j<=m;j++) sum = graph[i][j]==INF?INF:sum+graph[i][j];
      if(sum < ans){
	num = i;
	ans = sum;
      }
    }
    printf("%d %d\n",num,ans);
  }
  return(0);
}



Measured memory_bytes: 2564
#include<stdio.h>
#include<math.h>
 
#define L_MAX 2000 
#define R_MAX 2000
 
int main(){
  int i,j,k;
  int n,x,y;
  int Line[L_MAX];
  int Row[R_MAX];
  double sum = 0;
  double ave;
  
  scanf("%d\n", &n);
  for(i = 0;i < n; i++){
    scanf("%d", &x);
    Line[i] = x;
    scanf("%d\n", &y);
    Row[i] = y;
  }
  for(j = 0; j < n; j++){
   for(k = 0; k < n; k++){
     sum += sqrt((Line[j] - Line[k])*(Line[j] - Line[k]) + (Row[j] - Row[k])*(Row[j] - Row[k]));
   }
  }
  ave = sum/n;
  printf("%f\n", ave);
  return 0;
}

Measured memory_bytes: 2180
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+10;
vector<int> adj[N];
int h[N];
int32_t main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	int u,v;
	for(int i=0;i<m;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	int ct=0;
	for(int i=1;i<=n;i++)
	{
		int tt=h[i];
		bool gg=1;
		for(auto x:adj[i])
		{
			if(tt<=h[x])gg=0;
		}
		
		if(gg)ct++;
	}
	
	cout<<ct;
	
	
	
	
}

Measured memory_bytes: 10152
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000];
int ans = 100000007;
int main() {
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for(int i = -150;i <= 150;i++) {
		int tmp = 0;
		for(int j = 0;j < n;j++) {
			tmp += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static double solve(List<String> list){
		int i = 2;
		for(; i < list.size(); i++){
			if( list.get(i).equals("+") || list.get(i).equals("-") || list.get(i).equals("*") || list.get(i).equals("/")){
				double x;
				if( list.get(i).equals("+") ){
					x = Double.parseDouble(list.get(i-2)) + Double.parseDouble(list.get(i-1));
				} else if( list.get(i).equals("-") ){
					x = Double.parseDouble(list.get(i-2)) - Double.parseDouble(list.get(i-1));
				} else if( list.get(i).equals("*") ){
					x = Double.parseDouble(list.get(i-2)) * Double.parseDouble(list.get(i-1));
				} else {
					x = Double.parseDouble(list.get(i-2)) / Double.parseDouble(list.get(i-1));
				}
				list.remove(i); list.remove(i-1); list.remove(i-2);
				list.add(i-2, Double.toString(x));
				i = 1;
			}
		}
		return Double.parseDouble(list.get(0));
	}
			
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));		
			while( stdIn.hasNext() ){
				String[] s = stdIn.nextLine().split(" ");
				List<String> express = new LinkedList<String>();
				for(String str : s){
					express.add(str);
				}
				System.out.printf("%.6f%n", solve(express));		
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

int main(){
  int l, r;
  cin >> l >> r;
  
  if(l/2019 != r/2019){
  	cout << 0 << endl;
  }
  else{
  	int m = 2019;
  for(int i = l; i < r; i++){
  for(int j = i+1; j <= r; j++){
  	int re = (long long)i*j%2019;
    m = min(m, re);
  }
  }
  cout << m << endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    //char S[4+1];
    int head;
    int tail;
    int yymm;
    int mmyy;

    scanf("%2d%2d", &head, &tail);

    if(head >= 0 && head <= 99 && tail >= 1 && tail <= 12) {
        yymm = 1;
    } else {
        yymm = 0;
    }

    if(head >= 1 && head <= 12 && tail >= 0 && tail <= 99) {
        mmyy = 1;
    } else {
        mmyy = 0;
    }

    if(yymm == 1 && mmyy == 1) {
        printf("AMBIGUOUS\n");
    } else if(yymm == 1 && mmyy == 0) {
        printf("YYMM\n");
    } else if(mmyy == 1) {
        printf("MMYY\n");
    } else {
        printf("NA\n");
    }

    return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    };

    let mut ans = std::usize::MAX;

    for i in *a.iter().min().unwrap()..*a.iter().max().unwrap() + 1 {
        let cost = a.iter().fold(0, |acc, x| acc + (x-i).pow(2) as usize);
        if cost < ans {
            ans = cost;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
using namespace std;
int N;
int dp[100005][3];
int happy[100005][3];
int main(){
    cin >> N;
    rep(i,N) cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    
    rep(i,3) dp[0][i] = happy[0][i];
    
    rep(i,N-1) rep(j,3) dp[i+1][j] = happy[i+1][j] + max(dp[i][(j+1)%3], dp[i][(j+2)%3]);
    
    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;
    
}

Measured memory_bytes: 2560