akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue


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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int cnt[3];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, s.size()) {
		cnt[s.at(i) - 'a']++;
	}
	if (abs(cnt[0] - cnt[1]) <= 1 && abs(cnt[0] - cnt[2]) <= 1 && abs(cnt[1] - cnt[2]) <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
    int D; cin >> D;
    if (D==25) cout << "Christmas";
    else if (D==24) cout <<"Christmas Eve";
    else if (D==23) cout << "Christmas Eve Eve";
    else if (D==22) cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	int h, w;
	cin >> h >> w;
	cout << (H - h)*(W - w) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#define upzero(n) if (n < 0) n = 0
#pragma GCC optimize("Ofast")
using namespace std;
ll int BtoPmodM(ll int b, ll int p, ll int m) { // (b ^ p) % m (Big Mod)
    b %= m;
    if (p == 0) return 1;
    else if (p % 2 == 0) return (BtoPmodM(b, p / 2, m) * BtoPmodM(b, p / 2, m)) % m; // a^(p/2) * a^(p/2) = a^p
    else if (p % 2 == 1) return (BtoPmodM(b, (p - 1) / 2, m) * BtoPmodM(b, (p - 1) / 2, m) * b) % m; // +1
    else return 0; // a function must return something
}
ll int euclid_algo(ll int a, ll int b) { // Euclidean Algorithm
    if (b == 0) return a;
    else return euclid_algo(b,a % b);
}
bool coprime(ll int a, ll int b) {
    if (euclid_algo(a, b) == 1) return true;
    else return false;
}
ll int factModP(ll int n, ll int p) {
    ll int fac[n - 1];
    fac[0] = 1;
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p;
    }
    return fac[n];
}
ll int power(ll int x, ll int y, ll int p) { // x ^ y % p
    ll int res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y /= 2; 
        x = (x * x) % p; 
    } 
    return res; 
}
ll int modInverse(ll int n, ll int p) {
    return power(n, p - 2, p); 
}
ll int nCrModP(ll int n, ll int r, ll int p) {
    if (r == 0) return 1;
    else if (r > n) return 0;
    ll int fac[n + 1]; 
    fac[0] = 1; 
    for (ll int i = 1;i <= n;i++) {
        fac[i] = fac[i - 1] * i % p; 
    }
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
ll int nCr(ll int n, ll int r) {
    ll int ans = 1;
     if (r >= n - r) {
         for (ll int i = r + 1;i <= n;i++) ans *= i;
         for (ll int i = 1;i <= n - r;i++) ans /= i;
     } else {
         for (ll int i = n - r + 1;i <= n;i++) ans *= i;
         for (ll int i = 1;i <= r;i++) ans /= i;
     }
     return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // implementation
    int n;
    cin >> n;
    ll int sum = 0;
    for (int i = 1;i <= n;i++) {
    	if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;
}

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

int main() {
	int n, y,i,j,sum=0,count=0,a,b,c;
	cin >> n >> y;
	for(i = 0; i <= n; i++){
		for(j = i; j <= n; j++){
			sum = 10000 * i + 5000 * (j - i) + 1000 * (n - j);
			if(sum == y){
				count++;
				a=i;
				b=j-i;
				c=n-j;
			}
		}
	}
	if(count>0)cout << a << " " << b << " " << c << endl;
    else cout << "-1 -1 -1" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
 
class Main
{
  public static void main(String args[])
  {
    int num;
    String buf;
    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      buf = br.readLine();
      num = Integer.parseInt(buf);
      System.out.println(num * num * num);
    } catch(Exception e) {}
  }
}


Measured memory_bytes: 24452
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////


int main(){fastio
    ll n,k;cin>>n>>k;
    ll res=1;
    rep(i,1,1000){
        res*=k;
        if(n<res){
            cout<<i<<endl;return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import Data.Char
import Data.List

conv (d3:d2:d1:d0:_) =
  d3 * 1000 + d2 * 100 + d1 * 10 + d0

next x =
  let d0 =  x             `mod` 10
      d1 = (x `div`   10) `mod` 10
      d2 = (x `div`  100) `mod` 10
      d3 = (x `div` 1000)
      l  = conv $ reverse $ sort [d0,d1,d2,d3]
      s  = conv $ sort [d0,d1,d2,d3]
  in
    l - s

ans n x =
  let y = next x
  in
    if y == 0
    then -1
    else if x == 6174
         then n
         else ans (n+1) $ next x
    
main = do
  c <- getContents
  let i = takeWhile (/= 0) $ map read $ lines c :: [Int]
      o = map (ans 0) i
  mapM_ (\ d -> if d == -1
                then putStrLn "NA"
                else putStrLn $ show d ) o

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) cout << "Zero" << endl;
	else if (a < 0) {
		int dist = abs(a) - abs(min(b, 0)) + 1;
		if (dist % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
	else cout << "Positive" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 mp make_pair
#define fi first
#define sc second
int n,m;
char s[2000000];
bool solve(){
    scanf("%d",&n);
    if(n == 0)
        return false;
    scanf("%d%s",&m,s);

    vector<int> S;

    REP(i,m){
        if(s[i] == 'I'){
            char c[] = {'O','I'};

            i++;bool f = false;int l = 1;
            while(i < m && s[i] == c[f]){
                l++;f = (!f);i++;
            }
            if(f)l--;
            if(i < m && s[i] == 'I')
                i--;
            if(l > 2 && l >= 2 * n + 1){
                S.pb(l);
            }
        }
    }
    int sum = 0;
    REP(i,S.size()){
        sum += (S[i] - 1) / 2 - n + 1;
    }
    printf("%d\n", sum);
    return true;
}
int main(){
    while(solve());
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

ll f(ll x) {
    if(x % 4 == 0) return x;
    if(x % 4 == 1) return 1;
    if(x % 4 == 2) return x+1;
    if(x % 4 == 3) return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = f(b);
    if(a) ans ^= f(a-1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
n,k,q=map(int,input().split())
pt=[0 for _ in range(n)]
for _ in range(q):
    a = int(input())
    pt[a-1] += 1
base=q-k
for p in pt:
    print("No" if p <= base else "Yes")

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999

using namespace std;

int32_t main(){
    int n;
    cin >> n;
    vector<int> v(n), b(n);
    REP(i, n){
        cin >> v[i];
        b[i] = v[i] - i;
    }
    SORT(b);

    if(n%2){
        int cnt=0, m=b[n/2];
        REP(i, n){
            cnt+=abs(b[i]-m);
        }
        cout << cnt << endl;
    }
    else{
        int cnt_1, cnt_2=cnt_1=0, m=b[n/2-1];
        REP(i, n){
            cnt_1+=abs(b[i]-m);
        }
        m=b[n/2];
        REP(i, n){
            cnt_2+=abs(b[i]-m);
        }

        cout << max(cnt_1, cnt_2) << endl;
    }
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
ll wight[101];
ll val[101];
ll dp[100010][102];
int main(){
  int n,w;
  cin >> n >> w;
  rep(i,n){
    cin >> wight[i] >> val[i];
  }
  for (int i=0;i <= w;i++){
    for (int j=0;j < n;j++){
      if (i < wight[j]) dp[i][j+1]=dp[i][j];
      else dp[i][j+1]=max(dp[i][j],dp[i-wight[j]][j]+val[j]);
    }
  }
  cout << dp[w][n] << endl;
  


    
  return 0;
}


Measured memory_bytes: 79872
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
typedef long int l;
#define f(i,a,b) for(l i=(l)a;i<(l)b;i+=1)
#define rf(i,a,b) for(l i=(l)a;i>=(l)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
using namespace std;
#define MAX 1000001 
l spf[MAX];
void precompute()
{
	spf[1] = 1;
	for (l i = 2; i < MAX; i++)
		spf[i] = i;

	for (l i = 4; i < MAX; i += 2)
		spf[i] = 2;

	for (l i = 3; i * i < MAX; i++)
	{
		if (spf[i] == i)
		{
			for (l j = i * i; j < MAX; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

int main()
{
	FAST;
	ll n;
	ll ans = 0;
	cin >> n;
	f(i, 1, n + 1)
	{
		f(j, 1, n + 1)
		{
			f(k, 1, n + 1)
			{
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict

n = int(input())
li = list(map(int, input().split()))

li_count = defaultdict(int)

# 要素ごとの出現数を記録
for a in li:
    li_count[a] += 1

max_x_count = 0

for x in range(1, 10**5):
    # xにできるやつ
    x_count = li_count[x-1] + li_count[x] + li_count[x+1]
    max_x_count = max(max_x_count, x_count)
print(max_x_count)

Measured memory_bytes: 20724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
ll v[20001], dp[2][1010];
ll a[2][1010],b[2][1010];
int main(){
	ll n,m,k;	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<m;j++){
			dp[i][j]=INF;
			b[i][j]=INF;
		}
	}
	dp[0][0]=k;	a[0][0]=b[0][0]=v[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<m;j++){
			if(dp[0][j]==INF)	continue;
			//その箱に追加する場合
			if(j+1<m){
				dp[1][j+1]=dp[0][j];
				a[1][j+1]=max((ll)a[0][j],v[i]);
				b[1][j+1]=min((ll)b[0][j],v[i]);
			}
			//新しく箱を作る場合
			ll num=k+dp[0][j];
			num+=(a[0][j]-b[0][j])*(j+1);
			dp[1][0]=min(dp[1][0],num);
			a[1][0]=b[1][0]=v[i];
		}
		for(int j=0;j<m;j++){
			dp[0][j]=dp[1][j];	dp[1][j]=INF;
			a[0][j]=a[1][j];	a[1][j]=0;
			b[0][j]=b[1][j];	b[1][j]=INF;
		}
	}
	ll ans=INF;
	for(int i=0;i<m;i++){
		ll num=dp[0][i];
		num+=(a[0][i]-b[0][i])*(i+1);
		ans=min(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
bool calc(int x, int y, int z){
    if(x == y || y == z || z == x) return false;
    int mx = max({x, y, z});
    int mn = min({x, y, z});
    int cn = x + y + z - mx - mn;
    return mx < mn + cn;
}
void Main(){
    int n;
    cin >> n;
    vector<int> a(n);
    For(i,0,n) cin >> a[i];
    For(i,0,n){
        For(j,i+1,n){
            For(k,j+1,n){
                if(calc(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

template<typename T> class segtree {
private:
    int n,sz,h; vector<T> node, lazy;
    vector<bool> lazyFlag;
    void eval(int k) {
        if(lazyFlag[k]){
            node[k] = lazy[k];
            if(k < n) {
                lazy[k*2] = lazy[k*2+1] = lazy[k];
                lazyFlag[k*2] = lazyFlag[k*2+1] = true;
            }
            lazyFlag[k] = false;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0){
        while(n < sz) n *= 2, h++;
        node.resize(2*n, numeric_limits<T>::max());
        lazy.resize(2*n); lazyFlag.resize(2*n, false);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n - 1; i >= 1; i--) node[i] = min(node[i*2], node[i*2+1]);
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] = x, lazyFlag[k] = true; eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = min(node[2*k], node[2*k+1]);
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = numeric_limits<T>::max(), res2 = numeric_limits<T>::max();
        while(a < b) {
            if(a & 1) eval(a), res1 = min(res1, node[a++]);
            if(b & 1) eval(--b), res2 = min(res2, node[b]);
            a >>= 1, b >>= 1;
        }
        return min(res1, res2);
    }
    void _print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll h[n]; zep(i, 0, n)cin >> h[i];
    ll a[n]; zep(i, 0, n)cin >> a[i];

    vector<ll> v(n+1, 0);
    segtree<ll> sg(v);
    zep(i, 0, n){
        sg.range(h[i], h[i]+1, sg.query(0, h[i])-a[i]);
    }
    print(-sg.query(0, n+1))
    return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

vector<vector<int>> nextidx(const string &s) {
    int n = s.size();
    vector<vector<int>> ret(n + 1, vector<int>(26, n));
    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j)
            ret[i][j] = ret[i + 1][j];
        ret[i][s[i] - 'a'] = i;
    }
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    map<char, int> cnts;
    for (int i = 0; i < (int)s.size(); ++i) {
        cnts[s[i]] = 1;
    }
    for (int i = 0; i < (int)t.size(); ++i) {
        if (cnts[t[i]] == 0) {
            cout << -1 << "\n";
            return 0;
        }
    }
    lint ns = s.size();
    s += s;
    auto idx  = nextidx(s);
    lint ret  = 0;
    lint curr = 0;
    for (int i = 0; i < (int)t.size(); ++i) {
        curr = idx[curr][t[i] - 'a'] + 1;
        if (curr >= ns) {
            curr %= ns;
            ret += ns;
        }
    }
    cout << ret + curr << "\n";
    return 0;
}

Measured memory_bytes: 27116
using System;
using System.Linq;

namespace ConsoleApp13
{
    class Program
    {
        static void Main(string[] args)
        {
            C();

        }

        static void A()
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            Console.WriteLine(6 - A - B);
        }

        static void B()
        {
            var N = int.Parse(Console.ReadLine());
            var ST = Console.ReadLine().Split();

            for (var i = 0; i < N; i++)
            {
                Console.Write(ST[0][i]);
                Console.Write(ST[1][i]);

            }

            Console.WriteLine();
        }

        static void C()
        {
            long[] AB = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            long A = AB[0];
            long B = AB[1];

            var big = Math.Max(A, B);
            var small = Math.Min(A, B);


            var r = big % small;
            var a = small;
            var b = r;
            while (r != 0)
            {
                r = a % b;
                a = b;
                b = r;
            }

            Console.WriteLine(A * B / a);

        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll x, a, b;
  in3(x, a, b);
  out((x - a) % b);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
# define INF 0x3f3f3f3f 

using namespace std;

ll val[12345];


void pre(){
    for(int i = 1; i <= 10; i++){
        int cur = i*(i+1)/2;
        int nx = (i+1)*(i+2)/2;
        for(int j = cur; j < nx; j++) val[j] = i;
    }
}

int main() {
   ll n;
   cin >> n;

   map <ll,ll> mp;
   pre();
   for(ll i = 2; i*i <= n; i++){
       if(n%i == 0){
           while(n%i == 0){
               n /= i;
               mp[i]++;
           }
       }
   }
   if(n > 1LL) mp[n]++;
   ll ans = 0;
   for(auto x:mp){
       ans += val[x.second];
   }
   cout << ans;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

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

int n, k, c[10];
map<string, int>m;

void dfs(int cnt, string s, int v[]){
  if(cnt == k){
    if(m.count(s)) return;
    m[s] = 1;
    return;
  }

  rep(i, n){
    if(v[i]) continue;
    v[i] = 1;
    stringstream ss;
    ss << c[i];
    dfs(cnt + 1, s + ss.str(), v);
    v[i] = 0;
  }
}

int main(){
  while(scanf("%d%d", &n, &k) && n+k){
    rep(i, n) scanf("%d", c+i);
    m.clear();
    string s = "";
    int v[10] = {};
    dfs(0, s, v);
    printf("%d\n", (int)m.size());
  }
  return 0;
}

Measured memory_bytes: 1556
count = [0 for i in range(100)]
while True:
    try:
        count[int(input()) - 1] += 1
    except:
        break
max_e = 0
max_i = []
for i in range(100):
    temp = max_e
    max_e = max(count[i], max_e)
    if temp == max_e and count[i] == max_e:
        max_i.append(i + 1)
    elif temp != max_e:
        max_i = [i + 1]
for i in max_i:
    print(i)



Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int h,w;
	cin>>h>>w;
	bool a[110][110]={};
	bool r[110]={},s[110]={};
	fori(h){
		forj(w){
			char hoge;
			cin>>hoge;
			a[i][j]=(hoge=='#');
			if(a[i][j]){
				r[i]=true;s[j]=true;
			}
		}
	}

	fori(h){
		forj(w){
			if(r[i]&&s[j]){
				cout<<((a[i][j])?'#':'.');
			}

		}
		if(r[i])
			cout<<"\n";
	}
}

Measured memory_bytes: 3588
N, M = map(int,input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = map(int,input().split())
count = [0]*N

for i in a:
    count[i-1] += 1
for i in b:
    count[i-1] += 1

if all([i%2==0 for i in count]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 12592
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    ans = ""
    for i in range(len(S)):
        if S[i] == "A":
            ans += "T"
        if S[i] == "T":
            ans += "A"
        if S[i] == "C":
            ans += "G"
        if S[i] == "G":
            ans += "C"
    print ans



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;


int main()
{
    ciosup;
    int n;
    cin >> n;
    vint h(n);
    REP(i, n) { cin >> h[i]; }
    int now = h[n - 1];
    bool flag = true;
    IREP(i, n)
    {
        if (h[i] - now > 1){
            flag = false;
            break;
        }else if (h[i]-now == 1){
            --h[i];
        }
        now = h[i];
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
// #include <bits/stdc++.h>
// #include <cstdint> 
// #include <limits>
using namespace std;
int md=998244353;
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int points[n][3];
    for(int i=0;i<n;++i) cin>>points[i][0]>>points[i][1]>>points[i][2];
    int result[n][3];
    result[0][0] = points[0][0];
    result[0][1] = points[0][1];
    result[0][2] = points[0][2];
    for(int i=1;i<n;++i){
        result[i][0] = max(result[i-1][1]+points[i][0],result[i-1][2]+points[i][0]);
        result[i][1] = max(result[i-1][0]+points[i][1],result[i-1][2]+points[i][1]);
        result[i][2] = max(result[i-1][1]+points[i][2],result[i-1][0]+points[i][2]);
    }
    int ans = max(result[n-1][0],result[n-1][1]);
    ans = max(ans,result[n-1][2]);
    cout<<ans;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
int a[N], cnt[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int sum = 0;
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    rep(i, 1, n) {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    rep(i, 1, n) {
        int x = a[i];
        int cntt = cnt[x] - 1;
        int ans = sum - cnt[x] * (cnt[x] - 1) / 2 + cntt * (cntt - 1) / 2;
        cout << ans << endl;
    }
    return 0;
}


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

#define fi first
#define se second
#define pb push_back

typedef long long LL;
typedef long double LD;

const LL INF = (1LL << 60);

typedef vector<LL> VLL;
LL knapsack_limitation(VLL& v, VLL& w, VLL& m, int n, LL W);

int main() {

  ios_base::sync_with_stdio(0); cin.tie(0);

  int n; LL W;
  cin >> n >> W;

  VLL v, w, m;
  v.assign(n + 1, 0);
  w.assign(n + 1, 0);
  m.assign(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> v[i] >> w[i] >> m[i];
  }

  LL ans = knapsack_limitation(v, w, m, n, W);

  cout << ans << endl;

  return 0;
}

/**
 *
 * tested on http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_F
 */
LL dp[2005][10005];
LL knapsack_01(VLL& v, VLL& w, int n, LL W) {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = dp[i-1][j];
      if (w[i] <= j)
        dp[i][j] = max(dp[i][j],
                       dp[i-1][j-w[i]] + v[i]);
    }
  }
  return dp[n][W];
}

LL knapsack_limitation(VLL& v, VLL& w, VLL& m, int n, LL W) {
  VLL vv, ww; 
  vv.pb(0);
  ww.pb(0);

  int nn = 0;
  for (int i = 1; i <= n; i++) {
    for (LL mult = 1; m[i]; m[i] -= mult, mult = min(mult << 1, m[i])) {
      vv.pb(v[i] * mult);
      ww.pb(w[i] * mult);
      nn++;
    }
  }

  LL ans = knapsack_01(vv, ww, nn, W);

  return ans;
}


Measured memory_bytes: 112576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  ll q = n;
  int s = 0;
  while(1){
    if(n/10 == 0){
      s += n%10;
      break;
    }
    s += n%10;
    n /= 10;
  }
  if(q%s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int n,Count;
std::vector<int> Before,After;

int main(){
	while(std::cin>>n, n){
		Count=0;
		Before.clear();
		Before= After= std::vector<int>(n,0);
		for(int i=0;i<n;++i)
			std::cin>>Before[i];
		
		while(1){
			for(int i=0;i<n;++i){
				After[i]=std::count(Before.begin(),Before.end(),Before[i]);
			}
			if(Before==After)break;
			Before=After;
			++Count;
		}
		
		std::cout<<Count<<std::endl;
		for(int i=0;i<n;++i)
			std::cout<<Before[i]<<(i==n-1?"\n":" ");
	}
	return 0;
}

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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	vector<ll> sd(N + 1), sm(N + 1);
	for (int i = 0; i < N; i++) {
		sd[i + 1] = sd[i] + (S[i] == 'D');
		sm[i + 1] = sm[i] + (S[i] == 'M');
	}
	vector<ll> sum(N + 1);
	for (int i = 0; i < N; i++) {
		sum[i + 1] = sum[i] + (S[i] == 'M' ? sd[i] : 0);
	}
	int Q;
	cin >> Q;
	while (Q--) {
		int k;
		cin >> k;
		ll res = 0;
		for (int i = 0; i < N; i++) if (S[i] == 'C') {
			int l = max(i + 1 - k, 0);
			res += (sum[i] - sum[l]) - (sm[i] - sm[l]) * sd[l];
		}
		cout << res << endl;
	}
	return 0;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n;
int x[125252],y[125252];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
pll ps[430252];
pll ch[252521];

pll operator+(const pll &a,const pll &b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(const pll &a,const pll &b){
  return pll(a.first-b.first,a.second-b.second);
}
ll dot(const pll &a,const pll &b){
  return a.first*b.first + a.second*b.second;
}
ll cross(const pll &a,const pll &b){
  return a.first*b.second - a.second*b.first;
}
double norm(const pll &a){
  return sqrt(dot(a,a));
}
int ccw(const pll &a,const pll &b,const pll &c){
  ll cr = cross(b-a,c-a);
  if(cr>0)return -1;
  else if(cr==0)return 0;
  else return 1;
}

int main(){
  scanf("%d",&n);
  x[0]=y[0]=0;
  FOR(i,1,n){
    int s,t;
    scanf("%d%d",&s,&t);
    x[i]=x[s]+dx[t];
    y[i]=y[s]+dy[t];
  }
  REP(i,n){
    ps[4*i+0] = pll(x[i]+0,y[i]+0);
    ps[4*i+1] = pll(x[i]+0,y[i]+1);
    ps[4*i+2] = pll(x[i]+1,y[i]+0);
    ps[4*i+3] = pll(x[i]+1,y[i]+1);
  }
  sort(ps,ps+4*n);
  int m = unique(ps,ps+4*n)-ps;
  // spaghetti source
  int k = 0;
  REP(i,m){
    while(k>=2 && ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
    ch[k++] = ps[i];
  }
  int t = k;
  FORR(i,0,m-1){
    while(k>=t+1 && ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
    ch[k++] = ps[i];
  }
  --k;
  int x,y,z;
  x=y=z=0;
  double ans = 1e25;
  // DEBUG(k);
  REP(i,k){
    pll a = ch[i];
    pll b = i<k-1?ch[i+1]:ch[0];
    pll u = b-a;
    pll v = pll(-u.second,u.first);
    // printf("%lld,%lld\n",a.first,a.second);
    // printf("%lld,%lld\n",b.first,b.second);
    // printf("%lld,%lld\n",u.first,u.second);
    // printf("%lld,%lld\n",v.first,v.second);
    while(cross(v,ch[x]-a)>=cross(v,ch[x+1]-a))x=(x+1)%k;
    if(i==0)y=x;
    while(cross(u,ch[y]-a)>=cross(u,ch[y+1]-a))y=(y+1)%k;
    if(i==0)z=y;
    while(cross(v,ch[z]-a)<=cross(v,ch[z+1]-a))z=(z+1)%k;
    double h = (double)cross(u,ch[y]-a) / norm(u);
    double w = (double)cross(v,ch[z]-ch[x]) / norm(v);
    // DEBUG(x);
    // DEBUG(y);
    // DEBUG(z);
    // DEBUG(h);
    // DEBUG(w);
    CHMIN(ans,abs(h*w));
  }
  printf("%.9lf\n",ans);
  return 0;
}

Measured memory_bytes: 12684
#include<iostream>
#include<string>

using namespace std;
using std::string;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b > c) {
		cout << "Yes" << endl;
	}
	else if (a + b == c) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int N;
ll h[100010],dp[100010];

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>N;
	int K;	cin>>K;
	FOR(i,0,N)	cin>>h[i];
	dp[0]=0;
	FOR(i,1,N)	dp[i]=INF;
	
	FOR(i,0,N){
		FOR(k,1,K+1){
		chmin(dp[i+k],dp[i]+abs(h[i]-h[i+k]));
		}
	}
	
	cout<<dp[N-1]<<endl;

    return 0;
}




Measured memory_bytes: 1792
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,BigInt(x).modPow(2,n).toLong, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,BigInt(x).modPow(2,n).toLong,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5000) !(2 to Math.sqrt(n).toInt).exists(n%_ == 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> isPrime(readInt) })
  }
}

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

int main() 
{
	int a, b, c;
	cin >> a >> b >> c;
	int gcd = __gcd(a, b);
	int copy = gcd + 1;
	while (c > 0)
	{
		copy--;
		if (gcd % copy == 0) c--;
	}
	cout << copy;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 100000000;
using namespace std;

int countOsenbei(bool b[10][10000], bool isReverse[10], int h, int w){
    int total = 0;
    rep(i,w){
        int cnt = 0;
        rep(j,h){
            if(isReverse[j]){
                if(not b[j][i]) cnt++;
            }else{
                if(b[j][i]) cnt++;
            }
        }
        //show(cnt)
        total += max(cnt, h - cnt);
    }
    //show(total)
    return total;
}

int main(){
    int h, w;
    bool b[10][10000];

    while(cin >> h >> w, h||w){
        rep(i,h) rep(j,w) cin >> b[i][j];

        int ans = 0;
        rep(i,(1 << h)){
            int bit = 0;
            bool isReverse[10] = {0};
            rep(j,h){
                if((i >> j & 1) == 1){
                    isReverse[j] = 1;
                    bit++;
                }
            }
            if(bit > 5) continue;

            ans = max(ans, countOsenbei(b, isReverse, h, w));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3112
#include <stdio.h>
 
using namespace std;
 
 
int main(){
    int n,a,b,c,A,B,C;
    scanf("%d",&n);
 
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&a,&b,&c);
        A = a*a;
        B = b*b;
        C = c*c;
        if(A+B==C||B+C==A||C+A==B){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    string S; cin>>S;
    int s = S.size();
    vec count(2019,0);
    int t = 0; count[t]++;
    int p = 1;
    int ans = 0;
    IREP(i,s){
        t += p*(S[i]-'0');
        t %= 2019;
        p *= 10;
        p %= 2019;
        ans += count[t];
        count[t] ++;  
    }
    Out(ans);
}

Measured memory_bytes: 3736
import bisect
 
N, K = map(int, input().split())
V = [int(_) for _ in input().split()]
ans = 0
M = min(N, K)
 
for i in range(M+1):
    for j in range(M-i+1):
        tmplist = sorted(V[:i] + V[-1:-1-j:-1])
        minusindex = bisect.bisect_left(tmplist, 0)
        if minusindex == 0:
            tmpans = sum(tmplist)
        else:
            tmpans = sum(tmplist) - sum(tmplist[:min(minusindex, K-(i+j))])
            
        if tmpans > ans:
            ans = tmpans
 
print(ans)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

tmp = 0
for a in A:
	tmp += 1/a
print(1/tmp)


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

int main() {
    string S;
    int N;

    cin >> N >> S;

    rep(i, S.size()){
        int x = S[i] - 'A';
        x += N;
        x %= 26;
        S[i] = 'A' + x;
    }

    cout << S << endl;
    
}

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

typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ld k,n;	cin>>n>>k;
	ld p,ans=0,s;
	vector<ld> vec;
	FOR(i,0,n){
		cin>>p;
		vec.push_back(p);
	}
      s=accumulate(vec.begin(),vec.begin()+k,0);
 	  ans=s;
 	FOR(i,0,n-k){
      s=s-vec.at(i)+vec.at(i+k);
      ans=max(s,ans);
    }
  
	ld a=(ans+k)/2;
 	cout.setf(ios::fixed);
	cout<<a<<endl;

    return 0;
}

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

namespace ABC94A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, X;
            String[] str = Console.ReadLine().Split(' ');
            A = int.Parse(str[0]);
            B = int.Parse(str[1]);
            X = int.Parse(str[2]);

            if ((A + B) >= X && A <= X)
                Console.Write("YES");
            else
                Console.Write("NO");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int k= scan.nextInt();
		scan.close();

		int sum=1;
		for(int i=0;i<n;i++) {
			sum=Math.min(sum*2, sum+k);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21716
#include <cstdio>

int n, d[4001], c[2001];

main(){
  for(int i=0;i<1001;i++) for(int j=0;j<1001;j++) c[i+j]++;
  for(int i=0;i<2001;i++) for(int j=0;j<2001;j++) d[i+j] += c[i] * c[j];
  while(scanf("%d", &n) != EOF) printf("%d\n", d[n]);
}

Measured memory_bytes: 1052
/*input
23
1 1 1
2 1 1
*/
#include "bits/stdc++.h"
using namespace std;
int n,a[2][3],b[3];
long long solve(int n, int p){
	vector<long long> dp(n+1);
	for(int i=1;i<=n;++i) for(int j=0;j<3;++j)
		if(a[p][j] < a[!p][j] && i-a[p][j]>=0) 
			dp[i] = max(dp[i],a[!p][j]-a[p][j]+dp[i-a[p][j]]);
	return dp[n] + n;
}
int main(){
	cin>>n;
	for(int j=0;j<2;++j) for(int i=0;i<3;cin>>a[j][i++]);
	cout<<solve(solve(n,0),1);
}

Measured memory_bytes: 195584
#include<iostream>
using namespace std;
int main(){
  int a[101];
  int N,i,max,min;
  cin >> N;
  cin >> a[0];
  cin >> a[1];
  if(a[0] > a[1]){
    max = a[0];
    min = a[1];
  }
  else{
    min = a[0];
    max = a[1];
  }
  for(i = 2;i < N;i++){
    cin >> a[i];
    if(a[i] > max) max = a[i];
    if(a[i] < min) min = a[i];
  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
const int MOD = 1e9+7;

int n;
long long a[N],sum[N];
long long ans;

long long exgcd(int a,int b,int &x,int &y){
	if(b==0){
		x=1;y=0;return a;
	}	
	int tmp=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return tmp;
}

long long INV(int a,int m){
	int x,y;
	exgcd(a,m,x,y);
	return (x%m+m)%m;
}

int main() {
	
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",a+i);
	for(int i=1;i<=n;++i){
		long long inv=INV(i,MOD)%MOD;
		sum[i]=(inv+MOD)%MOD;
		sum[i]=(sum[i]+sum[i-1])%MOD;
	}
	
	for(int i=1;i<=n;++i)
		ans=( ( ans + a [ i ] * ( ( sum [ i ] + sum [ n - i +1 ] - 1 ) % MOD ) ) % MOD ) % MOD;
	for(int i=1;i<=n;++i)
		ans=(ans*i)%MOD;
	
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int N, W; 
int value[110], weight[110];
ll dp[110][100010] = {0}; //dpの中身は価値、dp[N][weight]

int main(void){
    
    cin >> N >> W;
    REP(i, N) cin >> value[i] >> weight[i];

    
    dp[0][0] = 0; // 初期設定

    for(int i = 0; i < N; i++){
        for(int w = 0; w <= W; w++){
            if(w - weight[i] >= 0)  chmax(dp[i + 1][w], dp[i][w - weight[i]] + value[i]);

            chmax(dp[i + 1][w], dp[i][w]);
        }
    }

    cout << dp[N][W] << endl;


}


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

namespace TYC
{
	typedef long long ll;
	const int N = 105;

	int n, dep[N], fa[N], deg[N], mxd[N];
	vector<int> E[N];

	void dfs(const int u, const int f)
	{
		dep[u] = dep[fa[u] = f] + 1;
		for (int v : E[u])
			if (v != f)
				dfs(v, u);
	}

	inline void add(const int u, const int v)
	{
		E[n].clear();
		E[n].push_back(u);
		E[n].push_back(v);
		E[u].erase(find(E[u].begin(), E[u].end(), v));
		E[v].erase(find(E[v].begin(), E[v].end(), u));
	}

	inline void restore(const int u, const int v)
	{
		E[n].clear();
		E[u].push_back(v);
		E[v].push_back(u);
	}

	ll solve(const int o)
	{
		dfs(o, 0);
		memset(mxd, 0, sizeof(int[n + 1]));
		int len = 0;
		for (int i = 1; i <= n; i++)
		{
			len = max(len, dep[i]);
			mxd[dep[i]] = max(mxd[dep[i]], deg[i] - (i != o));
		}
		ll ans = 1;
		for (int i = len - 1; i; i--)
			ans = ans * mxd[i];
		return ans;
	}

	void work()
	{
		scanf("%d", &n);
		if (n == 2)
			return void(puts("1 2"));
		for (int i = 1, u, v; i < n; i++)
		{
			scanf("%d%d", &u, &v);
			deg[u]++, deg[v]++;
			E[u].push_back(v);
			E[v].push_back(u);
		}
		int s = 1, t = 1;
		dfs(1, 0);
		for (int i = 2; i <= n; i++)
			if (dep[s] < dep[i])
				s = i;
		dfs(s, 0);
		for (int i = 2; i <= n; i++)
			if (dep[t] < dep[i])
				t = i;
		int o = t;
		while (dep[o] > (dep[t] + 1) / 2)
			o = fa[o];
		printf("%d ", dep[o]);
		if (dep[t] & 1)
		{
			ll ans = solve(o);
			deg[++n] = 2;
			vector<int> P;
			for (int p : E[o])
				P.push_back(p);
			for (int p : P)
			{
				add(o, p);
				ans = min(ans, solve(n));
				restore(o, p);
			}
			printf("%lld\n", ans);
		}
		else
		{
			int p = t;
			while (fa[p] != o)
				p = fa[p];
			deg[++n] = 2;
			add(o, p);
			printf("%lld\n", solve(n));
		}
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 256