akhauriyash/Code-Regression huggingface dataset:
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    static_assert(true, "foo");
    int N;
    cin >> N;
    vector<double> t(N + 1);
    vector<double> v(N + 1);
    rep(i, 0, N) cin >> t[i];
    rep(i, 0, N) cin >> v[i];
    t[N] = v[N] = 0.0;
    rrep(i, N - 1, 0)
    {
        chmin(v[i], v[i + 1] + t[i]);
    }

    double ans = 0.0;
    double vel = 0.0;
    rep(i, 0, N)
    {
        const double x = (t[i] + (v[i + 1] - vel)) * 0.5;
        assert(x >= 0.0);

        if (x <= t[i])
        {
            if ((vel + x) <= v[i])
            {
                ans += ((vel + (vel + x)) * x * 0.5) + (((vel + x) + v[i + 1]) * (t[i] - x) * 0.5);
                vel = v[i + 1];
            }
            else
            {
                if (v[i] > v[i + 1])
                {
                    const double t1 = v[i] - vel;
                    const double t2 = t[i] - (v[i] - v[i + 1]);
                    assert(t1 >= 0.0 && t1 <= t[i]);
                    assert(t2 >= 0.0 && t2 <= t[i]);
                    assert(t2 >= t1);
                    ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t2 - t1)) + ((v[i] + v[i + 1]) * (t[i] - t2) * 0.5);
                    vel = v[i + 1];
                }
                else
                {
                    const double t1 = v[i] - vel;
                    assert(t1 >= 0.0 && t1 <= t[i]);
                    ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t[i] - t1));
                    vel = v[i];
                }
            }
        }
        else
        {
            if ((vel + t[i]) <= v[i])
            {
                ans += (vel + (vel + t[i])) * t[i] * 0.5;
                vel = vel + t[i];
            }
            else
            {
                const double t1 = v[i] - vel;
                assert(t1 >= 0.0 && t1 <= t[i]);
                ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t[i] - t1));
                vel = v[i];
            }
        }
    }
    printf("%.15lf\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

ll x1,d1,k1;

int sgn(ll f)
{
    return f>0;
}

__int128 abs(__int128 x)
{
    if(x<0)
        return -x;
    return x;
}

void out(__int128 ans)
{
    vector<int> dg;
    while(ans)
    {
        dg.pb(ans%10);
        ans/=10;
    }
    reverse(all(dg));
    if(dg.empty()) dg.pb(0);
    
    for(int i=0;i<dg.size();i++)
        cout<<dg[i];
    cout<<'\n';
}

int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    
    cin>>x1>>k1>>d1;
    
    __int128 d=d1;
    __int128 x=x1;
    __int128 k=k1;
    
    __int128 f1=x-d*k;
    __int128 f2=x+d*k;
    __int128 ans=min(abs(f1),abs(f2));
    
    if(sgn(f1)!=sgn(f2))
    {
        __int128 lft=abs(x)%d;
        __int128 cnt=(abs(x)-lft)/d;

        if((k-cnt)%2==0)
            ans=min(ans,abs(lft));
        else
            ans=min(ans,abs(lft-d));
    }
    
    out(ans);
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n,m;
  while(cin>>n>>m,(n|m)!=0){
    map<int,int> h,w;
    vector<int> v;
    int tmp;
    REP(i,n){
      cin>>tmp;
      v.push_back(0);
      for(int &a:v){
	a+=tmp;
	h[a]++;
      }
    }
    v.clear();
    REP(i,m){
      cin>>tmp;
      v.push_back(0);
      for(int &a:v){
	a+=tmp;
	w[a]++;
      }
    }
    int sum=0;
    for(auto hh:h){
      if(w[hh.first]>0){
	sum+=w[hh.first]*hh.second;
      }
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 32408
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextLong()
    val K = sc.nextLong()

    val x = N / K
    println(Math.min(Math.abs(N - K * x), Math.abs(N - K * (x + 1))))
}


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

int main() {

	int n, m; cin >> n >> m;
	vector<vector<int>> s(m, vector<int>(n, -1));
	for (int i = 0; i < m; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int tmp_s; cin >> tmp_s;
			s[i][--tmp_s] = 1;
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {		
		vector<bool> suicchiOn(n, false);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				suicchiOn[i] = true;
			}
		}
		bool allOk = true;
		for (int i = 0; i < m; i++) {
			int tmpOnCnt = 0;
			for (int j = 0; j < n; j++) {
				if (s[i][j] == -1) continue;
				if (suicchiOn[j] && s[i][j] == 1) tmpOnCnt++;
			}
			if (tmpOnCnt % 2 != p[i]) allOk = false;
		}		
		if (allOk) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
using namespace std;

int main() {
ll n;
cin>>n;
//ll a[n+1];
//a[1]=a[2]=1;
//for(ll i=3;i<=n;i++)
//{
//    a[i]=i*a[i-2];
//}
//for(ll i:a)
//{
//    cout<<i<<endl;
//}
if(n%2==1)
{
    cout<<"0"<<endl;
}
else{
    ll ans=0;
    for(ll i=0;;i++)
    {
        if(n==0)
        {
            break;
        }
        ans+=(n/5)/2;
        n/=5;
    }

    cout<<ans<<endl;
}
    return 0;
}

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

int main()
{
	int a[3],n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> a[0] >> a[1] >> a[2];
		sort(a,a+3);
		if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2])
			cout << "YES";
		else
			cout << "NO";
		cout << endl;
	}
}

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

ll xx[4] = {-1, 0, 1, 0};
ll yy[4] = {0, 1, 0, -1};

bool isValid(ll i, ll j, vector<vector<bool>> &visited, vector<string> &G)
{
	if (i >= 0 && i < visited.size() && j >= 0 && j < visited[0].size() && G[i][j] == '.' && !visited[i][j])
	{
		return true;
	}
	else
	{
		return false;
	}
}

int main()
{
	ll h, w;
	cin >> h >> w;
	vector<string> G(h);
	for (ll i = 0; i < h; i++)
	{
		cin >> G[i];
	}
	ll res = 0;
	for (ll i = 0; i < h; i++)
	{
		for (ll j = 0; j < w; j++)
		{
			if (G[i][j] == '#')
			{
				continue;
			}
			vector<vector<bool>> visited(h, vector<bool>(w, false));
			visited[i][j] = true;
			queue<pair<pair<ll, ll>, ll>> q;
			q.push({{i, j}, 0});
			while (!q.empty())
			{
				auto t = q.front();
				ll x = t.first.first;
				ll y = t.first.second;
				q.pop();
				res = max(res, t.second);
				for (int k = 0; k < 4; k++)
				{
					if (isValid(x + xx[k], y + yy[k], visited, G))
					{
						visited[x + xx[k]][y + yy[k]] = true;
						q.push({{x + xx[k], y + yy[k]}, t.second + (ll)1});
					}
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  if(S == "SUN"){
    cout << 7-0 << endl;
  }else if(S == "MON"){
    cout << 7-1 << endl;
  }else if(S == "TUE"){
    cout << 7-2 << endl;
  }else if(S == "WED"){
    cout << 7-3 << endl;
  }else if(S == "THU"){
    cout << 7-4 << endl;
  }else if(S == "FRI"){
    cout << 7-5 << endl;
  }else if(S == "SAT"){
    cout << 7-6 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRII(N,M);
    VI v(N);
    REP(i,M){
        DRII(x,y);x--;y--;
        v[x]^=1;
        v[y]^=1;
    }
    REP(i,N){
        if(v[i])return 0*puts("NO");
    }
    return 0*puts("YES");
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<climits>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i>=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;
ll dp[3005][3005];
int main()
{
    char s[3005],t[3005];
    scs(s);
    scs(t);
    ll sz=strlen(s);
    ll tz=strlen(t);
    FOR(i,0,sz)
    {
        dp[tz][i]=0;
    }
    FOR(i,0,tz)
    {
        dp[i][sz]=0;
    }
    FORr(i,sz-1,0)
    {
        FORr(j,tz-1,0)
        {
            if(s[i]==t[j])
                dp[i][j]=dp[i+1][j+1]+1;
            else
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    ll index=dp[0][0];
    char arr[index+1];
    arr[index]='\0';
    index=0;
    ll i=0,j=0;
    while(i<sz&&j<tz)
    {
        if(s[i]==t[j])
        {
            arr[index]=s[i];
            index++;
            i++;
            j++;
        }
        else if(dp[i+1][j]>dp[i][j+1])
        {
            i++;
        }
        else
        {
            j++;
        }
    }
    //cout<<
    pts(arr);
    return 0;
}


Measured memory_bytes: 74124
program speedrun
    implicit none
    character(100)::S
    integer::ANS=0,L
    integer::i
    read*,S
    L=len_trim(S)
    do i=1,L/2
        if(S(i:i)/=S(L-i+1:L-i+1))ANS=ANS+1
    end do
    print"(i0)",ANS
end program speedrun

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		if(i*111>=n){
			cout<<i*111<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
int a, b, c;
cin >> a >> b >> c;
if (a < b){
	if (b < c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}else{
	cout << "No" << endl;
}

}



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>

#define INF 1000000000

struct edge//辺を表す構造体
{
	int from, to;
	int cost;
};

vector<int> bellman_ford(int start, vector<vector<P>>G) {
	//startから各点への最短距離を配列で返す
	//辿り着けなかったらINFにする
	//startから負の閉路に到達できたら空の配列を返す
	int V = G.size();
	vector<int>dist(V, INF);
	dist[start] = 0;

	vector<edge> es;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < G[i].size(); j++) {
			edge tmpes;
			tmpes.from = i;
			tmpes.to = G[i][j].first;
			tmpes.cost = G[i][j].second;
			es.push_back(tmpes);
		}
	}
	bool flag = true;

	for (int i = 0; i < V; i++) {
		for (auto& e : es) {
			if (dist[e.from] < INF && dist[e.from] + e.cost < dist[e.to]) {
				if (i == V - 1) {
					flag = false;
				}
				dist[e.to] = dist[e.from] + e.cost;
			}
		}
	}
	if (flag == true) {
		return dist;
	}
	else {
		dist.clear();
		return dist;
	}
}


int main() {
	int V, E, start;
	cin >> V >> E >> start;
	vector<vector<P>>G(V);
	rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		G[s].push_back(mp(t, d));
	}
	vector<int>dist = bellman_ford(start, G);
	if (!dist.empty()) {
		rep(i, V) {
			if (dist[i] == INF) {
				cout << "INF" << endl;
			}
			else {
				cout << dist[i] << endl;
			}
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}

}


Measured memory_bytes: 3224
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int k;cin>>k;
    string s;cin>>s;
    if(s.length()<=k)cout<<s<<Endl;
    else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






















































Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int main(){
	char str[128];
	int i;
	int OK;
	int len;
	int result = 0;
	
	while(scanf("%s",str)!=EOF){
		len = strlen(str);
		OK = 1;
		for(i=0;i<len-1-i&&OK==1;i++){
			if(str[i]!=str[len-1-i]){
				OK = 0;
				break;
			}
		}
		if(OK==1) result++;
	}
	
	printf("%d\n",result);
	return 0;
} 

Measured memory_bytes: 540
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  LINT a[N];
  REP(i, N) {
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(a, a+N);
  LINT b;
  if(N%2 == 0) b = (a[N/2-1] + a[N/2])/2;
  else b = a[N/2];
  //b: 中央値;
  LINT ans=0;
  REP(i, N) ans += abs(a[i]-b);
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b) swap(a, b);
    if(b>c) swap(b, c);
    if(a>b) swap(a, b);
    printf("%d %d %d\n", a, b, c);
}


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

	int a, b;
	string s;

	cin >> a >> s >> b;

	if (s == "+") {
		cout << a + b << endl;
	}
	else if (s == "-") {
		cout << a - b << endl;
	}
}


Measured memory_bytes: 256
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S;
int N;
int dp[33][101010];
int ans[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	N = S.length();

	rep(i, 0, N) {
		if (S[i] == 'R') dp[0][i] = i + 1;
		else dp[0][i] = i - 1;
	}

	rep(p, 0, 32) rep(i, 0, N) dp[p + 1][i] = dp[p][dp[p][i]];

	rep(i, 0, N) ans[dp[32][i]]++;
	rep(i, 0, N) printf("%d\n", ans[i]);
}







Measured memory_bytes: 14060
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

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

// ford-fulkerson
template <typename T> class Graph {
  struct Edge {
    int to, rev;
    T cap;
    Edge(int to, int rev, T cap) : to(to), rev(rev), cap(cap) {}
  };
  vector<vector<Edge>> g;
  T inf;
  vector<int> visited;

public:
  Graph(int n) {
    g.resize(n);
    inf = numeric_limits<T>::max() / 3;
    visited.resize(n, false);
  }
  void add_edge(int from, int to, T cap) {
    g[from].emplace_back(to, g[to].size(), cap);
    g[to].emplace_back(from, (int)g[from].size() - 1, 0);
  }
  void add_undirected_edge(int a, int b, T cap) {
    g[a].emplace_back(b, g[b].size(), cap);
    g[b].emplace_back(a, (int)g[a].size() - 1, cap);
  }
  T dfs(int i, T curf, int sink) {
    if (i == sink) return curf;
    visited[i] = true;
    for (auto &&e : g[i]) {
      if (visited[e.to] or e.cap == 0) continue;
      auto tmpf = dfs(e.to, min(e.cap, curf), sink);
      if (tmpf > 0) {
        e.cap -= tmpf;
        g[e.to][e.rev].cap += tmpf;
        return tmpf;
      }
    }
    return 0; // 流せなかった
  }
  T ford(int source, int sink) {
    T maxf = 0;
    while (true) {
      fill(visited.begin(), visited.end(), false);
      auto f = dfs(source, inf, sink);
      if (f > 0) {
        maxf += f;
      } else {
        break;
      }
    }
    return maxf;
  }
};

int main() {

  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  int sy, sx, gy, gx;
  rep(i, h) rep(j, w) {
    cin >> a[i][j];
    if (a[i][j] == 'S') {
      sy = i;
      sx = j;
    } else if (a[i][j] == 'T') {
      gy = i;
      gx = j;
    }
  }
  if (sy == gy or sx == gx) {
    cout << -1 << endl;
    return 0;
  }

  auto n = h + w;
  Graph<int> g(n + 2);
  auto S = n, T = n + 1;
  auto inf = numeric_limits<int>::max() / 3;
  g.add_edge(S, sy, inf);
  g.add_edge(S, sx + h, inf);
  g.add_edge(gy, T, inf);
  g.add_edge(gx + h, T, inf);
  rep(i, h) rep(j, w) if (a[i][j] == 'o') {
    g.add_edge(i, j + h, 1);
    g.add_edge(j + h, i, 1);
    // g.add_undirected_edge(i, j, 1);
  }

  cout << g.ford(S, T) << endl;

  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B, C, D, E, F;
bool water[3001], sugar[3001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B >> C >> D >> E >> F;
  water[0] = 1;
  rep(s, 3001) {
    if (water[s] == 0) continue;
    if (s + 100*A <= 3000) water[s+100*A] = 1;
    if (s + 100*B <= 3000) water[s+100*B] = 1;
  }

  sugar[0] = 1;
  rep(s, 3001) {
    if (sugar[s] == 0) continue;
    if (s + C <= 3000) sugar[s+C] = 1;
    if (s + D <= 3000) sugar[s+D] = 1;
  }

  P cur = P(-1, 1);
  P cur_i = P(0, 0);
  rep(a, 3001) {
    if (water[a] == 0) continue;
    rep(b, 3001) {
      if (sugar[b] == 0) continue;
      if (a+b > F) continue;
      if (a*E < 100*b) continue;
      int aa = b, bb = a+b;
      // 濃度: a/b
      // curA/curB < a/b
      // <=> curA*b < a*curB
      if (cur._1 * bb <= aa * cur._2) {
        cur = P(aa, bb);
        cur_i = P(a+b, b);
      }
    }
  }
  cout << cur_i._1 << " " << cur_i._2 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S%3600)/60;
	s=(S%3600)%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
from heapq import *
n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]
heapify(a)
bc.sort(key=lambda x:x[1],reverse=True)
maxlength = bc[0][0]
maxnumber = bc[0][1]
newbc = [[maxlength,maxnumber]]
for k,l in bc:
    if k > maxlength:
        newbc.append([k-maxlength,l])
        maxlength = k

for remain,number in bc:
    while remain > 0:
        temp = heappop(a)
        if number > temp:
            heappush(a,number)
            remain -= 1
        else:
            heappush(a,temp)
            remain = 0
print(sum(a))

Measured memory_bytes: 27080
package main

import "fmt"

func gcd(x, y int64) int64 {
	if y == 0 {
		return x
	} else {
		return gcd(y, x%y)
	}
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func main() {
	var n, i, ans int64
	fmt.Scan(&n)

	ans = 1

	for i = 0; i < n; i++ {
		var t int64
		fmt.Scan(&t)
		ans = lcm(ans, t)
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	int fre[26]={0};
	for(int i=0;i<s.length();i++)
		fre[s[i]-97]++;
	for(int i=0;i<26;i++)
	{
		if(fre[i]==0)
		{
			cout<<(char)(i+97);
			return 0;
		}
	}
	cout<<"None";
	return 0;
}



Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll a,b,c,k; cin >> a >> b >> c >> k;
  
  if(k <= a) cout << k << endl;
  else if(k <= a+b) cout << a << endl;
  
  else cout << 2*a + b -k << endl;
}

Measured memory_bytes: 3620
n = int(input().strip())
a = list(map(int, input().split()))

cnt = [0 for i in range(10**5)]
a = sorted(a)
s = sum(a)

for i in range(n):
    cnt[a[i]-1] += 1

q = int(input().strip())

for i in range(q):
    b, c = map(int, input().split())
    s += c * cnt[b - 1] - b * cnt[b - 1]
    cnt[c - 1] += cnt[b - 1]
    cnt[b - 1] = 0
    print(s)


Measured memory_bytes: 20844
# Selection Sort
N = int(input())
lst = list(map(int,input().split()))
cnt = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if (lst[j] < lst[minj]):
            minj = j
    lst[i],lst[minj] = lst[minj],lst[i]
    if (i != minj):
        cnt += 1
print(" ".join(list(map(str, lst))))
print(cnt)


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll inf = (ll)1e18;
const ll N = (ll)2e5+77;
const ll mod = (ll)1e9+7;

int main() {
    fast;
    ll n, m, y;
    cin >> n >> y;
    forn(i, n + 1) {
        if (y - i * 10000 < 0) continue;
        forn(j, n - i + 1) {
            if (y - i * 10000 - j * 5000 < 0) continue;
            if (y - i * 10000 - j * 5000 == (n - i - j) * 1000) {
                printf("%d %d %d\n", i, j, n - i - j);
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007 
using namespace std;
void solve(){
    ll n;
    cin>>n;
    if(n%1000==0)cout<<0<<endl;
    else
    cout<<1000-(n%1000)<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='+'){
      cout << a+b << endl;
    }else if(op=='-'){
      cout << a-b << endl;
    }else if(op=='*'){
      cout << a*b << endl;
    }else if(op=='/'){
      cout << a/b << endl;
    }else if(op=='?'){
      break;
    }
  }
  return(0);
}



Measured memory_bytes: 3112
import java.util.*;

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

        int n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        for (int i=0 ;i<n; i++) p[i] = sc.nextInt();
        for (int i=0; i<n; i++) q[i] = sc.nextInt();

        int[] cntP = new int[n];
        int[] cntQ = new int[n];

        cntP[0] = p[0]-1;
        cntQ[0] = q[0]-1;

        for (int i=1; i<n; i++){
            int tmp = p[i];
            int tmp2 = q[i];
            int cnt = 0;
            int cnt2 = 0;
            for (int j=0; j<i; j++){
                if (p[j]<tmp) cnt++;
            }
            for (int j=0; j<i; j++){
                if (q[j]<tmp2) cnt2++;
            }
            cntP[i] = tmp-1-cnt;
            cntQ[i] = tmp2-1-cnt2;

        }


        StringBuilder s = new StringBuilder();
        StringBuilder t = new StringBuilder();

        for (int i=0; i<n; i++) s.append(p[i]);
        for (int i=0; i<n; i++) t.append(q[i]);


        int left = Integer.parseInt(s.toString());
        int right = Integer.parseInt(t.toString());

        int start;
        int end;

        s = new StringBuilder();
        t = new StringBuilder();

        for (int i=0; i<n; i++) s.append(i+1);
        for (int i=n; i>=1; i--) t.append(i);

        start = Integer.parseInt(s.toString());
        end = Integer.parseInt(t.toString());

        int cntLeft = 0;
        int cntRight = 0;



        int[] fact = {40320, 5040, 720, 120, 24, 6, 2, 1};

        for (int i=0; i<n-1; i++){
            cntLeft += cntP[i]*fact[9-n+i];
            cntRight += cntQ[i]*fact[9-n+i];
//            int tmp = left/(int)Math.pow(10, i+1);
//            int tmp2 = right/(int)Math.pow(10, i+1);
//            tmp %= 10;
//            tmp2 %= 10;
//            cntLeft += (tmp-1)*fact[i];
//            cntRight += (tmp2-1)*fact[i];
        }

        System.out.println(Math.abs(cntLeft-cntRight));




    }
}

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((i + 1) % 2 == 0) continue;
    if (a[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
while True:
	n,x = list(map(int, input().split()))
	if (n == 0 and x == 0):
		break
	result = 0
	for a in range(1, x // 3):
		for b in range(a + 1, x // 2):
			c = x-a-b
			if b < c <= n:
				result +=1
	print(result)

Measured memory_bytes: 7604
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cassert>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rep_down(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int N = 500000 + 7;
const int M = 27;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * N * 1000;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;


string s;
int nxt[N][M]; // 26 = empty
int n;

int f[N][20];



void solve() {
    cin >> s;
    n = sz(s);
    
    
    rep(j, 0, 27) nxt[n][j] = n + 1;
    
    rep_down(i, n, 0) {
        int c = s[i] - 'a';
        
        rep(j, 0, M) nxt[i][j] = n + 1;
        
        
        nxt[i][c] = i + 1;
        int cur = i + 1;
        
        rep(t, c, 26) {
            if (cur >= n) break;
            
            cur = nxt[cur][t];
            nxt[i][t + 1] = cur;
        }
        if (nxt[i][M - 1] < n) {
            int rr = nxt[i][M - 1];
            rep(t, 0, c)
                nxt[i][t] = nxt[rr][t];
        }
    }
    
    rep_down(i, n, 0) {
        f[i][0] = nxt[i][M - 1];
        rep(j, 1, 20) {
            if (f[i][j - 1] >= n) f[i][j] = inf;
            else f[i][j] = f[f[i][j - 1]][j - 1];
        }
    }
    
    
    
    int query; cin >> query;
    
    
    while (query-- > 0) {
        int u, v;
        scanf("%d%d", &u, &v);
//        ++v;
        --u;
        
        rep_down(j, 20, 0) {
//            cout << u << ' ' << j << '\n';
            if (f[u][j] <= v) {
                u = f[u][j];
            }
            if (u == v) break;
        }
        if (u == v) puts("Yes");
        else puts("No");
        
    }
    
    
    
}


int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //t1=clock();
#endif
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
    
#ifdef _LOCAL_
    cout<<"\n" << clock() / CLOCKS_PER_SEC<<endl;
#endif
}


Measured memory_bytes: 93060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
        int max = p;
		if(max < q) max = q;
        if(max < r) max = r;
		System.out.println(p+q+r-max);
	}
}

Measured memory_bytes: 21712
import math
N, X, M = map(int, input().split(" "))

h = [0 for i in range(M + 1)]
r = [0 for i in range(M + 1)]

A = X
result = A
h[A] = 1
i = 2
f = True
while i < N + 1:
    r[A] = result

    A = (A * A) % M
    if A == 0:
        break
    result = result + A
    if f and h[A] > 0:
        f = False
        d = i - h[A]
        result = (result - r[A]) * int((N - i) / d) + result
        i = N - (N - i) % d
    h[A] = i
    i = i + 1
print(result)


Measured memory_bytes: 15156
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,a,ans=0; cin >> n;
  REP(i,n) {
    cin >> a;
    ans+=a-1;
  }
  COUT(ans);
  return 0;
}

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

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

const int N = 1000007, inf = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;


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

	int n, m; cin >> n >> m;

	int aux = m;
	if(aux%2 == 0) aux--;
	int last = 1 + aux;

	for(int i = 1, j = 1 + aux; i < j; i++, j--, aux -= 2) {
		cout << i << ' ' << j << endl;
	}

	aux = m;
	if(aux%2) aux--;

	for(int i = last + 1, j = last + 1 + aux; i < j; i++, j--, aux -= 2) {
		cout << i << ' ' << j << endl;
	}


}

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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    cin >> a >> b;
    
    if(a <= 9 and b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
aRows = []
n.times{ aRows.push gets.split.map(&:to_i) }
bs = []
m.times{ bs.push gets.to_i }
aRows.each{|r|
	puts r.zip(bs).map{|a|a[0]*a[1]}.inject(:+)
}

Measured memory_bytes: 9032
S=input()
ans=0
for i in range(1<<3):
    lst = ['-']*3
    for j in range(3):
        if 1&(i>>j):
            lst[2-j] = '+'
    total = ''
    for n, m in zip(S, lst+['']):
        total += (n+m)
    if eval(total) == 7:
        print(total + '=7')
        break

Measured memory_bytes: 3060
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    a,b,c = [],[],[]
    cost = 0
    for j in range(N):
        r = (i//(4**j)) % 4
        if r == 1:
            a.append(l[j])
        elif r == 2:
            b.append(l[j])
        elif r == 3:
            c.append(l[j])
    if a and b and c:
        cost += sum(max((len(x)-1), 0)*10 for x in [a,b,c])
        a = sum(a)
        b = sum(b)
        c = sum(c)
        cost += sum(abs(x-y) for x,y in [(a,A),(b,B),(c,C)])
        ans = min(ans, cost)
print(ans)

Measured memory_bytes: 75292
#include <stdio.h>
#include <math.h>

typedef struct Point{
  double x;
  double y;
}Point;

void koch(int n, Point a, Point b){

  if(n==0) return;

  Point s, t, u;
  double th;

  th = M_PI*60.0/180.0;

  s.x=(2.0*a.x + 1.0*b.x)/3.0;
  s.y=(2.0*a.y + 1.0*b.y)/3.0;
  t.x=(1.0*a.x + 2.0*b.x)/3.0;
  t.y=(1.0*a.y + 2.0*b.y)/3.0;
  u.x=(t.x - s.x)*cosl(th) - (t.y - s.y)*sinl(th) + s.x;
  u.y=(t.x - s.x)*sinl(th) + (t.y - s.y)*cosl(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> sticks(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &sticks[i]);
  }
  sort(sticks.begin(), sticks.end(), greater<ll>());
  vector<ll> sides;
  for (int i = 0; i < N and sides.size() < 2; ) {
    int j = i;
    while (j < N and sticks[i] == sticks[j]) { ++j; }
    int cnt = j - i;
    if (cnt >= 4) {
      sides.push_back(sticks[i]);
      sides.push_back(sticks[i]);
      break;
    }
    else if (cnt >= 2) {
      sides.push_back(sticks[i]);
    }
    i = j;
  }
  ll ans = 0;
  if (sides.size() >= 2) { ans = sides[0] * sides[1]; }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
using System;
					
public class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine()); 
		
		string str = N.ToString();
		
	  int b = (int)str[str.Length-1]  - '0';
	  switch (b)
      {
          case 3:
              Console.WriteLine("bon");
              break;
          case 2:
		  case 4:
		  case 5:
		  case 7:
		  case 9:
              Console.WriteLine("hon");
              break;
          default:
              Console.WriteLine("pon");
              break;
      }
		
	}
}

Measured memory_bytes: 17620
using System;
using System.Collections.Generic;
using System.Linq;

namespace Bingo
{
    class Program
    {
        static void Main(string[] args)
        {
            int numberRows = 3;
            int numberColumns = 3;
            double[,] input = new double[numberRows, numberColumns];


            for (int i = 0; i < numberRows; i++)
            {                
                string[] temp = Console.ReadLine().Split(' ');

                for (int y = 0; y < numberColumns; y++)
                {
                    input[i, y] = Convert.ToDouble(temp[y]);
                }
            }

            List<double> checkList = new List<double>();
            for (int i = 0; i < numberRows; i++)
            {
                for (int y = 0; y < numberColumns; y++)
                {
                    checkList.Add(input[i, y]);
                }
            }

            if(checkList.Count() != checkList.Distinct().Count())
            {
                Console.WriteLine("Invalid Input");
                return;
            }

            int bingoNumbers = Convert.ToInt32(Console.ReadLine());

            List<double> array = new List<double>();

            for (int i = 0; i < bingoNumbers; i++)
            {
                int inputNumber = Convert.ToInt32(Console.ReadLine());
                array.Add(inputNumber);
            }

            if (array.Count() != array.Distinct().Count())
            {
                Console.WriteLine("Invalid Input");
                return;
            }

            for (int i = 0; i < numberRows; i++)
            {
                int counterRows = 0;
                for (int y = 0; y < numberColumns; y++)
                {
                    if (array.Any(x => x == (input[i, y])))
                    {
                        counterRows++;
                    }
                }
                if (counterRows == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            for (int y = 0; y < numberColumns; y++)
            {
                int counterColumns = 0;
                for (int i = 0; i < numberRows; i++)
                {
                    if (array.Any(x => x == (input[i, y])))
                    {
                        counterColumns++;
                    }
                }
                if (counterColumns == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            if (array.Any(x => x == input[0, 0]) && array.Any(x => x == input[1, 1]) && array.Any(x => x == input[2, 2]))
            {
                Console.WriteLine("Yes");
                return;
            }

            if (array.Any(x => x == input[0, 2]) && array.Any(x => x == input[1, 1]) && array.Any(x => x == input[2, 0]))
            {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
# 木全体の根が決まっているのでふつうにbfsでいい気がするが...
# 毎回探索するんじゃなくて、各枝にポイントをつけておいて、探索するときに1回だけ渡して更新していく
# 考え方は累積和
# なんかafter_contestってテストケースでハネられるんだが。。。。。なんだこれ
# i<jのときiのほうが根に近い、というのを決め打ちしても通ってしまう防止らしい
# 回避するべく
# 両方のノードからエッジを貼り(graph[b].append(a))、
# 探索のときに訪問済みの場所は抜くことにした(if node not in used:)

n, q = map(int, input().split())
graph = [[] for _ in range(n)]
points = [0 for _ in range(n)]

for _ in range(n - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    points[p - 1] += x

path = [0]
used = set()
used.add(0)
while len(path) > 0:
    cur_node = path.pop()
    cur_point = points[cur_node]
    for node in graph[cur_node]:
        if node not in used:
            used.add(node)
            points[node] += cur_point
            path.append(node)
print(" ".join(list(map(str, points))))


Measured memory_bytes: 73476
var n,l,i,j:integer;s:array[0..100]of string;
begin
 readln(n,l);
 for i:=1 to n do
  readln(s[i]);
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if s[i]>s[j] then
    begin
     s[0]:=s[i];
     s[i]:=s[j];
     s[j]:=s[0];
    end;
 for i:=1 to n-1 do
  write(s[i]);
 writeln(s[n]);
end.

Measured memory_bytes: 128
//1_3_C
#include <stdio.h>
#include <math.h>

int main(int x, int y)
{
	for(; scanf("%d %d", &x, &y), (x != 0 || y != 0);){
		printf("%.f %.f\n", fmin(x, y), fmax(x, y));
	}
	return 0;
}

Measured memory_bytes: 636
N = int(input())
d = [0]*(N+1)
A = [0]+list(map(int, input().split()))+[0]
ac =[0]*(N+2)

for i in range(1, N+2):
    d[i-1] = abs(A[i]-A[i-1])
for i in range(1, N+2):
    ac[i] = ac[i-1]+d[i-1]


for i in range(1, N+1):
    v = abs(A[i-1]-A[i+1])
    print(v+ac[i-1]-ac[0]+ac[N+1]-ac[i+1])

Measured memory_bytes: 58604
a=input()
x=0;y=0
ans=0
for i in range(len(a)):
    if(x==y):
        x=x+1
        if(a[i]=='p'):
            ans=ans-1
    else:
        y=y+1
        if(a[i]=='g'):
            ans=ans+1
print(ans)

Measured memory_bytes: 3316
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
    ll a ,b;
    cin >> a >> b;
    if (a + b == 15){
        cout << "+" << endl;
    } else if (a * b == 15){
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        String[] S = new String[N];
        for (int i=0; i<N; i++) {
            S[i] = sc.next();
        }

        String[] ans = solve(N, S);
        for (int i=0; i<ans.length; i++) {
            System.out.println(ans[i]);
        }
    }

    private static String[] solve(int N, String[] S) {
        Map<String, Integer> map = new HashMap();
        int most = 0;

        for (int i=0; i<N; i++) {
            String key = S[i];
            int count = 0;

            if (map.containsKey(key)) {
                count = (Integer)map.get(key);
                map.put(key, (count+1));
            } else {
                map.put(key, 1);
            }

            most = Math.max(most, count+1);
        }

        List<String> ans = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            // System.err.println(entry.getKey() + ":" + entry.getValue());
            if (entry.getValue() == most) {
                ans.add(entry.getKey());
            }
        }


        Collections.sort(ans);

        return ans.toArray(new String[0]);
    }
}

Measured memory_bytes: 78628
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll MOD = 1000000007;
ll fact[2000005];
ll invfact[2000005];
ll bpow(ll b, ll p) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % MOD)
    if (p & 1)
      rt = rt * b % MOD;
  return rt;
}
ll ncr(ll n, ll r) { return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD; }
int main() {
  fact[0] = invfact[0] = 1;
  for (int i = 1; i <= 2000000; i++)
    fact[i] = fact[i - 1] * i % MOD;
  for (int i = 1; i <= 2000000; i++)
    invfact[i] = bpow(fact[i], MOD - 2);
  int k;
  string s;
  cin >> k >> s;
  ll sum = 0;
  for (int i = s.length(); i <= s.length() + k; i++)
    sum = (sum + ncr(s.length() + k, i) * bpow(25, s.length() + k - i) % MOD) %
          MOD;
  cout << sum % MOD << endl;
}

Measured memory_bytes: 36520