akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

template<typename T>
void p(T elem) {cout << elem << endl;}
template<typename T>
void ps(vector<T>& arr) { for(T e: arr) p(e); }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    int num;
    cin >> num;
    int total = num*(num-1)/2;

    map<pii, vector<pii>> graph;
    // vector<vector<int>> graph(num*num);
    vector<vector<pii>> matches(num, vector<pii>(num-1));
    // vector<vector<int>> matches(num, vector<int>(num-1));
    for(int i = 0; i < num; i++) {
        for(int j = 0; j < num-1; j++) {
            int target;
            cin >> target;
            target--;
            int smaller = min(i, target);
            int larger = max(i, target);
            pii p = make_pair(smaller, larger);
            matches[i][j] = p;
        }
    }

    map<pii, int> outdeg;
    for(int i = 0; i < num; i++) {
        pii prev = matches[i][0];
        for(int j = 1; j < num-1; j++) {
            pii cur = matches[i][j];
            graph[prev].push_back(cur);
            outdeg[cur]++;
            prev = cur;
        }
    }

    queue<pii> queue;
    for(int i = 0; i < num; i++) {
        for(int j = i+1; j < num; j++) {
            pii p = make_pair(i, j);
            if(outdeg[p]) continue;
            queue.push(p);
        }
    }

    int cnt = 0;
    // 1-indexed
    int ans = 1;
    vector<char> bitmap(num);
    while(!queue.empty()) {
        pii src = queue.front(); queue.pop();
        debug("pii: %d, %d\n", src.first, src.second);
        cnt++;
        if(bitmap[src.first] || bitmap[src.second]) {
            ans++;
            fill(bitmap.begin(), bitmap.end(), 0);
        }
        bitmap[src.first] = bitmap[src.second] = 1;
        for(pii dst: graph[src]) {
            outdeg[dst]--;
            if(!outdeg[dst]) queue.push(dst);
        }
    }
    debug("cnt: %d ans: %d\n", cnt, ans);
    cout << (cnt < total ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 97296
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;


int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i <= n ; ++i){
        int sz = 0 , tmp = i;
        while(tmp)sz++ , tmp /= 10;
        ans += (sz & 1);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
const int N = 10000;
int main()
{
	int a[N] = {0},n,max=-1000000,min=1000000;
	long long sum = 0;
	scanf("%d",&n);
	for(int i =0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
		max = a[i];
		}
		if(a[i]<min)
		{
		min = a[i];
		}
		sum += a[i]; 
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1e12+5
#define ninf         -1e17
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=2e5+5;
int Arr[N];
int sizer[N];
void initialize()
    {
        for(int i = 0;i<N;i++)
        {
          Arr[i] = i ;
          sizer[i] = 1;
        }
    }


int root(int i)
    {
        while(Arr[i]!= i)
        {
            Arr[i] = Arr[Arr[i]] ; 
            i = Arr[i]; 
        }
    return i;
    }

void union1(int A,int B)
    {
        int root_A = root(A);
        int root_B = root(B);
        if(sizer[root_A]<sizer[root_B])
        {
          Arr[root_A] = Arr[root_B];
          sizer[root_B]+= sizer[root_A];
        }
        else
        {
          Arr[root_B] = Arr[root_A];
          sizer[root_A] += sizer[root_B];
        }

    }



int main() 
{ 
          fast();
        
          initialize();
          int n,m;
          cin >> n >> m;
          while(m--){
            int a,b;
            cin >> a >> b;
            if(root(a)!=root(b))
            union1(a,b);
          }
          set<int> s;
          for(int i=1;i<=n;i++)
            s.insert(root(i));
          int maxi=0;
          for(auto i=s.begin();i!=s.end();i++)
            if(sizer[*i]>maxi)
              maxi=sizer[*i];

            cout<<maxi;

          

          
           return 0; 

} 

Measured memory_bytes: 14544
#include<bits/stdc++.h>
using namespace std;
map<int,int>my;
map<int,int>mc;
typedef long long LL;
int c[100005];
int main(void)
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        my.clear();mc.clear();
        for(int i = 0;i < N;i++)
        {
            int t;
            scanf("%d",&t);
            c[i] = t;
            my[t]++;
        }
        sort(c,c+N);
        LL sum = 0;
        LL it[2],cnt = 0;
        for(int i = N-1;i >= 0;i--)
        {
            if(my[c[i]] >= 4)
            {
                sum = max((LL)c[i]*(LL)c[i],sum);
                if(cnt == 0)
                    break;
                else
                {
                    it[cnt++] = (LL)c[i];
                    sum = it[0] * it[1];
                    break;
                }
            }
            else if(my[c[i]] >= 2)
            {   my[c[i]] = 1;
                if(cnt == 0)
                {
                   it[cnt++] = (LL)c[i];
                }
                else
                {
                    it[cnt++] = (LL)c[i];
                    sum = it[0] * it[1];
                    break;
                }
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
 
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;
 
  cout << endl;
}
 
int main(){
  int n;
  cin >> n;
  call(n);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN], b[mxN], c[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[i] = x;
    c[i] = x;
  }
  for (int i = 0; i < n; ++i) cin >> b[i];
  int diff1 = 0, diff2 = 0, i = 1;
  sort(c, c + n);
  do {
    bool c1 = true, c2 = true;
    for (int i = 0; i < n; ++i)
      if (a[i] != c[i]) c1 = false;
    for (int i = 0; i < n; ++i)
      if (b[i] != c[i]) c2 = false;
    if (c1) diff1 = i;
    if (c2) diff2 = i;
    ++i;
  } while (next_permutation(c, c + n));
  cout << abs(diff1 - diff2);
  return 0;
}



Measured memory_bytes: 3720
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;


namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            ProgramA a = new ProgramA();
            a.main();

        }
    }

    //ABC096
    class ProgramA
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            Console.WriteLine((a -1)*(b-1));
        }
    }

    class ProgramB
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());

            int ans = 0;
            for (int i = 1; i <= n; i = i + 2)
            {
                int count = 0;
                for (int j = 1; j < Math.Sqrt(i);j++)
                {
                    if(i % j == 0)
                    {
                        if (i == j * j)
                            count++;
                        else
                            count += 2;
                    }
                }

                if (count == 8)
                    ans++;
            }

            Console.WriteLine(ans);
            

        }
    }

    class ProgramC
    {
        public void main()
        {
            string s = Console.ReadLine();
            long k = long.Parse(Console.ReadLine());

            int pos = 0;
            for(int i = 0;i < s.Length;i++)
            {
                if (s[i] != '1')
                {
                    pos = i;
                    break;
                }
            }

            if (k - 1 < pos)
                Console.WriteLine("1");
            else
                Console.WriteLine(s[pos]);

        }
    }

    class ProgramD
    {
        public void main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] xi = Console.ReadLine().Split(' ');

            long[] a = new long[n];

            for (int i = 0; i < n; i++)
                a[i] = long.Parse(xi[i]);

            //ソートする
            Array.Sort(a);

            //最大値候補
            long sum = a[n - 1] / 2;

            //二分探索
            long min = -1;
            long max = n;
            while(min + 1 != max)
            {
                long temp = (min + max) / 2;
                if (a[temp] <= sum)
                    min = temp;
                else
                    max = temp;
            }

            if(min == -1)
            {
                Console.WriteLine(a[n - 1] + " " + a[0]);
                return;
            }

            if (min == n - 2)
            {
                Console.WriteLine(a[n - 1] + " " + a[n - 2]);
                return;
            }

            if (sum - a[min] < a[max] - sum)
                Console.WriteLine(a[n - 1] + " " + a[min]);
            else
                Console.WriteLine(a[n - 1] + " " + a[max]);

        }

    }

    

}


Measured memory_bytes: 27172
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    to = [-1 for _ in range(len(s))]
    fr = 0
    for i in range(len(s)):
        if s[i] == "L":
            for j in range(fr, i):
                to[j] = i
            fr = i+1
    t = s[::-1]
    fr = 0
    for i in range(len(t)):
        if t[i] == "R":
            for j in range(fr, i):
                to[len(t)-j-1] = len(t)-i-1
            fr = i+1
    cnt = [0 for _ in range(len(s))]
    for i in range(len(s)):
        if abs(to[i]-i) % 2 == 0:
            cnt[to[i]] += 1
        elif i < to[i]:
            cnt[to[i]-1] += 1
        else:
            cnt[to[i]+1] += 1
    print(" ".join(map(str, cnt)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14616
/* ex 9_2
   Tarara */

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

#define SIZE (int)(1e5 + 10)

//リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem)
{
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first)
{
    char elem;
    node *tmp = *first;
    if (tmp == NULL)
        exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void)
{
    int count = 0;
    char input[SIZE];
    //最初のノードの指す先
    node *first = NULL;
    int i;

    // 入力
    scanf("%s", input);

    for (i = 0; i < strlen(input); i++)
    {
        //　入力文字列を先頭から順に取り出す
        push(&first, input[i]);
        // スタックの一番上の2つのキューブが異なれば，それらを取り除く
        if (first->next != NULL && first->elem != first->next->elem)
        {
            count += 2;
            pop(&first);
            pop(&first);
        }
    }

    //　出力
    printf("%d\n", count);
    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



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

    string s;
    cin >> s;

    int x1[] = {0,0,1,1}, x2[] = {0,1,0,1};

    REP(i, 4) {
        vector<int> ans(N); // 0:S, 1:W
        ans[0] = x1[i];
        ans[1] = x2[i];

        for (int i = 1; i <= N - 2; i++){
            if (s[i] == 'o') {
                ans[i + 1] = (ans[i] == 0 ? ans[i-1] : 1 - ans[i-1]);
            } else {
                ans[i + 1] = (ans[i] == 0 ? 1 - ans[i-1] : ans[i-1]);
            }
        }

        // N番目と1番目の主張が矛盾していなければOK
        bool c1 = (s[0] == 'o' && ((ans[0] == 0 && ans[N-1] == ans[1]) || (ans[0] == 1 && ans[N-1] != ans[1])))
               || (s[0] != 'o' && ((ans[0] == 1 && ans[N-1] == ans[1]) || (ans[0] == 0 && ans[N-1] != ans[1])));
        bool c2 = (s[N-1] == 'o' && ((ans[N-1] == 0 && ans[N-2] == ans[0]) || (ans[N-1] == 1 && ans[N-2] != ans[0])))
               || (s[N-1] != 'o' && ((ans[N-1] == 1 && ans[N-2] == ans[0]) || (ans[N-1] == 0 && ans[N-2] != ans[0])));
        if(c1 && c2) {
            REP(i, N) cout << (ans[i] == 0 ? 'S' : 'W');
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int g[] = { 0,2,0,1,0,1,0,0,1,0,1,0 };
int main() {
	int a, b;
	cin >> a >> b;
	puts((g[--a] == g[--b]) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <math.h>
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long

using namespace std;

int main () {
    FASTIO
    char ch;
  	cin >> ch;
  	ch ++;
  	cout << ch << '\n';
    return 0;
}

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

const int MOD = 1e9 + 7;
const int MAX = 510000; 

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    long long t;
    while (b)
    {
        t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long com(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

long long perm(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n-k] % MOD;
}

int main(void)
{
    COMinit();

    int n, m; cin >> n >> m;
    long long ans = 0;

    long long tmp;
    for (int k = 0; k <= n; k++)
    {
        tmp = com(n, k) * perm(m, k) % MOD * perm(m-k, n-k) % MOD * perm(m-k, n-k) % MOD;
        if (k % 2 == 1) ans -= tmp;
        else ans += tmp;
        ans %= MOD;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  if(s <= "2019/04/30")
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k;
vector<int>v;
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		int a; cin >> a;
		v.pb(a);
	}
	int ans = -mod;
	for(int l = -1; l < n; l++)
	{
		for(int r = n; r > l; r--)
		{
			vector<int>u;
			for(int i = 0; i <= l; i++)
				u.pb(v[i]);
			for(int i = n - 1; i >= r; i--)
				u.pb(v[i]);
			if(sz(u) > k)
				continue;
			sort(all(u));
			int cur = 0;
			for(int a : u)
				cur += a;
			int ops = k - sz(u);
			for(int i = 0; i < sz(u); i++)
			{
				if(ops > 0 && u[i] < 0)
				{
					ops--;
					cur -= u[i];
				}
			}
			ans = max(ans, cur);
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 110, P = 1000000007;

int n;
int h[N], stk[N], ch[N][2];
int dp[N][2];

int mpow(int x, int k) {
  int ret = 1;
  while (k) {
    if (k & 1)
      ret = ret * (ll)x % P;
    x = x * (ll)x % P;
    k >>= 1;
  }
  return ret;
}

void dfs(int x, int v) {
  dp[x][0] = 1;
  for (int k = 0; k < 2; ++k)
    if (ch[x][k]) {
      int c = ch[x][k];
      dfs(c, h[x]);
      dp[x][1] = (dp[x][1] * (ll)(dp[c][0] + dp[c][1]) * 2 + dp[x][0] * ((ll)dp[c][0] + dp[c][1] * 2)) % P;
      dp[x][0] = dp[x][0] * (ll)dp[c][0] % P;
    }
  dp[x][0] = dp[x][0] * (ll)mpow(2, h[x] - v) % P;
}

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

  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> h[i];
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int cur = 0;
    while (cnt && h[stk[cnt]] > h[i]) {
      ch[stk[cnt]][1] = cur;
      cur = stk[cnt--];
    }
    ch[i][0] = cur;
    stk[++cnt] = i;
  }
  int cur = 0;
  while (cnt > 1) {
    ch[stk[cnt]][1] = cur;
    cur = stk[cnt--];
  }
  int rt = stk[1];
  ch[rt][1] = cur;
  dfs(rt, 1);
  int ans = (dp[rt][0] + dp[rt][1]) % P * 2 % P;
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
//rank is equal to number of vertices in a connected component
class UnionFind 
{
  public: v32 p, rank;
  // remember: vi is vector<int>
  UnionFind(int N) { rank.assign(N, 1);
  p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) 
  {
  if (!isSameSet(i, j)) {
  // if from different set
  int x = findSet(i), y = findSet(j);
  if (rank[x] > rank[y]) p[y] = x,rank[x]+=rank[y];
  // rank keeps the tree short
  else 
     {
     p[x] = y;
     rank[y]+=rank[x]; 
     }
  
  } 
 
  }   
};
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
// int mat[][]
v1024 v;
int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t;
    // cin>>t;
    t=1;
    int temp=t;
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        int x,y,z;cin>>x>>y>>z;
        cout<<z<<" "<<x<<" "<<y<<"\n";
    }   
    return 0; 	
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let h = Array.init n (fun _ -> Scanf.scanf " %d" (fun h -> h)) in
    let m = Array.fold_left max 0 h in

    let rec loop i x mode acc =
        if i > m then acc else
            if x = n then loop (i + 1) 0 0 (if mode = 0 then acc else acc + 1) else
            if h.(x) >= i then loop i (x + 1) 1 acc else
                let acc = if mode = 0 then acc else acc + 1 in
                loop i (x + 1) 0 acc
    in
    loop 1 0 0 0 |> Printf.printf "%d\n"
)

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

int main() {
	string S ;
  	cin >> S ;
  	
  	int N = S.size();
  	
  	for (int i = 0; i < N/2 ; i++) {
    	if (S.at(i) != S.at(N-1-i)){
        	cout << "No" << endl;
          	return 0;
        }
    }
  	for (int i = 0; i < N/2/2 ; i++) {
    	if (S.at(i) != S.at(N/2-1-i)){
        	cout << "No" << endl;
          	return 0;
        }
    }
  	
  	cout << "Yes" << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int Q; cin >> Q;
    while(Q--) {
        int lx, ly, rx, ry;
        cin >> lx >> ly >> rx >> ry;
        lx--; ly--;

        int ans = (rx - lx) * (ry - ly);
        for(int x=lx; x<rx; x++) {
            for(int y=ly; y<ry; y++) {
                if(x % 2 == 0 and y % 2 == 1) ans--;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

using namespace std;

int main() {
  int N;
  int a[100];

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

  sort(a, a + N, greater<int>());

  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i += 2) {
    alice += a[i];
    if (i + 1 < N)
      bob += a[i + 1];
  }

  cout << alice - bob << endl;

  return 0;
}

Measured memory_bytes: 256
player_list = ['a', 'b', 'c']
s = {player_list[n]: list(raw_input()) for n in xrange(len(player_list))}

current_turn = player_list[0]

while True:
    if not s[current_turn]:
        print current_turn.upper()
        break
    else:
        current_turn = s[current_turn].pop(0)

Measured memory_bytes: 2568
#include <iostream>
#include <string>

using namespace std;

void show_me(int *a, size_t size)
{
    for (size_t i = 0; i < size; ++i)
    {
        cout << (i == 0 ? "" : " ") << a[i];
    }
    cout << endl;
}

int do_bubble_sort(int *a, size_t size)
{
    int num_of_exchange = 0;
    bool flag = true;
    for (int i = 0; flag; ++i)
    {
        flag = false;
        for (int j = size - 1; j > i; --j)
        {
            if (a[j] < a[j - 1])
            {
                flag = true;
                swap(a[j], a[j - 1]);
                num_of_exchange++;
            }
        }
        // show_me(a, size);
    }
    return num_of_exchange;
}

int main()
{
    int A[100] = {};
    size_t n;
    cin >> n;
    for (size_t t = 0; t < n; ++t)
    {
        cin >> A[t];
    }
    int num;
    num = do_bubble_sort(A, n);
    show_me(A, n);
    cout << num << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  string s;
  cin >> n >> s;
  vector<ll> R(n+1,0),G(n+1,0),B(n+1,0);
  for (int i = n-1; i >= 0; --i) {
    if (s[i] == 'R') R[i]++;
    if (s[i] == 'G') G[i]++;
    if (s[i] == 'B') B[i]++;
    R[i] += R[i+1];
    G[i] += G[i+1];
    B[i] += B[i+1];
  }
  debug(R[0], G[0], B[0], R[n-1], G[n-1], B[n-1]);
  ll ans = R[0]*G[0]*B[0];
  for (int i = 0; i <= n-3; ++i) {
    for (int j = i+1; j <= n-2; ++j) {
      int k = j+j-i;
      if (k > n-1) break;
      if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int maxn=107;
int n;
char s[maxn];

int main()
{
	scanf("%d",&n);
	if(n%2) {
		printf("No");
		return 0;
	}
	scanf("%s",s+1);
	int f=1;
	for(int i=1;i<=n/2;++i) {
		if(s[i]!=s[i+n/2]) f=0;
	}
	printf(f==1?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w,h,xs,ys,n,xg,yg,c,d,x,y,area[105][105],c_area[105][105];
int x_p[4]={-1,0,1,0},y_p[4]={0,-1,0,1};

bool flag=false;
void solve(int x,int y,int c);

int main(){
    while(1){
        cin >> w >> h;
        if(w==0&&h==0)break;
        cin >> xs >> ys >> xg >> yg >> n;
        for(int i=0;i<n;i++){
            cin >> c >> d >> x >> y;
            if(d==0){
            for(int j=y;j<y+2;j++){
                for(int k=x;k<x+4;k++){
                    area[k][j]=c;
                }
            }
            }else{
            for(int j=y;j<y+4;j++){
                for(int k=x;k<x+2;k++){
                    area[k][j]=c;
                    }
                }
            }
        }
        if(area[xs][ys]!=area[xg][yg]);
        else {
        solve(xs,ys,area[xs][ys]);
        }
        if(flag==true)cout << "OK" << endl;
        else cout << "NG" << endl;
        flag=false;
        fill(area[0],area[104],0);
    }

return 0;
}

void solve(int x,int y,int c){

    if(x==xg&&y==yg){
        flag=true;
    return;
    }else{
        for(int i=0;i<4;i++){
        if(area[x+x_p[i]][y+y_p[i]]==c){
                //c_area[x][y]=area[x][y];
                area[x][y]=0;
                solve(x+x_p[i],y+y_p[i],c);
                //area[x][y]=c_area[x][y];
            }
        }
    }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll>kosu(n+1,0);
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            kosu[j]++;
        }
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ans += kosu[i]*i;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 81340
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int   a, b, x;
    cin >> a >> b >> x;
    
    long long int ans = 0;
    long long int ans_before = 0;
    
    if(a % x == 0)ans_before = a / x;
    else ans_before = a / x + 1;
    
    ans = b / x - ans_before + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node {
	int key;
	struct node *r,*l,*p;
};
struct node *NIL,*root;
int a=0,b=0;
void insert(int k) {
	struct node *x=root,*y=NIL,*z;
	z=(struct node*)malloc(sizeof(struct node));
	z->key=k;
	z->l=NIL;
	z->r=NIL;
	while(x!=NIL) {
		y=x;
		if(k<x->key)
			x=x->l;
		else
			x=x->r;
	}
	z->p=y;
	if(y==NIL) {
		root=z;
	} else if(z->key<y->key)
		y->l=z;
	else
		y->r=z;
}
void inOrder(struct node *p) {
	if(p==NIL)
	return;
	inOrder(p->l);
    printf(" %d",p->key);
	inOrder(p->r);
}
void preOrder(struct node *p) {
	if(p==NIL)
	return;
	printf(" %d",p->key);
	preOrder(p->l);
	preOrder(p->r);
}
int getit(struct node *p) {
	a=0;
	b=0;
	inOrder(p);
	printf("\n");
	preOrder(p);
	printf("\n");
	return a;
}
int main() {
	int m,i,j,o=0,k;
	char str[10];
	int len[11];
	scanf("%d",&m);
	for(i=0; i<m; i++) {
		scanf("%s",str);
		if(str[0]=='i') {
			scanf("%d",&k);
			insert(k);
		} else {
			getit(root);
		}
	}//输入
	return 0;
}


Measured memory_bytes: 25144
#include<stdio.h>


int main(){

  int W,H,x,y,r;

  scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);

  if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  
  
  return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
         if (S.contains("a") && S.contains("b") && S.contains("c")){
             System.out.println("Yes");
         }else{
             System.out.println("No");
         }
    }
}

Measured memory_bytes: 21588
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

def point(op):
    if op == 'r':
        return p
    elif op == 's':
        return r
    else:
        return s

res = 0
for mod in range(k):
    len = (n-mod+k-1) // k
    dp_free = [0] * len
    dp_win = [0] * len
    dp_win[0] = point(t[mod])
    for i in range(1, len):
        dp_free[i] = max(dp_win[i-1], dp_free[i-1])
        dp_win[i] = dp_free[i-1] + point(t[mod+k*i])
        if t[mod+k*i] != t[mod+k*(i-1)]:
            dp_win[i] = max(dp_win[i], dp_win[i-1] + point(t[mod+k*i]))
    res += max(dp_win[-1], dp_free[-1])
print(res)


Measured memory_bytes: 7940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var N = input[0];
            var D = input[1];
            var count = 0;

            for (int i = 0; i < N; i++)
            {
                var pq = GetLongNumArray();
                var p = pq[0];
                var q = pq[1];
                if (Math.Sqrt(Math.Pow(p, 2) + Math.Pow(q, 2)) <= D)
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static int[] GetIntNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => int.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 41464
N,M = map(int,input().split())
ball_num = [1]*N
red = [0]*N
red[0] = 1

for _ in range(M):
    x, y = map(int,input().split())
    if ball_num[x-1] == 1:
        if red[x-1] == 1:
            ball_num[x - 1] -= 1
            ball_num[y - 1] += 1
            red[x-1] = 0
            red[y-1] = 1
        else:
            ball_num[x-1] = 0
            ball_num[y-1] += 1
    else: #ボールが複数ある場合
        if red[x-1] == 1:
            ball_num[x-1] -= 1
            ball_num[y-1] += 1
            red[y-1] = 1
        else:
            ball_num[x-1] -= 1
            ball_num[y-1] += 1

print(sum(red))

Measured memory_bytes: 4596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> h >> w;;
	vector<vector<char>> data(h + 2, vector<char>(w + 2));

	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			cin >> data[i][j];
		}
	}

	bool ans = true;

	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			if (data[i][j] == '#') {

			
			if (data[i - 1][j] != '#' && data[i + 1][j] != '#' && data[i][j - 1] != '#' && data[i][j + 1] != '#') {
				ans = false;
			}

			}
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	

}
	

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define INF (int )1e9

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans = INF,dp[HMAX][WMAX];
string S;
vector<char > v;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 0; i < S.size(); ++i)
	{
		if(find(v.begin(), v.end(),S[i]) == v.end()){
			v.push_back(S[i]);
		}
	}
	for (int i = 0; i < v.size(); ++i)
	{
		int first = -1,temp = 0;
		for (int j = 0; j < S.size(); ++j)
		{
			if(S[j] == v[i]){
				temp = max(temp,j-first-1);
				first = j;
			}else if(j == S.size()-1){
				temp = max(temp,(int)(S.size()-first-1));
			}
		}
		ans = min(ans,temp);
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;

    int a[n];
    forn(i,n){
        int x;
        cin>>x;
        x--;
        a[x] = i+1;
    }
    forn(i,n)   cout<<a[i]<<" ";
    return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <vector>

using namespace std;

int main(){
  vector<bool> b;
  vector<string> init{"SS","SW", "WS", "WW"};
  int n;
  char ox;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> ox;
    if (ox == 'o') {
      b.push_back(true);
    } else {
      b.push_back(false);
    }
  }

  for (auto it = init.begin();it != init.end();it++) {
    string animals = *it;
    for (int i=2;i<n+2;i++) {
      if (b[(i-1)%n] ^ (animals[(i-2)%n] == animals[(i-1)%n])) {
	animals += 'W';
      } else {
	animals += 'S';
      }
    }
    if (animals[0] == animals[n] && animals[1] == animals[n+1]) {
      cout << animals.substr(0, n) << endl;
      return(0);
    }
  }
  cout << -1 << endl;
  return(0);
}


Measured memory_bytes: 632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	dp := make([][4][4][4]int, n+4)
	dp[0][3][3][3] = 1

	for i := 0; i < n+3; i++ {
		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				for l := 0; l < 4; l++ {
					for m := 0; m < 4; m++ {
						if k == 0 && l == 2 && m == 1 {
							continue
						}
						if k == 0 && l == 1 && m == 2 {
							continue
						}
						if k == 2 && l == 0 && m == 1 {
							continue
						}
						if j == 0 && k == 2 && m == 1 {
							continue
						}
						if j == 0 && l == 2 && m == 1 {
							continue
						}
						dp[i+1][k][l][m] += dp[i][j][k][l]
						dp[i+1][k][l][m] %= MOD
					}
				}
			}
		}
		// debug(dp[i+1])
	}

	fmt.Fprintln(wr, dp[n+3][3][3][3])

}

// MOD constant
const MOD = 1000000007


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

int main() {
  int N, M; cin >> N >> M;
  vector<int> like(M, 0);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;

    for (int k = 0; k < K; k++) {
      int a;
      cin >> a;
      a--;
      like[a]++;
    }
  }
  cout << count(like.begin(), like.end(), N) << endl;
  return 0;
}

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

int main(){
  string S;
  string a=" ";
  string b=" ";
  int count=0;
  int count2=0;
  cin >> S;
  for(int i=0;i<4;i++){
    for(int j=i+1;j<4;j++){
      if(S[i]==S[j]){
        if(a==" "){
          count++;
          a=S[i];
        }
        else if(S[j]==a[0]){
          count++;
        }
        else{
          b=S[i];
        }
        if(S[j]==b[0]){
          count2++;
        }
      }
    }
  }
  if(count==1 && count2==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define pb              push_back
#define fi              first
#define se              second
#define mod             1000000007 // 998244353 // 1e9 + 7
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL
#define mt              make_tuple
#define eps             1e-6
#define endl            '\n'
#define test            int tttt; cin>>tttt; while(tttt--)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

set < int > par;
set < int > x, y;
map < int, int > mp;
void dfs(vector < vector < int > > &adj, int v, int par, int dis)
{
	
}

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n + 4];
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	set < int > s;
	vector < int > v;
	int len;
	s.insert(1);
	v.pb(1);
	int beg;
	while(1)
	{
		int to = a[v.back()];
		if(s.count(to) != 0)
		{
			 beg = to;
			 break;
		}
		s.insert(to);
		v.pb(to);
	}
	int idx;
	for(int i = 0; i < v.size(); i++)
	{
		if(v[i] == beg)
		{
			idx = i;
			break;
		}
	}
	if(k <= idx)
	{
		cout << v[k] << endl;
		return;
	}
	k -= idx;
	int z = k % (v.size() - idx);
	cout << v[z + idx] << endl;

}
signed main()
{
    fast_io
    // test
    {
      solve();
    }
    return 0;       
}


Measured memory_bytes: 15348
#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;

signed main(){
	ll n;
	cin>>n;
	ll ans=0;
	vector<ll>a(n+2),b(n+2,0);
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n+1){
		if(a[i]<=b[i]){
			b[i]-=a[i];
			ans+=a[i];
			if(a[i+1]<=b[i]){
				ans+=a[i+1];
				a[i+1]=0;
			}
			else {
				a[i+1]-=b[i];
				ans+=b[i];
			}
		}
		else {
			ans+=b[i];

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


Measured memory_bytes: 1792