akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S){
  ll ans=0;
  string prev="";
  REP(S.size()){
    if(prev!=S.substr(i,1)){
      ++ans;
      prev=S.substr(i,1);
    }else{
      if(i==S.size()-1)break;
      ++ans;
      prev=S.substr(i,2);
      ++i;
    }
    dump(prev);
  }
  cout<<ans<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

class sentenceClass{
public:
    string character="";
    int numOccurrence=1;
};

int main(void){
    string maxNumSentence="";
    sentenceClass sentence[1000];
    
    int sentenceNum = 0;
    int loop = 0;
    while( cin >> sentence[sentenceNum].character )
    {
        /* Serch Max Sentence */
        if( maxNumSentence.size() < sentence[sentenceNum].character.size() )
        {
            maxNumSentence = sentence[sentenceNum].character;
        }
        
        /* Update Frequent Appearance */
        for( loop=0; loop < sentenceNum; loop++ )
        {
          if( sentence[loop].character == sentence[sentenceNum].character )
          {
            sentence[loop].numOccurrence = sentence[loop].numOccurrence + 1;
          }
        }
        sentenceNum++;   /* next sentence */
    }
    
    int maxNumOccurrence=0;
    string frequentAppearanceSentence="";
    /* Serch Max Sentence */
    for( loop=0; loop < sentenceNum; loop++ )
    {
        if( maxNumOccurrence < sentence[loop].numOccurrence )
        {
            maxNumOccurrence = sentence[loop].numOccurrence;
            frequentAppearanceSentence = sentence[loop].character;
        }
    }
    cout << frequentAppearanceSentence << " " << maxNumSentence << endl;

    return 0;
}

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

int main()
{
	int a,b,c,d;
	
	cin>>a>>b>>c>>d;
	
    if((a+b)>(c+d))
		cout<<"Left\n";
	else if((a+b)<(c+d))
		cout<<"Right\n";
	else
		cout<<"Balanced\n";
	
	return 0; 
}

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

using namespace std;

int main() {
	int H[100000];
	int W[100000];
	int count = 0;
	for (count = 0; ; count++) {
		cin >> H[count] >> W[count];
		if (H[count] == 0 && W[count] == 0) {
			break;
		}
	}
	for (int m = 0; m < count; m++) {
		for (int i = 0; i < H[m]; i++) {
			for (int j = 0; j < W[m]; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(void){
  string s;
  cin >> s;
  int n=s.size(),cnt=0,ans=0;
  rep(i,0,n){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }else{
      ans= max(ans, cnt);
      cnt=0;
    }
  }
  ans= max(ans, cnt);
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 764
l,n = map(int, input().split())
s = input()
oocnt = 0
for i in range( len(s)-1 ):
    if s[i] == 'o' and s[i+1] == 'o' : oocnt = oocnt + 1
total_oocnt = 0
for i in range( n ):
    total_oocnt = total_oocnt + oocnt
    oocnt = oocnt*2
print( 3*total_oocnt + l)



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

int main() {
    int A, B;
    cin >> A >> B;
    int answer;
    for (int i = 0; i < B - A + 1; i++) {
        string s = to_string(A + i);
        if (s.at(0) == s.at(4) && s.at(1) == s.at(3)) {
            answer++;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


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

    vector<vector<int>> c(10, vector<int>(10, 0));

    for1n(i, n){
        int x = i % 10;
        int y = i / (int)pow(10, (int)floor(log10(i)));
        // cout << i << ","<< x << ","<< y << "\n";
        ++c[x][y];
    }
    int result = 0;
    for1n(i, 9)for1n(j, 9){
        result += c[i][j] * c[j][i];
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	N, W := ReadInt(), ReadInt()
	v := make([]int, N)
	w := make([]int, N)
	for i := 0; i < N; i++ {
		v[i], w[i] = ReadInt(), ReadInt()
	}
	// dp[i][j] = i番目まで使って、重さjまで使うときの最大の価値
	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, W+1)
	}
	for i := 0; i < N; i++ {
		for j := 1; j < W+1; j++ {
			dp[i+1][j] = Max(dp[i][j], dp[i+1][j-1])
			if j >= w[i] {
				dp[i+1][j] = Max(dp[i+1][j], dp[i][j-w[i]]+v[i])
			}
		}
	}
	fmt.Println(dp[N][W])
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }



Measured memory_bytes: 9680
#include<stdio.h>

int main(void)
{
	int i,j;

	for(i = 1;i <= 9;i++)
	{
		for(j = 1;j <= 9;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}

	return 0;
}

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

string shuffle(string s,int h){
    string head=s.substr(0,h);
    string tail=s.substr(h,s.size()-h);
    return tail+head;
}

int main(){
    string S;
    int n,a;
    while(1){
        cin >> S >> n;
        if (S=="-") break;
        for (int i=0; i<n; i++){
            cin >> a;
            S=shuffle(S,a);
        }
        cout << S << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long int BCnt = 0, ans = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'B') BCnt++;
        else if (S[i] == 'W') ans += BCnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()
H = LI()

result = []
cnt = 0
for i in range(n-1):
    if H[i] - H[i+1] >= 0:
        cnt += 1
    else:
        result.append(cnt)
        cnt = 0

result.append(cnt)
ans = max(result)
print(ans)

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

const int N = 100 * 1000 + 20;
int a[N];

int main() {
  	int h, n, sum = 0;
  	cin >> h >> n;
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
 	for (int i = 0; i < n; i++)
      	sum += a[i];
 	cout << (sum >= h? "Yes": "No") << "\n";
} 	

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

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  rep(i,n){
    ans = min(ans*2, ans+k);
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int i,x;
    
    i = 0;
    
    while(1){
        cin >> x;
        i++;
        
        if(x == 0){
            break;
        }
        
        cout << "Case" << " " << i << ": " << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3000
import java.util.Scanner;

class B {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final char[] A = sc.next().toCharArray();
        final char[] B = sc.next().toCharArray();
        final char[] C = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
                if (A[i] != B[i] || B[i] != C[i])
                    ans++;
            } else
                ans += 2;
        }
        System.out.println(ans);
    }
}
public class Main {
    public static void main(String... args) {
        B.main();
    }
}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    string patt[4] = {"SS", "SW", "WS", "WW"};

    for(int i = 0; i < 4; ++i){
        string an;
        an += patt[i];
        for(int j = 2; j < n; ++j){
            if(an[j-1] == 'S'){
                if(s[j-1] == 'o'){
                    an += an[j-2];
                }
                else{
                    an += an[j-2]=='S'?'W':'S';
                }
            }
            else{
                if(s[j-1] == 'o'){
                    an += an[j-2]=='S'?'W':'S';
                }
                else{
                    an += an[j-2];
                }
            }
        }

        bool ok = true;
        for(int i = 0; i < n; ++i){
            if(!(((an[(i-1+n)%n] == an[(i+1+n)%n] and s[i] == 'o' or an[(i-1+n)%n] != an[(i+1+n)%n] and s[i] == 'x') and an[i] == 'S') or ((an[(i-1+n)%n] == an[(i+1+n)%n] and s[i] == 'x' or an[(i-1+n)%n] != an[(i+1+n)%n] and s[i] == 'o') and an[i] == 'W'))){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << an << endl;
            return 0;
        }

    }

    ppp(-1);


    return 0;
}


Measured memory_bytes: 712
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

VEC(int) Bfs(VEC(VEC(int))& Edges, int src)
{
    const int N = Edges.size();
    queue<int> bfsQ;
    VEC(int) DistA(N, -1);
    auto Visit = [&](int node, int dist) {
        if (DistA[node] < 0) {
            DistA[node] = dist;
            bfsQ.push(node);
        }
    };

    Visit(src, 0);
    while (!bfsQ.empty()) {
        int node = bfsQ.front();
        bfsQ.pop();
        for (int next : Edges[node])
            Visit(next, DistA[node] + 1);
    }

    return DistA;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, T, A;
    cin >> N >> T >> A;
    T--; A--;
    VEC(VEC(int)) Edges(N);
    FOR(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        Edges[a].push_back(b);
        Edges[b].push_back(a);
    }

    VEC(int) DistT = Bfs(Edges, T), DistA = Bfs(Edges, A);

    auto check = [&](int t) {
        int mx = 0;
        FOR(i, 0, N)
            if (DistT[i] <= t && DistT[i] % 2 == t % 2)
                mx = max(mx, DistA[i]);

        return mx <= t ? mx : -1;
    };

    int lo = 1, hi = N - 1;
    while (hi - lo > 1) {
        int md = (lo + hi) / 2;
        if (check(md) >= 0)
            hi = md;
        else
            lo = md + 1;
    }

    if (check(lo) < 0)
        lo = hi;

    cout << check(lo) << endl;
    return 0;
};

Measured memory_bytes: 6656
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    
    int sum = 0;
    int max = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      sum += n;
      max = max < n ? n : max;
    }
    
    sum -= max/2;
    System.out.println(sum);
  }
}

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

#define MAX 100
int main(){
	int n, m, l;  //a:(n,m),b:(m,l)
	
	cin >> n >> m >> l;
	
	//配列の定義	
	int a[MAX][MAX];
	int b[MAX][MAX];
	long c[MAX][MAX];
	
	//データの読み込み
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(int j = 0; j < m; j++){
		for(int k = 0; k < l; k++){
			cin >> b[j][k];
		}
	}
	
	//行列の積を計算
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			c[i][j] = 0;
			for(int k = 0; k < m; k++){
				c[i][j] += a[i][k]*b[k][j];
			}
			cout << c[i][j];
			if(j == l-1)
				cout << endl;
			else
				cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int> PII;


int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c) cout << "No" << endl;
    else{
        ll x = (c - a - b) * (c - a - b);
        ll y = 4 * a * b;
        if(x > y) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
int a,b;
  cin >>a>>b;
  if(a<=0 && b>=0) cout << "Zero"<<endl;
  else if(b <=0){
  if(abs(abs(a)-abs(b))%2 ==0 ) cout <<"Negative" <<endl;
     else cout << "Positive"<<endl;
     }
     else cout << "Positive" <<endl;
}
  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, c, d) = [int(e) for e in lines[0].split(' ')]

    return (a, b, c, d)


def solve(a, b, c, d):

    ta = c // b
    if c % b != 0:
        ta = ta + 1
    ao = a // d
    if a % d != 0:
        ao = ao + 1

    if ta <= ao:
        result = 'Yes'
    else:
        result = 'No'
    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 62168
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        n: usize,
        t: [[usize; 3]; n],
    }
    let mut t = t.to_vec();
    t.insert(0, vec![0, 0, 0]);

    for i in 1..t.len() {
        let dt = t[i][0] as i32 - t[i-1][0] as i32;
        let dx = t[i][1] as i32 - t[i-1][1] as i32;
        let dy = t[i][2] as i32 - t[i-1][2] as i32;
        let d = dx.abs() + dy.abs();

        if d > dt {
            println!("{}", "No");
            return;
        }

        if dt % 2 == 0 {
            if d % 2 != 0 {
                println!("{}", "No");
                return;
            }
        } else {
            if d % 2 == 0 {
                println!("{}", "No");
                return;
            }
        }
    }
    println!("{}", "Yes");
}


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

#define FOR(i,a,n) for (ll i = a; i < (ll)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll n; cin >> n;
  vector<ll> d(n);
  FOR(i,1,n+1) {
    ll p; cin >> p;
    d[p-1] = i;
  }
  FOR(i,1,n+1) {
    cout << 30000*i << " ";
  }
  cout << endl;
  FOR(i,1,n+1) {
    cout << 30000*(n-i)+d[i-1] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.InputMismatchException;
import java.util.Scanner;

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

                try
                    {
                        int input = scanner.nextInt();

                        int result = (int) Math.pow(input, 3);

                        System.out.println(result);
                    }
                catch (InputMismatchException e)
                    {
                        System.out.println("整数を入力してください");
                        e.printStackTrace();
                    }
            }
    }

Measured memory_bytes: 17172
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());
        scan.close();

        if (a < b) {
            if (a < c && c < b) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if (b < c && c < a) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

    }

}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        // int[] s = new int[n];

        // for (int i = 0; i < n; i++) {
        // s[i] = Integer.parseInt(sc.next());

        // }
        System.out.println(n * (n - 1) / 2 + m * (m - 1) / 2);

        sc.close();
    }
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    puts(N % 10 == 3 ? "bon" : ((((N % 10) | 1) == 1) || (N % 10 == 6) || (N % 10 == 8)) ? "pon" : "hon");
    return 0;
}

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

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

    vector<int> minCost(n);
    minCost[0] = 0;
    minCost[1] = abs(height[0] - height[1]);
    for (int i = 2; i < n; i++) {
        minCost[i] = abs(height[i] - height[i - 1]) + minCost[i - 1];
        for (int j = i - 2; j >= i - k && j >= 0; j--)
            minCost[i] = min(minCost[i], abs(height[i] - height[j]) + minCost[j]);
    }

    cout << minCost.back();
    return 0;
}


Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def read_matrix(H, W):
    '''return np.ndarray shape=(H,W) matrix'''
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

N = a_int()
A = read_matrix(N, N)

'''
一方の集合を管理してDPというアイデア

dp[i][s] ... 男性を:i人目まで見たときに、マッチングした女性の集合がsであるような通りの総数

更新式
dp[i+1][s+1<<j] += dp[i][s] for s のjbit目は0 かつ A[i,j]==1

これでは計算量がO(2^N 2N)なのでTLE
iと|s|は同じなのだから状態をまとめることができる
(二次元dpでいうとi=|s|のセルでしか状態遷移が発生しない)

よって単純sだけでループしても良さそうだし、()内のアイデアで枝刈りしても良さそう
'''

from numba import njit


@njit('(i8,i8[:,:])', cache=True)
def solve_TLE(N, A):
    dp = np.zeros((N + 1, 1 << N), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(N):
        for s in range(1 << N):
            for j in range(N):
                if (s >> j) & 1 == 0 and A[i, j] == 1:
                    dp[i + 1, s + (1 << j)] += dp[i, s]
                    dp[i + 1, s + (1 << j)] %= MOD
    print(dp[N, (1 << N) - 1] % MOD)


@njit('(i8,i8[:,:])', cache=True)
def solve(N, A):  # 遷移のi==|s|の遷移しか生じないことに注目すれば
    dp = np.zeros((N + 1, 1 << N), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(N):
        for s in range(1 << N):
            if dp[i, s] == 0:  # 遷移するものがない
                continue
            for j in range(N):
                if (s >> j) & 1 == 0 and A[i, j] == 1:
                    dp[i + 1, s + (1 << j)] += dp[i, s]
                    dp[i + 1, s + (1 << j)] %= MOD
    print(dp[N, (1 << N) - 1] % MOD)


solve(N, A)


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

int main(){
	int n, fraction;
	int debt = 100000;

	cin >> n;

	for(int i = 0; i < n; i++){
		debt = debt + (int)(debt*0.05);
		fraction = debt % 1000;
		if(fraction > 0) debt += 1000 - fraction;
	}

	cout << debt << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }
template<typename V> void printVec(V v) {ll i=0;for(auto x : v){std::cout << " [" << i++ << "] " << x;} print();}

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

  std::string s;
  std::cin >> s;

  ll ans = 0;
  for (char c : s) {
    if (c == '+') ans++;
    else ans--;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>

#include <iostream>
#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 <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using namespace atcoder;
using lint = long long int;
long long int INF = 1000000000LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {

  int n, k; cin >> n >> k;
  vector<vector<lint>> a(n, vector<lint>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  mcf_graph<lint, lint> g(n * 2 + 2);
  int source = n * 2;
  int sink = n * 2 + 1;

  g.add_edge(source, sink, n * k, INF);

  // source -> i
  for (int i = 0; i < n; i++) {
    g.add_edge(source, i, k, 0);
  }

  // i -> sink
  for (int i = 0; i < n; i++) {
    g.add_edge(i + n, sink, k, 0);
  }

  // i -> j
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int from = i;
      int to = j + n;
      g.add_edge(from, to, 1, INF - a[i][j]);
    }
  }


  auto res = g.flow(source, sink, n * k);
  cout << n * k * INF - res.second << endl;


  vector<vector<char>> grid(n, vector<char>(n, '.'));
  auto edges = g.edges();
  for (auto e : edges) {
    if (e.from == source || e.to == sink || e.flow == 0) continue;
    grid[e.from][e.to - n] = 'X';
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3520
h,w,m=map(int,input().split())
item=[list(map(int,input().split())) for i in range(m)]
row=[0]*h
col=[0]*w
for i in range(m):
    x,y=item[i]
    row[x-1]+=1
    col[y-1]+=1
mr,mc=max(row),max(col)
xr=set([i for i in range(h) if row[i]==mr])
xc=set([i for i in range(w) if col[i]==mc])
check=len(xr)*len(xc)
for i in range(m):
    r,c=item[i]
    if r-1 in xr and c-1 in xc:
        check-=1
print(mr+mc if check>0 else mr+mc-1)

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  string S;
  cin >> S;
  int a = INF, z = -1;
  
  REP(i, S.length()){
    if(S[i] == 'A'){
      a = MIN(a, (i+1));
    }
    if(S[i] == 'Z'){
      z = MAX(z, (i+1));
    }
  }
  cout << z - a + 1 << endl;

}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int ans,pasuta,juice,most1=10000,most2=10000;
  for(int i=0;i<3;i++){
    cin >> pasuta;
    if(most1>pasuta){
      most1=pasuta;
    }
  }
  for(int i=0;i<2;i++){
    cin >> juice;
    if(most2>juice){
      most2=juice;
    }
  }
  ans=most1+most2-50;
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 1164
from collections import defaultdict
b = defaultdict(int)
n = int(raw_input())
a = []
for i in xrange(n):
    x = list(raw_input())
    x.sort()
    a.append(''.join(x))
i = 0
ans = 0
for i in a:
    b[i] += 1
for i in b.values():
    ans += i*(i-1)/2
print ans

Measured memory_bytes: 58268
m,s[]={0,31,60,91,121,152,182,213,244,274,305,335};main(d){char a[7][9]={"Thurs","Fri","Satur","Sun","Mon","Tues","Wednes"};while(1){scanf("%d%d",&m,&d);if(!m)exit(0);d+=s[m-1];printf("%sday\n",&a[(d%7)?(d%7-1):6][0]);}}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>

using namespace std;
using ll = long long;
const ll inf = 1e15;
const int MN = 308;
ll n,k,a[MN];
ll memo[MN][MN][MN];
bool memod[MN][MN][MN];
ll f(int i, int lnm, int kl){
	//cerr<<i<<' '<<lnm<<' '<<kl<<endl;
	if(memod[i][lnm][kl])return memo[i][lnm][kl];
	if(i>n+1)return 0;
	memod[i][lnm][kl]=1;
	memo[i][lnm][kl]=(a[lnm]>a[i]?a[lnm]-a[i]:0)+f(i+1,i,kl);
	if(kl>0 && i!=n+1){
		memo[i][lnm][kl] = min(memo[i][lnm][kl], f(i+1,lnm,kl-1));
	}
	return memo[i][lnm][kl];
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1; i<=n; ++i)cin>>a[i];
	cout<<f(0,0,k)<<endl;
	return 0;
}



Measured memory_bytes: 252416
from fractions import gcd

def main():
    n,m = map(int, input().split())
    s = input()
    t = input()
    g = gcd(n,m)
    smatch = []
    tmatch = []
    flag = True
    for i in range(g):
        smatch.append(s[i*(n//g)])
        tmatch.append(t[i*(m//g)])
    for k,l in zip(smatch,tmatch):
        if k != l:
            flag = False

    if flag:
        print(n*m//g)
    else:
        print(-1)


main()

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

int n,a,p[200010],fa[200010],cnt[200010][2];
long long ans=0;
struct node{
	int id,cnt0,cnt1;
	bool operator <(const node &x)const{
		return 1ll*cnt0*x.cnt1<1ll*cnt1*x.cnt0;
	}
};
priority_queue<node>que;

int find(int x){
	return fa[x]==x?x:fa[x]=find(fa[x]);
}

int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++){
		fa[i]=i;
		scanf("%d",&a);
		cnt[i][a]=1;
		if(i>1)que.push((node){i,cnt[i][0],cnt[i][1]});
	}
	while(!que.empty()){
		node u=que.top();que.pop();
		int k=u.id;
		if(cnt[k][0]==u.cnt0&&cnt[k][1]==u.cnt1){
			int nk=fa[k]=find(p[k]);
			ans+=1ll*cnt[nk][1]*cnt[k][0];
			cnt[nk][0]+=cnt[k][0];
			cnt[nk][1]+=cnt[k][1];
			fa[find(k)]=nk;
			if(nk!=1)que.push((node){nk,cnt[nk][0],cnt[nk][1]});
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7284
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;

int main()
{
	ll ANS=0;
	string s,t;
	cin>>s>>t;
	rep(i,s.size()){
		if(s[i]!=t[i])ANS++;
	}
	cout<<ANS<<endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

#define MX 100007

int main(void) {
    ios_base::sync_with_stdio(false);
    vll dp(MX,INF);
    dp[0]=0;
    F(MX) {
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(ll j=6; i+j<MX; j*=6)
            dp[i+j]=min(dp[i+j],dp[i]+1);
        for(ll j=9; i+j<MX; j*=9)
            dp[i+j]=min(dp[i+j],dp[i]+1);
    }
    int n; cin >> n;
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
#include<bits/stdc++.h>
using namespace std; 
int main(){
   long long int n;
   cin>>n;
   vector<long long int> v(n);
   vector <long long int> copy(n);
   for(int i=0;i<n;i++){
       cin>>v[i];
       copy[i]=v[i];
   }
   sort(copy.begin(),copy.end());
   long long int max,sec_max;
   max= copy[n-1];
    sec_max= copy[n-2];
    for(int i=0;i<n;i++){
        if(v[i]==max)
        cout<<sec_max<<endl;
        else cout<<max<<endl;
    }
   return 0; 
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dp[1005][1005], n, m;
char arr[1005][1005];
ll mod = 1e9 + 7;
int solve(int i, int j) {
	if (i >= n || j >= m ||arr[i][j] == '#' )
		return 0;
	if (i == n - 1 && j == m - 1)
		return 1;
	if (~dp[i][j])
		return dp[i][j];
	return dp[i][j] = ((solve(i + 1, j) % mod) + (solve(i, j + 1) % mod))%mod;
}
int main() {
	IO
	cin >> n >> m;

	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++){
			cin >> arr[i][j];
		}
	}
	cout << solve(0, 0);

	return 0;
}


Measured memory_bytes: 5248
#include <cstdio>

#define a(d, n) if (*(unsigned int*)s == *(unsigned int*)d) { puts(#n); return 0; }

int main()
{
  char s[4];
  scanf("%s", s);
  a("SUN", 7);
  a("MON", 6);
  a("TUE", 5);
  a("WED", 4);
  a("THU", 3);
  a("FRI", 2);
  puts("1");
  return 0;
}

Measured memory_bytes: 128
N=int(input())
T,A=map(int, input().split(' '))
H=list(map(lambda h : T - float(h) * 0.006 , input().split(' ')))

ans = -1
min = 1000000000
for i in range(len(H)):
  dif=abs(A - H[i])
  if dif < min:
    ans = i + 1
    min = dif
print(ans)


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

    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 10000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;  
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    const double PI=acos(-1.0);

    int main(){ 
                            
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif 

        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int r;
            cin>>r;
            printf("%.12lf\n",2*PI*r);
        }  
        return 0;       
    }       


    // First, solve the problem. Then, write the code. 
    

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  string s;ll k;
  cin >> s >> k;
  rep(i,s.size()){
    if(k == 0)break;
    if(s[i] == 'a')continue;
    else {
      if(('z'-s[i]+1) > k)continue;
      k -= ('z'-s[i]+1);
      s[i] = 'a';
    }
  }
  if(k > 0){
    k %= 26;
    s.back() = (s.back()-'a'+k)%26+'a';
  }
  cout << s << endl;
  





  return 0;
}

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

int main()
{
    int n, t[105], m, x, p;
    int sum[105] = {0};

    cin >> n;

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

    cin >> m;

    for (int i = 0; i < m; i++){
        cin >> p >> x;
        int tmp = t[p - 1];
        t[p - 1] = x;
        for (int j = 0; j < n; j++){
            sum[i] += t[j];
        }
        t[p - 1] = tmp;
    }

    for (int i = 0; i < m; i++){
        cout << sum[i] << endl;
    }

    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;

  string a;
  for (int i = 0; i < h; i++) {
    cin >> a;
    cout << "#" << a << "#" << endl;
  }

  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main(){
  long long int n, w;
  cin>>n>>w;
  vector<int> we(n);
  vector<ll> v(n);
  for(int i =0; i<n; i++){
    int x;
    ll y;
    cin>>x>>y;
    we[i]=x;
    v[i]=y;
  }
  vector<vector<ll>> dp(n, vector<ll>(w+1, 0));
  
  for(int i =0; i<n; i++){
    for(int j = 0; j<=w; j++){
      if(j==0) {dp[i][j]=0;
                continue;}
      if(i==0){
        dp[0][j]=(j>=we[0])?v[0]:0;
        continue;
      }
      if(we[i]>j) dp[i][j] = dp[i-1][j];
      else{
        if(dp[i-1][j]>=dp[i-1][j-we[i]]+v[i]) dp[i][j] = dp[i-1][j];
        else dp[i][j] =dp[i-1][j-we[i]]+v[i];
      }
    }
  }
  cout<<dp[n-1][w]<<endl; 


}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  int n;
  cin >> n;
  map<string, bool> x;
  REP(i, n) {
    string s;
    cin >> s;
    x[s] = true;
  }
  cout << x.size() << endl;
  return 0;
}

Measured memory_bytes: 19252
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=400005;
struct data{
	int to,next;
}e[N];
int head[N],gs,m,n,x,y;

void add(int fr,int to)
{
	e[++gs].to=to;e[gs].next=head[fr];head[fr]=gs;
}

bool solve()
{
	for(int i=head[1];i;i=e[i].next)
	{
		int u=e[i].to;
		for(int j=head[u];j;j=e[j].next)
			if(e[j].to==n)	return 1;
	}
	return 0;
}

inline int read()
{
	int x=0;char c=getchar();
	while(c<'0'||c>'9')	c=getchar();
	while(c>='0'&&c<='9')	x=x*10+c-'0',c=getchar();
	return x;
}

int main()
{
//	freopen("1.txt","r",stdin);
//	freopen("11.txt","w",stdout);9
	n=read(),m=read();
	for(int i=1;i<=m;++i)
	{
		x=read(),y=read();
		add(x,y),add(y,x);
	}
	if(solve())	puts("POSSIBLE");
	else	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 4096
#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;


int main(){
	int ac[100] = {0};
	int rank[32] = {0};

	int cntTeam = 0;
	while(true){
		int n, a;
		scanf("%d,%d", &n, &a);
		if(n == 0 && a == 0){
			break;
		}
		ac[n] = a;
		if(rank[a] == rank[a+1]){
			for(int i = 0; i < 31; i++){
				if(i <= a){
					rank[i]++;
				}
			}
		}
		cntTeam++;
	}

	int n;
	while(cin >> n){
		cout << rank[ac[n]] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n, t, a, *h, i;
    cin >> n >> t >> a;
    h = new int[n];
    for (i = 0; i < n; i++) {
        cin >> h[i];
    }
    int ans = 0;

    for (i = 1; i < n; i++) {
        if (abs(a-(t-h[ans]*0.006)) > abs(a-(t-h[i]*0.006))) {
            ans = i;
        }
    }

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

Measured memory_bytes: 256
import numpy as np

def check(number):
    string = str(number)
    if("3" in string and "5" in string and "7" in string):
        if(number <= N):
            return 1
    return 0

def make_root_three(num):
    ans = 0
    i = 0
    while(num // 3):
        ans += (num % 3) * (10 ** i)
        num = num // 3
        i += 1
    ans += num * (10 ** i)
    return ans

def make_number_from_seed(seed, l):
    ans = 0
    string = str(seed).zfill(l)
    for i in range(l):
        ans += candidates[int(string[i])] * (10 ** i)
    return ans

N = int(input().strip())
length = int(np.log10(N)) + 1

candidates = [3, 5, 7]
ans = 0

for l in range(3, length + 1):
    for i in range(3**l):
        seed = make_root_three(i)
        number = make_number_from_seed(seed, l)
        ans += check(number)
    
print(ans)

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



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


  int n,a,b; cin >> n >> a >> b;
  cout << min(a,b) << " ";
  if(n <= a+b) cout << a+b-n << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M;
  std::cin >> N >> M;
  vvi data = vv(M, 0, 0, int);
  for(int i=0;i<M;i++){
    int ki;
    std::cin >> ki;
    for(int j=0;j<ki;j++) {
      int k;
      std::cin >> k;
      data[i].push_back(k);
    }
  }
  std::vector<int> p(M);
  for(int i=0;i<M;i++) std::cin >> p[i];
  ll sw = (1 << N)-1;
  ll count=0;
  while(sw >= 0){
    std::vector<int> num(N);
    ll s = sw;
    ll ans = 1;
    for(int i=0;i<N;i++){
      num[i] = s%2;
      s/=2;
    }
    for(int i=0;i<M;i++){
      int reg = 0;
      for(int j=0;j<data[i].size();j++){
        if(num[data[i][j]-1]==1) reg++;
      }
      if(reg%2!=p[i]) ans=0;
    }
    if(ans==1) count++;
    sw--;
  }
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;
char color[4] =  "WBR";

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<int> > col(h, vector<int>(256, 0));
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			char c;
			cin >> c;
			col[i][(int)c]++;
		}
	}

	int ans = inf;
	int white=0;
	for(int i=0; i<h-2; i++){
		white += col[i]['B'] + col[i]['R'];
		int blue=0;
		for(int j=i+1; j<h-1; j++){
			blue += col[j]['W'] + col[j]['R'];
			int red=0;
			for(int k=j+1; k<h; k++){
				red += col[k]['W'] + col[k]['B'];
				if(k==h-1) ans = min(ans, white +blue +red);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF 2e9
const int maxn=100000+10;
int n;

typedef struct
{
    char c;
    int v;
} Card;
Card card[maxn];
Card B[maxn];
Card L[maxn/2+2],R[maxn/2+2];
void merge(Card a[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0; i<n1; i++) L[i]=a[left+i];
    for(int i=0; i<n2; i++) R[i]=a[mid+i];
    L[n1].v=INF,R[n2].v=INF;
    int i=0,j=0;
    for(int k=left; k<right; k++)
    {
        if(L[i].v<=R[j].v)
        {
            a[k]=L[i++];

        }
        else
        {
            a[k]=R[j++];

        }
    }



}
void merge_sort(Card a[],int left,int right)
{
    if(right-left>1)
    {
        int mid=(left+right)/2;
        merge_sort(a,left,mid);
        merge_sort(a,mid,right);
        merge(a,left,mid,right);

    }

}

int partition(int left,int right)
{
    int key=card[right].v;

    int i=left-1;
    for(int j=left; j<right; j++)
    {


        if(card[j].v<=key)
        {
            i++;
            swap(card[i],card[j]);
        }
    }
    swap(card[i+1],card[right]);
    return i+1;
}
void quick_sort(int left,int right)
{
    if(right>left)
    {


        int mid=partition(left,right);
        quick_sort(left,mid-1);
        quick_sort(mid+1,right);
    }

}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        getchar();
        scanf("%c %d",&card[i].c,&card[i].v);
    }
    memcpy(B,card,sizeof(card));
    merge_sort(B,0,n);

    quick_sort(0,n-1);

    bool flag=true;
    for(int i=0;i<n;i++)
    {
        if(card[i].c!=B[i].c||card[i].v!=B[i].v)
        {
            flag=false;
            break;
        }
    }
    if(flag) printf("Stable\n");
    else printf("Not stable\n");
    for(int i=0; i<n; i++) printf("%c %d\n",card[i].c,card[i].v);


    return 0;
}

Measured memory_bytes: 5472