akhauriyash/Code-Regression huggingface dataset:
///////////////////////////////////////////
//                                       //
//      Gagan_Sharma : DTU               // 
//                                       //                   
///////////////////////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       '\n'
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
// #define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

void read(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //      freopen("input.txt",  "r",  stdin);
    //      freopen("output.txt", "w", stdout);
    // #endif
}

//____________________________________________________________________________________


void solve(){
    int n;cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){
        string p;cin>>p;
        s.insert(p);
    }
    int ans = s.size();
    cout<<ans;
    
}
 
int32_t main(){
    read();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    


    return 0;
}                                                                                         


Measured memory_bytes: 19248
# https://atcoder.jp/contests/agc044/submissions/13542551

def main():
    from heapq import heappush, heappop

    T = int(input())
    for _ in range(T):
        N, A, B, C, D = map(int, input().split())

        h = [(0, N)]  # cost,value
        checked = set()

        ans = N * D + 1
        while h:
            cost, x = heappop(h)
            if cost >= ans: continue
            if x in checked: continue
            checked.add(x)

            # 0まで1ずつ減らす
            ans = min(ans, cost + x * D)

            for d, c in ((2, A), (3, B), (5, C)):
                # すでにheapqからnxがpopしていれば
                # より低コストでnxを生成できているので
                # nxの生成は不要
                nx, r = divmod(x, d)
                if nx not in checked:
                    heappush(h, (cost + r * D + c, nx))
                if (r > 0) and ((nx + 1) not in checked):
                    heappush(h, (cost + (d - r) * D + c, nx + 1))

        print(ans)


if __name__ == '__main__':
    main()


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

from operator import itemgetter

N = int(input())
SP_list = []
SP_dict = {}
for i in range(N):
    name, point = input().split()
    pair = (name, int(point))
    SP_list.append(pair)
    SP_dict[pair] = i + 1

for i in range(len(SP_list)):
    SP_dict[SP_list[i]] = i + 1

point_sorted = sorted(SP_list, key=itemgetter(1), reverse=True)
name_sorted = sorted(point_sorted, key=itemgetter(0))

for pair in name_sorted:
    print (SP_dict[pair])

Measured memory_bytes: 3188
;; E - Crested Ibis vs Monster

(defun solve (h ab)
  (let* ((infty (1+ (* 10000 10000))) ; ∞ (maxB * maxH + 1)
         (min-mp (make-array (1+ h) :initial-element infty)))
         ; (aref min-mp h) == 体力hを削るのに必要な最小魔力
    (setf (aref min-mp 0) 0)
    (loop for i from 1 to h
       do (loop for (a . b) in ab
                for j = (max 0 (- i a))
                for m = (+ (aref min-mp j) b)
             do (setf (aref min-mp i) (min (aref min-mp i) m))))
    (aref min-mp h)))

(let* ((h (read))
       (n (read))
       (ab (loop repeat n collect (cons (read) (read)))))
  (princ (solve h ab)))


Measured memory_bytes: 19300
#include<stdio.h>
int main(){

unsigned int num[2];
unsigned int ans[2] = {};

	scanf("%d",&num[0]);
	scanf("%d",&num[1]);

	ans[0] = num[0]*num[1];
	ans[1] = num[0]*2+num[1]*2;

	printf("%d %d\n",ans[0],ans[1]);

return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
int v,e;
vector<vector<int>> Graph(15,vector<int>(15,INF));
vector<vector<int>> dp(pow(2,15),vector<int>(15,INF));


int main(){
        cin >> v >> e;
        rep(i,e){
                 int a,b,c;
                 cin >> a >> b >>c;
                Graph.at(a).at(b) = c;
        }
        dp[1][0] = 0;
  
  //配るdp
        rep(i,pow(2,v)){   //iはこれまでに通った頂点の集合
                rep(j,v){  //jは最後に通った頂点
                        if(dp.at(i).at(j) ==INF) continue;
                        rep(k,v){//kはjの次に通る頂点
                                if(Graph.at(j).at(k) ==INF) continue;
                                if(i>>k & 1) continue;
                                dp.at((1<<k)|i).at(k) = min(dp.at((1<<k)|i).at(k),dp.at(i).at(j) + Graph.at(j).at(k));
                        }
                }
        }                
        
        int ans = INF;
        rep(i,v){
                if(i == 0) continue;
                if(dp.at(pow(2,v)-1).at(i) ==INF) continue;
                if(Graph.at(i).at(0) ==INF) continue;
                ans = min(ans,dp.at(pow(2,v)-1).at(i)+Graph.at(i).at(0));
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans <<endl; 
        
  
                                                                   
        return 0;
}




Measured memory_bytes: 6164
class node:
    def __init__(self,key,pri,left=None,right=None):
        self.left = left
        self.right = right
        self.key = key
        self.pri = pri

def insert(n,key,pri):
    if(n == None):
        return node(key,pri)
    if(key == n.key):
        return n
    if(key < n.key):
        n.left = insert(n.left, key, pri)
        if(n.pri < n.left.pri):
            n = rightRotate(n)
    else:
        n.right = insert(n.right, key, pri)
        if(n.pri < n.right.pri):
            n = leftRotate(n)
    return n


def rightRotate(n):
    child = n.left
    swapL,swapR,swapK,swapP = child.left,child.right,child.key,child.pri
    n.left = swapR
    n = node(swapK,swapP,swapL,n)
    return n

def leftRotate(n):
    child = n.right
    swapL,swapR,swapK,swapP = child.left,child.right,child.key,child.pri
    n.right = swapL
    n = node(swapK,swapP,n,swapR)
    return n

def find(n,key):
    if(n == None):
        return None
    elif(n.key == key):
        return n
    elif(n.key > key):
        return find(n.left,key)
    else:
        return find(n.right,key)

def delete(n, key):
    if(n == None):
        return None
    if(key < n.key):
        n.left = delete(n.left, key)
    elif(key > n.key):
        n.right = delete(n.right, key)
    else:
        return _delete(n, key)
    return n

def _delete(n, key):
    if(n.left == None and n.right == None):
        return None
    elif(n.left == None):
        n = leftRotate(n)
    elif(n.right == None):
        n = rightRotate(n)
    else:
        if(n.left.pri > n.right.pri):
            n = rightRotate(n)
        else:
            n = leftRotate(n)
    return delete(n, key)

def inorder(n):
    if(n==None):
        return
    if(n.left != None):
        inorder(n.left)
    print(" "+str(n.key), end='')
    if(n.right != None):
        inorder(n.right)

def preorder(n):
    if(n==None):
        return
    print(" "+str(n.key), end='')
    if(n.left != None):
        preorder(n.left)
    if(n.right != None):
        preorder(n.right)

op_num=(int)(input())
root = None
for i in range(op_num):
    items = input().split()
    if(items[0] == "insert"):
        root = insert(root,(int)(items[1]),(int)(items[2]))
    elif(items[0] == "delete"):
        root = delete(root,(int)(items[1]))
    elif(items[0] == "find"):
        res = find(root,(int)(items[1]))
        if(res == None):
            print("no")
        else:
            print("yes")
    else:
        inorder(root)
        print("")
        preorder(root)
        print("")



Measured memory_bytes: 52024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

/***************************************************************************************************/
// グレゴリオ暦の年月日から曜日を求める（ツェラーの公式）
// 関数値 : 0から6の値で、それぞれ土日月火水木金に対応
/***************************************************************************************************/
int zeller(long long y, int m, int d)
{
    if(m <= 2){
        -- y;
        m += 12;
    }
    long long j = y / 100;
    int k = y % 100;
    return (d + ((m+1)*26 / 10) + k + (k / 4) + (j / 4) + 5 * j) % 7;
}

long long solve(long long y1, int m1, int d1, long long y2, int m2, int d2)
{
    long long ans = 0;
    for(long long y=y1; y<=y2; ++y){
        for(int m=1; m<=12; ++m){
            if(make_tuple(y1, m1, d1) <= make_tuple(y, m, 13) && make_tuple(y, m, 13) <= make_tuple(y2, m2, d2) && zeller(y, m, 13) == 6)
                ++ ans;
        }
    }
    return ans;
}

int main()
{
    long long y1, y2;
    int m1, d1, m2, d2;
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if(y2 - y1 < 1000){
        cout << solve(y1, m1, d1, y2, m2, d2) << endl;
        return 0;
    }

    long long y3 = (y1 + 400) / 400 * 400;
    long long y4 = (y2 - 1) / 400 * 400;
    long long ans = solve(1, 1, 1, 400, 12, 31) * ((y4 - y3) / 400);

    ans += solve(y1, m1, d1, y3 - 1, 12, 31);
    ans += solve(y4, 1, 1, y2, m2, d2);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1168
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int i, N, M;
    unsigned long long n = 1, m = 1;
    scanf("%d %d", &N, &M);
    if ( abs(N-M) >= 2 ){
        printf("0\n");
        return 0;
    }
    for (i = 0; i < N; i++ ){
        n *= N - i;
        n %= 1000000007LL;
    }
    for (i = 0; i < M; i++ ){
        m *= M - i;
        m %= 1000000007LL;
    }
    if ( N == M ){
        printf("%lld\n", (n * m * 2) % 1000000007LL);
    } else {
        printf("%lld\n", (n * m) % 1000000007LL);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a%2==0 and a==b and b==c)
  {
    cout<<-1<<endl;
    return 0;
  }
  
  int count=0;
  while(true)
  {
    if(a%2==1 or b%2==1 or c%2==1)
      break;
    int tmpa=a/2;
    int tmpb=b/2;
    int tmpc=c/2;
    a=tmpb+tmpc;
    b=tmpa+tmpc;
    c=tmpa+tmpb;
    count++;
  }
  cout<<count<<endl;
}

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

int main() {
	int k;
	long ans = 0;
	cin >> k;
	for(int i = 1;i <= k;i++){
		for(int j= 1;j <= k;j++){
			for(int l = 1;l <= k;l++){
				ans += gcd(gcd(i,j),l);
			}
		}
	}
	cout <<ans << endl;

 }



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=3e5;

int n,a[N];
LL x[N],y[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		x[i]=x[i-1]^a[i];
		y[i]=y[i-1]+a[i];
		//printf("i=%d x=%lld y=%lld\n",i,x[i],y[i]);
	}
	LL ans=0;
	for(int i=1;i<=n;i++) {
		int l=i,r=n,mid,res=0;
		while(l<=r) {
			mid=(l+r)/2;
			//printf("x[mid]=%lld x[i-1]=%lld y[mid]=%lld y[i-1]=%lld\n",x[mid],x[i-1],y[mid],y[i-1]);
			if((x[mid]^x[i-1])==(y[mid]-y[i-1])) {
				l=mid+1;
				res=mid-i+1;
			}
			else r=mid-1;
		}
		//printf("i=%d res=%d\n",i,res);
		ans+=res;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4608
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

A = [0]*(100000)

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            A[i**2+j**2+k**2+i*j+j*k+k*i] += 1

for i in range(1,N+1):
    print(A[i])

Measured memory_bytes: 69196
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

bool check(string s, int len) {
    unordered_map<string, int> pos;
    for(int i = 0; i <= s.size()-len; i++) {
        string tmp = s.substr(i, len);
        if (pos.count(tmp) > 0) {
            if (i-pos[tmp] >= len)
                return true;
        } else {
            pos[tmp] = i;
        }

    }
    return false;
}
int main() {
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = s.size();
    while(l < r) {
        int mid = l+(r-l)/2;
        if (check(s, mid) == true) {
            l = mid;
            if (l+1 == r) {
                if (check(s, r) == true) {
                    cout << r << endl;
                    return 0;
                } else {break;}
            }
        } else {
            r = mid-1;
        }
    }
    cout << l << endl;
    return 0;
}




Measured memory_bytes: 6684
# 整数の入力
n=int(input())
a=list(map(int, input().split()))

p=1
flag=0 #増加中なら1,減少中なら-1

for i in range(1,n):
  if a[i-1]<a[i]:
    if flag>=0:#継続
      flag=1
    if flag==-1:#切断
      flag=0
      p+=1
      i+=1
  if a[i-1]>a[i]:
    if flag<=0:#継続
      flag=-1
    if flag==1:#切断
      flag=-0
      p+=1
      i+=1
print(p)

Measured memory_bytes: 14252
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void dfs(int x, int p, vvint &vv, vint &d, int dd){
	d[x] = dd;
	for(int y: vv[x]){
		if(y==p) continue;
		dfs(y, x, vv, d, dd+1);
	}
}

void mainmain(){
	int n;
	cin>>n;
	vvint vv(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		vv[a].PB(b);
		vv[b].PB(a);
	}
	vint d1(n);
	dfs(0, -1, vv, d1, 0);
	vint d2(n);
	dfs(n-1, -1, vv, d2, 0);
	int a=0,b=0;
	rep(i,n){
		if(d1[i]<=d2[i]) a++;
		else b++;
	}
	if(a>b) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

template<class T> inline T gcd(T a, T b) {
    if (b == 0) return a;
    return  gcd(b, a % b);
}

template<class T> inline T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll l = lcm(c, d);
    ll divL = (b / l) - ((a - 1) / l);
    ll divC = (b / c) - ((a - 1) / c);
    ll divD = (b / d) - ((a - 1) / d);

    ll ans = (b - a + 1) - (divC + divD - divL);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N, ans = 1 ;
  cin >> N ;
  string S[N] ;
  for(int i=0;i<N;i++){
    cin >> S[i] ;
  }
  sort(S,S+N) ;
  for(int i=0;i<(N-1);i++){
    if(S[i] != S[i+1]) ans++ ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 9888
n = gets.to_i
a = gets.split.map(&:to_i)
sum2_min = 10000000
for t in -100..100 do
  sum2 = a.inject(0) { |result, v| result + (v - t) ** 2 }
  sum2_min = [sum2_min, sum2].min
end
puts sum2_min


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[114514], b[114514];
	pair<ll, int> ab[214514];
	cin>>n;
	REP(i, n){
		cin>>a[i]>>b[i];
		ab[i]=make_pair(a[i], i);
		ab[n+i]=make_pair(b[i], n+i);
	}
	sort(ab, ab+n*2);
	ll ans=0, sum1=0, sum2=0;
	REP(i, n){
		ans+=ab[i].first;
		sum1+=a[i];
		sum2+=b[i];
	}
	if(sum1!=ans && sum2!=ans){
		bool ok=false;
		REP(i, n){
			if((a[i]<ab[n-1].first && b[i]<ab[n-1].first) || (a[i]==ab[n-1].first && b[i]==ab[n-1].first && ab[n-2].first==ab[n-1].first)){
				ok=true;
				break;
			}
		}
		if(!ok){
			if(abs(ab[n-1].second-ab[n].second)==n){
				ans=ans+min(ab[n+1].first-ab[n-1].first, ab[n].first-ab[n-2].first);
			}
			else{
				ans=ans+ab[n].first-ab[n-1].first;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define sprint(X) printf("%f\n", (X)) // 小数点の出力
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){

  int x,y,z;
  cin >> x >> y >> z;

  cout << z _ x _ y << "\n";

 return 0;
}


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

int main() {
	int A[45];
	A[0] = A[1] = 1;
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		A[i] = A[i - 1] + A[i - 2];
	}
	cout << A[n] << endl;

	return 0;

}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 300000;
int a[N];
vector < pair < int, int > > v;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    int len = 0;
    for (int i = 1; i <= n; i++){
        if (a[i] != a[i - 1] && i != 1){
            if ((a[i] - a[i - 1] + len) % 2) v.pb({a[i - 1] - 1 - (len + 1) % 2, n - i});
            len = 1;
        } else if (i == 1) len = 1; else len++;
    }
    int ans = (a[n] + len - 1) % 2;
   // cout << v.size() << endl;
    for (auto i: v){
        //cout << i.F << " " << i.S << endl;
        if (i.F - i.S >= 0) ans ^= 1;
    }
    if (ans == 0) cout << "First"; else cout << "Second";
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();

		if (k == n) {
			s = s.substring(0, k - 1) + s.substring(k - 1).toLowerCase();
		} else if (1 < k && k < n) {
			s = s.substring(0, k - 1) + s.substring(k - 1, k).toLowerCase() + s.substring(k);
		} else if (1 == k) {
			s = s.substring(k - 1, k).toLowerCase() + s.substring(k);
		}

		System.out.println(s);

	}

}


Measured memory_bytes: 21204
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll a = 2;
  ll b = 1;
  ll n;
  cin>>n;
  rep(i,0,n-1){
    ll c = a+b;
    a = b;
    b = c;
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n;
	double x,t=0.0;
	string s;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x >> s;
		if (s == "JPY")t += x;
		else t +=(380000 * x);
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N;

int Main() {
    cin >> N;
    vl a(N);
    rep(i,N-1) {
        cin >> a[i];
        a[i]--;
    }
    vl v(N);
    rep(i,N-1) {
        v[a[i]] += 1;
    }
    
    rep(i,N) {
        cout << v[i] << endl;
    }
    return 0;
}

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


Measured memory_bytes: 6328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.function.LongSupplier;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String str[] = line.split("");
		int n = str.length;
		int num[] = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(str[i]);
		}

		ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();

		for (int bit = 0; bit < (1 << (n - 1)); bit++) {
			list.add(new ArrayList<String>());
			for (int i = 0; i < n - 1; i++) {
				if ((bit & (1 << i)) != 0) {
					list.get(bit).add("+");
				} else {
					list.get(bit).add("-");
				}
			}
		}

		String ans = "";

		for (int i = 0; i < list.size(); i++) {
			int sum = num[0];
			String s = String.valueOf(sum);
			for (int j = 0; j < list.get(i).size(); j++) {
				if (list.get(i).get(j).equals("+")) {
					sum += num[j + 1];
					s += "+" + String.valueOf(num[j + 1]);
				} else {
					sum -= num[j + 1];
					s += "-" + String.valueOf(num[j + 1]);
				}
			}
			if (sum == 7) {
				ans = s + "=7";
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21460
n,m=map(int,input().split())
jobs=[]
for i in range(n):
    a,b=map(int,input().split())
    jobs.append((a,-b))
jobs.sort(reverse=True)

import heapq
hp=[]
ans=0
for i in range(1,m+1):
    while jobs and jobs[-1][0]<=i:
        heapq.heappush(hp,jobs.pop()[1])
    if hp:
        ans-=heapq.heappop(hp)
print(ans)

Measured memory_bytes: 67288
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define N 1000000007

using namespace std;

ll A(int n) {
	ll a = 1, b;
	for( int i=1; i<=n; i++ ) {
		a *= i;
		a %= N;
	}
	return a;
}

int main(){
	int a, b;
	cin >> a >> b;
	int result = 0;
	if( a>b ) {
		swap(a, b);
	}
	if( b-a==0||b-a==1 ) {
		result = (A(a) * A(b))%N;
	}
	if( b-a==0 ) {
		result = (2*result)%N;
	}
	cout << result << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A, B;cin>>A>>B;
  
  vector<int> vec(50);
  for(int i=0;i<50;i++){
    vec[i]=(A-1)*i+1;
  }
  
  for(int i=0;i<50;i++){
    if(vec[i]>=B){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
int n,m;
int ans;

signed main(){
	acc_io;
	cin>>n>>m;
	vl s(n),c(n);
	map<int,int>mp;
	rep(i,0,m){
		cin>>s[i];
		cin>>c[i];
		if(n>1&&s[i]==1&&c[i]==0){
			cout<<-1<<endl;
			return 0;
		}
		if(mp[s[i]]==0){
			mp[s[i]]=c[i];
		}
		else{
			if(mp[s[i]]!=c[i]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	int tmp=0;
	if(n==3){
		if(mp[1]==0)mp[1]=1;
		ans=mp[1]*100+mp[2]*10+mp[3];
	}
	else if(n==2){
		if(mp[1]==0)mp[1]=1;
		ans=mp[1]*10+mp[2];
	}
	else{
		ans=mp[1];
	}
	cout<<ans<<endl;
	return 0;
}


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



int MOD=1000000007;
int main(void){
	long long N;
	cin >> N;
	long long a[N+10];
	for(int i=0; i<N; i++){
		cin >> a[i];
	}

	sort(a,a+N);
	for(int i=0; i<N-1; i++){
		if(a[i]==a[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;


}


Measured memory_bytes: 1792
// Problem : G - Longest Path
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_g
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()

const ll inf=0x3f3f3f3f3f3f3f3f;
const ll N = 1e5 + 5;
vi g[N];
ll dp[N] = {0};
vi vis(N, 0);

ll dfs(ll v) {
	vis[v] = true;
	if(g[v].empty()) {
		//leaf
		return dp[v] = 1;
	}
	ll mx = 0;
	for(auto u:g[v]) {
		if(!vis[u]) {
			dp[v] = max(dfs(u) + 1, dp[v]);
		}
		else {
			dp[v] = max(dp[u] + 1, dp[v]);
		}
	}
	return dp[v];
}

int main() {
    SPEED;
    ll n, m;
    cin>>n>>m;
    for(ll i = 0; i < m; i++) {
    	ll u, v;
    	cin>>u>>v;
    	g[u].pb(v);
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
    	if(!vis[i]) {
    		ans = max(ans, dfs(i));
    	}
    }
    cout<<ans - 1;
    return 0;
}

Measured memory_bytes: 12068
import sys
input = sys.stdin.readline

#import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
#from collections import deque, defaultdict, Counter
#from heapq import heappush, heappop
#from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
#from operator import itemgetter as ig

#sys.setrecursionlimit(10 ** 7)
#nf = 10 ** 20
#INF = float("INF")
#mod = 10 ** 9 + 7

'''
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]
# 深さ優先探索
def dfs(G, v):
    global time, first_order,seen,last_order
    time += 1
    first_order[v-1] = time   #　行きがけ

    seen[v-1] = True # v を訪問済みにする
    # v から行ける各頂点 next_v について
    for next_v in G[v]:
        if seen[next_v-1]:
            continue
        dfs(G, next_v)

    time += 1
    last_order[v - 1] = time  # 帰りがけ
'''

def main():

    N, Q = map(int, input().split())
    S = input()
    task = []
    for i in range(Q):
        task.append(list(map(int, input().split())))

    count = [0,0]
    p = 0
    for i in range(1,len(S)):
        if S[i-1] == 'A' and S[i] == 'C':
            p += 1
            count.append(p)
        else:
            count.append(p)

    for task_n in task:
        print(count[task_n[1]] - count[task_n[0]])

if __name__ == '__main__':
    main()


Measured memory_bytes: 90712
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<long long> v[11];

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[200311];
int l[11];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=998244353,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[3];
stack<long long> s;
//set<int> s[222][22];
//priority_queue<P> q;
//queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[222253];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d %d %d",&a,&b,&c);
    for(int t=1;t<=a;o[t]=t,t++);
    o[a+1]=0;
    o[1]=1;
    for(int t=1;t<=c;t++)
    {
        scanf("%d %d",&n,&m);
        o[n]=min(o[n],m-1);
    }
    for(int t=1;t<=a;t++)
    {
        if(o[t]>o[t+1])
        {
            printf("%d",t);
            return 0;
        }
        o[t+1]=min(o[t]+1,o[t+1]);
    }
}






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

int main(){
	int n,m,l;
	cin >> n >> m >> l;
	
	long long int a[100][100], b[100][100];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> b[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			long long int elem=0;
			for(int k=0; k<m; k++){
				elem += a[i][k]*b[k][j];
			}
			if(j==0) cout << elem;
			else cout << " " << elem;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
using namespace std;
int main()
{

	int n;

	while(true){
		cin >> n;
		if(n==0)
			break;

		int ice[10];
		int x;
		int c=0;
		
		for(int i=0 ;i<10 ;i++){
			ice[i] = 0;
		}
		for(int i=0 ;i<n ;i++){
			cin >> x;
		
			for(int j=0; j<10 ;j++){
				if(j==x){
					ice[j]++;
				}
			}
		}
		for(int i=0 ;i<10 ;i++){
			if(ice[i] > 0){
				for(int j=0 ;j<ice[i] ;j++){
					cout << '*' ;
				}
				cout << endl;
			}
			else if(ice[i] == 0)
				cout << '-' << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
using namespace std;

int main (void)
{
	char data[1200];
	int i, p, key;

	scanf("%[^\n]", data);

	for (p=0; data[p] != '\0'; p++);

	key = 'a' - 'A';

	for (i=0; i<p; i++){
		if (data[i] >= 'A' && data[i] <= 'Z')
			printf("%c", data[i]+key);
		else if (data[i] >= 'a' && data[i] <= 'z')
			printf("%c", data[i]-key);
		else
			printf("%c", data[i]);
	}
          printf("\n");
	return 0;
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s,t;
    cin >> s >> t;
    auto n = s.size();
    cout << (t.compare(0,n,s) == 0 ? "Yes" : "No") << endl;
    
    
    return 0;
}

Measured memory_bytes: 3644
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  multimap<string, int> m;
  while (q--) {
    int t = in();
    if (t == 0) {
      string k;
      int x;
      cin >> k >> x;
      m.emplace(k, x);
    }
    if (t == 1) {
      string s = in<string>();
      for (auto it = m.lower_bound(s), end = m.upper_bound(s); it != end; it++) cout << it->second << endl;
    }
    if (t == 2) m.erase(in<string>());
    if (t == 3) {
      string l, r;
      cin >> l >> r;
      for (auto it = m.lower_bound(l), end = m.upper_bound(r); it != end; it++) cout << *it << endl;
    }
  }
}



Measured memory_bytes: 24700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+5;
ll f[N],n,ans;
int main(){
   for(int i=1;i<N;i++) for(int j=i;j<N;j+=i) f[j]++;
   cin>>n; for(int i=1;i<=n;i++) ans+=f[i]*i; cout<<ans;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

int n;
set<int> st;

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

	cin>>n;
	REP(i,n) {
		int a; cin>>a; a--;
		st.insert(a);
	}

	cout<<(st.size()+(st.size()&1?0:-1))<<endl;

	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
  int w,h;

  while(1) {
    scanf("%d %d", &w, &h);

    if(w == 0 && h == 0) break;

    for(int i = 0; i < w; i++) {
      for(int j = 0; j < h; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2064
use proconio::input;

fn main() {
    input! {
        n:usize,
        A:[i32;n]
    }
    if n % 2 == 1 {
        println!(
            "{}",
            A.iter()
                .map(|a| a.to_string())
                .collect::<Vec<String>>()
                .join(" ")
        );
        return;
    }

    let mut sum = 0;
    for a in A.iter() {
        sum ^= a;
    }
    println!(
        "{}",
        A.iter()
            .map(|a| (a ^ sum).to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}


Measured memory_bytes: 18612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9+1;
const ll LINF = 1e18+1;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    IN(int, n);
    vector<pair<int, int>> a(n);
    REP(i, n){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    SORT(a);
    REP(i, n){
        cout << a[i].second;
        if (i<n-1) {
            cout << " ";
        }else{
            ENDL;
        }
    }
}


Measured memory_bytes: 3984
# 141a(A - Weather Prediction)
# 問題文
# 高橋君の住む町の天気は、
# 一日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)、晴れ、くもり、雨、… と周期的に変化します。
# 今日の天気を表す文字列 S が与えられるので、明日の天気を予測してください。
#
# 制約: S は Sunny, Cloudy, Rainy のいずれかである

# 入力: 入力は以下の形式で標準入力から与えられる。
# S
# 出力: 明日の天気を入力と同じ形式で出力せよ。

S = input()
if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
elif S == 'Rainy':
    print('Sunny')

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

void Yes(){
	cout<<"Yay!"<<endl;
}
void No(){
	cout<<":("<<endl;
}

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	lli data[100100];
	REP(i,0,100100)data[i]=0;
	REP(i,0,n){
		cin>>a[i];
		data[a[i]]++;
	}

	lli use[100100];
	REP(i,0,100100)use[i]=0;
	use[0]=3;

	lli d=1;
	REP(i,0,n){
		lli now=a[i];
		d*=use[now];
		use[now]--;
		use[now+1]++;
		d%=MOD;
	}
	cout<<d<<endl;
	
	return 0;
}

Measured memory_bytes: 1792