akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2E5+10;
int n,x;
int a[N],opt[N];
long long sum[N],ans=100000000000000000ll;
int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	long long s=0;
	for(int k=1;k<=n;k++){
		long long res=1ll*(n+k)*x+s,d=1;
		for(int i=n;i>0;i-=k){
			int j=max(0,i-k);
			long long x=d*d*k,q=2*d+1;d++;
			res+=(sum[i]-sum[j])*max(q,5ll);
			if(res>ans) break;
		}
		ans=min(res,ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,n;
    cin >> n >> k;
    vector<pair<ll,ll> > dt(n);
    REP(i,n){
        ll t,d;
        cin >> t >> d;
        t--;
        dt[i] = make_pair(d,t);
    }
    sort(rALL(dt));
    vint used(n,0);
    ll ans=0;
    vll v;
    ll cnt = 0;
    REP(i,k){
        auto p = dt[i];
        ans += p.fi;
        if(used[p.se]==0){
            used[p.se]=1;
            cnt++;
        }else{
            v.pb(p.fi);
        }
    }
    sort(rALL(v));
    ans+=cnt*cnt;
    ll pre = ans;
    int now = k;
    for(int i = cnt+1;i<=k;i++){
        while(now<n){
            ll tmp = ans;
            auto p = dt[now];
            if(used[p.se]==0){
                tmp = pre-v.back()+p.fi+2*cnt+1LL;
                v.pop_back();
                used[p.se]=1;
                ans = max(tmp,ans);
                pre = tmp;
                cnt++;
                now++;
                break;
            }
            now++;
        }
    }
    cout <<  ans << endl;

    return 0;
}

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

void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
int main() 
{   
    fast();
    string s;
    cin>>s;
    int ok1=0,ok2=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A')
            ok1=1;
        if(s[i]=='B')
            ok2=1;
    }
    if(ok1+ok2==2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// AOJ DSL_4_A Union of Rectangles
// 2018.5.14 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 2005
#define MAX   4005

typedef struct { int x1, y1, x2, y2; } TBL;
TBL tbl[MAX_N];

int x[MAX], xs;
int y[MAX], ys;
short s[MAX][MAX];

int cmp(int *a, int *b) { return *a - *b; }

int xbsch(int a)
{
	int m, l = 0, r = xs;

    while (l < r) {
        m = (l + r) >> 1;
        if (x[m] < a) l = m + 1; else r = m;
    }
	return l;
}
int ybsch(int a)
{
	int m, l = 0, r = ys;

    while (l < r) {
        m = (l + r) >> 1;
        if (y[m] < a) l = m + 1; else r = m;
    }
	return l;
}

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int main()
{
	int N, i, j, x1, y1, x2, y2;
	long long ans;

	N = in(); xs = ys = 0;
	for (i = 0; i < N; i++) {
		tbl[i].x1 = x1 = in(), tbl[i].y1 = y1 = in();
		tbl[i].x2 = x2 = in(), tbl[i].y2 = y2 = in();
		x[xs++] = x1, x[xs++] = x2;
		y[ys++] = y1, y[ys++] = y2;
	}
	qsort(x, xs, sizeof(int), cmp); // xs = uniq(x, xs);
	qsort(y, ys, sizeof(int), cmp); // ys = uniq(y, ys);

	for (j = 0, i = 0; i < N; i++) {
		x1 = xbsch(tbl[i].x1), x2 = xbsch(tbl[i].x2);
		y1 = ybsch(tbl[i].y1), y2 = ybsch(tbl[i].y2);

		s[y1][x1]++, s[y1][x2]--;
		s[y2][x1]--, s[y2][x2]++;
	}

	ans = 0;
	for (j = 0; j < ys; j++) {
		for (i = 1; i < xs; i++) s[j][i] += s[j][i-1];
	}

	for (j = 1; j < ys; j++) {
		for (i = 0; i < xs; i++) s[j][i] += s[j-1][i];
	}

	for (j = 0; j < ys; j++) {
		for (i = 0; i < xs; i++) if (s[j][i]) {
			ans += (long long)(x[i+1]-x[i])*(long long)(y[j+1]-y[j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}



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

int main() {
	int N;	// N円支払う.
	int A;	// 1円硬貨の枚数.
	cin >> N;
	cin >> A;
	if ((N % 500) <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
//(a + b ) % m = (a % m + b % m ) %m
//(a - b ) % m = ( (a % m - b % m ) + m ) %m
//(a * b ) % m = (a % m * b % m ) %m
//(a / b ) % m = (a % m * inv(b) ) %m where inv(b) = pow(b,m,m-2)



ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}


void solve(){
	ll i,j,n,k,d,A;
	cin>>n>>k;
	ll sum=0;
	ll snack[n+1]={0};
	for(i=0;i<k;i++){
		cin>>d;
		for(j=1;j<=d;j++){
			cin>>A;
			snack[A]=1;
		}
	}
	for(i=1;i<=n;i++){
		if(snack[i]==0){
			sum++;
		}
	}
	cout<<sum<<endl;
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

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

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ld n;
    ld p = 3.14159265358979323846;
    cin >> n;
    cout << fixed << setprecision(10) << p*n*2.0 << endl;
}


Measured memory_bytes: 3804
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int[] ans = new int[n + 1];
		int n2 = (int) Math.sqrt(n);
		for (int x = 1; x <= n2; x++) {
			for (int y = x; y <= n2; y++) {
				for (int z = y; z <= n2; z++) {
					int v = x*x + y*y + z*z + x*y + y*z + z*x;
					if (v > n) {
						break;
					}
					int cnt = 0;
					if (x == y) {
						cnt++;
					}
					if (y == z) {
						cnt++;
					}
					if (cnt == 0) {
						ans[v] += 6;
					} else if (cnt == 1) {
						ans[v] += 3;
					} else {
						ans[v]++;
					}
				}
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 1; i <= n; i++) {
			pw.println(ans[i]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 36800
N = int(input())
P = [int(i) for i in input().split(' ')]
Q = [int(i) for i in input().split(' ')]

fact = [1] * 8
for i in range(1,8):
    fact[i] = fact[i-1] * i

a = 0
remain = list(range(1,N+1))

for i , v  in enumerate(P):
    num = remain.index(v)
    remain.remove(v)
    a += num * fact[(N - i - 1)]

b = 0
remain = list(range(1,N+1))

for i , v  in enumerate(Q):
    num = remain.index(v)
    remain.remove(v)
    b += num * fact[(N - i - 1)]

print(abs(b-a))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define booga cout << "booga" << endl
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

void testcase(){

}

int main(int argc, char** argv){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	double curr = 0,inp;
	while(n--){
		cin >> inp;
		curr += 1 / inp;
	}
	cout << fixed << setprecision(5) << 1 / curr << "\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
         
int main(){
    int n ;
    cin >> n;
    vector<int> a (n) ;
    rep(i, n){
        cin >> a[i] ;
    }
    deque<int> d ; 
    rep(i, n){
        int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin() ;
        if(p == 0){
            d.push_front(a[i]) ;
        }
        else {
            d[p - 1] = a[i] ;
        }
    }
    int ans = d.size() ;
    cout << ans << endl ;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint cur = 100;
  lint x; cin >> x;
  for (lint i = 1;; i++) {
    cur *= 1.01;
    if (cur >= x) {
      cout << i << endl;
        return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    int ans = 0;
    rep(i,N+1){
        int d = i*1.08;
        if(d == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ch="abcdefghijklmnopqrstuvwxyz";
	long long int n;
	cin>>n;
	string s="";
	if(n<=26)
	{
		cout<<ch[n-1];
		return 0;
	}
	while(n)
	{
		int x=n%26;
		if(x)
		{
			s=ch[x-1]+s;
		}
		else
		{
			s = 'z'+s;
		}
		if(!x)
		{
			n/=26;
			n--;
		}
		else
		{
			n/=26;
		}
	}
	cout<<s<<endl;
    return 0;
}/*RUSTAM1111 🦁🦁🦁💪💪💪😎😎😎🔥🔥🔥🔥⚔️⚔️⚔️*/



Measured memory_bytes: 3556
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1,N):
  S[i] = S[i-1] + L[i]
c = 1
for i in range(N):
  if S[i] > X:
    break
  c += 1
print(c)

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll r;
  cin >> r;

  cout << (r < 1200 ? "ABC" : r < 2800 ? "ARC" : "AGC") << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int a,b,c,i;
	int ans;
	
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%d %d",&b,&c);
		ans=b%c;
		if(ans==0){
			printf("%d\n",c);
		}else{
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 2728
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct p{
    int x, y;
};

int main()
{
    int h, w, d; cin >> h >> w >> d;
    int n = h*w;
    vector<p> pos(h*w);
    rep(i, h) rep(j, w){
        int t;
        cin >> t;
        pos[t-1] = {i, j};
    }

    vint a(n, 0);
    // vector<bool> seen(h*w, false);
    rep(i, n){
        if(a[i]!=0) break;
        for(int j=i+d; j<n; j+=d){
            a[j] += a[j-d];
            a[j] += abs(pos[j].x - pos[j-d].x) + abs(pos[j].y - pos[j-d].y);
        }
    }
    // prvec(a);

    int q; cin >> q;
    rep(i, q){
        int f, t; cin >> f >> t;
        f--; t--;
        pr(a[t] - a[f]);
    }
    return 0;}

Measured memory_bytes: 4308
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define ll long long

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans1=min(a,b);
  int ans2=max(0,a+b-n);
  cout<<ans1<<" "<<ans2<<endl;

}


Measured memory_bytes: 888
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

void printa(vector<int>& a)
{
	for(int i = 0; i < a.size(); i++)
	{
		printf("%d%s", a[i], (i == a.size()-1?"\n":" "));
	}
}

void judge(vector<int>& num, int n, int prev)
{
	if(n == 0)
	{
		printa(num);
	}
	for(int i = n; i > 0; i--)
	{
		if(prev < i)
		{
			continue;
		}
		num.push_back(i);
		judge(num, n - i, i);
		num.pop_back();
	}
	return;
}

/*
   0 , 5
   5 , 0

   4 , 1
   4 1 , 0

   3 , 2
   3 2, 0

   3 1 , 1
   3 1 1, 0

   2 , 3
   2 3 , 0

   2 2 , 1
   2 2 1 ,0

   1, 4
   1 4, 0

   1 3, 1
   1 3 1, 0
   1 2, 2
   1 2 2, 0
   1 2 1 1, 0

   1 1 , 3
   1 1 3 , 0

   1 1  ,
   1 1 1 1 , 0
   1 
   */
int main()
{
	int n;
	while(cin >> n)
	{
		vector<int> num;
		judge(num, n, 100);
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

ll factorial(ll n) {
    if (n == 0) return 1;
    return n % MOD * factorial(n - 1) % MOD;
}

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

    int n, m; cin >> n >> m;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
        return 0;
    }

    ll ans;
    if (abs(n - m) == 1) {
        ans = factorial(n) % MOD * factorial(m) % MOD;
    } else {
        ans = 2 * factorial(n) % MOD * factorial(m) % MOD;
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n,k;
    sc(n);sc(k);
    int arr[30];
    reset(arr, 0);
    char str[15];
    FOR(i,n){
        scanf("%s", str);
        arr[str[0]-'A']++;
    }
    int tot = 0;
    while(true){
        int ct = 0;
        bool valid = false;
        sort(arr, arr + 26);
        for(int i = 25;i>=0;i--){
            if(arr[i]){
                arr[i]--;
                ct++;
            }
            if(ct == k){
                tot++;
                valid = true;
                break;
            }
        }
        if(!valid)break;
    }

    cout << tot << endl;

    return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using LL = long long;

class Solution {
public:
	/* time: O(n + m), space: O(n), where n = # of items, m = # of tickets */
	LL powerfulDiscountTickets(const vector<int>& items, int m) {
		LL ans = 0;
		for (int item : items)
			ans += item;

		priority_queue<int> candidates(items.begin(), items.end());
		for (int i = 0; i < m; ++i) {
			const int before = candidates.top(), after = before / 2;
			candidates.pop(), candidates.push(after);
			ans -= before, ans += after;
		}
		return ans;
	}
};

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

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

	Solution sol;
	LL ans = sol.powerfulDiscountTickets(items, m);
	cout << ans << endl;
	return 0;
}


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

int main()
{
  int h,w;
  for(;cin>>h>>w,h||w;)
    {
      //  char maps[h][w];
      int tate[h][w];
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  {
	    char tmp;
	    cin>>tmp;
	    if(tmp=='*')
	      {
		tate[i][j]=0;
	      }
	    else
	      {
		if(i==0)
		  tate[i][j]=1;
		else
		  tate[i][j]=tate[i-1][j]+1;
	      }
	  }
      //      cout<<endl;
      int ans=0;
      for(int i=h-1;i>=0;i--)
	for(int j=w-1;j>=0;j--)
	{
	  int cnt=0;
	  int min_tate=99999;
	  for(int k=j;k>=0;k--)
	    {
	      if(tate[i][k]>0)
		{
		  min_tate=min(min_tate,tate[i][k]);
		  cnt++;
		  ans=max(ans,min_tate*cnt);
		  //	  	  cout<<ans<<endl;
		}
	      else
		break;
	    }
	}
      cout<<ans<<endl;

    }

}

Measured memory_bytes: 2136
import sys
input=sys.stdin.readline
n=int(input())

ans=0
for i in range(1,n+1):
    ans+=i*(i+1)//2

for _ in range(n-1):
    u,v=map(int,input().split())
    if u>v:
        u,v=v,u
    ans-=u*(n+1-v)

print(ans)


Measured memory_bytes: 80172
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
	
int main(){
	init();
	ll A,B;cin>>A>>B;
	if(A+B>9)cout<<"error"<<endl;
	else cout<<A+B<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
pairs = []
res = []
for _ in range(m):
	pair = list(map(int, input().split()))
	pairs.append(pair)
for i in range(1, n+1):
	c = 0
	for j in pairs:
		if i in j:
			c += 1
	res.append(c)
for i in res:
	print(i)

Measured memory_bytes: 9076
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int n = stdIn.nextInt();
			if(n==0) break;
			int check = 0;
			int count = 0;
			for(int i=1;i<n;i++){
				check = i;
				for(int j=i+1;j<n;j++){
					check+=j;
					if(n==check){
						count++;
						break;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 19924
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b;
  cin >> a >> b;
  ll tap = 1;
  ll count = 0;
  while (tap < b){
    tap += a - 1;
    count++;
  }
  print(count);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	stack<int> st;
	while (cin >> s) {
		if (isdigit(s[0]))st.push(stoi(s));
		else {
			int v2 = st.top(); st.pop();
			int v1 = st.top(); st.pop();
			if (s[0] == '+')st.push(v1 + v2);
			if (s[0] == '-')st.push(v1 - v2);
			if (s[0] == '*')st.push(v1 * v2);
		}
	}
	cout << st.top() << endl;
	return 0;
}


Measured memory_bytes: 3184
# C - Traveling Salesman around Lake
K,N = list(map(int, input().split()))
A = list(map(int, input().split()))

a = A[1] - A[0]
for i in range(1,N-1):
    j = i + 1
    a = max(a,A[j]-A[i])

b = K-(A[N-1]-A[0])
c = max(a,b)
ans = K -c
print(ans)

Measured memory_bytes: 26444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1001
  
void count(char *A,char *B){
  int i,j,x[N][N];
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      x[i][j]=0;
    }
  }
  for(i=0; i<strlen(A); i++){
    for(j=0; j<strlen(B); j++){
      if(A[i]==B[j])x[i+1][j+1]=x[i][j]+1;
      else if(x[i][j+1]>x[i+1][j]) x[i+1][j+1]=x[i][j+1];
      else x[i+1][j+1]=x[i+1][j];
    }
  }
  printf("%d\n",x[strlen(A)][strlen(B)]);
}
  
int main(){
  int n,i,j;
  char A[N],B[N];
  scanf("%d",&n);

for(i=0;i<n;i++){
    scanf("%s",A);
    scanf("%s",B);
    count(A,B);
  }
  return 0; 
}

Measured memory_bytes: 4524
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
	int ans[3];
	int a, b, c;
	while(cin >> a >> b >> c){
		ans[0] = a;
		ans[1] = b;
		ans[2] = c;
		sort(ans, ans+3);
		a = ans[0];
		b = ans[1];
		c = ans[2];
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string get_unique(string &str) {
  string sort_str = str;
  std::sort(sort_str.begin(), sort_str.end());
  sort_str.erase(std::unique(sort_str.begin(), sort_str.end()), sort_str.end());
  return sort_str;
}

int main() {
  int N = 0;
  std::cin >> N;
  std::string str;
  std::string str_1;
  std::string str_2;
  std::string uni_str_1;
  std::string uni_str_2;
  std::cin >> str;
  std::vector<int> Ascee_vec(N, 0);

  int Max_count = 0;
  for (int i = 0; i < str.size(); i++) {
    str_1 = str.substr(0, i);
    str_2 = str.substr(i);

    uni_str_1 = get_unique(str_1);
    uni_str_2 = get_unique(str_2);

    int tmp_counter = 0;
    for (int i = 0; i < uni_str_1.size(); i++) {
      for (int j = 0; j < uni_str_2.size(); j++) {
        if (uni_str_1[i] == uni_str_2[j]) {
          tmp_counter += 1;
        }
      }
    }
    if (Max_count < tmp_counter) {
      Max_count = tmp_counter;
    }
  }
 std::cout << Max_count << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//2120-

int main(void) {
	int i;
	int N;
	long int *a;
	long int steps;
	char buf[128], *ch;
	char *great_buf;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	a = (long int *)calloc(N, sizeof(long int));
	great_buf = (char *)calloc(N * 16, sizeof(char));

	fgets(great_buf, N * 16, stdin);
	ch = strtok(great_buf, " ");
	a[0] = atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		a[i] = atoi(ch);
	}
	free(great_buf);

	steps = 0;
	for(i = 0; i < N; i += 1) {
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			steps += 1;
		}
	}

	free(a);
	printf("%ld\n", steps);

	return 0;
}


Measured memory_bytes: 2172
// 2012/11/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_prime[1000001];

	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<=1000000; i++){
		is_prime[i] = true;
	}

	for(int i=2; i*i<=1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<=1000000; j+=i){
				is_prime[j] = false;
			}
		}
	}

	while(true){
		int n, x;
		cin >> n >> x;

		if(n==0&&x==0)
			break;

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

		bool dp[1000001];

		dp[0] = true;
		for(int i=1; i<=x; i++){
			dp[i] = false;
		}

		for(int i=0; i<n; i++){
			for(int j=K[i]; j<=x; j++){
				if(!dp[j]&&dp[j-K[i]]){
					dp[j] = true;
				}
			}
		}

		int ans = -1;
		for(int i=x; i>=2; i--){
			if(is_prime[i]&&dp[i]){
				ans = i;
				break;
			}
		}

		if(ans!=-1){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define all(c) (c).begin(), (c).end()
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 1e5 + 2;
int dp[N], mx = -1;
vector<int> v[N];

int dfs(int node){
	if (dp[node])return dp[node];
	for (auto x : v[node])dp[node] = max(dp[node], 1 + dfs(x));
	return dp[node];
}

int main(){
    speed
    int n, m;
    cin >> n >> m;
    f(i, 0, m){
    	int x, y;
    	cin >> x >> y;
    	v[x].push_back(y);
    }
    f(i, 1, n + 1)mx = max(mx , dfs(i));
    cout << mx << endl;
}

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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int a,b,c,k,r=0;
    cin>>k;
    for(a=1;a<=k;a++){
        for(b=1;b<=k;b++)
        {
            for(c=1;c<=k;c++)
                r+=__gcd(__gcd(a,b),c);
        }
    }
    cout<<r<<endl;
    return 0;
}

//Created Time  :2020/4/12 20:06:46



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

ll MOD = 1000000007;

ll powmod(ll x,ll n) {
    ll res = 1;
    for(int i = 0;i < n;i++) {
        res = res * x % MOD;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ans = powmod(10,n) - powmod(9,n) - powmod(9,n) + powmod(8,n);
    ans%=MOD;
    ans = (ans+MOD)%MOD;
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;typedef pair<double,string> P;main(){string l;for(double N,p,a,b,c,d,e,f,s,m,i;cin>>N,N;puts("#")){vector<P>v;for(i=0;i++<N;v.push_back(P(-(f*s*m-p)/(a+b+c+(d+e)*m),l)))cin>>l>>p>>a>>b>>c>>d>>e>>f>>s>>m;for(sort(v.rbegin(),v.rend());N>0;)cout<<v[--N].second<<endl;}}

Measured memory_bytes: 0
n, k = map(int, input().split())
A = [int(i) for i in input().split()]
D = []

for i in range(n - k + 1):
    L = A[i]
    R = A[i + k -1]
    dist = min(abs(L) - L + R, abs(R) + R - L)
    D.append(dist)
    
print(min(D))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<string> s(n);
   rep(i, 0, n) cin >> s[i];
   map<string, int> mp;
   rep(i, 0, n) mp[s[i]]++;
   int mx = -1;
   for (auto p : mp) {
      chmax(mx, p.second);
   }
   hr();
   for (auto p : mp) {
      if (p.second == mx) cout << p.first << endl;
   }
   return 0;
}

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

vector<int> t[200001];
int cnt[200001];

void dfs(int v, int p) {
    for (auto a : t[v]) {
        if (a == p) continue;
        cnt[a] += cnt[v];
        dfs(a, v);
    }
}

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

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }

    rep(i, q) {
        int p, x;
        cin >> p >> x;
        cnt[p - 1] += x;
    }

    dfs(0, -1);

    rep(i, n) {
        cout << cnt[i];
        if (i != n - 1) cout << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 23424
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double r = scan.nextDouble();
    double S = r*r*Math.PI;
    double L = 2*r*Math.PI;
    System.out.printf("%.6f %.6f",S,L);
  } 
}

Measured memory_bytes: 28152
import sys
n,m = map(int,input().split())
inf = float("inf")
ls = [-inf]*n
for i in range(m):
    a,b = map(int,input().split())
    if ls[a-1] == -inf:
        ls[a-1] = b
    elif ls[a-1] != b:
        print(-1)
        sys.exit()
if ls[0] == 0:
    if n != 1:
        print(-1)
        sys.exit()
    else:
        print(0)
        sys.exit()
for j in range(n):
    if ls[j] == -inf:
        if j == 0 and n == 1:
            print(0)
            sys.exit()
        elif j == 0 and n != 1:
            ls[j] = 1
        else:
            ls[j] = 0
ls = list(map(str,ls))
print("".join(ls))
        
    

Measured memory_bytes: 3064
from bisect import bisect_left
MOD = 10**9 + 7

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    f = True
    st = set()
    for v in a:
        if v in st:
            f = False
            break
        st.add(v)
    st = set()
    for v in b:
        if v in st:
            f = False
            break
        st.add(v)
    if f:
        a.sort()
        b.sort()
        ans = 1
        for v in reversed(range(1, n*m+1)):
            idx_a = bisect_left(a, v)
            idx_b = bisect_left(b, v)
            if idx_a == n or idx_b == m:
                f = False
                break
            if a[idx_a] == v and b[idx_b] == v:
                ans *= 1
            elif a[idx_a] > v and b[idx_b] == v:
                ans *= n - idx_a
            elif a[idx_a] == v and b[idx_b] > v:
                ans *= m - idx_b
            else:
                ans *= (n - idx_a) * (m - idx_b) - (n*m - v)
            ans %= MOD
    if f:
        print(ans % MOD)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9340
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

//const int N=300010,Mod=1e9+7;

int main(){
    IOS;
    /* START CODE */
    bool su=0;
    int n;
    cin>>n;
    for(int i=1,cnt=0;i<=n;++i){
        int a,b;
        cin>>a>>b;
        if(a==b) cnt++;
        else cnt=0;
        if(cnt>=3) su=1;
    }
    if(su) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3128
from bisect import bisect_left as bl,bisect_right as br
n,a,b=map(int,input().split())
l=[int(input()) for i in range(n)]
a=a-b
l.sort()
def enough(t):
    global l,a,b,n
    ans=0
    for i in range(br(l,b*t),n):
        ans-=(-l[i]+b*t)//a
    return ans<=t
ub,lb=-(-l[-1]//b),-1
while ub-lb>1:
    if enough((ub+lb)//2):ub=(ub+lb)//2
    else:lb=(ub+lb)//2
print(ub)

Measured memory_bytes: 7512
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, k, h[100005], dp[100005];

int solve(int pos) {
    if (pos == n-1) return 0;
    if (dp[pos] != -1) return dp[pos];

    int ans = INF;
    for (int i = pos+1; i <= min(n-1, pos+k); i++)
        ans = min(ans, abs(h[pos] - h[i]) + solve(i));

    return dp[pos] = ans;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n >> k;

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

    memset(dp, -1, sizeof(dp));

    cout << solve(0) << '\n';
 
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 ll n,k; 
  cin >> n >> k ;
  VI a(n);
  VI b(n); 
  map<int ,ll> cnt;
  rep(i,n){
    cin >> a.at(i) >> b.at(i);
    if(cnt.count(a.at(i))){
      cnt.at(a.at(i))+=b.at(i);
    }
    else{
      cnt[a.at(i)]=b.at(i);
    }
  }
  ll sum=0;
  int ans;
  for(pair<int,ll> p: cnt){
    int key=p.first;
    ll value=p.second;
  sum+=value;
    if(sum>=k){
      ans=key;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <map>
#include <cstdio>
using namespace std;
void solve(int T){
	map<pair<int,int>,int> m;
	char cmd[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(auto it=m.begin();it!=m.end();){
				if(it->second==n){
					auto it2=it;
					++it;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			auto it=m.lower_bound(make_pair(n,2000000000));
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int cur=0;
			scanf("%d",&k);
			for(auto it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>k)d=k;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				k-=d;
				if(k==0)break;
				cur=it->first.second+1;
			}
			if(k)m[make_pair(cur,cur+k-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

Measured memory_bytes: 1236
n=list(input())
S=0
for i,l in zip(range(len(n)),n):
  if i%2==0 and int(l)==0:
    S=S
  elif i%2==0 and int(l)==1:
    S=S+1
  elif i%2==1 and int(l)==0:
    S=S+1
  else:
    S=S
M=0
for i,l in zip(range(len(n)),n):
  if i%2==0 and int(l)==0:
    M=M+1
  elif i%2==0 and int(l)==1:
    M=M
  elif i%2==1 and int(l)==0:
    M=M
  else:
    M=M+1
print(min(M,S))

Measured memory_bytes: 3956
n=int(input())
t=[0]
x=[0]
y=[0]
flag=True
for i in range(n):
  a,b,c=map(int,input().split())
  t.append(a)
  x.append(b)
  y.append(c)
  if(abs(x[i+1]+y[i+1]-x[i]-y[i])>t[i+1]-t[i] or (x[i+1]+y[i+1]+t[i+1]-x[i]-y[i]-t[i])%2!=0):
    flag=False
    break
if(flag):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 11796
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)return temp*temp;
    else{
        if(y > 0)return x * temp * temp;
        else return (temp * temp) / x;
    }
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n)
	ll a[n];
	ll sum=0,max=0;
	for(ll i=0;i<n;i++){
        in(a[i]);
        sum+=a[i];
	}
	ll hash[100001]={0};
    for(ll i=0;i<n;i++)hash[a[i]]++;
    din(q);
    vector<ll> ans;
    for(ll i=0;i<q;i++){
        din(b);din(c);
        sum-=hash[b]*b;
        sum+=hash[b]*c;
        hash[c]+=hash[b];
        hash[b]=0;
        ans.push_back(sum);
    }
    for(ll i=0;i<q;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 5816
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let a: i64 = sc.cin();
    let b: i64 = sc.cin();
    put!(a * b);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;

vector<P> G[100010];
int d[100010];
signed main(){
	int n, a, b, c;
	scanf("%lld", &n);
	
	for(int i = 0;i < n-1;i++){
		scanf("%lld%lld%lld", &a, &b, &c);
		G[a].push_back(P(b, c));
		G[b].push_back(P(a, c));
	}
	int m, k;
	scanf("%lld%lld", &m, &k);
	
	queue<P> q;d[k] = 0;
	q.push(P(k, -1));
	while(!q.empty()){
		P p = q.front();q.pop();
		int from = p.fi, prev = p.se;
		for(int i = 0;i < G[p.fi].size();i++){
			int to = G[from][i].fi, c = G[from][i].se;
			if(prev != to){
				d[to] = d[from]+c;
				q.push(P(to, from));
			}
		}
	}
	
	for(int i = 0;i < m;i++){
		scanf("%lld%lld", &a, &b);
		printf("%lld\n", d[a]+d[b]);
	}
	return 0;
}

Measured memory_bytes: 10736
/**
 *    author:  tourist
 *    created: 17.11.2019 00:55:25       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, T;
  cin >> n >> T;
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i < n - 1) ans += min(T, t[i + 1] - t[i]); else ans += T;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
a=[0 for i in range(10**5+3)]
b=[1 for i in range(10**5+3)]
for i in range(2,10**5+3):
    if b[i]==1:
        for j in range(2*i,10**5+3,i):
            b[j]=0
b[0]=0
b[1]=0
for i in range(1,10**5+3,2):
    a[i]=b[i] and b[(i+1)//2]
e=[a[0]]
for i in range(1,10**5+3):
    e.append(a[i]+e[i-1])
#print(e)
for i in range(int(input())):
    l,r=map(int,input().split())
    print(e[r]-e[l-1])

Measured memory_bytes: 13344
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
red.sort(reverse=True)
blue.sort(key=lambda x:x[1])
blue_check = [0]*N
for i in range(N):
    for k in range(N):
        if blue_check[k] == 1:
            continue
        if red[i][0] < blue[k][0] and red[i][1] < blue[k][1]:
            blue_check[k] = 1
            break
print(sum(blue_check))


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

int main() {
    cout<< fixed << setprecision(10);
    int n;
    cin >> n;
    double ans = 0;
    for (int i = 0; i < n; ++i) {
        double a;
        string s;
        cin >> a >> s;
        if (s == "JPY") ans += a;
        else ans += 380000.0 * a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr.begin(),arr.end());
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(arr[i]==arr[j])
                continue;
            int k = n-1;
            while(k>j)
            {
                if(arr[k]==arr[j]||arr[k]==arr[i])
                {
                    k--;
                    continue;
                }
                if(arr[i]+arr[j]>arr[k])
                {
                    ans++;
                }
                k--;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();

    if(N == 1)
      System.out.println("Hello World");
    else{
      int A = scan.nextInt();
      int B = scan.nextInt();
      System.out.println(A + B);

    }
  }
}


Measured memory_bytes: 24020
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{

long long x;

cin>>x;



if(x==7 or x==5 or x==3){
	cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;


return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

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

  int ans = 0;
  rep(_,2){
    vector<int> l(n,0),r(n,0);
    rep(i,n){
      if(s[i]=='>') r[i]++;
      if(i>0) r[i] += r[i-1];
    }
    for(int i=n-1; i>=0; i--){
      if(s[i]=='<') l[i]--;
      if(i<=n-2) l[i] += l[i+1];
    }
    rep(i,n){
      if(s[i]=='>'){
        if(r[i] == -l[i]){
          int idx = lower_bound(all(l), 0) - l.begin();
          ans = max(ans, idx);//dbg(i,idx);
        }
        else if(r[i] < -l[i]){
          int x = l[i] + r[i] -1;
          int idx = upper_bound(all(l), x) - l.begin();
          idx--;
          ans = max(ans, idx+1);//dbg(i,idx+1);
        }
        else {
          int x = l[i]+r[i];
          int idx = lower_bound(all(r), x) - r.begin();
          ans = max(ans, n - idx);// dbg(i,n-idx);
        }
      }
    }
    reverse(all(s));
    rep(i,n){
      if(s[i]=='>') s[i]='<';
      else s[i]='>';
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3908