akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main() {
    int r; cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
W = []
f = True
for i in range(N):
  W.append(input())
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    f = False
W = sorted(W)
for i in range(N-1):
  if W[i] == W[i+1]:
    f = False
if f:
  print("Yes")
else:
  print("No")

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;
  int ans = 0;
  REP(i, n - 2) {
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      ans++;
    }
  }

  cout << ans << endl;
}


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

namespace Volume0005
{
    class Program
    {
        static long[] _numbers = new long[2];
        static long _number1 = 0;
        static long _number2 = 0;

        static void Main(string[] args)
        {
            string str = "";
            while ((str = Console.ReadLine()) != null)
            {
                _numbers = str.Split(' ').Select(long.Parse).ToArray();
                _number1 = _numbers[0];
                _number2 = _numbers[1];
                Console.WriteLine(Calclation.Gcd(_number1, _number2) + " " + Calclation.Lcm(_number1, _number2));
            }
        }
    }
    class Calclation
    {
        static internal long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            long remainder = 0;
            while (b != 0)
            {
                remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
        static internal long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }
    }
}



Measured memory_bytes: 16380
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    TreeMap<String,Integer> tm = new TreeMap<>();
    int max = 1;
    for(int i = 0;i<n;i++){
      String s = sc.next();
      if(tm.containsKey(s)){
        tm.put(s,tm.get(s) + 1);
        max = Math.max(max,tm.get(s));
      }else{
        tm.put(s,1);
      }
    }
    for(String ss: tm.keySet()){
      if(tm.get(ss) == max){
        System.out.println(ss);
      }
    }
  }
}


Measured memory_bytes: 85768
x=int(input())
for A in range(120):
    k=A**5-x
    if k>=0:
        l=int(k**0.2)
        if l**5==k:
            print(A,l)
            break
    else:
        k=-k
        l=int(k**0.2)
        if l**5==k:
            print(A,-l)
            break

Measured memory_bytes: 9320
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    long long n,t[128],i,r;
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        scanf("%lld",&t[i]);
        if(i==1){r=t[i];}else{r=lllcm(r,t[i]);}
    }
    printf("%lld\n",r);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

double dist(PLL f, PLL t){
  return sqrt((f.fst - t.fst) * (f.fst - t.fst) + (f.snd - t.snd) * (f.snd - t.snd));
}

int main(){
  PLL st, ed;
  scanf("%lld %lld %lld %lld\n", &st.fst, &st.snd, &ed.fst, &ed.snd);

  int N;
  scanf("%d\n", &N);

  vector<PLL> vs;
  VL rs;
  vs.push_back(st);
  rs.push_back(0);
  REP(i, 0, N){
    PLL a;
    ll c;
    scanf("%lld %lld %lld\n", &a.fst, &a.snd, &c);
    vs.push_back(a);
    rs.push_back(c);
  }
  vs.push_back(ed);
  rs.push_back(0);

  double es[1002][1002];
  REP(i, 0, N + 1){
    REP(j, i, N + 2){
      if(i == j){
        es[i][j] = 0;
      } else {
        es[i][j] = es[j][i] = max(0.0, dist(vs[i], vs[j]) - rs[i] - rs[j]);
      }
    }
  }

  bool used[1002] = {false};
  double d[1002];
  fill_n(d, 1002, pow(10, 19));
  d[0] = 0;

  REP(i, 0, N + 2){
    int v = -1;
    REP(j, 0, N+2){
      if(!used[j] && (v == -1 || d[v] > d[j])){
        v = j;
      }
    }
    //printf("bef,d[%d]: %lf \n\n", v, d[v]);
    if(v == -1){
      break;
    }
    used[v] = true;
    REP(i, 0, N + 2){
      //printf("es[%d][%d]: %lf\n", v, i, es[v][i]);
      d[i] = min(d[i], d[v] + es[v][i]);
      //printf("d[%d]: %lf\n\n", i, d[i]);
    }
  }
  printf("%.10lf\n", d[N+1]);
  return 0;
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    i64 K, N;
    cin >> K >> N;
    vector<i64> A(N);
    rep(i, 0, N) cin >> A[i];
    auto ans = K - (A[0] + abs(K - A[N - 1]));
    rep(i, 0, N - 1) {
        auto d = abs(A[i] - A[i + 1]);
        auto t = K - d;
        chmin(ans, t);
    }
    cout << ans << "\n";
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for(auto&& i : a)
	{
		cin >> i;
	}
	queue<tuple<int, int, int>> que;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			if(a[i][j] == '#')
			{
				que.push(make_tuple(i, j, 0));
			}
		}
	}
	int ans = 0;
	int dx[] = { 1, 0, -1, 0 };
	int dy[] = { 0, 1, 0, -1 };
	while(!que.empty())
	{
		auto status = que.front();
		que.pop();
		
		int x = get<0>(status);
		int y = get<1>(status);
		ans = get<2>(status);
		for(int i = 0; i < 4; i++)
		{
			if (x + dx[i] < 0 || y + dy[i] < 0 || x + dx[i] == h || y + dy[i] == w) continue;
			if (a[x + dx[i]][y + dy[i]] == '#') continue;
			a[x + dx[i]][y + dy[i]] = '#';
			que.push(make_tuple(x + dx[i], y + dy[i], ans + 1));
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main() {
    long double a,b,c;
    cin >> a >> b >> c;
    long double eps = 1.0E-14;
    if (pow(a,0.5) + pow(b,0.5) + eps < pow(c,0.5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

//解説AC

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if(n == 1){
        cout << 1 << endl;
        return 0; 
    }
    if(n == 2){
        if(s[0] == s[1]){
            cout << 1 << endl;
        }else{
            cout << 2 << endl;
        }
        return 0;
    }

    int dp[n]{};
    dp[0] = 1;
    if(s[0] == s[1]){
        dp[1] = 1;
    }else{
        dp[1] = 2;
    }
    if(s[0] != s[1] && s[1] != s[2]){
        dp[2] = 3;
    }else{
        dp[2] = 2;
    }
    for(int i = 3; i < n; i++){
        if(s[i-1] == s[i]){
            dp[i] = dp[i-3] + 2;
        }else{
            dp[i] = dp[i-1] + 1;
        }
    }
    
    cout << dp[n-1] << endl;
    return 0;
}



Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define all(a) begin(a),end(a)

int main()
{
    string S; cin >> S;
    int Q; cin >> Q;
    vi T(Q);
    vi F(Q);
    vs C(Q);

    string pre, suf;

    int dir = 0;
    rep(i, Q) {
        cin >> T[i];
        if (T[i] == 1) {
            dir++;
        } else {
            cin >> F[i] >> C[i];
            if (F[i] == 1) {
                if (dir%2==0) {
                    pre += C[i];
                } else {
                    suf += C[i];
                }
            } else {
                if (dir%2==0) {
                    suf += C[i];
                } else {
                    pre += C[i];
                }
            }
        }
    }

    string ans;
    if (dir % 2 == 0) {
        reverse(all(pre));
        ans = pre + S + suf;
    } else {
        reverse(all(S));
        reverse(all(suf));
        ans = suf + S + pre;
    }

    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int a,b,C,M;

int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

int main() {
  while(1){
    int m,n,A,B;
    cin>>m>>n>>A>>B;
    if(!(m+n))break;
    a=A;
    b=B;
    C = ~(1<<31);
    M = (1<<16)-1;
    vector<tuple<int,int,int>> v;
    REP(i,m){
      int x,y,z;
      cin>>x>>y>>z;
      v.emplace_back(x,y,z);
    }
    REP(i,n){
      int x=r(),y=r(),z=r();
      v.emplace_back(x,y,z);
    }
    sort(begin(v),end(v));
    vector<set<tuple<int,int>>> dp(1<<20);
    dp[0].insert(make_tuple(-1,-1));
    auto vitr = begin(v), veitr = begin(v);
    while(veitr != end(v)) {
      vector<tuple<int,int,int>> add;
      vector<tuple<int,int,int>> er;
      while(veitr != end(v)
          && get<0>(*veitr) == get<0>(*vitr)) ++veitr;
      for(; vitr != veitr; ++vitr) {
        int y,z;
        tie(ignore,y,z) = *vitr;
        int k=1<<19;
        int j=0;
        while(k){
          int nj=j+k;
          auto itr = dp[nj].lower_bound(make_tuple(y,0));
          if (itr != begin(dp[nj])) {
            --itr;
            if (get<1>(*itr) < z) j=nj;
          }
          k /= 2;
        }
        ++j;
        auto itr = dp[j].lower_bound(make_tuple(y,z));
        if (itr != begin(dp[j])) {
          int py,pz;
          tie(py, pz) = *prev(itr);
          if (py == y || pz == z) continue;
        }
        while(itr != end(dp[j])
            && (get<0>(*itr) == y || get<1>(*itr) >= z)) {
          er.emplace_back(j,get<0>(*itr),get<1>(*itr));
          ++itr;
        }
        add.emplace_back(j,y,z);
      }
      sort(begin(er),end(er));
      er.erase(unique(begin(er),end(er)),end(er));
      for (auto s:er) {
        int j,y,z;
        tie(j,y,z) = s;
        dp[j].erase(make_tuple(y,z));
      }
      sort(begin(add),end(add));
      add.erase(unique(begin(add),end(add)),end(add));
      auto itr = begin(add), eitr = begin(add);
      while(eitr != end(add)) {
        while(eitr != end(add) &&
            get<0>(*eitr) == get<0>(*itr)) ++eitr;
        vector<tuple<int,int>> tp;
        int j = get<0>(*itr);
        for(; itr != eitr; ++itr) {
          int y,z;
          tie(ignore,y,z) = *itr;
          //cout<<j<<' '<<y<<' '<<z<<endl;
          if (tp.empty() || (get<0>(tp.back()) < y && get<1>(tp.back()) > z)) {
            tp.emplace_back(y,z);
          }
        }
        for(auto r:tp) {
          dp[j].insert(r);
        }
      }
    }
    int maxl = 0;
    REP(i,1<<20) {
      if(!dp[i].empty()) {
        maxl = i;
      }
    }
    cout<<maxl<<endl;
  }
  return 0;
}

Measured memory_bytes: 60436
#include<stdio.h>
int main(){
  int n,k,i,j,p[1000],x[1000],sum=0;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    x[i]=1000;
  }
  for(i=0;i<n;i++){
    for(j=0;j<k;j++){
      if(p[i]>x[j]){
        if(j>0){x[j-1]=p[i];}
        break;
      }else{
         if(j>0){x[j-1]=x[j];}
      }
      if(j==k-1){x[j]=p[i];}
    }
  }
  for(j=0;j<k;j++){
    sum+=x[j];
  }
  printf("%d\n",sum);
}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b;

signed main() {
	cin >> a >> b;
	if (a%2 && b%2) cout << "Odd" << ln;
	else cout << "Even" << ln;
}

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

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }

int main() {
    int N, X;
    bool xfl = false;
    cin >> N >> X;
    vector<int> x(N);
    for(int i = 0; i < N; ++i) {
        cin >> x[i];
        if(x[i] == X)
            xfl = true;
    }
    sort(x.begin(), x.end());
    if(!xfl) {
        auto itr = upper_bound(x.begin(), x.end(), X);
        x.insert(itr, X);
    }
    int ans = x[1] - x[0];
    for(int i = 1; i < x.size() - 1; ++i) {
        ans = gcd(x[i + 1] - x[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int func(int x) {
  if (x%100 != 0) return 0;
  return func(x/100) + 1;
}

int main () {
  int d, n;
  cin >> d >> n;
  int cnt = 0;
  for (int x = 1;; ++x) {
    if (func(x) == d) {
      cnt++;
      if (cnt == n) {
        cout << x << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//素集合データ構造
// ref:https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
struct union_find {
    // parent[v]==w(>=0):vの親はw
    // parent[v]==k(<0):vは根&&vの属するグループの要素数は-k
    vector<long long int> parent;
    int dimH_0;
    //コンストラクタ
    union_find(long long int n) : dimH_0(n) {
        parent.assign(n, -1);
    }
    // vの根を求める
    //求めると同時に親を根に置き換える(木の圧縮)
    long long int root(long long int v) {
        if (parent[v] < 0) {
            return v;
        } else {
            parent[v] = root(parent[v]);
            return parent[v];
        }
    }
    // vが属するグループの要素数を求める
    long long int size(long long int v) {
        return -parent[root(v)];
    }
    // vとwを繋げる
    void unite(long long int v, long long int w) {
        v = root(v);
        w = root(w);
        if (v == w) return;
        if (parent[v] < parent[w]) swap(v, w);
        parent[w] += parent[v];
        parent[v] = w;
        dimH_0--;
    }
    // vとwが同値か判定
    bool isSame(long long int v, long long int w) {
        return root(v) == root(w);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    union_find langs(m);
    vector<int> native_lang(n);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k >> native_lang[i], native_lang[i]--;
        for (int j = 0; j < k - 1; j++) {
            int l;
            cin >> l, l--;
            langs.unite(native_lang[i], l);
        }
    }
    for (int i = 0; i < n - 1; i++) {
        if (!langs.isSame(native_lang[i], native_lang[i + 1])) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main() {

	int N;
	string S;

	cin >> N >> S;

	for (int i = 0; i < S.size(); i++) {
		char c = S[i] - 'A';
		c = (c + N) % 26;
		cout << char('A' + c);
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e17+7;
const int maxn = 200005;
ll T,n,m;
int a[405][405];
char c[405][405];
int main() {
	int h,w,k;
	cin>>h>>w>>k;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>c[i][j];
	int cnt = 1;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			if(c[i][j]=='#'){
				int l=1,r=w,d=h;
				for(int x=j-1;x>=1;x--){
					if(c[i][x] == '#'){
						l = x+1;
						break;
					}
						
				}
				for(int x=j+1;x<=w;x++){
					if(c[i][x] == '#'){
						r = x-1;	
						break;
					}
				}
				for(int y=i+1;y<=h;y++){
					if(c[y][j] == '#'){
						d = y-1;
						break;
					}
						
				}
	
				for(int x=l;x<=r;x++)
					for(int y=i;y<=d;y++){
						a[y][x] = cnt;
					
					}
						
				cnt++;
			}
		}
	for(int i=h-1;i>=1;i--){
		for(int j=1;j<=w;j++)
		if(a[i][j]==0)
			a[i][j]=a[i+1][j];
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cout<<a[i][j]<<" ";
		}
			
		cout<<"\n";
	}
    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int n,m; cin >> n >> m;
  vector<tii> table;
  rep(i,n){
    int a,b; cin >> a >> b;
    table.pb(tii{a,b});
  }
  sort(ALL(table));
  priority_queue<int,vt<int>, less<int>> t;
  rep(i,m)t.push(0);
  table.pb(tii{10000000,0});
  ll ans = 0;
  int now = 0;
  rep(i,m){
    while(get<0>(table[now]) <= i+1){
      t.push(get<1>(table[now++]));
    }
    //cerr << t.top() << endl;
    ans += t.top(); t.pop();
  }
  cout << ans <<  endl;
}


Measured memory_bytes: 2548
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */
/*my variables are anime character */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define vll vector<ll>
#define pll pair<ll , ll> 
#define vpll vector<pll>
#define umpll unordered_map<ll , ll>
#define mpll map<ll , ll>
#define sll set<ll>
#define stll stack<ll>
#define FIO  ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);



ll N,T;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;

  if(N==0)
    cout<<1<<'\n';

  else
    cout<<0<<'\n';
  
}



int main(){
  
  FIO 
  
 solve();

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist[2];
    dist[0].resize(N, INF);
    dist[1].resize(N, INF);
    function<void(int,int,int,int)> dfs = [&](int v, int p, int d, int k) {
        dist[k][v] = d;
        FORE(w, g[v]) {
            if (w == p) continue;
            dfs(w, v, d + 1, k);
        }
    };
    dfs(0, -1, 0, 0);
    dfs(N - 1, -1, 0, 1);
    int f = 0, s = 0;
    REP(i, N) {
        if (dist[0][i] <= dist[1][i]) {
            f++;
        } else {
            s++;
        }
    }
    if (f <= s) {
        cout << "Snuke" << endl;
    } else {
        cout << "Fennec" << endl;
    }
    return 0;
}



Measured memory_bytes: 18176
#include <stdio.h>

int main(void){
    long long int n,a,b,quo,rem;
    scanf("%lld%lld%lld",&n,&a,&b);

    quo = n / (a + b);

    rem = n % (a + b);

    if(rem >= a){
        printf("%lld",a*quo + a);
    }

    else if(rem < a){
        printf("%lld",a*quo + rem);
    }

    return 0;

}

Measured memory_bytes: 128
def XOR(n):
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return n + 1
    if n % 4 == 3:
        return 0
    if n % 4 == 0:
        return n

A, B = [int(s) for s in input().split(' ')]
if A == B:
    print(A)
else:
    print(XOR(A-1) ^ XOR(B))


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

int main() {
  int N;
  cin >> N;
  int N1 = N / 1000 % 10;
  int N2 = N / 100 % 10;
  int N3 = N / 10 % 10;
  int N4 = N % 10;
  if ((N1 == N2 && N1 == N3) || (N2 == N3 && N2 == N4))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
class BIT():

    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        '''i番目の要素にxを加算する'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def get(self, i, j):
        '''[i, j)の和を求める'''
        return self._sum(j) - self._sum(i)


n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]

cumsum_a = [0]*(n+1)
for i in range(n):
    cumsum_a[i+1] = cumsum_a[i] + a[i]
for i in range(n+1):
    cumsum_a[i] = cumsum_a[i] - k*i

#座標圧縮したリストを返す
def compress(list1):
    len_list1 = len(list1)
    list11 = sorted(set(list1))
    memo = {value : index for index, value in enumerate(list11)}
    list2 = [0]*(len_list1)
    for i in range(len_list1):
        list2[i] = memo[list1[i]]
    return list2

cumsum_a = compress(cumsum_a)

bit = BIT(n+1)
ans = 0
for i in range(n+1):
    ans += bit.get(0, cumsum_a[i] + 1)
    bit.add(cumsum_a[i], 1)
print(ans)

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  int answer=0;
  for(int i=0;i<N;i++){
    cin>>h[i];
    if(h[i] >= K){
      answer++;
    }
    
  }
  cout << answer;
}

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

struct Card { char mark; int number; };

void bubbleSort(Card* c, int n);
void selectionSort(Card* c, int n);
void trace(Card* c, int n);

int main() {
  Card card[100];
  int n;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> card[i].mark >> card[i].number;
  }

  Card cb[100];
  Card cs[100];

  for (int i = 0; i < n; ++i) {
    cb[i] = card[i];
    cs[i] = card[i];
  }

  bubbleSort(cb, n);
  selectionSort(cs, n);

  trace(cb, n);
  cout << "Stable" << endl;
  trace(cs, n);
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    if (cb[i].mark != cs[i].mark) { flag = false; break; }
  }
  if (flag)
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;

  return 0;
}

void bubbleSort(Card* c, int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; j >= i + 1; --j) {
      if (c[j].number < c[j - 1].number) {
        Card tc = c[j];
        c[j] = c[j - 1];
        c[j - 1] = tc;
      }
    }
  }
}

void selectionSort(Card* c, int n) {
  for (int i = 0; i < n; ++i) {
    int minj = i;
    for (int j = i + 1; j < n; ++j) {
      if (c[j].number < c[minj].number)
        minj = j;
    }
    Card tc = c[i];
    c[i] = c[minj];
    c[minj] = tc;
  }
}

void trace(Card* c, int n) {
  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    cout << c[i].mark << c[i].number;
  }
  cout << endl;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<limits.h>
#define N 500000
#define M 300000
#define SEN INT_MAX
int n,a=0;
int L[M],R[M],S[N];
int mergeSort(int,int);
int merge(int,int,int);
main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  mergeSort(0,i);
  
  for(j=0;j<i;j++){
    printf("%d",S[j]);
    if(j<i-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",a);
  return 0;
}

int mergeSort(int left,int right){
  int mid;
  if (left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}





int merge(int left, int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;


  for(i=0;i<n1;i++) L[i]=S[left+i];
  for(i=0;i<n2;i++) R[i]=S[mid+i];
  L[n1]=SEN;
  R[n2]=SEN;

  i=0;
  j=0;
  k=0;

  for(k=left;k<right;k++){
    a++;    
    if(L[i]<=R[j]){
      S[k]= L[i];
      i++;
    }
    else{
      S[k] = R[j];
      j++;
    }
  }
}

Measured memory_bytes: 4708
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const int MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main(){
    int N;
    cin >> N;
    string c;
    cin >> c;
    int r=0;
    rep(i,N){
        if(c[i] == 'R') r++;
    }
    int ans = 0;
    rep(i,r){
        if(c[i] == 'W') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3752
n = int(input())
s = input()

res = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i+1, n-1):
        k = j + (j - i)
        if k < n:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                res -= 1
        else:
            break

print(res)

Measured memory_bytes: 9200
N, A, B, C, D = map(int, input().split())
S = '$' + input() + '$'

def isOk(fr, to):
    if S[fr: to + 1].count('##') > 0:
        return False
    return True

if not (isOk(A, C) and isOk(C, D)):
    print('No')
    exit()

def canSwitch():
    if S[max(A, B) - 1: min(C, D) + 2].count('...'):
        return True
    return False

if A < B and D < C or B < A and C < D:
    if not canSwitch():
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3636
class dice:
    def __init__(self,label):
        self.d = label
    def roll(self,op):
        d = self.d
        if   op=='N': self.d = [d[1],d[5],d[2],d[3],d[0],d[4]]
        elif op=='E': self.d = [d[3],d[1],d[0],d[5],d[4],d[2]]
        elif op=='W': self.d = [d[2],d[1],d[5],d[0],d[4],d[3]]
        elif op=='S': self.d = [d[4],d[0],d[2],d[3],d[5],d[1]]
    def print(self):
        print(self.d[0])
    def print_r_side(self,t,f):
        d = self.d
        if   (t,f)==(d[0],d[1]): print(d[2])
        elif (t,f)==(d[0],d[2]): print(d[4])
        elif (t,f)==(d[0],d[3]): print(d[1])
        elif (t,f)==(d[0],d[4]): print(d[3])
        elif (t,f)==(d[1],d[0]): print(d[3])
        elif (t,f)==(d[1],d[2]): print(d[0])
        elif (t,f)==(d[1],d[3]): print(d[5])
        elif (t,f)==(d[1],d[5]): print(d[2])
        elif (t,f)==(d[2],d[0]): print(d[1])
        elif (t,f)==(d[2],d[1]): print(d[5])
        elif (t,f)==(d[2],d[4]): print(d[0])
        elif (t,f)==(d[2],d[5]): print(d[4])
        elif (t,f)==(d[3],d[0]): print(d[4])
        elif (t,f)==(d[3],d[1]): print(d[0])
        elif (t,f)==(d[3],d[4]): print(d[5])
        elif (t,f)==(d[3],d[5]): print(d[1])
        elif (t,f)==(d[4],d[0]): print(d[2])
        elif (t,f)==(d[4],d[2]): print(d[5])
        elif (t,f)==(d[4],d[3]): print(d[0])
        elif (t,f)==(d[4],d[5]): print(d[3])
        elif (t,f)==(d[5],d[1]): print(d[3])
        elif (t,f)==(d[5],d[2]): print(d[1])
        elif (t,f)==(d[5],d[3]): print(d[4])
        elif (t,f)==(d[5],d[4]): print(d[2])

label = list(map(int,input().split()))
q = int(input())
d0 = dice(label)
for _ in range(q):
    t,f = list(map(int,input().split()))
    d0.print_r_side(t,f)

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

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


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL C[200011];
LL A[200011];
LL pre[200011];
LL dp[200011];
LL MOD=1e9+7;
int main(){
	cin>>N;
	REP(i,200001){
		C[i]=-1;
		A[i]=-1;
		pre[i]=-1;
	}
	REP(i,N){
		cin>>C[i];
		pre[i]=-1;
		A[i]=-1;
	}
	for(int i=N-1;i>=0;i--){
		A[i]=pre[C[i]];
		pre[C[i]]=i;
	}
	REP(i,N){
		dp[i]=0;
	}
	
	REP(i,N){
		if(i==0){
			dp[i]=1;
			//cout<<A[i]<<endl;
			if((A[i]!=-1)&&(A[i]!=i+1)){
				dp[A[i]]+=1;
			}
			continue;
		}
		dp[i]+=dp[i-1];
		dp[i]%=MOD;
		if((A[i]!=-1)&&(A[i]!=i+1)){
			dp[A[i]]+=dp[i];
			dp[A[i]]%=MOD;
		}
		
	}
	/*REP(i,N){
		cout<<"dp"<<i<<" "<<dp[i]<<endl;
	}*/
	cout<<dp[N-1]%MOD<<endl;
}

Measured memory_bytes: 6528
#include <stdio.h>
int main() {
  char s[6];
  scanf("%s",s);
  if(s[0] == 'C') {

    puts("Rainy");
  }else if(s[0] == 'R') {

    puts("Sunny");
  }else {

    puts("Cloudy");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll k; cin >> k;
    ll a; cin >> a;
    ll b; cin >> b;
    ll tmp = 0;
    while(true){
        if ((a <= tmp) && (tmp <=b)){
            cout << "OK" << endl;
            return 0;
        }
        if (b < tmp){
            cout << "NG" << endl;
            return 0;
        }
        tmp += k;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
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;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

int main(){

	ll n,a,b;
	cin >> n >> a >> b;
	ll x[100010];
	FOR(i,n){
		cin >> x[i];
	}
	ll ans=0;
	for(int i=1;i<n;i++){
			ans+=min((x[i]-x[i-1])*a,b);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> ans(h, vector<int>(w, 0));
    int num = 1, cnt = 0;
    rep(i, h) {
        int scnt = 0;
        rep(ii, w) {
            if (s[i][ii] == '#') scnt++;
        }
        if (scnt == 0) continue;
        rep(ii, w) {
            if (s[i][ii] == '#') {
                if (cnt > 0) {
                    num++;
                    cnt = 0;
                }
                cnt++;
            }
            ans[i][ii] = num;
        }
        if (cnt > 0) {
            num++;
            cnt = 0;
        }
    }
    rep(i, h) {
        if (ans[i][0] != 0) continue;
        int pos = -1;
        reps(ii, i + 1, h) {
            if (ans[ii][0] != 0) {
                pos = ii;
                break;
            }
        }
        if (pos != -1) {
            rep(ii, w) {
                ans[i][ii] = ans[pos][ii];
            }
            continue;
        }
        rrep(ii, i) {
            if (ans[ii][0] != 0) {
                pos = ii;
                break;
            }
        }
        if (pos != -1) {
            rep(ii, w) {
                ans[i][ii] = ans[pos][ii];
            }
            continue;
        }
    }
    rep(i, h) {
        rep(ii, w) {
            printf("%d%s", ans[i][ii], (ii == (w - 1)) ? "\n" : " ");
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
            if(b%2==0 && b>=a*2 && b<=a*4){
            printf("Yes\n");
          }
        else{
            printf("No\n");
        }
    return 0;
} 

Measured memory_bytes: 1628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuilder answer = new StringBuilder();
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            String tmp = String.valueOf(s.charAt(i));
            int number = (str.indexOf(tmp) + n);
            answer.append(str.substring(number, number + 1));
        }
        System.out.println(answer);
        sc.close();
    }
}


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

typedef long long int lli;

lli eleva(lli n, lli e){
	lli res = 1;
	for(lli i = 1; i <= e; i++){
		res *= n;
	}
	return res;
}

int main (){
	
	lli n, p, i, ax;
	cin >> n >> p;
	ax = p;
	lli res = 1;
	lli c = 0;
	for(i = 2; i*i <= ax; i++){
		c = 0;
		while(p%i==0){
			p /= i;
			c++;
		}
		//cout << "kka";
		//cout << i << " " << c << endl;
		if(c >= n){
			res = res*eleva(i,c/n);
		}
	}
	
	//cout << p << endl;
	if(n==1){
		cout << ax << endl;
	}else{
		cout << res << endl;
	}
	
}


Measured memory_bytes: 256
from math import cos
from math import radians
a,b,h,m=map(int,input().split())
alpha=(h*60+m)/2
beta=6*m
n=radians(min(abs(alpha-beta),360-abs(alpha-beta)))
ans=(a**2+b**2-2*a*b*cos(n))**(1/2)
print(ans)

Measured memory_bytes: 9448
// 16:32 - 
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

vector<int> a[N];
bool isCyc[N];
int w[N], from[N];

void FindCycle(int u){
	static int stk[N], vst[N];
	if(vst[u]){
		isCyc[u] = 1;
		while(stk[stk[0]] != u){
			isCyc[stk[stk[0]]] = 1;
			stk[0]--;
		}
		return;
	}
	vst[u] = 1;
	stk[++stk[0]] = u;
	FindCycle(from[u]);
}

void DFS(int u){
	set<int> s;
	for(auto v: a[u]){
		if(w[v] == -1) DFS(v);
		s.insert(w[v]);
	}
	for(int i=0; ; i++)
		if(s.find(i) == s.end()){
			w[u] = i; break;
		}
}

bool Check(int rt, int x){
	int o = from[rt];
	w[rt] = x;
	while(o != rt){
		set<int> s;
		for(auto v: a[o])
			s.insert(w[v]);
		for(int i=0; ; i++)
			if(s.find(i) == s.end()){
				w[o] = i; break;
			}
		o = from[o];
	}
	set<int> s;
	for(auto v: a[rt])
		s.insert(w[v]);
	for(int i=0; ; i++)
		if(s.find(i) == s.end())
			return i == x;
}

int main(){
	ios::sync_with_stdio(0);

	int n; cin >> n;
	for(int i=1; i<=n; i++){
		int u; cin >> u;
		a[u].push_back(i);
		from[i] = u;
	}

	FindCycle(1);

	memset(w, -1, sizeof(w));
	
	int rt = 0;
	for(int i=1; i<=n; i++)
		if(!isCyc[i]) DFS(i);
		else rt = i;
	
	set<int> srt;
	for(auto v: a[rt])
		if(!isCyc[v]) srt.insert(w[v]);
	int v1 = -1, v2 = -1;
	for(int i=0; ; i++){
		if(srt.find(i) != srt.end()) continue;
		if(v1 == -1) v1 = i;
		else{
			v2 = i; break;
		}
	}

	bool f = 1;
	if(!Check(rt, v1) && !Check(rt, v2)) f = 0;
	cout << (f ? "POSSIBLE\n" : "IMPOSSIBLE\n");

	return 0;
}


Measured memory_bytes: 13440