akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int prev = sc.nextInt();
        int idx = 0;
        for (int i = 1; i < n; i++) {
            int x = sc.nextInt();
            if (prev + x >= k) {
                idx = i;
                break;
            }
            prev = x;
        }
        if (idx == 0) {
            System.out.println("Impossible");
            return;
        }
        System.out.println("Possible");
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < idx; i++) {
            sb.append(i).append("\n");
        }
        for (int i = n - 1; i > idx; i--) {
            sb.append(i).append("\n");
        }
        sb.append(idx).append("\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 48488
class Work:
    count=0
    def __init__(self,payday,money):
        Work.count+=1
        self.count=Work.count
        self.payday=payday
        self.money=money
 #moneyが大きい方、同じなら早くもらえる方、それも同じなら最初に書いてある方が強い方
    def __ft__(self,other):
        if self.money>other.money:
            return True
        if self.money==other.money:
            if self.payday<other.payday:
                return True
            if self.payday==other.payday:
                if self.count<other.count:
                    return True
        return False

    def __gt__(self,other):
        if self.money<other.money:
            return True
        if self.money==other.money:
            if self.payday>other.payday:
                return True
            if self.payday==other.payday:
                if self.count>other.count:
                    return True
        return False

#バイトの数、いつまでに稼ぐのか 
n,limit=[int(i) for i in input().split()]

#バイトのリストを作り、クラスを入れる O(n)
baitolist=[]
for i in range(n):
    payday,money=[int(i) for i in input().split()]
    work=Work(payday,money)
    baitolist.append(work)

#日数でランク付け　O(n)
summoney=0    
rank=[[] for i in range(limit+1)]
for baito in baitolist:
    if baito.payday<=limit:
        rank[baito.payday].append(baito)

        
import heapq
accessible=[]
count=1


for i in range(limit):
    for baito in rank[count]:
        heapq.heappush(accessible,baito)
    if accessible!=[]:
        dowork=heapq.heappop(accessible)
        summoney+=dowork.money
    count+=1
    
    
print(summoney)        


Measured memory_bytes: 89560
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int cnt = 0;

        for (int i=0; i<n-1; i++) {
            if (arr[i]==i+1) {
                cnt++;
                int tmp = arr[i+1];
                arr[i+1] = arr[i];
                arr[i] = tmp;
            }
        }

        if (arr[n-1]==n) cnt++;

        System.out.println(cnt);

    }
}

Measured memory_bytes: 51168
A, B = map(int, input().split())

def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

d=set(prime_factorize(A)) & set(prime_factorize(B))

print(len(d))

Measured memory_bytes: 40368
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C) // ポインタ変数に整数値を入れる

	ans := C - (A - B)
	if ans < 0 {
		ans = 0
	}
	fmt.Println(ans)
}


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

using namespace std;
const double EPS = 1e-10;

int main()
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	double AB, CD;
	int num = 0, i = 0;

	cin >> num;
	while ( i < num )
	{
		cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
		if ( fabs( ( xa - xb ) * ( yc - yd ) - ( xc - xd ) * ( ya - yb ) ) < EPS )
		{	
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

		i = i + 1;
	}

	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

int p[8];
int pvisit[9];
int q[8];
int qvisit[9];
int fact[9];

int comb(int a, int b) {
  return fact[a]/fact[a-b];
}


int main()
{
  int n;
  
  fact[0] = 1;
  
  for(int i = 1; i < 8; i++)
    fact[i] = fact[i-1] * i;
  
  scanf("%d", &n);
  
  for(int i = 0; i < n; i++)
    scanf("%d", &p[i]);
  
  for(int i = 0; i < n; i++)
    scanf("%d", &q[i]);
  
  int porder = 0;
  int qorder = 0;
  for(int i = 0; i < n; i++)
  {
    pvisit[p[i]] = 1;
    qvisit[q[i]] = 1;
    
    int psmaller = 0;
    for(int j = 0; j < p[i]; j++)
      if (pvisit[j] == 0)
        psmaller++;
                         
    int qsmaller = 0;
    for(int j = 0; j < q[i]; j++)
      if (qvisit[j] == 0)
        qsmaller++;
    
    porder += psmaller * fact[n-i-1];
    qorder += qsmaller * fact[n-i-1];
    
  }
  
  printf("%d\n", abs(qorder-porder));
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N, M, Q, P;
  cin >> N;
  char s[4];
  
  int AC=0, WA=0, TLE=0, RE=0;
  for(int i = 0; i < N; i++){
    cin >> s;
    switch(s[0]){
      case 'A': AC++; break;
      case 'W': WA++; break;
      case 'T': TLE++; break;
      case 'R': RE++; break;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;

  return 0;
}

Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }
  

void solve() {
   int n;
   cin>>n;
   vi a(n,0);
   rep(i,0,n) cin>>a[i];
   int mini=a[0],ct=0;
   rep(i,0,n) {
	     if(a[i]<=mini) ct++;
	     mini=min(a[i],mini);
	   } 
	   
	   cout<<ct<<endl;                           
}

    
int32_t main() {
	cool;
	int t=1;	
   
	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


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

int main() {
	int N;
	cin >> N;
	int A = 0, B = 0, AB = 0, BA = 0;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		A += (s.back() == 'A' && s.front() != 'B');
		B += (s.back() != 'A' && s.front() == 'B');
		BA += (s.back() == 'A' && s.front() == 'B');
		for (int j = 0; j < s.length() - 1; j++) AB += (s.substr(j, 2) == "AB");
	}
	while (BA > 0 && A != B) {
		(A < B ? A : B)++;
		BA--;
	}
	if (A == 0 && B == 0) BA--;
	cout << AB + min(A, B) + max(0, BA) << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;

namespace _20200426_ABC164A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);

            string[] sp = input[0].Split(' ');
            int S = int.Parse(sp[0]);
            int W = int.Parse(sp[1]);

            string output = "unsafe";
            if (S > W)
            {
                output = "safe";
            }

            Console.WriteLine(output);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }
    }
}


Measured memory_bytes: 17896
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}


int main(){
	
	int n,l;
	int i;
	int sum=0,ans,ans2;
	cin >> n >> l;
	syc(n,2,200);
	syc(n,-100,100);
	int a[n];
	
	for(i=0;i<n;i++){
		a[i]=l+i;
		sum+=a[i];
	}
	
	ans=a[0]*a[0];
	ans2=a[0];
	
	for(i=1;i<n;i++){
		if(ans>a[i]*a[i]){
			ans = a[i]*a[i];
			ans2 = a[i];
		}
	}
	
	cout << sum-ans2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2000*2000;
const char newl = '\n';

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

  string s, t;
  cin >> s;

  rep(i, s.size()) {
    if(s[i] == 'A') t += 'A';
    else if(i<s.size()-1 && s[i] == 'B' && s[i+1] == 'C') {t += 'B'; i++;}
    else if(t.back() != 'D') t += 'D';
  }
  ll ans=0, cnt=0;
  rep(i, t.size()) {
    if(t[i] == 'A') cnt++;
    else if(t[i] == 'B') ans += cnt;
    else if(t[i] == 'D') cnt = 0;
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3892
H, W = map(int,input().split())
S = [list(input()) for _ in range(H)]
for i in range(H):
  for j in range(W):
    up = down = left = right = "."
    if S[i][j] == "#":
      if i-1 >= 0:
        up = S[i-1][j]
      if j-1 >= 0:
        left = S[i][j-1]
      if i+1 <= H-1:
        down = S[i+1][j]
      if j+1 <= W-1:
        right = S[i][j+1]
      if up == down == left == right == ".":
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for(int i = 0; i <= (n - 3); i++) {
      if((s.charAt(i) == 'A') && (s.charAt(i + 1) == 'B') && (s.charAt(i + 2) == 'C')) ans++;
    }
    System.out.println(ans);
  }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const long inf=1e14;
int u = 1;
vector<int> g[size];
vector<int> h[size];
void dfs(int v, int c){
	for(int t:g[c]){
		u++;
		h[v].push_back(u);
		dfs(u, t);
	}
}
int main(){
	string s; cin>>s;
	int n = s.size();
    rep(i,0,n-1)if(s[i] != s[n-2-i]){ cout<<-1<<endl; return 0; }
    if(s[0] == '0' || s[n-1] == '1'){ cout<<-1<<endl; return 0; }
    s[n-1] = '1';
	set<int> st; int j = 1;
	rep(i,2,n+1){
		if(s[i-1] == '0') continue;
		g[i].push_back(j);
        rep(k,0,i-1-j) g[i].push_back(1);
        j = i;
	}
	for(int v:st){
		if(st.count(n - v)){ cout<<-1<<endl; return 0; }
	}
	dfs(1, n);
	rep(i,1,n+1){
		for(int j:h[i]) cout<<i<<" "<<j<<endl;
	}
}

Measured memory_bytes: 17152
#include <stdio.h>
int hour(int s)
{
	int h;
	h = s/3600;
	return h;
}
int min(int s)
{
	int m;
	m = s/60;
	return m;
}
int main()
{
	int a, h, m, s;
	scanf("%d", &a);
	h = hour(a);
	m = min(a-(3600*h));
	s = a-(3600*h)-(60*m);
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define nrep(i,n) for(int i=1;i<=(n);i++)
#define FST first
#define SEC second
using namespace std;

typedef pair <int,int> pxy;
#define WMAX 20
#define HMAX 20
int dd[5]={0,1,0,-1,0};
int W,H;

void print(char map[HMAX][WMAX]){
  putchar('\n');
  rep(i,H){
    rep(j,W){
      cout << map[i][j];
    }
    putchar('\n');
  }
}

int dfs(char map[HMAX][WMAX]){
  stack <pxy> s;
  int n=0;
  rep(i,H){
    if(n) break;
    rep(j,W){
      if(map[i][j]=='@'){
	s.push(pxy(j,i));
	n=1;
	break;
      }
    }
  }

  while(!s.empty()){
    int cx=s.top().FST, cy=s.top().SEC;
    s.pop();
    if(map[cy][cx]=='.')
      n++;
    map[cy][cx]='#';
    rep(r,4){
      int nx=cx+dd[r], ny=cy+dd[r+1];
      if(nx<0||W<=nx||ny<0||H<=ny||map[ny][nx]=='#')
	continue;
      s.push(pxy(nx,ny));
    }
  }
  return n;
}


int main(){
  for(;;){
    scanf("%d %d",&W,&H);
    if(!(W+H)) break;
    
    char map[HMAX][WMAX];
    rep(i,H){
      string s;
      cin >> s;
      strcpy(map[i],s.c_str());
    }
    printf("%d\n",dfs(map));
  }
}

Measured memory_bytes: 1260
import Data.Bits
import Data.List
import Data.Maybe(fromJust)
import Control.Monad
import Data.Array as A ((!))
import Data.Graph
import qualified Data.Vector.Unboxed as V
--import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Char8 as BS
--import Debug.Trace

toTuple :: [a] -> (a,a)
toTuple (x:y:_) = (x,y)
toTuple _ = undefined

getInt :: IO Int
getInt = fst . fromJust. BS.readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile (== ' ')) <$> BS.getLine

getLineB :: (Read a) => IO [a]
getLineB = map (read.BS.unpack) . BS.words <$> BS.getLine

solve :: Int -> Graph -> Int
solve n graph = sub 1 1 [1]
  where
    sub s h ls | h > n  = 0
               | h == n = if sort ls == [1..n] then 1 else 0
               | otherwise = sum [sub nh (h+1) (nh:ls) | nh <- graph A.! s]

main :: IO ()
main = do
  [n,m] <- getIntList
  es <- replicateM m $ toTuple <$> getIntList
  print $ solve n (buildG (1,n) (es++(map (\(a,b) -> (b,a)) es)))


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

using namespace std;

int main() {
    vector<string> str_vec;
    int n, l;

    cin >> n >> l;

    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        str_vec.push_back(str);
    }

    sort(str_vec.begin(), str_vec.end());

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

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

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

    if (y >= 2*x && y <= 4*x && y%2 == 0) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3660
N = int(input())

nmod2 = N % 2
lists = []

for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if nmod2 == 0:
            if i + j != N + 1:
                lists.append([i, j])
        else:
            if i + j != N:
                lists.append([i, j])

print(len(lists))
for l in lists:
    print(l[0], l[1])


Measured memory_bytes: 4124
s = input()
n = len(s)
i = 0
if 'k' in s and 'eyence' in s:
    if s[:1] =='k' and s[n-6:] == 'eyence':
        print('YES')
        exit()
if 'ke' in s and 'yence' in s:
    if s[:2] =='ke' and s[n-5:] == 'yence':
        print('YES')
        exit()
if 'key' in s and 'ence' in s:
    if s[:3] =='key' and s[n-4:] == 'ence':
        print('YES')
        exit()
if 'keye' in s and 'nce' in s:
    if s[:4] =='keye' and s[n-3:] == 'nce':
        print('YES')
        exit()
if 'keyen' in s and 'ce' in s:
    if s[:5] =='keyen' and s[n-2:] == 'ce':
        print('YES')
        exit()
if 'keyenc' in s and 'e' in s:
    if s[:6] =='keyenc' and s[n-1:] == 'e':
        print('YES')
        exit()
if 'keyence' in s:
    if s[:7] == 'keyence' or s[n-7:] == 'keyence':
        print('YES')
        exit()
print('NO')

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int n, m;
vector<int> G[610];

int main(){
    cin >> n >> m;
    int s, t;
    for (int i = 0; i < m; ++i) {
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
    }

    vector<double> e(n, 0.0);
    for (int i = n-2; i >= 0; --i) {
        double x = 0;
        for (int j = 0; j < G[i].size(); ++j) {
            x += (1.0 + e[G[i][j]]);
        }
        e[i] = x / (double)G[i].size();
    }

    double res = e[0];
    for (int i = 0; i < n-2; ++i) {
        if (G[i].size() == 1) continue;
        double mv = -1;
        int mn;
        for (auto v : G[i]) {
            if (chmax(mv, e[v])) mn = v;
        }

        vector<double> ex(n, 0.0);
        for (int j = i+1; j < n; ++j) {
            ex[j] = e[j];
        }
        for (int j = i; j >= 0; --j) {
            double x = 0;
            for (int k = 0; k < G[j].size(); ++k) {
                if (j == i && G[j][k] == mn) continue;
                x += (1.0 + ex[G[j][k]]);
            }
            if (j == i) ex[j] = x / (double)(G[j].size() - 1);
            else ex[j] = x / (double)G[j].size();
        }
        chmin(res, ex[0]);
    }
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> b;
  rep(i, n) b[a[i]]++;
  ll ans = 0;
  for (auto x : b)
    ans += x.second * (x.second - 1) / 2;
  rep(i, n)
  {
    ll before = b[a[i]] * (b[a[i]] - 1) / 2;
    ll after = (b[a[i]] - 1) * (b[a[i]] - 2) / 2;
    cout << ans - (before - after) << endl;
  }
}


Measured memory_bytes: 11900
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	int n; cin >> n;
	vi a(n), b(n);
	for(auto& p: a) cin >> p;
	for(auto& p: b) cin >> p;

	vi v(n);
	FOR(i, n) v[i] = i+1;

	int ans1 = -1, ans2 = -1;
	int cnt = 1;
	do{
		int i;
		for(i = 0; i < n && v[i] == a[i]; i++);
		if(i == n) ans1 = cnt;
		for(i = 0; i < n && v[i] == b[i]; i++);
		if(i == n) ans2 = cnt;
		cnt++;
	}while(next_permutation(all(v)));

	cout << abs(ans1-ans2) << '\n';

	return 0;
}

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

int main() {
  int number_a;
  int number_b;
  
  cin >> number_a >> number_b ;
  
  if (number_a * number_b % 2 == 0){
    cout << "Even" << endl;
  } else {
	cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  ll s=0,ans=0;
  rrep(k,50) {
    ll c1=0,c2=0;
    rep(i,n) {
      if(a[i]&(1LL<<k)) c1+=1LL<<k;
      else c2+=1LL<<k;
    }
    if((s|(1LL<<k))>m) c2=0;
    ans+=max(c1,c2);
    if(c1<c2) s|=1LL<<k;
  }
  pr(ans);
}

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


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

template <typename T> istream &operator>>
(istream &is, vector<T> &vec) 
{ for (auto &v : vec) is >> v; return is; }

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back


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

const int mx = 1e6 + 5;
const int INF = mod;

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}



// Check for number of Cases!!
void solve() {
    int n, w;
    cin >> n >> w;

    vector<ll> weight(n), value(n);

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

    ll dp[n+1][w+1];

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= w; j++) {
            if(i == 0 || j == 0) {
                dp[i][j] = 0;
            }else {
                if(weight[i-1] <= j) {
                    dp[i][j] = max(value[i-1] + dp[i-1][j - weight[i-1]], dp[i-1][j]);
                }else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }
    cout << dp[n][w];
}

int main(){

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }
}

Measured memory_bytes: 82396
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string r[] = {"maerd", "remaerd", "esare", "resare"};
    string s;
    cin >> s;
    
    reverse(s.begin(),s.end());    

    int itr=0;
    bool ans = true;
    while(1){
        bool ok = false;
        rep(i, 4){
            //cout << s[itr] << r[i][0] << endl;
            if (strncmp(&s[itr], &r[i][0], strlen(&r[i][0]))==0){
                //cout << itr << r[i] << endl;
                ok = true; 
                itr += strlen(&r[i][0]);
                break;
            }
        }
        if (!ok){
            ans = false;
            break;
        }

        if (itr >= s.size()) break;
    }

    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;

}



Measured memory_bytes: 512
// Rotation

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	char C[2][3];
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> C[i][j];

	if (C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
N,D,*xs=$<.read.split.map(&:to_i)
xs=xs.each_slice(D).to_a

ret = 0
N.times do |i|
    (i+1).upto(N-1) do |j|
        x = 0
        xs[i].zip(xs[j]) do |y,z|
            x+=(y-z)**2
        end
        x = Math.sqrt(x)
        ret += 1 if x - x.to_i == 0
    end
end

puts ret


Measured memory_bytes: 1788
void main()
{
    long n, k;
    rdVals(n, k);
    long[] a = rdRow;
    long[] f = rdRow;

    a.sort!"a < b";
    f.sort!"a > b";

    bool check(long x)
    {
        long total;
        foreach (i; 0 .. n)
        {
            total += max(0, a[i]-x/f[i]);
        }
        return total <= k;
    }

    long ok = inf, ng = -1;
    while (abs(ng - ok) > 1)
    {
        long m = (ok + ng) / 2;
        if (check(m)) ok = m;
        else ng = m;
    }

    ok.writeln;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 14432
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



a,b = map(int,input().split())

GCD = gcd(a,b)

fac = factorization(GCD)

if fac[0][0] == 1:
    print(1)
else:
    print(len(factorization(GCD))+1)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

getData = (\[p, t] -> (readInt p, readDouble t)) . words <$> getLine
sortData = sortBy $ on compare snd
printData (n,t) = putStrLn $ show n ++ " " ++ show t
main = do
    rs <- replicateM 3 $ sortData <$> replicateM 8 getData
    let [as, bs, cs] = rs
    mapM_ printData $ take 2 as
    mapM_ printData $ take 2 bs
    mapM_ printData $ take 2 cs
    mapM_ printData $ take 2 $ sortData $ concat $ map (drop 2) rs
    return ()

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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	int m = 0;
	int b[n] = {0};
	for (int i = n; i > 0; i--) {
		int sum = 0;
		for (int j = i; j <= n; j += i) {
			sum += b[j-1];
		}
		if (sum % 2 != a[i-1]) {
			m++;
			b[i-1] = 1;
		}
	}

	bool flag = false;
	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = i; j < n; j += i + 1) {
			sum += b[j];
		}
		if (sum % 2 != a[i]) {
			flag = true;
			break;
		}
	}

	if (flag) {
		cout << -1 << endl;
	} else {
		cout << m << endl;
		for (int i = 0; i < n; i++) {
			if (b[i] == 1) {
				cout << i + 1 << endl;
			}
		}
	}
}

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

int main() {

	int a, b;

	cin >> a >> b;

	if (a == 1) { a += 13; }
	if (b == 1) { b += 13; }

	if (a>b) {
		puts("Alice");
	}

	else if (a==b) {
		puts("Draw");
	}

	else {
		puts("Bob");
	}

	return 0;
}

Measured memory_bytes: 256
function main(input) {
    var inputArray = input.split(' ');
    var d = parseInt(inputArray[0]);
    var n = parseInt(inputArray[1]);
    var result;

    if (d == 0){
        result = n;
        if (result === 100){
            result = 101;
        }
    } else if (d == 1) {
        result = n * 100;
        if (result === 10000){
            result = 10100;
        }
    } else if (d == 2) {
        result = n * 10000;
        if (result === 1000000){
            result = 1010000;
        }
    }
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>

using namespace std;

int main(){
    int N, a;
    cin >> N;
    int A[N], B[N];
    B[0] = 0;
    for(int i = 1; i < N; i++){
        cin >> A[i];
        B[i] = 0;
    }
    for(int j = 1; j < N; j++){
        a = A[j] - 1;
        B[a] += 1;
    }
    for(int k = 0; k < N; k++){
        cout << B[k] << "\n";
    }
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j,k;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  rep(i,d)
  {
    t[i] = i%26;
  }
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  int m = 10000;
  int mwid = 20;
  for(mwid=20;mwid>=1;mwid--)
  {
    rep(i,m)
    {
      int wid = rand()%mwid;
      wid++;
      int tans = 0;
      int tod,q;
      tod = rand()%(d-wid);
      int d1q = t[tod];
      int d2q = t[tod+wid];
      t[tod] = d2q;
      t[tod+wid] = d1q;
      sums -= s[tod][d1q];
      sums -= s[tod+wid][d2q];
      sums += s[tod][d2q];
      sums += s[tod+wid][d1q];
      int rowd1q = rowans[d1q];
      int rowd2q = rowans[d2q];
      rowans[d1q] = 0;
      rowans[d2q] = 0;
      vector<int> klas(26,0);
      rep(j,d)
      {
        klas[t[j]] = j+1;
        rowans[d1q] += c[d1q]*(j+1-klas[d1q]);
        rowans[d2q] += c[d2q]*(j+1-klas[d2q]);
      }
      tans = sums;
      rep(j,26) tans -= rowans[j];
      if(tans >= kans)
      {
        kans = tans;
        las = klas;
      }
      else
      {
        t[tod] = d1q;
        t[tod+wid] = d2q;
        sums += s[tod][d1q];
        sums += s[tod+wid][d2q];
        sums -= s[tod][d2q];
        sums -= s[tod+wid][d1q];
        rowans[d1q] = rowd1q;
        rowans[d2q] = rowd2q;
      }
    } 
  }
  double tmp = 100000.0;
  double alpha = 0.99;
  m = 100;
  while(tmp <= 100.0)
  {
    int mwid = (int)tmp/5000;
    rep(i,m)
    {
      int wid = rand()%mwid;
      wid++;
      int tans = 0;
      int tod,q;
      tod = rand()%(d-wid);
      int d1q = t[tod];
      int d2q = t[tod+wid];
      t[tod] = d2q;
      t[tod+wid] = d1q;
      sums -= s[tod][d1q];
      sums -= s[tod+wid][d2q];
      sums += s[tod][d2q];
      sums += s[tod+wid][d1q];
      int rowd1q = rowans[d1q];
      int rowd2q = rowans[d2q];
      rowans[d1q] = 0;
      rowans[d2q] = 0;
      vector<int> klas(26,0);
      rep(j,d)
      {
        klas[t[j]] = j+1;
        rowans[d1q] += c[d1q]*(j+1-klas[d1q]);
        rowans[d2q] += c[d2q]*(j+1-klas[d2q]);
      }
      tans = sums;
      rep(j,26) tans -= rowans[j];
      int dis = kans-tans;
      double prob = ((double)rand())/32767.0;
      if(tans >= kans)
      {
        kans = tans;
        las = klas;
      }
      else if(prob <= exp(-(double)dis/(double)tmp))
      {
        kans = tans;
        las = klas;
      }
      else
      {
        t[tod] = d1q;
        t[tod+wid] = d2q;
        sums += s[tod][d1q];
        sums += s[tod+wid][d2q];
        sums -= s[tod][d2q];
        sums -= s[tod+wid][d1q];
        rowans[d1q] = rowd1q;
        rowans[d2q] = rowd2q;
      } 
    }
    tmp *= alpha;
  }
  rep(i,d)
  {
    cout << t[i]+1 << "\n";
  }
}


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n;
    cin >> n;
    vi p(n);
    rep (i, n) {
        cin >> p[i];
        p[i]--;
    }

    ll base = 30000;

    vl a(n), b(n);
    rep (i, n) {
        a[i] = i * base;
        b[i] = (n - 1 - i) * base;
        b[i]++;
    }

    rep (i, n) {
        a[p[i]] += (i + 1);
    }

    rep (i, n) {
        cout << a[i] << " ";
    }
    cout << endl;
    rep (i, n) {
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,x,y,r,k,d,n,q,m,t,a,b;
	cin>>k>>a>>b;
	ll f=0;
	for(i=a;i<=b;i++)
	{
	    if(i%k==0)
	    {
	        f=1;
	        break;
	    }
	}
	if(f)
	cout<<"OK";
	else
	cout<<"NG";
	return 0;
	
	
}


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

def main():
    H, W, K = map(int, input().split())
    c = [input() for i in range(H)]

    ans = 0
    for maskR in range(2 ** H):
        for maskC in range(2 ** W):
            black = 0
            for i in range(H):
                for j in range(W):
                    if 2 ** i & maskR > 0 and 2 ** j & maskC > 0 and c[i][j] == '#':
                        black += 1
                    
            if black == K:
                ans += 1
            
    print(ans) 

main()

Measured memory_bytes: 8988
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  char a;
  cin >> a;
  if (a == 'a' or a == 'i' or a == 'u' or a == 'e' or a == 'o') {
    D("vowel");
  } else {
    D("consonant");
  }
  return 0;
} 




Measured memory_bytes: 256
#include<stdio.h>

int main (void) {
int i,j,k;
int n,x;
int count;

while (1) {
scanf("%d %d", &n, &x);
if (n+x == 0) break;

count = 0;
for (i = 1; i <= n-2; i++)
for (j = i+1; j <= n-1; j++)
for (k = j+1; k <= n; k++)
if(i+j+k == x) count++;

printf("%d\n", count);
}

return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,x,s[205];
int dp[205][100005],tot[100005];

int main(){
	scanf("%d %d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	sort(s+1,s+n+1);
	for(int i=0;i<=x;i++){
		int l=1,r=n,p=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(s[mid]<=i) p=max(p,mid),l=mid+1;
			else r=mid-1;
		}
		tot[i]=p;
	}
	dp[0][x]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=x;j++){
			if(dp[i-1][j]==0) continue;
			for(int k=1;k<=tot[j];k++) (dp[i][j%s[k]]+=dp[i-1][j])%=mod;
			int p=n-tot[j];
			if(i<=p) (dp[i][j]+=1ll*(p-i+1)*dp[i-1][j]%mod)%=mod;
		}
	}
	int ans=0;
	for(int i=0;i<=x;i++) (ans+=1ll*i*dp[n][i]%mod)%=mod;
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 78976
#include <iostream>
using namespace std;
int main(){
    
    int a,b,c;
    cin >> a >> b >> c ;
    
    if(a < b){
        if(b < c){
            cout << a << " " << b << " " << c << endl;
        }
        else{
            if(a < c){
                cout << a << " " << c << " " << b << endl;
            }
            else{
                cout << c << " " << a << " " << b << endl;
            }
        }
    }
    else{
        if(a < c){
            cout << b << " " << a << " " << c << endl;
        }
        else{
            if(b < c){
                cout << b << " " << c << " " << a << endl;
            }
            else{
                cout << c << " " << b << " " << a << endl;
            }
        }
    }
    
    
    
    
    
    
    
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
#define  is_not_5(n) if(n!=5)

int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3 = x2+y1-y2;
    int y3 = y2+x2-x1;
    int x4 = x1-(y2-y1);
    int y4 = y1+x2-x1;
    cout << x3<< " "<<y3 << " "<<x4<<" "<<y4<< endl;
    
    
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 100;
int N;
ll W;
ll w0;
vector<ll> w[4];
vector<ll> w_sum[4];

int main()
{
    cin >> N >> W;
    rep(i, N){
        ll w_;
        ll v;
        cin >> w_ >> v;
        if(i == 0){
            w0 = w_;
            w[0].pb(v);
        } else {
            w[w_-w0].pb(v);
        }
    }
    rep(i, 4){
        if(not w[i].empty()){
            sort(w[i].begin(), w[i].end(), greater<ll>());            
        }
    }
    for(int i = 0 ; i < 4; i++){
        w_sum[i].resize(w[i].size()+1);
    }
    rep(i, 4){
        w_sum[i][0] = 0;
    }
    rep(i, 4){
        rep1(j, static_cast<int>(w[i].size())){
            w_sum[i][j] = w_sum[i][j-1]+w[i][j-1];
        }
    }

    ll max_ = 0;
    rep(i, min(N+1, (int)w[0].size()+1)){
        const ll v0 = w_sum[0][i];
        rep(j, min(N+1-i, (int)w[1].size()+1)){
            const ll v1 = w_sum[1][j];
            rep(k, min(N+1-i-j, (int)w[2].size()+1)){
                const ll v2 = w_sum[2][k];
                rep(l, min(N+1-i-j-k, (int)w[3].size()+1)){
                    const ll v3 = w_sum[3][l];
                    if(w0*(i+j+k+l) + j + 2*k+3*l <= W){
                        chmax(max_, v0+v1+v2+v3);
                    }
                }
            }
        }
    }
    cout << max_ << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanLine() []float64 {
	var s []float64
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		i, _ := strconv.ParseFloat(v, 64)
		s = append(s, i)
	}
	return s
}

func main() {
	var n float64
	fmt.Scan(&n)
	s := scanLine()

	var denominator float64
	for _, v := range s {
		denominator += 1 / v
	}
	fmt.Println(1 / denominator)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<string> a(n);
	vector<int> t(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> t[i];
	}
	string x;
	cin >> x;
	bool ok = false;
	int answer = 0;
	for (int i = 0; i < n; ++i) {
		if (ok) {
			answer += t[i];
		}
		if (a[i] == x) {
			ok = true;
		}
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256