akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
}


Measured memory_bytes: 764
#!/usr/bin/env python3
s = input()
n = len(s)

def tasu(a,b):
    if a == n-1:
        return sum(list(map(int,b.split("+"))))

    return tasu(a+1,b+s[a+1])+ \
        tasu(a+1,b+"+"+s[a+1])
print(tasu(0,s[0]))

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

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

int main(){
 ll x;
  cin >> x;
  for(int i=0;i<=1000;i++){
	for(int j=0;j<=i;j++){
      ll n=pow(i,5);
      ll m=pow(j,5);
      if(n==x+m){
        cout << i << " " << j << endl;
        break;
      }
      else if(n==x-m){
        cout << i << " " << 0-j << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 4060
using System;

public class Hello{
    public static void Main(){
        string[] str;
        str = Console.ReadLine().Split(' ');
        int a =int.Parse(str[0]);
        int b =int.Parse(str[1]);
        int c =int.Parse(str[2]);
        
        if(a <= b && b <= c){
            Console.WriteLine( a + " " + b + " " + c );
        }
        else if(a <= c && c <= b){
            Console.WriteLine( a + " " + c + " " + b );
        }
        else if(b <= a && a <= c){
            Console.WriteLine( b + " " + a + " " + c );
        }
        else if(b <= c && c <= a){
            Console.WriteLine( b + " " + c + " " + a );
        }
        else if(c <= a && a <= b){
            Console.WriteLine( c + " " + a + " " + b );
        }
        else if(c <= b && b <= a){
            Console.WriteLine( c + " " + b + " " + a );
        }
    }
}


Measured memory_bytes: 15944
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static  ll INF = 1e9;
using namespace std;

//ワーシャルフロイド法
int d[105][105];int n;

void warshall_floyd(){
	for(int k=0;k<n;++k){
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}

signed main(){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;++i){
		if(i!=x-k+1)cout<<" ";
		cout<<i;
	}cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<long long> A(N);
    rep(i,N){
        cin>>A[i];
    }
    long long  max=0;
    long long ans=0;
    max=A[0];
    rep(i,N){
        if(max>A[i]){
            ans=ans+(max-A[i]);
        }else{
            max=A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll f[10010];
int main(){
	rep(i,10010)f[i]=0;
	for(ll x=1;x<=100;x++)for(ll y=1;y<=100;y++)for(ll z=1;z<=100;z++){
		ll res=x*x+y*y+z*z+x*y+y*z+z*x;
		if(res<10010)f[res]++;
	}
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)cout<<f[i]<<"\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  // map<p, bool> checked;
  bool checked[2000][2000];
  // rep(i, 2000) rep(j, 2000) checked[i][j] = false;
  queue<pair<p, int>> q;
  int count = 0;
  rep(i, h){
    cin >> v[i];
    rep(j, w){
      if(v[i][j] == '#'){
        q.push({{i, j}, count});
        checked[i][j] = true;
      }
    }
  }

  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  int res = 0;
  while(!q.empty())
  {
    int y = q.front().first.first;
    int x = q.front().first.second;
    int count = q.front().second;
    res = count;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny >= 0 && nx >= 0 && ny < h && nx < w){
        if(!checked[ny][nx] && v[ny][nx] == '.'){
          v[ny][nx] = '#';
          checked[ny][nx] = true;
          q.push({{ny, nx}, count+1});
        }
      }
    }
  }
  // print(v);
  cout << res << endl;



}


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

using namespace std;

int main() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> a(r, vector<int> (c));
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i <= r; ++i) {
        if (i < r) {
            int sum = 0;
            for (int j = 0; j < c; ++j) {
                if (j > 0) {
                    cout << " ";
                }
                cout << a[i][j];
                sum += a[i][j];
            }
            cout << " " << sum << '\n';
        }
    }
    int all = 0;
    for (int j = 0; j < c; ++j) {
        if (j > 0) {
            cout << " ";
        }
        int sum = 0;
        for (int i = 0; i < r; ++i) {
            sum += a[i][j];
            all += a[i][j];
        }
        cout << sum;
    }
    cout << " " << all << '\n';
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e9 + 7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep1(i, n) cin >> a[i];
    ll ans = INF;
    for (ll i=0; i+k-1<(n); i++){
        ll res;
        if (a[i+k-1]*a[i]>=0) res = max(abs(a[i+k-1]), abs(a[i]));
        else res = max(abs(a[i+k-1]), abs(a[i])) + min(abs(a[i+k-1]), abs(a[i]))*2;
        ans = min(ans, res);
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4008
N, Y = map(int, input().split())
result = "%s %s %s" % (-1,-1,-1)
for i in range(N+1):
    for j in range(i+1):
       total = 10000 * (N-i) + 5000 * (i-j) + 1000 * j
       if (total == Y):
            result = "%s %s %s" % (N-i, i-j, j)
            break
print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int dp[105][1<<15];
int sum[1<<15];
vector<int> w;
int rec(int d,int S){
	if(dp[d][S]!=-1)return dp[d][S];
	int add = abs(w[d]-sum[S]);
	if(d==0)dp[d][S]=add;
	else dp[d][S]=rec(d-1,S)+add;
	for(int j=0;j<N;j++){
		int mask = (1<<j);
		if((S>>j)&1){
			chmin(dp[d][S],rec(d,S-mask));
			if(d>0)chmin(dp[d][S],rec(d-1,S-mask)+add);
		}
	}
	return dp[d][S];
}
int solve(){
	scanf("%d %d",&N,&M);
	if(N+M==0)return 1;
	vector<int> s(N);
	w.resize(M);
	for(int i=0;i<N;i++)scanf("%d",&s[i]);
	for(int i=0;i<M;i++)scanf("%d",&w[i]);
	sort(all(w));
	memset(sum,0,sizeof(sum));
	for(int i=0;i<(1<<N);i++){
		for(int j=0;j<N;j++){
			if((i>>j)&1){
				sum[i]+=s[j];
			}
		}
	}
	memset(dp,-1,sizeof(dp));
	int ans = INF;
	for(int i=0;i<(1<<N);i++)chmin(ans,rec(M-1,i));
	//for(int i=0;i<(1<<N);i++)cout << rec(M-1,i) << endl;
	printf("%d\n",ans);
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

Measured memory_bytes: 16728
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long t=sc.nextLong();
  		long ans=t;

  		long[] a=new long[n];
		for(int c=0;c<n;c++){
    		a[c]=sc.nextInt();
    	}
  		for(int d=1;d<n;d++){
         if((a[d]-a[d-1])<t){
          ans=ans-t+a[d]-a[d-1];
         }
          ans+=t;
        }
    
 	
    	System.out.println(ans);
    }
}


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

vector<int> dislike;
int n,k;

bool ok(int x) {
    while(x > 0) {
        if(dislike[x % 10])
            return false;
        x /= 10;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n >> k) {
        dislike = vector<int>(10, 0);
        for(int i = 0; i < k; i++) {
            int x; cin >> x;
            dislike[x] = 1;
        }
        while(!ok(n)) {
            n++;
        }
        cout << n << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    unordered_map<ll, ll> A_cnt_m;
    ll A_max = 0;
    rep(i, N) {
        cin >> A[i];
        if (A_cnt_m.find(A[i]) == A_cnt_m.end()) {
            A_cnt_m[A[i]] = 1;
        } else {
            A_cnt_m[A[i]] += 1;
        }
        A_max = max(A_max, A[i]);
    }
    vector<bool> dp(A_max, true);
    SORT(A);
    set<ll> A_set(A.begin(), A.end());
    for (auto a : A_set) {
        ll i = a + a;
        while (i <= A_max) {
            dp[i - 1] = false;
            i += a;
        }
    }

    ll ans = 0;
    for (auto a : A) {
        if (A_cnt_m[a] == 1) {
            ans += dp[a - 1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 22520
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define MOD (int)(1e9+7)
using namespace std;
typedef pair<int, int> P;
struct edge {
    int to, cost;
};

class dijkstra {
private:
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<>> que;

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

    int find(int e) {
        return d[e];
    }
};

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

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

bool prime(int a) {
    if (a == 1)
        return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)
            return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y))
            return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}
signed main() {
    int n,a[200000],mx=-1,mx1=-1;
    bool ifmanymax=false;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(mx==a[i]){
            ifmanymax=true;
        }
        else if(mx<a[i]){
            ifmanymax=false;
            mx1=mx;
            mx=a[i];
        }
        else if(mx1<a[i])mx1=a[i];
    }
    rep(i,n){
        if(ifmanymax)cout<<mx<<endl;
        else if(mx==a[i])cout<<mx1<<endl;
        else cout<<mx<<endl;
    }

}


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

void Main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    vector<long> cost(n+1);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        long c1 = 1e10;
        long c2 = 1e10;
        if(i>=1) c1 = cost[i-1] + abs(h[i-1]-h[i]);
        if(i>=2) c2 = cost[i-2] + abs(h[i-2]-h[i]);
        if(i==0) cost[i] = 0;
        else cost[i] = min(c1, c2);
    }
    
    cout << cost[n-1] << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

using namespace std;
#define ll long long int
ll const mod=3e9;
//vector<ll>v1[100001];
//vector<ll>v2(100001,0);
//vector<ll>h(100001,0);

int main()
{
    int k;
    cin>>k;
    while(k--)
    {
        cout<<"ACL";
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;



int main(){
    ll l,r; cin >> l >> r;

    if(r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }

    ll ans = INF;

    rep(i,l,r){
        rep(j,i+1,r+1){
            ll tmp = (i*j) % 2019;
            ans = min(ans,tmp);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
K = gets.to_i
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
ans = list[K - 1]
puts ans

Measured memory_bytes: 1788
#include <iostream>

int main() {
  long A, B, K;

  std::cin >> A;
  std::cin >> B;
  std::cin >> K;

  long i=A;

  for (; i<A+K && i<=B; i++)
    std::cout << i << std::endl;

  i = i>(B-K+1) ? i : B-K+1;

  for (; i<=B; i++)
    std::cout << i << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int n;
long double x[1005], y[1005], X, Y, d, e;
long double dist(long double a, long double b) {
    return a*a + b*b;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%Lf%Lf", &x[i], &y[i]);
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    long double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    printf("%.9Lf\n", sqrtl(d));
}

Measured memory_bytes: 128
using System;

namespace AOJ.Volume2
{
    public class FatWallet
    {
        public static int Main()
        {
            var coin = new int[6] { 1, 5, 10, 50, 100, 500 };
            var input = Console.ReadLine().Split(' ');

            int amount = 0;
            for (int i = 0; i < 6; i++) { amount += coin[i] * int.Parse(input[i]); }

            Console.WriteLine(amount >= 1000 ? 1 : 0);

            return 0;
        }
    }
}

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

vector<long long>adj[30];

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,ans=0,res=0,ttl=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;


        cin>>str; cin>>ttr;  sz=str.size(); tz=ttr.size();

        for(i=0;i<sz;i++)
        {
            h=str[i]-97; adj[h].push_back(i);

        }

        e=-1; vector<long long>::iterator it;

        for(i=0;i<tz;i++)
        {

            h=ttr[i]-97; r=adj[h].size();

            if(r==0){  printf("-1\n"); flag=0; break;  }


            it=upper_bound(adj[h].begin(),adj[h].end(),e); sc=it-adj[h].begin();

            if(sc==r){  ans=ans+sz; e=-1; i--;  }
            else{ fr=adj[h][sc];  e=fr;  if(i==tz-1){  ans=ans+fr; ans++;  }     }



        }


        if(flag==1)printf("%lld\n",ans);




    return 0;
}





Measured memory_bytes: 4668
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=1; i<=3000; i++){
        cin >> x >>y;
        if(x == 0 && y == 0){
            break;
        }
        else if(x > y){
            swap(x, y);
        }
        cout << x << " " << y << endl;
    }
   return 0; 
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P,P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int main() {
    int h, w;
    while(cin >> w >> h, h){
        string s[25];
        int si, sj;
        UnionFindTree g;
        g.init(h*w);
        REP(i,h) cin >> s[i];
        REP(i,h){
            REP(j,w){
                if(s[i][j]=='#')continue;
                if(s[i][j]=='@'){
                    si = i;
                    sj = j;
                }
                REP(k,4){
                    int ni = i+di[k], nj = j+dj[k];
                    if(ni < 0 || ni >= h) continue;
                    if(nj < 0 || nj >= w) continue;
                    if(s[ni][nj]=='#') continue;
                    g.unite(i*w+j,ni*w+nj);
                }
            }
        }
        cout << g.size(si*w+sj) << endl;
    }
    return 0;
}



Measured memory_bytes: 3144
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	ss := s + s
	cs := make(map[string][]int)
	for i := 0; i < len(ss); i++ {
		c := string(ss[i])
		cs[c] = append(cs[c], i)
	}

	n := len(s)
	ans := 0
	p := 0
	for i := 0; i < len(t); i++ {
		c := string(t[i])
		a := cs[c]
		if len(a) == 0 {
			fmt.Println(-1)
			return
		}

		x := lowerBound(a, p)
		p = a[x] + 1
		if n <= p {
			p -= n
			ans += n
		}
	}
	ans += p

	fmt.Println(ans)
}

func lowerBound(a []int, x int) int {
	lb, ub := -1, len(a)
	for ub-lb > 1 {
		mid := (lb + ub) / 2
		if a[mid] < x {
			lb = mid
		} else {
			ub = mid
		}
	}
	return ub
}


Measured memory_bytes: 10624
import bisect

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0

for i in B:
    num_A = bisect.bisect_left(A, i)
    num_B = bisect.bisect_right(C, i)
    ans += num_A * (N - num_B)

print(ans)

Measured memory_bytes: 29416
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int ans=30;

    rep(i,n){
        int m;
        cin >> m;
        rep(i,ans){
            if(m%2==0){
                m = m/2;
                if(m==1){
                    ans = min(ans,i+1);
                    break;
                }
                else{
                    continue;
                }
            }
            else{
                ans = min(ans,i);
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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


void solve(std::vector<long long> M, std::vector<long long> D){
    if(M.at(0) != M.at(1)){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::vector<long long> M(2);
    std::vector<long long> D(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&M[i]);
        scanf("%lld",&D[i]);
    }
    solve(std::move(M), std::move(D));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010];
long long ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        ans+=a[i]/2;
        a[i]%=2;
        if(i<n&&a[i]&&a[i+1]){ans++;a[i]--;a[i+1]--;}
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 768
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

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

ll fib[20];

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

    // input
    ll H, W, K;
    cin >> H >> W >> K;

    ll dp[H+1][W+1];

    // フィボナッチ
    fib[0]=0;
    fib[1]=1;
    fib[2]=1;
    FOR(i, 3, 20){
        fib[i] = fib[i-1] + fib[i-2];
    }
    
    FOR(i, 0, W+1){
        dp[0][i] = 0;    
    }
    dp[0][1] = 1;
    
    FOR(h, 1, H+1){
        FOR(w, 1, W+1){
            ll left = w-2; // 自由な本数
            ll right = W - w;
            ll X = fib[left+1] * fib[right+1];

            left = w-1;
            right = W - w;
            ll Y = fib[left+1] * fib[right+1];

            left = w-1;
            right = W - w - 1;
            ll Z = fib[left+1] * fib[right+1];

            dp[h][w] = X * dp[h-1][w-1] + Y * dp[h-1][w] + Z * dp[h-1][w+1];
            dp[h][w] %= mod;
        }
    }

    p(dp[H][K]);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
using namespace std;

void BubbleSort(vector<string> Array, int N)
{
	for(int i = 0; i< N;i++)
    {
      string key = Array[i];
      for(int j=N-1;j>=i+1;j--)
      {
        if(Array[j][1] - '0' < Array[j-1][1] - '0')
        {
          string tmp = Array[j];
          Array[j] = Array[j-1];
          Array[j-1] = tmp;
        }
      }
    }
  	
	for(int i=0;i<N-1;i++)
    {
      cout << Array[i] << " ";
    }
  	cout << Array[N-1] << endl;
  	cout << "Stable" << endl;
}

void SelectionSort(vector<string> Array, int N)
{
  	bool isStable=true;
  	for(int i = 0; i< N;i++)
    {
      int min_idx = i;
      bool isSame = false;
      int same_idx;
      for(int j=i+1;j<N;j++)
      {
        if(Array[j][1] - '0' == Array[min_idx][1] - '0') 
        {
          isSame=true;
          same_idx = j;
        }
        if(Array[j][1] - '0' < Array[min_idx][1] - '0')
        {
          min_idx = j;
        }
      }
      if(isSame && same_idx < min_idx) isStable = false;
      string tmp = Array[i];
      Array[i] = Array[min_idx];
      Array[min_idx] = tmp;
    }
	for(int i=0;i<N-1;i++)
    {
      cout << Array[i] << " ";
    }
  	cout << Array[N-1] << endl;
  	if(isStable) cout << "Stable" << endl;
  	else cout << "Not stable" << endl;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long N;
	cin >> N;
  	vector<string> Array(N);
  	int idx = 0;
  	while(cin >> Array[idx]) idx++;
  	BubbleSort(Array, N);
  	SelectionSort(Array, N);
  	return 0;
}



Measured memory_bytes: 3216
from sys import stdin

inf = 10**10
h,w = [int(x) for x in stdin.readline().rstrip().split()]

li = [["#" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

def all_pairs_shortest_paths(W):
    # 頂点の数
    n = len(W)
    # 結果を格納する行列を用意する
    res = [[0] * n for i in range(n)]
    # 用意した行列を初期化する
    for i in range(n):
        for j in range(i, n):
            if i == j:
                val = 0
            elif W[i][j]:
                val = W[i][j]
            else:
                val = inf
            res[i][j] = res[j][i] = val
    # 動的計画法ですべての超点間の最短距離を求める
    for k in range(n):
        for u in range(n):
            for v in range(n):
                res[u][v] = min(res[u][v], res[u][k] + res[k][v])
    return res

a = [[0 for i in range(w)]for j in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] = i*w + j

lin = [[0 for i in range(h*w)]for j in range(h*w)]

for i in range(h):
    for j in range(w-1):
        if li[i][j] == "." and li[i][j+1] == ".":
            lin[a[i][j]][a[i][j+1]] = 1
            lin[a[i][j+1]][a[i][j]] = 1

for i in range(h-1):
    for j in range(w):
        if li[i][j] == "." and li[i+1][j] == ".":
            lin[a[i][j]][a[i+1][j]] = 1
            lin[a[i][j]][a[i+1][j]] = 1

lis = all_pairs_shortest_paths(lin)

ma = 0
for i in range(h*w):
    for j in range(h*w):
        if lis[i][j] != 10**10:
            ma = max(lis[i][j],ma)

print(ma)

Measured memory_bytes: 44592
x,n = map(int,input().split())
l = list(map(int,input().split()))
ans = 10**10
if n == 0:
    print(x)
    exit()
for i in range(-100,1000):
    if i in l:
        continue
    if ans > abs(i-x):
        ans1 = i
        ans = abs(i-x)
print(ans1)
    

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

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

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

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



signed main(){

    int H, W, N; cin >> H >> W >> N;
    int m = max(H, W);
    int ans = (N - 1 + m) / m;
    Out(ans); 

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int b = sc.nextInt();
			int r = sc.nextInt();
			int g = sc.nextInt();
			int c = sc.nextInt();
			int s = sc.nextInt();
			int t = sc.nextInt();
			if(b==0 && r==0 && g==0 && c==0 && s==0 && t==0)break;
			
			int sum = (b+r)*15 + (b*5+r*3)*16 + g*7 + c*2 + 100 - (t-s)*3;
			
			System.out.println(sum);
		}
	
	}	
}

Measured memory_bytes: 20968
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main(void)
{
  	std::string A, B, C;
    std::cin >> A >> B >> C;
  
  	auto check = [&](){
      if (A.at(A.size()-1) != B.at(0)) return "NO";
      if (B.at(B.size()-1) != C.at(0)) return "NO";
      return "YES";
    };
  
    std::cout << check() << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) {
        cin>>a[i]>>b[i];
    }
    sort(all(a));
    sort(all(b));
    if (n%2) {
        ll mn = a[n/2];
        ll mx = b[n-1-(n/2)];
        cout << mx-mn+1 << endl;
    }
    else {
        ll mx = b[n/2] + b[n/2-1];
        ll mn = a[n/2] + a[n/2-1];
        cout << mx - mn + 1 << endl;
    }

    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var T = input[1];
            var ans = 10000;

            for (int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var c = input[0];
                var t = input[1];
                if (t <= T && c < ans)
                {
                    ans = c;
                }
            }

            if (ans != 10000) Console.WriteLine(ans);
            else Console.WriteLine("TLE");
        }
    }
}

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

int N;
map<string, int> S;
string W[100];

int main() {
    cin >> N;
    rep(i, N) {
        string tmp;
        cin >> tmp;
        S[tmp]++;
        W[i] = tmp;
    }
    
    if (S.size() != N) {
        cout << "No" << endl;
        return 0;
    }

    string ans = "Yes"; 
    rep(i, N - 1) {
        if (W[i][W[i].size() - 1] != W[i + 1][0]) {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    queue<char> a, b, down, right;
    bool loop = true;
    while(loop){
        string str;
        char inp;
        rep(i,3){
            getline(cin, str);
            if(str[0] == '-'){
                 loop = false;
                 break;
            }
            for(int j = 0; j < str.size(); j++){
                if(i == 0) a.push(str[j]);
                else if(i == 1) b.push(str[j]);
                else if(i == 2) down.push(str[j]);
            }
        }
        int p = 2;
        while(!a.empty() || !b.empty()){
            if(p == 1){
                if(a.front() == down.front()){
                    a.pop(); down.pop();
                }else{
                    right.push(a.front());
                    a.pop();
                    p = 2;
                }
            }else if(p == 2){
                if(b.front() == down.front()){
                    b.pop(); down.pop();
                    p = 1;
                }else{
                    right.push(b.front());
                    b.pop();
                }
            }
        }
        while(!right.empty()){
            cout << right.front();
            right.pop();
        }
        if(loop){
            cout << endl;
        }
    }
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	for (int i=0;i<S.size();i++){
		if (i%2==0){
			cout<<S[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<vector<P>> to(n);
   rep(i, 0, n) {
      int a;
      cin >> a;
      rep(j, 0, a) {
         int x, y;
         cin >> x >> y;
         x--;
         to[i].emplace_back(x, y);
      }
   }
   int ans = 0;
   rep(s, 0, 1 << n) {
      bool ok = true;
      rep(i, 0, n) {
         if (s >> i & 1) {
            rep(j, 0, to[i].size()) {
               if (((s >> to[i][j].first) & 1) != to[i][j].second) {
                  ok = false;
               }  
            }
         }
      }
      if (ok) chmax(ans, __builtin_popcount(s));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3664
N=gets.to_i
S=gets.chomp
MOD=10**9+7

accS=0
ans=1
S.each_char do |c|
  if (accS.even? && c=="B") || (accS.odd? && c=="W")
    accS+=1
    #print "["
  else
    ans*=accS
    ans%=MOD
    accS-=1
    #print "]"
  end
end
if accS!=0
  p 0
  exit
end

N.times do |i|
  ans*=(i+1)
  ans%=MOD
end
p ans


Measured memory_bytes: 2172
#include<iostream>
#include<string>
#include<ctype.h>

//int main() {
//
//	int N = 0;
//	int K = 0;
//	std::string S;
//
//	std::cin >> N;
//	std::cin >> K;
//	std::cin >> S;
//
//	S[K - 1] = tolower(S[K - 1]);
//
//	std::cout << S << std::endl;
//
//}

int main() {
	int S;
	int a = 0;
	int b = 0;
	int count = 0;
	std::cin >> S;
	a = S / 100;
	b = S % 100;
	//std::cout << a << "\t" << b << std::endl;
	if ((b <= 0 || b >= 13) && (a <= 0 || a >= 13)) {
		std::cout << "NA" << std::endl;
	}
	else if (a > 0 && a < 13 && b > 0 && b < 13) {
		std::cout << "AMBIGUOUS" << std::endl;
	}
	else if (a <= 0 || a >= 13 && b > 0 && b < 13) {
		std::cout << "YYMM" << std::endl;
	}
	else if(a > 0 && a < 13 && b <= 0 || b >= 13){
		std::cout << "MMYY" << std::endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

inline int read() {
   	int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 505;
const int M = 200005;

int n,m,Q;
int num[N][N],ans[N][N];

int main() {

	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	n=read(),m=read(),Q=read();
	rep(i,1,m) {
		int l=read(),r=read();
		num[l][r]++;
	}

	per(i,n,1) {
		int tmp=0;
		rep(j,i,n) {
			tmp+=num[i][j];
			ans[i][j]=ans[i+1][j]+tmp;
		}
	}

	while (Q--) {
		int p=read(),q=read();
		printf("%d\n",ans[p][q]);
	}

	return 0;
}



Measured memory_bytes: 2944
n= int(input())
spot = input().split()
ans = []
for i in spot:
    spot.append(int(spot[0]))
    del spot[0]
if n == 1:
    print(0)
else:
    if max(spot)==min(spot):
        ans.append(0)
    for s in range(min(spot),max(spot)):
        x = 0
        for t in spot:
            x += (s-t)**2
        ans.append(x)
if n != 1:
    ans.sort(reverse=False)
    print(ans[0])

Measured memory_bytes: 3064
/// In The Name Of God

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

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

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N], b[N];

vector <int> st;
ll ans;
int get(int l, int r) {
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	int m1 = (1 << k), m2 = m1 << 1;
	for (int i = 1; i <= n; i++) {
		st[i - 1] = a[i] & (m2 - 1);
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] & (m2 - 1);
		cnt += get(m1 - cur, m2 - cur - 1);
		cnt += get(m1 + m2 - cur, m2 << 1);
	}
	if (cnt & 1) ans += m1;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &b[i]);
	}
	st.resize(n);
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	printf ("%lld\n", ans);
	ioi
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

	cout << (N-1)/2 << endl;

	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n,k;cin>>n>>k;
    vector<int> data(n);
    REP(i,n){
        cin>>data[i];
    }
    sort(ALL(data),greater<int>());
    int res=0;
    REP(i,k){
        res+=data[i];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    java.util.Scanner input = new java.util.Scanner (System.in);
    String userInput = input.nextLine();

    if (userInput.equals("a") || userInput.equals("A"))
    {
       System.out.println("T");
    }
    else if (userInput.equals("t") || userInput.equals("T"))
    {
       System.out.println("A");
    }
    else if (userInput.equals("g") || userInput.equals("G"))
    {
       System.out.println("C");
    }
    else if (userInput.equals("c") || userInput.equals("C"))
    {
       System.out.println("G");
    }
  }
}


Measured memory_bytes: 35680
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()
    var passed = 0
    var passedB = 0
    sc.next().map {
        if (passed < a + b && (it == 'a' || it == 'b' && passedB < b)) {
            println("Yes")
            passed++
            if (it == 'b') passedB++
        } else {
            println("No")
        }
    }
}

Measured memory_bytes: 39952
n = int(input())
temp = []
for i in range(n):
    temp.append(input())
temp_res = set(temp)
if len(temp) != len(temp_res):
    print("No")
else:
    ans = 0
    for i in range(n-1):
        # print(i)
        temp_c1 = str(temp[i])
        temp_c2 = str(temp[i+1])
        # print()
        # print(temp_c1)
        # print(temp_c2)
        if temp_c1[-1] == temp_c2[0]:
            ans+=1
        # print(ans)
    if ans == n-1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
a,b,c,x,y = map(int,input().split())

if (2*c<a and 2*c<b):
    #cだけを買う
    ans = max(x,y)*2*c

elif (2*c<a and 2*c>b):
    ans = x*2*c
    ans += max(0,y-x)*b
    pass

elif (2*c<b and 2*c>a):
    ans = y*2*c
    ans += max(0,x-y)*a
elif 2*c<(a+b):
    ans = min(x,y)*2*c
    if x>y:
        ans+=(x-y)*a
    else:
        ans+=(y-x)*b
else:
    ans = x*a+y*b
print(ans)



Measured memory_bytes: 3064