akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n;
	cin >> n;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	int min = 1e9;
	for(int i=1; i<=100; i++) {
		int sum = 0;
		rep(j,n) {
			sum +=(x[j] - i)*(x[j] - i);
		}
		min = min < sum ? min : sum;
	}
	cout << min << endl;
  return 0;
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;

int32_t main() {
	fastio;

	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe";
	else cout << "safe";

	return 0;
}


Measured memory_bytes: 3640
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N, K = map(int, input().split())
    N_list = [1 for x in range(N)]
    s_list = [x for x in range(1, N)] 
    
    for i in range(K):
        di = int(input())
        A_i = list(map(int, input().split()))
        for j in A_i:
            N_list[j - 1] = 0

    print(N_list.count(1))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 10820
#include<stdio.h>
 
int main(void){
 int A=0,B=0,C=0,count=0;
  scanf("%d %d %d",&A,&B,&C);
  if(A==7||A==5)
    count+=A;
  if(B==7||B==5)
    count+=B;
  if(C==7||C==5)
    count+=C;
  
  if(count==17)
    printf("YES");
  else
    printf("NO");
  
  return 0;
}

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

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

using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
const int MAX = 200005;
const int INF = 1001001001;

struct Pt
{
    int x, y, dir;
    P cost;
    bool operator<(const Pt& x) const { return this->cost > x.cost; }
};

int main(int, char**)
{
    int H, W, K;
    cin >> H >> W >> K;
    vector< vector< vector<P> > > dp(H, vector< vector<P> >(W, vector<P>(4,{INF,0})));

    int xs, ys, xe, ye;
    cin >> xs >> ys >> xe >> ye;
    xs--; ys--; xe--; ye--;

    char c;
    rep(i,H) rep(j,W) {
        cin >> c;
        if (c=='@') rep(k,4) dp[i][j][k] = {-1,0};
    }

    const int dx[4] = { -1,  0,  1,  0 };
    const int dy[4] = {  0, -1,  0,  1 };

    priority_queue<Pt> q;
    rep(i,4) {
        q.push({xs,ys,i,{0,0}});
        dp[xs][ys][i] = {0,0};
    }
    while (!q.empty()) {
        Pt pt = q.top(); q.pop();
        int x = pt.x;
        int y = pt.y;
        int d = pt.dir;
        P c = pt.cost;
        if (dp[x][y][d] < c) continue;
        rep(i,4) {
            int nx = x;
            int ny = y;
            P nc;
            if (i==d) {
                nx += dx[i];
                ny += dy[i];
                if (nx < 0 || nx >= H || ny < 0 || ny >= W || dp[nx][ny][i].first == -1) continue;
            }
            if (i!=d) nc = {c.first + (c.second>0?1:0) ,0};
            else nc = {c.first+(c.second+1)/K,(c.second+1)%K};

            if (nc >= dp[nx][ny][i]) continue;
            dp[nx][ny][i] = nc;
            q.push({nx,ny,i,nc});
        }
    }

    int ans = INF;
    rep(i,4) {
        P p = dp[xe][ye][i];
        if (p.first == INF) { cout << -1 << endl; return 0; }
        else ans = min(ans, p.first + (p.second>0?1:0));
    }
    cout << ans << endl;

    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n >> m;
    MSG((n-1) * (m-1))

}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double radians(double deg) {
    return deg * PI / 180;
}

void main() {
    auto xs = readints;
    int a = xs[0], b = xs[1], c = xs[2];

    /*
        2 辺 a, b とその間の角 c (度)から
        - 面積 S
        - 周の長さ L
        - a を底辺としたときの高さ h
        をそれぞれ求める
    */

    double h = b * sin(radians(c));
    double area = a * h * 0.5;
    // 余弦定理より辺の長さを求める
    double perimeter = a + b + sqrt(a^^2 + b^^2 - 2 * a * b * cos(radians(c)));

    writefln("%.6f", area);
    writefln("%.6f", perimeter);
    writefln("%.6f", h);
}



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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n;
    cin >> n;
    vector<vector<int>> vec(2, vector<int>(n));
    REP(i,2){
        REP(j,n){
        cin >> vec.at(i).at(j);
        }
    }

    int max = 0;
    REP(i,n){
        int sum = 0;
        REP(j,i){
            sum += vec.at(0).at(j);
        }
      	sum += vec.at(0).at(i);
        for(int j = i; j < n; j++){
            sum += vec.at(1).at(j);
        }
        if(max < sum){
            max = sum;
        }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,gcd=0; cin>>n; 
    while (n--){
        int a; cin>>a;
        gcd = __gcd(gcd,a);
    }
    cout << gcd << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
	int a,b;
  	string c;
  	cin >> a>>b>>c;
	if(c[a] != '-') {
      	cout << "No" << endl;
      	return 0;
    }
  	for(int i = 0; i < a+b+1; i++) {
		if(i == a)
          continue;
        if(c[i] == '-') {
          cout << "No" << endl;
          return 0;
	    }
    }
	cout << "Yes" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#define LL long long
#define mod 1000000007
using namespace std;

LL N,A,B,a[100010],cl[100010],dp[100010],s[100010];

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

    cin >> N >> A >> B;
    if (A>B) swap(A,B);
    LL i;
    for (i=1; i<=N; i++) cin >> a[i];

    for (i=1; i<=N-2; i++)
        if (a[i+2]-a[i]<A){
            cout << 0 << "\n";
            return 0;
        }

    a[0]=-B;
    cl[N]=cl[N-1]=N+1;
    for (i=N-2; i>=0; i--){
        cl[i]=cl[i+1];
        if (a[i+2]-a[i+1]<A) cl[i]=i+1;
    }

    LL l=N+1;
    for (i=N; i>=0; i--){
        while (a[l-1]-a[i]>=B) l--;
        if (l==N+1){
            if (cl[i]==N+1) dp[i]=1;
            else dp[i]=0;
        }
        else{
            if (cl[i]==N+1) dp[i]=(1+s[l])%mod;
            else{
                if (l>cl[i]+1) dp[i]=0;
                else dp[i]=(s[l]-s[cl[i]+2]+mod)%mod;
            }
        }

        s[i]=(s[i+1]+dp[i])%mod;
    }

    cout << (dp[0]+mod)%mod << "\n";
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
pair<pii, int> a[1004];
ll dp[1003][20002];

ll solve(int idx, int rem){
    ll &ans = dp[idx][rem];
    if(ans == -1){
        ans = solve(idx+1, rem);
        if(rem >= a[idx].fi.fi)
            ans = max(ans, a[idx].se + solve(idx+1, min(rem - a[idx].fi.fi, a[idx].fi.se)));
    }
    return ans;
}

int main(){
    scanf("%d", &n);
    for(i=0;i<n;++i)
        scanf("%d %d %d", &a[i].fi.fi, &a[i].fi.se, &a[i].se);
    sort(a, a+n, [](const pair<pii, int> &a, const pair<pii, int> &b) -> bool{
        return a.fi.fi+a.fi.se > b.fi.fi+b.fi.se;
    });
    memset(dp, -1, sizeof dp);
    memset(dp[n], 0, sizeof dp[n]);
    ll ans = solve(0, 2e4);
    printf("%lld\n", ans);
    return 0;
}

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

const int MOD = 1000000007;
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  string s[2];
  cin >> s[0] >> s[1];
  ll res = (s[0][0] == s[1][0] ? 3 : 6);
  for(int i = s[0][0] == s[1][0] ? 1 : 2;i < n;){
    if(s[0][i] == s[1][i]){
      if(s[0][i - 1] == s[1][i - 1]){
        res *= 2;
      }
      i++;
    }else{
      if(s[0][i - 1] == s[1][i - 1]){
        res *= 2;
      }else{
        res *= 3;
      }
      i += 2;
    }
    res %= MOD;
  }
  cout << res;
}



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

ll n;
ll a[100005][3];
ll memo[100009][3];

ll fil(ll cur,ll pid)
{
    if(cur>=n)return 0;
    if(memo[cur][pid]!=-1)return memo[cur][pid];

    ll ans=0;
    for(ll j=0;j<3;j++)
    {
        if(pid==j)continue;
        ans=max(ans,fil(cur+1,j)+a[cur][j]);
    }
    return memo[cur][pid]=ans;
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    memset(memo,-1,sizeof(memo));
    ll ans=0;

    ans=max(ans,fil(1,0)+a[0][0]);
    ans=max(ans,fil(1,1)+a[0][1]);
    ans=max(ans,fil(1,2)+a[0][2]);

    cout<<ans<<endl;
}


Measured memory_bytes: 11136
n,k=map(int,input().split())

mod=10**9+7

MAX_N=n+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

for i in range(1,k+1):
  ans=nCk(n-k+1,i)*nCk(k-1,i-1)
  ans%=mod
  print(ans)

Measured memory_bytes: 3572
///"Bismillahir Rahmanir Raheem"///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
const int LOGN = 20;
int main(){
    int n,a,b,c,x = 0,y = 0,z = 0,p,q,r;
            cin>>n;
        while(n--){
            cin>>a>>b>>c;
            p = max(a+y,a+z);
            q = max(b+x,b+z);
            r = max(c+x,c+y);
            x = p; y = q; z = r;
        }
    cout<<max(p,max(q,r))<<endl;
return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [0] * (n + 1)
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] = a[i] + max(b[i - 1], c[i - 1])
    b[i] = b[i] + max(c[i - 1], a[i - 1])
    c[i] = c[i] + max(a[i - 1], b[i - 1])
print(max(a[n], b[n], c[n]))

Measured memory_bytes: 14924
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


const int inf=2e9;

int main(){
    int n,g; cin>>n>>g;
    vector<int> p(n),c(n);
    rep(i,n) cin>>p[i]>>c[i];
    int ans=inf;
    rep(i,1<<n){
        vector<int> che(n,0);
        rep(j,n) if(i>>j&1) che[j]=1;
        int cnt=0, kari=0;
        rep(j,n){
            if(che[j]==1){
                cnt+=p[j]; kari+=(p[j]*(j+1)*100+c[j]);
            }
        }
        if(kari<g){
            int num=-1;
            rep(j,n){
                if(che[j]==0) num=j;
            }
            if(num==-1) continue;
            int kosu=(g-kari+(num+1)*100-1)/((num+1)*100);
            if(kosu<p[num]){
                cnt+=kosu;
            }
            else continue;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = getLine >> readInts >>= print . solve 0 . map fromIntegral

solve _ [] = 0 :: Integer
solve t (a:as) = max 0 ( t - a ) + solve ( max t a ) as

Measured memory_bytes: 13444
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e6+3;
ll fact[upperlimit];
int main() {
	fact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	int q,a,d,n;
	sd(q);
	while(q--){
		sd(a);sd(d);sd(n);
		if(d==0){
			plldn(powmod(a,n,mod));continue;
		}
		ll temp=a;temp*=powmod(d,mod-2,mod);temp%=mod;
		temp+=n;
		if((temp>mod)||(temp==n)) pdn(0);
		else{
			ll ans=fact[temp-1];ans*=powmod(fact[temp-n-1],mod-2,mod);ans%=mod;
			ans*=powmod(d,n,mod);ans%=mod;
			plldn(ans);
		}
	}
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int x;
	if (n >= 100 && n <= 111)
		x = 111;
	else if (n > 111 && n <= 222)
		x = 222;
	else if (n > 222 && n <=333)
		x = 333;
	else if (n >= 333 && n <=444)
		x = 444;
	else if (n >= 444 && n <=555)
		x = 555;
	else if (n >= 555 && n <=666)
		x = 666;
	else if (n >= 666 && n <=777)
		x = 777;
	else if (n >= 777 && n <=888)
		x = 888;
	else if (n >= 888 && n <=999)
		x = 999;

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
s_1 = input()
s = s_1[::-1]
while len(s) >= 0:
  if s[0:5] == "maerd":
    s = s[5:len(s)]
    continue
  elif s[0:7] == "remaerd":
    s = s[7:len(s)]
    continue
  elif s[0:5] == "esare":
    s = s[5:len(s)]
    continue
  elif s[0:6] == "resare":
    s = s[6:len(s)]
    continue
  elif s == "":
    print("YES")
    break
  else:
    print("NO")
    break

Measured memory_bytes: 3316
#include<iostream>

using namespace std;



main(){

  int n;
  
  while(cin >> n){
  
    int ca=0;
    int a,b,c,d;

    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    
	    if(n==a+b+c+d)ca++;
	    
	  }
	}
      }
    }
    cout << ca << endl;
  }
  
  
  return 0;


}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  struct Data {int A, B;};
  vector<Data> D(N);
  for(auto& i: D) cin >> i.A >> i.B;
  sort(begin(D), end(D), [&](auto l, auto r) {return l.A < r.A;});
  queue<Data> q;
  for(auto& i: D) q.emplace(i);
  int ans = 0;
  multiset<int, greater<int>> S;
  for(auto i=1; i<=M; ++i) {
    while(!q.empty() && q.front().A<=i) {
      S.emplace(q.front().B);
      q.pop();
    }
    if(S.empty()) continue;
    ans += *begin(S);
    S.erase(begin(S));
  }
  cout << ans << endl;
}


Measured memory_bytes: 8708
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let d: f64 = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for _ in 0..n {
        let x: f64 = iterator.next().unwrap().parse().unwrap();
        let y: f64 = iterator.next().unwrap().parse().unwrap();
        if (x * x + y * y).sqrt() <= d {
            ans += 1;
        }
    }
    ans.to_string()
}


Measured memory_bytes: 4840
#include<stdio.h>
int main(void) {
	int a;
	int v[51];
	int c[51];

	scanf("%d", &a);
	
	int i;

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

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



	int sum=0 ;


	
	for (i = 0; i < a; i++) {
		if (v[i] > c[i]) {
			sum = sum+v[i] - c[i];
			
		}
	}

	

	printf("%d\n", sum);
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N;
string S;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> S;
	
	map<string, ll> data;

	for (int x = 0; x < (1 << N); ++x) {
		string a, b;
		for (int i = 0; i < N; ++i) {
			if (x & (1 << i)) 
				a += S[N + i];
			else 
				b += S[N + i];
		}
		data[a + "|" + b]++;
	}

	ll ans = 0;

	for (int x = 0; x < (1 << N); ++x) {
		string a, b;
		for (int i = 0; i < N; ++i) {
			if (x & (1 << i))
				a += S[i];
			else
				b += S[i];
		}

		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());

		ans += data[a + "|" + b];
	}

	print(ans);
}

Measured memory_bytes: 67968
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// Not gonna give up until it's over
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
vector<ll> graph[MAXN];
ll MOD;
vector<ll> going_toward[MAXN];
ll down[MAXN];
ll ans[MAXN];

void dfs(ll u,ll p){
    down[u] = 1;

    for(ll v:graph[u]){
        if(v == p) continue;
        dfs(v,u);
        down[u] = (down[u]*(1+down[v]))%MOD;
    }

    vector<ll> pref,suff;

    for(ll v:graph[u]){
        if(v == p) pref.push_back(1);
        else pref.push_back(down[v] + 1);
    }

    suff = pref;
    FOR(i,1,(ll)pref.size()-1) pref[i] = (pref[i-1]*pref[i])%MOD;
    RFOR(i,0,(ll)suff.size()-2) suff[i] = (suff[i+1]*suff[i])%MOD;

    FOR(i,0,(ll)graph[u].size()-1){
        if(graph[u][i] == p) going_toward[u].push_back(-1);
        else {
            ll mul1 = 1; if(i-1 >= 0) mul1 = pref[i-1];
            ll mul2 = 1; if(i+1 <= suff.size()-1) mul2 = suff[i+1];
            going_toward[u].push_back((mul1*mul2)%MOD);
        }
    }
}

void root_change_dfs(ll u,ll p){
    ans[u] = down[u];

    FOR(i,0,(ll)graph[u].size()-1){
        ll v = graph[u][i];
        if(v == p) continue;
        
        ll oldu = down[u],oldv = down[v];
        down[u] = (going_toward[u][i]*(1+down[p]))%MOD;
        down[v] = (down[v]*(1+down[u]))%MOD;
        root_change_dfs(v,u);
        down[u] = oldu,down[v] = oldv;
    }
}

void solve(){
    ll n; cin>>n>>MOD;

    FOR(i,1,n-1){
        ll u,v; cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dfs(1,0);

    root_change_dfs(1,0);

    FOR(i,1,n) cout<<ans[i]<<endl;
}

signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 24192
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int mul(int a, int b) {
	return (a * b) % MOD;
}

int add(int a, int b) {
	return (a + b) % MOD;
}

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

    int n;
    cin >> n;
    vector<int> c(n);
    for (auto &t : c) {
    	cin >> t;
    }

    vector<int> pw(n + 1);
    pw[0] = 1;
    for (int i = 1; i <= n; i++) {
    	pw[i] = 2 * pw[i - 1] % MOD;
    }

    vector<int> dp(n + 1);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
    	dp[i] = mul(4, dp[i - 1]);
    	dp[i] = add(dp[i], mul(2, mul(pw[i - 1], pw[i - 1])));
    	// dp[i] = 4 * dp[i - 1] + 2 * pw[i - 1] * pw[i - 1];
    	// dp[i] %= MOD;
    }
    int ans = 0;
   	sort(c.begin(), c.end());
   	for (int i = 0; i < n; i++) {
   		int cadd = c[i];
   		cadd = mul(cadd, pw[i]);
   		cadd = mul(cadd, pw[i]);
   		int keks = add(mul(pw[n - 1 - i], pw[n - 1 - i]), dp[n - 1 - i]);
   		cadd = mul(cadd, keks);
   		ans = add(ans, cadd);
   		// ans += (c[i]) * (pw[i]) * (pw[i]) * (pw[n - 1 - i] * pw[n - 1 - i] + dp[n - 1 - i]) % MOD;
   		// ans %= MOD;
   	}
   	ans = mul(ans, 2);
   	cout << ans << endl;
}   

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

int main()
{
	string s;
	cin>>s;
	int l=0;
	int r=0;
	string str;
	while(r<=s.length()){
		if(str.length()<2){
			str.push_back(s[r]);
			r++;
		}
		else if(str.length()>2){
			str.erase(0,1);
			l++;
		}
		else if(str.length()==2){
			if(str=="ST"){
				s.erase(l,2);
				str.erase(0);
				if(l>0) l--;
				r=l;
			}
			else{
				str.push_back(s[r]);
				r++;
			}
		}
	}
	cout<<s.length();
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(a%2!=b%2)
  {
    cout<<"Borys"<<endl;
  }
  else
  {
    cout<<"Alice"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 5e5 + 9, M = 1e6 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll INF = 2e18;
using namespace std;

map<char, int> mp;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int n;
	string str;
	cin >> n >> str;
	for(auto it: str)
		mp[it]++;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if(str[i] == str[j]){
				--mp[str[j]];
				continue;
			}
			set<int> st = {str[i], str[j]};
			if(st.find('R') == st.end()) {
				char c = 'R';
				sum += mp[c];
				int diff = j - i;
				if((j + diff < n && str[j + diff] == c))
					--sum;
			} else if(st.find('G') == st.end()) {
				char c = 'G';
				sum += mp[c];
				int diff = j - i;
				if((j + diff < n && str[j + diff] == c))
					--sum;
			} else {
				char c = 'B';
				sum += mp[c];
				int diff = j - i;
				if((j + diff < n && str[j + diff] == c))
					--sum;
			}
			--mp[str[j]];
		}
		--mp[str[i]];
		for (int j = i + 1; j < n; ++j) {
			mp[str[j]]++;
		}
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3644
/*
 * 001.cpp
 */

//include files
#include<bits/stdc++.h>

using namespace std;

//DEFINE MACROS
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PRINTLN(s) cout << s << endl

//DEFINE CONSTANT

//DEFINE PROTOTYPE

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

  int min = a+b;
  if (min > b+c) {
    min = b+c;
  }
  if (min > c+a) {
    min = c+a;
  }

  cout << min << "\n";
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main()
{
  int x,y,z;
  cin >> x >> y>> z;
  
  int t;
  t=x; x=y; y=t;
  
  t=x; x=z; z=t;
  
  cout << x << " " << y << " " << z <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll mod=1e9+7;
bool prime[1000005];
ll arr[1000001],spf[1000001];
vector<ll> primes;
unordered_map<ll,bool> seen;
ll good=1;

void sieve()
{
    // cout<<"n sicve ";
    ll n=1000000;
    for(ll i=0;i<=n;i++)
    {
        if(i%2 ==0) prime[i]=0;
        else prime[i]=1;
        if(i%2 !=0)
        spf[i]=i;
        else spf[i]=2;
    }
    // cout<<"n sicve 2";

    prime[2]=1; prime[1]=0;
    primes.pb(2);

    for(ll i=3;i<=n;i+=2)
    {
        if(spf[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }
}


void primefactorize(ll n)
{
    ll prev=-1;
    while(n>1)
    {
        if(spf[n]!=prev && seen[spf[n]]) good=0;
        seen[spf[n]]=1;
        prev=spf[n];
        n/=spf[n];
    }
}

int main()
{
    sieve();
    // for(int i=0;i<10;i++) cout<<primes[i]<<" ";cout<<endl;
        ll n;cin>>n;
        for(int i=0;i<n;i++) {cin>>arr[i];}
        ll g=arr[0];
        for(int i=0;i<n;i++)
        {
            primefactorize(arr[i]);
            g=__gcd(g,arr[i]);;
        }
        if(good) cout<<"pairwise coprime";
        else if(g==1) cout<<"setwise coprime";
        else cout<<"not coprime";
    
}

Measured memory_bytes: 23196
#include <stdio.h>

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((a < b)&&(b < c)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2564
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ECommonSubsequence solver = new ECommonSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class ECommonSubsequence {
        public static long mod = 10000_0000_7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long dp[][] = new long[n + 1][m + 1];
            int a[] = new int[n + 1];
            int b[] = new int[m + 1];
            for (int i = 0; i <= n; i++) dp[i][0] = 1;
            for (int i = 0; i <= m; i++) dp[0][i] = 1;
            for (int i = 1; i <= n; i++) a[i] = in.nextInt();
            for (int i = 1; i <= m; i++) b[i] = in.nextInt();
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    dp[i][j] += (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + mod) % mod;
                    dp[i][j] %= mod;
                    if (a[i] == b[j]) {
                        dp[i][j] += dp[i - 1][j - 1] % mod;
                        dp[i][j] %= mod;
                    }
                }
            }
            out.println(dp[n][m]);


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 79700
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#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 repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

bool ok(string& S, int l, int r) {
  repp(i, l, r - 1) {
    if (S[i] == S[i + 1] && S[i + 1] == '#')
      return false;
  }
  return true;
}

bool triple(string& S, int l, int r) {
  repp(i, l - 1, r - 1) {
    if (S[i] == S[i + 1] && S[i + 1] == S[i + 2] && S[i] == '.')
      return true;
  }
  return false;
}

signed main() {
  int N;
  cin >> N;
  int A, B;
  cin >> A >> B;
  A--, B--;
  int C, D;
  cin >> C >> D;
  C--, D--;
  string S;
  cin >> S;

  if (C < D) {
    if (ok(S, B, D) && ok(S, A, C))
      cout << "Yes\n";
    else
      cout << "No\n";
  } else {
    if (ok(S, B, D) && ok(S, A, C) && triple(S, B, D))
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
const long mod=1e9+7;
long N,memo[111][6][6][6][6];
// b3は3文字前,b2は2文字前,b1は1文字前
long rec(int now,int b3,int b2,int b1,int b){
  // printf("%d %d %d %d %d\n",now,b3,b2,b1,b);
  if(memo[now][b3][b2][b1][b]!=-1)return memo[now][b3][b2][b1][b];
  if(b3==0&&b2==1&&b==2)return 0;// AG?Cの場合
  if(b3==0&&b1==1&&b==2)return 0;// A?CGの場合
  if(b2==0&&b1==1&&b==2)return 0;// ?AGCの場合
  if(b2==0&&b1==2&&b==1)return 0;// ?ACGの場合
  if(b2==1&&b1==0&&b==2)return 0;// ?GACの場合
  if(now==N)return 1;
  long ans=0;
  for(int i=0;i<4;i++)ans+=rec(now+1,b2,b1,b,i);
  return memo[now][b3][b2][b1][b]=ans%mod;
}
int main(){
  cin>>N;
  memset(memo,-1,sizeof(memo));
  cout<<rec(0,4,4,4,4)<<endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        int[] I = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
        int A = I[0];
        int B = I[1];
        Console.WriteLine(Lcm(A, B));
    }

    static long Gcd(long a, long b)
    {
        if (a > b)
        {
            if (a % b == 0)
                return b;
            else
            {
                a %= b;
                return Gcd(a, b);
            }
        }
        else
            return Gcd(b, a);
    }

    static long Lcm(long a, long b)
    {
        long ret = a * b / Gcd(a, b);
        return ret;
    }
}


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

int main()
{
    int N;
    cin >> N;

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    int ans = 0;
    while (*max_element(h.begin(), h.end()) != 0)
    {
        for (int i = 0; i < N; i++)
        {
            if(h[i] == 0)
            {
                continue;
            }

            else
            {
                ans++;

                while (i < N && h[i] > 0)
                {
                    h[i]--;
                    i++;
                }   
            }
        }
    }

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

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B;
  cin >> A >> B;

  string ans = "Odd";
  if ((A * B) % 2 == 0) ans = "Even";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, *ABC = gets.split.map(&:to_i)
l = []
N.times do
  l << gets.to_i
end

cost = 10 ** 9
[0, 1, 2, 3].repeated_permutation(N).each do |arys|
  next if [0, 1, 2].any? { |i| !arys.include?(i) }
  temp_cost = 0
  length = [0, 0, 0] # a,b,c
  mp = 0

  N.times do |i|
    if arys[i] != 3
      length[arys[i]] += l[i]
      mp += 10
    end
  end

  temp_cost = mp
  3.times do |i|
    temp_cost += (length[i] - ABC[i]).abs
  end

  cost = cost > temp_cost ? temp_cost : cost
end

p cost - 30

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

int main(){

int N,A,B;
std::string s1 = "Hello World";
cin >> N;

if(N == 1){
printf("%s",s1.c_str());
}

if(N == 2){
cin >> A;
cin >> B;
cout << A+B << endl;
}
}



Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iostream> 
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b==100){
		b=101;
	}
	if(a==0){
		cout<<b;
		return 0;
	}
	else if(a==1){
		printf("%d",b*100);
		return 0;
	}else{
		printf("%d",b*10000);
		return 0;
	}
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            int r = line[0], c = line[1];

            var ret = new int[r + 1][];

            for (var i = 0; i < r; i++)
            {
                ret[i] = (Console.ReadLine() + " 0").Split().Select(s => int.Parse(s)).ToArray();
            }

            // 列ごとの合計を入れるために空の行を追加する
            ret[r] = new int[c + 1];

            // 行ごとの合計計算
            for (var i = 0; i < ret.Length; i++)
            {
                ret[i][c] = ret[i].Sum();
            }

            // 列ごとの合計計算
            for (var i = 0; i < c+1; i++)
            {
                var sum = 0;
                for (var j = 0; j < ret.Length; j++)
                {
                    sum += ret[j][i];
                }
                ret[r][i] = sum;
            }

            // 出力
            foreach (var ans in ret)
            {
                Console.WriteLine(string.Join(" ", ans));
            }

        }

    }

}



Measured memory_bytes: 16468
#include <stdio.h>

int main(void) {
  int start, count, i, end, n, nums[51], sec = 0;
    nums[50] = 0;
    while(scanf("%d",&n), n != 0 ) {
        for(i = 0; i < n; i++ ) {
            scanf("%d",&nums[i]);
        }
        for(i = 0; i < n; i++ ) {
            start = nums[i];
            count = 0;
            for(; i < n - 1; i++ ) {
                if(nums[i] + 1 != nums[i + 1]) {
                    break;
                }
                count++;
            }
            if(count) {
                printf("%d-%d",start, nums[i]);
            } else {
                printf("%d",start);
            }
            if(!(i == n - 1)) {
                printf(" ");
            }
        }
	puts("");
    }
    return 0;
}

Measured memory_bytes: 616
N=int(input())
A,B=(int(i) for i in input().split())
point=[int(i) for i in input().split()]
point.sort()
pointp=point[::-1]
p=[i for i in  point if i<=A]
q=[i for i in point if A<i<=B]
r=[i for i in pointp if i>B]
print(min(len(p),len(q),len(r)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  string s;
  cin>>s;
  int k=stoi(s);
  int l=k/100,m=k%100;
  if((l==0||l>12)&&(m==0||m>12)){cout<<"NA"<<endl;}
  else if((l>12||l==0)&&m<=12&&m>0){cout<<"YYMM"<<endl;}
  else if(l<=12&&l>0&&(m>12||m==0)){cout<<"MMYY"<<endl;}
  else cout<<"AMBIGUOUS"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

#define BN (1000000007)

using namespace std;

long long mypower(long long m,long long n){
	if(n==0){
		return 1;
	}else{
		long long powered=mypower((m*m)%BN,n/2);
		if(n%2==0){
			return powered;
		}else{
			return (powered*m)%BN;
		}
	}
}

int main(){
	long long m,n;
	cin >> m >> n;
	
	cout << mypower(m,n) << endl;
	
	return 0;
}	


Measured memory_bytes: 1160
from bisect import bisect_right, bisect_left
N=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a.sort()
c.sort()
ans=0
for i in range(N):
  s=b[i]
  k=bisect_left(a,s)*(N-bisect_right(c,s))
  ans+=k
print(ans)

Measured memory_bytes: 105104
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

class union_find
{
private:
    std::vector<int> parent;
    std::vector<int> rank;
    vll size;
    int node_num;
public:
    union_find(int node_num);
    void unite(int x, int y);
    int find(int x);
    ll get_size(int x);
};

union_find::union_find(int node_num) :
    parent(node_num + 1, 0),
    rank(node_num + 1, 0),
    node_num(node_num),
    size(node_num + 1, 1)
{
    for (int i = 0; i <= node_num; i++) {
        parent[i] = i;
    }
}

void union_find::unite(int x, int y) {
    int x_root = find(x);
    int y_root = find(y);
    if (x_root == y_root) return;
    if (rank[x_root] > rank[y_root]) {
        parent[y_root] = x_root;
        size[x_root] += size[y_root];
    }
    else {
        parent[x_root] = y_root;
        if (rank[x_root] == rank[y_root]) {
            rank[y_root]++;
        }
        size[y_root] += size[x_root];
    }
}
ll union_find::get_size(int x) {
    return size[find(x)];
}
int union_find::find(int x) {
    if (x != parent[x]) {
        parent[x] = find(parent[x]);
    }
    return parent[x];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vint A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];
    union_find uf(N);
    rep(i, M)
        uf.unite(A[i], B[i]);

    ll max_size = 0;
    rep(i, N) {
        max_size = max(max_size, uf.get_size(i + 1));
    }

    cout << max_size << endl;
    return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b){puts("0");return 0;}
	if(n==1){
		if(a==b) puts("1"); else puts("0");
		return 0;
	}
	cout<<a+b*(n-1)-b-a*(n-1)+1;
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 320 , M = 100020;
struct edge { int ver,val,next; } e[M*2];
int n,m,q,L,t,Head[N],f[N][N],dis[N],vis[N];
inline void insert(int x,int y,int v) { e[++t] = (edge){y,v,Head[x]} , Head[x] = t; }
inline void input(void)
{
    scanf("%d%d%d",&n,&m,&L);
    for (int i=1;i<=m;i++)
    {
        int x,y,v;
        scanf("%d%d%d",&x,&y,&v);
        insert( x , y , v );
        insert( y , x , v );
    }
}
inline void Dijkstra(int s)
{
    memset( dis , 0x3f , sizeof dis );
    memset( vis , 0x00 , sizeof vis );
    priority_queue < pair<int,int> > Heap;
    Heap.push( make_pair(0,s) ) , dis[s] = 0;
    while ( !Heap.empty() )
    {
        int x = Heap.top().second; Heap.pop();
        if ( vis[x] ) continue; vis[x] = true;
        for (int i=Head[x];i;i=e[i].next)
        {
            int y = e[i].ver;
            if ( dis[y] > dis[x] + e[i].val && dis[x] + e[i].val <= L )
            {
                dis[y] = dis[x] + e[i].val;
                f[s][y] = 0;
                Heap.push( make_pair(-dis[y],y) );
            }
        }
    }
}
int main(void)
{
    input();
    memset( f , 0x3f , sizeof f );
    for (int i=1;i<=n;i++) Dijkstra(i);
    for (int k=1;k<=n;k++)
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                f[i][j] = min( f[i][j] , f[i][k] + f[k][j] + 1 );
    scanf("%d",&q);
    for (int i=1;i<=q;i++)
    {
        int s,t; scanf("%d%d",&s,&t);
        printf("%d\n",f[s][t]==0x3f3f3f3f?-1:f[s][t]);
    }
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100
#define V 1000
int v[N+1],w[N+1],dp[2][N*V+1],Sum[N+1];
signed main(){
	int n,m,i;scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)scanf("%lld%lld",w+i,v+i),Sum[i]=Sum[i-1]+v[i];
	memset(dp,0x3f,sizeof(dp));dp[0][0]=0;
	for(i=1;i<=n;i++)for(int j=0;j<=Sum[i];j++)
		dp[i&1][j]=min(dp[i-1&1][j],(j>=v[i]?dp[i-1&1][j-v[i]]+w[i]:0x3f3f3f3f));
	for(i=Sum[n];;i--)if(dp[n&1][i]<=m)return printf("%lld\n",i),0;
}
/*1
3 8
3 30
4 50
5 60
*/
/*2
1 1000000000
1000000000 10
*/
/*3
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/

Measured memory_bytes: 1792