akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll n, x[105], y[105];
vector<pair<double, P> > ls, tmp;

int main() {
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i];
        ls.push_back({atan2(y[i],x[i]),{x[i],y[i]}});
    }
    double ans = 0.0;
    SORT(ls);
    for(int i=0;i<n;i++){
        ls.push_back(ls[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<=n;j++){
            ll xs = 0, ys = 0;
            for(int k=0;k<j;k++){
                xs += ls[i+k].second.first;
                ys += ls[i+k].second.second;
            }
            ans = max(ans, pow(pow(xs,2)+pow(ys,2), 0.5));
        }
    }
    printf("%.12lf\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int judge(int);
int main(){
  int n,a,i,j,count = 0,judge;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a);
    if(a == 2) judge = 0;
    else if(a % 2 == 0) judge = 1;
    else{
      judge = 0;
      for(j = 3;j <= sqrt(a);j += 2){
	if(a % j == 0){
	  judge = 1;
	  break;
      }
      }
    }
    if(judge == 0) 
      count++;
    
  }
    printf("%d\n",count);
    return 0;
}

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

using namespace std;

const int N = 1000000 + 10;

int f[N][2];
int num[N];

int main()
{
	int n, i;
	string s;
	cin>>s;
	n = s.size();
	for (i=0; i<n; i++) num[i+1] = s[i] - '0';
	f[0][0] = 0;
	f[0][1] = 1;
	for (i=1; i<=n; i++)
	{
		f[i][0] = min(f[i-1][0] + num[i], f[i-1][1] + 10 - num[i]);
		f[i][1] = min(f[i-1][0] + num[i] + 1, f[i-1][1] + 9 - num[i]);
	}
	cout<<f[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 13060
N, Y = map(int, input().split())

ans = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N + 1):
        z = N - x - y
        if z < 0:
            continue
            
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = [x, y, z]
            
print(*ans)

Measured memory_bytes: 3064
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

main :: IO ()
main = hinaArare

hinaArare :: IO ()
hinaArare = do
  n :: Int <- readLn
  ss <- T.getLine
  let ans = length $ nub $ T.unpack $ T.filter (/= ' ') ss
  putStrLn $ case ans of
    1 -> "One"
    2 -> "Two"
    3 -> "Three"
    _ -> "Four"

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

using namespace std;

string s;

int main() {
    int k;
    cin >> s >> k;
    for (int i = 0; i < s.size(); ++i) {
        int q = ('z' - s[i] + 1) % 26;
        if (k >= q) {
            s[i] = 'a';
            k -=q;
        }
    }
    k %= 26;
    if (k > 0) {
        s[s.size() - 1] += k;
        if (s[s.size() - 1] > 'z') {
            s[s.size() - 1] -= 'z';
        }
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
using namespace std;
#define Mod 998244353
#define N 200050
int n,i,f[2*N],c[N];
long long m;
struct matrix{
	int a[2][2];
	matrix operator * (const matrix &jb)const{
		matrix cll;memset(cll.a,0,sizeof(cll.a));
		for (int ii=0;ii<2;ii++)
		for (int jj=0;jj<2;jj++)
		for (int kk=0;kk<2;kk++) cll.a[ii][jj]=(cll.a[ii][jj]+1LL*a[ii][kk]*jb.a[kk][jj] % Mod) % Mod;
		return cll;
	}
};
int qmi(int di,int zhi)
{
	int ret=1,x=di;
	while (zhi){
		if (zhi & 1) ret=1LL*ret*x % Mod;x=1LL*x*x % Mod;zhi>>=1;
	}return ret;
}
int main()
{
	scanf("%d%lld",&n,&m);
	n--;matrix gh;gh.a[1][0]=gh.a[1][1]=gh.a[0][0]=0;gh.a[0][1]=1;
	long long zhi=2*n+m-1;matrix x;x.a[0][0]=0;x.a[0][1]=x.a[1][0]=x.a[1][1]=1;
	while (zhi){
		if (zhi & 1) gh=gh*x;x=x*x;zhi>>=1;
	}int ans=gh.a[0][1];f[1]=1;f[2]=1;
	for (i=3;i<=2*n;i++) f[i]=(f[i-1]+f[i-2]) % Mod;
	c[0]=1;for (i=1;i<=n;i++) c[i]=(1LL*c[i-1]*((m-1+i) % Mod) % Mod)*qmi(i,Mod-2) % Mod;
	for (i=1;i<=n;i++) ans=(ans-1LL*f[2*i]*c[n-i] % Mod) % Mod;
	printf("%d\n",(ans+Mod) % Mod);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 int main(){
  string s;
   cin >> s;
   int L = s.size();
   string ans = "AC";
   
   if(s[0] != 'A'){
     ans = "WA";
   }
   
   int cnt =0;
   for(int i=1;i<L;i++){
     if(isupper(s[i])){
       if(i == 1 || i == L-1 || s[i] != 'C'){
         ans = "WA";
       }
       cnt++;
     }
   }
   if(cnt != 1){
     ans = "WA";
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++){
    if (A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i +1];
  A[i +1] = A[r];
  A[r] = t;

  return i + 1;
}

int main(){
  int i,q;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    scanf("%d",&A[i]);

  q = partition(0,n - 1);

  for(i = 0;i < n;i++){
    if(i)
      printf(" ");
    if( i == q)
      printf("[");
    printf("%d",A[i]);
    if(i == q)
      printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2084
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        
        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];

        int ans = 0;

        for (int i = 0; i < 2; i++)
        {
            if(A < B)
            {
                ans = ans + B;
                B = B - 1;

            }
            else
            {
                ans = ans + A;
                A = A - 1;
                
            }
        }

            Console.WriteLine(ans);
    }
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        a: usize,
        b: usize
    }
    let ans = max((100 * a + 7) / 8, 10 * b);
    if ans * 8 / 100 == a && ans / 10 == b {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int m, d, cnt = 0;
    cin >> m >> d;
    for(int i=20;i<=d;i++){
        if(i%10 < 2) continue;
        if((i/10)*(i%10) <= m) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = [int(w) for w in input().split()]

node = [0] * (n+1)

for i in range(m):
    a, b = [int(w) for w in input().split()]
    node[a] ^= 1
    node[b] ^= 1

cond = all([w == 0 for w in node])
print("YES" if cond else "NO")


Measured memory_bytes: 10564
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	p := iSScan(n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 1; i <= n; i++ {
		a[i-1] = i * n
		b[n-i] = i * n
	}
	for i := 0; i < n; i++ {
		b[p[i]-1] += i
	}
	fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	fmt.Println(strings.Trim(fmt.Sprint(b), "[]"))
}


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

using namespace std;
const int MAX_INT=1000000010;
int A[500100];
int cnt=0;

void merge(int A[],int l,int m,int r)
{
    int n1=m-l;
    int n2=r-m;
    int L[n1+1];
    int R[n2+1];

    for(int i=0;i<n1;++i)
    {
        L[i]=A[l+i];
    }
    for(int j=0;j<n2;++j)
    {
        R[j] =A[m +j];
    }

    L[n1]=MAX_INT;
    R[n2]=MAX_INT;
    int i=0;
    int j=0;

    for(int k=l;k<r;++k)
    {
        if(L[i]<=R[j])
        {
            A[k] = L[i];
            ++i;
        }
        else
        {
            A[k]=R[j];
            j++;
        }
        cnt++;
    }
}
void mergeSort(int A[],int l,int r)
{
    if(l+1<r)
    {
        int mid = (l+r)/2;
        mergeSort(A,l,mid);
        mergeSort(A,mid,r);
        merge(A,l,mid,r);
    }
}
int main()
{
    int n;cin >>n;
    for(int i=0;i<n;++i)
    {
        cin >> A[i];
    }
    mergeSort(A,0,n);
    for(int i=0;i<n;++i)
    {
        if(i==0) cout << A[i];
        else
        {
            cout << " " << A[i];
        }
        
    }
    cout << endl;
    cout << cnt << endl;

}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

struct edge { int to, cost; };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

ll dp[110][100010];

int main()
{
	int N,W;
	cin >> N >> W;
	vi w(N),v(N);
	rep(i,N) cin >> w[i] >> v[i];
	rep(i,110) rep(j,100010) dp[i][j] = 1e18;
	dp[0][0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 100010; j++){
			if(dp[i][j] == INF && dp[i][j]+w[i] > W) continue;
			dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		}
	}
	int ans = 0;
	for(int j = 0; j < 100010; j++){
		if(dp[N][j] != 0 && dp[N][j] <= W) ans = j;
	}
	cout << ans << endl;
	return 0;	
}

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

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 (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// メモリ確保テスト
int dp[10000][10000];

char to_lower(char c){
    ll diff = 'A' - 'a';
    return c - diff;
}

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

    // input
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;

    s[K-1] = to_lower(s[K-1]);
    p(s);
        
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		while (a >= b) {
			b *= 2;
			k--;
		}
		while (b >= c) {
			c *= 2;
			k--;
		}
		
		String ans = k >= 0 ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}
	
}



Measured memory_bytes: 27068
import sys
import copy



S = input()
op_list = ["+"]*(len(S)-1)

sum = 0
for i in range(2**len(op_list)):
    op_list = ["+"]*(len(S)-1)
    for j in range(len(op_list)):

        if (i >> j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(op_list)):
        s = s + S[k] + op_list[k]
    s = s + S[len(S)-1]
    sum = sum + eval(s)


print(sum)
    




Measured memory_bytes: 3444
/*
* @Author: _dp95
* @Date:   2020-04-06 08:48:18
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 2*1000*10 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int n, k, dp[MAX][101][2] ;

int sol( string &s, int ind, int mod, bool flag ){
  if( ind == n )
    return !mod ;
  int &ans = dp[ind][mod][flag] ;
  if( ans != -1 )
    return ans ;
  ans = 0 ;
  int d = flag?9:(s[ind]-'0');
  for( int i = d ; i >= 0 ; i-- ){
    ans += sol( s, ind+1, (mod+i)%k, flag|(i<d) ) ;
    if( ans >= MOD )
      ans -= MOD ;
  }
  return ans ;
}

signed main( ){
  timesaver ;
  string s ;
  cin >> s >> k ;
  n = sz(s) ;
  mem( dp, -1 ) ;
  string a(n, '0');
  int r = sol( s, 0, 0, 0 ) ;
  mem( dp, -1 ) ;
  int l = sol( a, 0, 0, 0 ) ;
  cout << ( r - l + MOD )%MOD << nl ;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans += s[i] != t[i];
    }
    cout << ans;
}

Measured memory_bytes: 3780
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):*a,c=I();R+=[(a,c)];Y+=c,;X+=a
for i in r(m):a,*b=I();H+=[(a,b)];X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)+1
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*-~K for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

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

bool same(string s, string t) {
	bool ok = true;
	int N = s.size();
	for (int i = 0; i < N; i++) {
		if (s[i] != '?' && t[i] != '?' && s[i] != t[i]) {
			ok = false;
		}
	}
	return ok;
}

int main()
{
	string S, T;
	cin >> S >> T;
	int sl = S.size(), tl = T.size();
	bool ng = true;
	for (int i = sl - tl; i >= 0; i--) {
		if (same(S.substr(i, tl), T)) {
			ng = false;
			for (int j = 0; j < tl; j++) {
				S[i + j] = T[j];
			}
			for (int j = 0; j < sl; j++) {
				if (S[j] == '?') {
					S[j] = 'a';
				}
			}
		}
	}
	if (ng) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << S << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(void){
	int lop2,fg=0;
	string s;
	char moji[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

	cin>>s;

	for(int lop=0;lop<26;lop++){
		lop2=0;
		while(s[lop2]!='\0'){
			if(s[lop2]==moji[lop]){
				fg=1;
				break;
			}
			lop2++;
		}
		if(fg==0){
			cout<<moji[lop]<<endl;
			return 0;
		}else{
			fg=0;
		}
	}

	cout<<"None"<<endl;


	return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

void DFS();
void ReVisit(int);
void print();

int Adj[100][100];
int d[100];
int f[100];
int n, i, j, count;

int main() {
  int u, v, k;

  scanf("%d",&n);

  for( i=0 ; i<n ; i++ ) {
    d[i] = 0;
    f[i] = 0;
    for( j=0 ; j<n ; j++ ) {
      Adj[i][j] = 0;
    }
  }
  
  for( i=0 ; i<n ; i++ ) {
    scanf("%d%d",&u,&k);
    for( j=0 ; j<k ; j++ ) {
      scanf("%d",&v);
      Adj[i][v-1] = 1;
    }
  }

  DFS();
  print();

  return 0;
}
void DFS() {
  count = 1;
 
  for( i=0 ; i<n ; i++ ) {
      if(d[i] == 0)
    ReVisit(i);
    }
}
 
void ReVisit(int u) {
  int l;
  d[u] = count++;
  for( l=0 ; l<n ; l++ ) {
    if(Adj[u][l] == 1 && d[l] == 0) ReVisit(l);
  }
  f[u] = count++;
}

void print() {
  for( i=0 ; i<n ;i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

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

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

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    string s;
    int q;
    cin >> s >> q;
    string left = "";
    string right= "";
    int flag = 0;
    rep(_,q){
        int t;
        cin >> t;
        if(t==1){
            flag = abs(flag-1);
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(flag==0){
                if(f==1){
                    left = c + left; 
                }
                else{
                    right += c;
                }
            }
            else{
                if(f==1){
                    right += c;
                }
                else{
                    left = c+ left;
                }
            }
        }
    }
    if(flag == 0){
        cout << left << s << right << endl;
    }
    else{
        reverse(right.begin(),right.end());
        reverse(left.begin(),left.end());
        reverse(s.begin(),s.end());
        cout << right << s << left << endl;
    }
}

Measured memory_bytes: 1104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
typedef unsigned long long ull;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int a[n+1]={0},b[n+1]={0},c[n+1]={0};
	rep(n)
	{
		scanf("%d",a+i);
	}
	rep(n)
	{
		scanf("%d",b+i);
	}
	rep(n)
	{
		scanf("%d",c+i);
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	a[n]=1e9+1;
	c[n]=1e9+1;
	ll ans=0;
	int i,j,k;
	for(i=0,j=0,k=0;j<n;j++)
	{
		while(a[i++]<b[j]);
		i--;
		while(c[k++]<=b[j]);
		k--;
		ans+=1LL*(i)*(n-k);
//		cout<<i<<' '<<j<<' '<<n-k<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N, M;cin >> N >> M;
  int A;
  for (int i=0; i<M; i++) {
    cin >> A;
    N -= A;
  }
  int ans = N;
  if (N < 0) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N],B[N];
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  vector<P> Q;
  for (int i = 0; i < N; i++) {
    Q.push_back(make_pair(A[i]+B[i],i));
  }
  sort(Q.begin(),Q.end());
  reverse(Q.begin(),Q.end());
  ll Asum = 0;
  ll Bsum = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Asum += A[Q[i].second];
    } else {
      Bsum += B[Q[i].second];
    }
  }
  cout << Asum - Bsum << endl;
  return 0;
}

Measured memory_bytes: 6864
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int W, H;

int a[12][12];
int sy, sx;
int nei_count = 0;
int house_count = 0;

int dfs(int y, int x, int zan)
{
	if (zan == 0) {
		return y == sy || x == sx;
	}

	int res = 0;

	for (int nowy = y - 1; nowy >= 1; --nowy) {
		if (a[nowy][x] == 1) {
			a[nowy][x] = -1;

			res += dfs(nowy, x, zan - 1);

			a[nowy][x] = 1;
			break;
		}
	}

	for (int nowy = y + 1; nowy <= H; ++nowy) {
		if (a[nowy][x] == 1) {
			a[nowy][x] = -1;

			res += dfs(nowy, x, zan - 1);

			a[nowy][x] = 1;
			break;
		}
	}

	for (int nowx = x - 1; nowx >= 1; --nowx) {
		if (a[y][nowx] == 1) {
			a[y][nowx] = -1;

			res += dfs(y, nowx, zan - 1);

			a[y][nowx] = 1;
			break;
		}
	}

	for (int nowx = x + 1; nowx <= W; ++nowx) {
		if (a[y][nowx] == 1) {
			a[y][nowx] = -1;

			res += dfs(y, nowx, zan - 1);

			a[y][nowx] = 1;
			break;
		}
	}

	return res;
}

signed main()
{
	while (cin >> W >> H, W) {
		house_count = 0;

		rep1(i, H) rep1(j, W) {
			cin >> a[i][j];
			if (a[i][j] == 1) {
				house_count += 1;
			}
			else if (a[i][j] == 2) {
				sy = i, sx = j;
			}
		}

		cout << dfs(sy, sx, house_count) << endl;
	}
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);swap(a,c);
	cout<<a<<" "<<b<<" "<<c; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






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

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

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

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

	int n,k,t;
	int idx = -1;
	int Min = 1e9;

	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		if(Min>t)
		{
			Min = t;
			idx = i; 
		}
	}

	int res = 0;
	int temp = idx;

	while(1)
	{
		if(temp+1>=n)
		{
			break;
		}
		temp += (k-1);
		res++;
	}

	temp = idx;
	while(1)
	{
		if(temp-1<0)
		{
			break;
		}
		temp -= (k-1);
		res++;
	}

	if(idx<k)
	{
		int cnt = 1;
		int temp = k-1;
		while(1)
		{
			if(temp+1>=n)
			{
				break;
			}
			temp += (k-1);
			cnt++;
		}

		res = min(res,cnt);
	}

	if(idx>=n-k)
	{
		int cnt = 1;
		int temp = n-k;
		while(1)
		{
			if(temp-1<0)
			{
				break;
			}
			temp -= (k-1);
			cnt++;
		}

		res = min(res,cnt);
	}

	int l = idx - (k-1)/2;
	int r = idx + (k-1)/2;
	int cnt = 1;

	while(1)
	{
		if(l-1<0)
		{
			break;
		}
		l -= (k-1);
		cnt++;
	}

	while(1)
	{
		if(r+1>=n)
		{
			break;
		}
		r += (k-1);
		cnt++;
	}

	res = min(res,cnt);

	cout << res << '\n';

	return 0;	
}

Measured memory_bytes: 256
sf=""
sb=input()
q=int(input())

rev=1

for _ in range(0,q):
  n=input().split()
  if n[0]=="1":
    rev*=-1
  else:
    a,b=n[1],n[2]
    if (a=="1" and rev==1) or (a=="2" and rev==-1):
      sf+=b
    else:
      sb+=b

s=sf[::-1]+sb

if rev==1:
  print(s)
else:
  print(s[::-1])


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

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

int main(void) {
    char a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    REP(i, max(a - '0', b - '0')) {
        cout << min(a - '0', b - '0');
    }

    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc162/tasks/abc162_d

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();
void solve2();

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  map<char, VL> total;
  total['R'] = VL(N + 1);
  total['G'] = VL(N + 1);
  total['B'] = VL(N + 1);

  rep(i, N) {
    total['R'][i + 1] = total['R'][i] + (S[i] == 'R');
    total['G'][i + 1] = total['G'][i] + (S[i] == 'G');
    total['B'][i + 1] = total['B'][i] + (S[i] == 'B');
  }

  auto get_other = [](char a, char b) {
    string cur = "";
    cur.push_back(a);
    cur.push_back(b);
    sort(all(cur));

    if (cur == "BG") return 'R';
    if (cur == "BR") return 'G';
    if (cur == "GR") return 'B';
  };

  ll res = 0;

  rep(k, N) rep(j, k) {
    if (S[j] == S[k]) continue;

    ll ct = 0;
    ct += total[get_other(S[j], S[k])][j];

    ll i_index = j - (k - j);
    if (0 <= i_index && get_other(S[j], S[k]) == S[i_index]) ct--;

    res += ct;
  }

  cout << res << "\n";
}

void solve2() {
  ll N;
  string S;
  cin >> N >> S;

  map<char, ll> total;

  rep(i, N) total[S[i]]++;

  auto get_other = [](char a, char b) {
    string cur = "";
    cur.push_back(a);
    cur.push_back(b);
    sort(all(cur));

    if (cur == "BG") return 'R';
    if (cur == "BR") return 'G';
    if (cur == "GR") return 'B';
  };

  ll res = total['R'] * total['G'] * total['B'];

  rep(k, N) rep(j, k) {
    if (S[j] == S[k]) continue;

    ll i_index = j - (k - j);
    if (0 <= i_index && get_other(S[j], S[k]) == S[i_index]) res--;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#define N 100010
using namespace std;
vector<int> V[N];
int n;
int dis_from_1[N];
int dis_from_n[N];
void DFS(int start,int pre,bool mode)
{
    if(mode)
    {
        dis_from_1[start]=dis_from_1[pre]+1;
    }
    else
    {
        dis_from_n[start]=dis_from_n[pre]+1;
    }
    for(int i=0;i<V[start].size();i++)
    {
        int next=V[start][i];
        if(next!=pre)
        {
            DFS(next,start,mode);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        for(int i=1;i<=n;i++) V[i].clear();
        int a,b;
        for(int i=1;i<=n-1;i++)
        {
            cin>>a>>b;
            V[a].push_back(b);
            V[b].push_back(a);
        }
        dis_from_1[0]=-1;
        DFS(1,0,true);
        dis_from_n[0]=-1;
        DFS(n,0,false);
        int F_point=0;
        int S_point=0;
        for(int i=1;i<=n;i++)
        {
            if(dis_from_1[i]<=dis_from_n[i]) F_point++;
            else S_point++;
        }
        //cout<<"F:"<<F_point<<"  S:"<<S_point<<endl;
        if(F_point>S_point) cout<<"Fennec"<<endl;
        else cout<<"Snuke"<<endl;
    }
}

Measured memory_bytes: 12800
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]

#最も近いチェックポイントを返す
def CheckPoint(x,y):
    ans = 1
    before = abs(cd[0][0]-x) + abs(cd[0][1]-y)
    for i in range(m):
        if abs(cd[i][0]-x) + abs(cd[i][1]-y) < before:
            before = abs(cd[i][0]-x) + abs(cd[i][1]-y)
            ans = i+1
    return ans

for xy in ab:
    print(CheckPoint(xy[0],xy[1]))

Measured memory_bytes: 3064
n = int(input())
c1, c2, c3, c4 = 0, 0, 0, 0
for _ in range(n):
    s = input()
    if s == 'AC':
        c1 += 1
    elif s == 'WA':
        c2 += 1
    elif s == 'TLE':
        c3 += 1
    elif s == 'RE':
        c4 += 1
print('AC x', c1)
print('WA x', c2)
print('TLE x', c3)
print('RE x', c4)


Measured memory_bytes: 9164
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  ul n;
  cin>>n;
  int a[20];
  for (size_t i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  ul q,maxn=1<<n,cq;
  cin >> q;
  string ans;
  for (size_t i = 0; i < q; i++)
  {
    cin>>cq;
    ans = "no";
    for (size_t j = 1; j <= maxn; j++)
    {
      ul cj=0;
      for (size_t k = 0; k < n; k++)
      {
        cj+=(j>>k&1)*a[k];
      }
      if (cj==cq) {ans="yes";break;}
    }
    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3172
import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int dist = Math.abs(b - a) % 2;
        out.println(dist == 1 ? "Borys" : "Alice");
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

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

Measured memory_bytes: 22996
#include<stdio.h>
int main(){
	long long dp[102][22]={0};
	int a[101],n,k,i,j,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	dp[1][a[1]]=1;
	for(i=1;i<n;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(j-a[i+1]>=0)dp[i+1][j-a[i+1]]+=dp[i][j];
				if(j+a[i+1]<=20)dp[i+1][j+a[i+1]]+=dp[i][j];
			}
		}
	}
	printf("%lld\n",dp[n-1][a[n]]);
	return 0;
}


Measured memory_bytes: 2140
N = int(input())
A = {}
for i in range(N):
    tmp = input()
    if tmp not in A:
        A[tmp] = 1
    else:
        A[tmp] +=1
M = int(input())
B = {}
for j in range(M):
    tmp = input()
    if tmp not in B:
        B[tmp] = 1
    else:
        B[tmp] +=1
maxV = 0
for k,v in A.items():
    if k in B:
        maxV = max(maxV,v-B[k])
    else:
        maxV = max(maxV,v)
print(maxV)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define COUT(a) cout << (a);
#define ENDL cout << "\n";
int MOD = 1e9+7;
int prime[1001];
int ooo[1001]={0};

void sieve() {
    prime[0]=prime[1]=1;
    for(int i=2;i<1001;i++) {
        for(int j=2;j<=i;j++) {
            if(i%j==0) {
                prime[i] = j;
                break;
            }
        }
    }
}

void solve(int a) {
    int tmp,c;
    while(a>1) {
        tmp = prime[a];
        c=0;
        while(a%tmp==0) {
            a/=tmp;
            ++c;
        }
        ooo[tmp] += c;
    }
}

int main(int argc, char *argv[]) {
    sieve();
    int n,count=0;
    long long ans=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) solve(i);
    for(int i=1;i<=n;i++) {
        if(ooo[i]) ans = ans*(long long)(ooo[i]+1) % (long long)MOD;
    }
    COUT(ans)
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

#define sqr(x) ((x) * (x))

#define ll long long int
#define MOD 1000000007
#define MN 200005
#define foru(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)


using namespace std;
void checkDefine();

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



void checkDefine(){
	ll n, a[MN];
	map<ll, ll> m;
	cin >> n;
	FOR(i, 0, n - 1) {
		cin >> a[i];
		m[a[i]]++;
	}

	string s; cin >> s;
	DEBUG(s);
	PR0(a, n);
	DEBUG("------------");
	EACH(it, m){
		cout << it->first << " " << it->second << endl;
	}
	//if(s.find("abc") != npos) // found
}
	




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,k,x,f,a[10]={0};
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		scanf("%d",&x);
		a[x]=1;
	}
	for(int i=n;;i++)
	{
		f=0;
		for(int j=i;j;j/=10)
		{
			x=j%10;
			if(a[x])
			{
				f=1;
				break;
			}
		}
		if(!f)
		{
			printf("%d\n",i);
			break;
		}
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
#define ll long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007


#define MAX_V 10; 
int N = 10; // N = 10(const.)
ll G[10][10]; ll A[210][210];
ll d[10];
bool used[10];
ll mt0[10];
void dijkstra(int s) {
	for (int i = 0; i < 10; i++) {
		d[i] = INF;
		used[i] = false;
	}
	d[s] = 0;

	while (true) {
		int v = -1;
		for (int i = 0; i < N; i++) {
			if (!(used[i]) && (v == -1 || d[v] > d[i])) v = i;
		}
		if (v == -1) break;
		used[v] = true;

		for (int i = 0; i < N; i++) {
			d[i] = min(d[i], d[v] + G[v][i]);
		}
	}
}
int main(void) {
	long long H; cin >> H;
	long long W; cin >> W;

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

	for (int i = 0; i < N; i++) {
		dijkstra(i);
		mt0[i] = d[1];
	}

	ll ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] != -1) {
				ans += mt0[A[i][j]];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
"use strict"
function main(arg) {
    var p = arg.trim().split("\n")[0].split(" ").map(Number)
    if (p[0] <= p[1]) {
        console.log('unsafe')
    } else {
        console.log('safe')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,K;
  cin >> N >> K;
  int R,S,P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  vector<char> W[K];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (T[i] == 'r') ans += P;
    if (T[i] == 's') ans += R;
    if (T[i] == 'p') ans += S;
    W[i % K].push_back(T[i]);
  }
  int streak = 1;
  for (int i = 0; i < K; i++) {
    streak = 1;
    for (int j = 1; j < W[i].size(); j++) {
      if (W[i][j - 1] == W[i][j]) {
        streak++;
      } else if (W[i][j - 1] == 'r') {
        ans -= P * (streak / 2);
        streak = 1;
      } else if (W[i][j - 1] == 's') {
        ans -= R * (streak / 2);
        streak = 1;
      } else {
        ans -= S * (streak / 2);
        streak = 1;
      }
    }
    if (W[i][W[i].size() - 1] == 'r') {
      ans -= P * (streak / 2);
    }
    if (W[i][W[i].size() - 1] == 's') {
      ans -= R * (streak / 2);
    }
    if (W[i][W[i].size() - 1] == 'p') {
      ans -= S * (streak / 2);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,s;
	scanf("%d %d %d",&n,&k,&s);
	int inf = 1e9;
	if (s == inf) inf--;
	for (int i = 1; i <= k; i++) printf("%d%s" , s , i == n ? "\n" : " ");
	for (int i = k + 1; i <= n; i++) printf("%d%s" , inf , i == n ? "\n" : " ");
} 


Measured memory_bytes: 3792
#include<iostream>

using namespace std;

int mnLine[100000];


int main(){

	mnLine[0]=6;
	mnLine[1]=8;

	int cnt=2;

	for(int i=9;i<=300000;i++){
		if(i%7==1||i%7==6){
			int flag=0;
			for(int j=0;mnLine[j]*mnLine[j]<=i;j++){
				if(i%mnLine[j]==0){
					flag=1;
					break;
				}
			}
			if(flag==0){
				mnLine[cnt]=i;
				cnt++;
			}
		}
	//	cout<<"i="<<i<<endl;
	}

//	cout<<"unko"<<endl;
	int num;
	while(cin>>num){
		if(num==1)break;
		cout<<num<<":";
		for(int i=0;i<cnt;i++){
			if(num%mnLine[i]==0){
				cout<<" "<<mnLine[i];
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define int long long
#define ALL(c) begin(c),end(c)
using namespace std;
const int INF=1e9;
signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> cnt(n,vector<int>(3,0));
    for(int i=0; i<n; i++) {
        string s;
        cin>>s;
        for(int j=0; j<m; j++) {
            if(s[j]=='W') cnt[i][0]++;
            if(s[j]=='B') cnt[i][1]++;
            if(s[j]=='R') cnt[i][2]++;
        }
    }



    int ans=INF;
    for(int a=0; a<n-2; a++) {
        for(int b=1; b<n-1; b++) {
            int sum=0;
            for(int i=0; i<n; i++) {
                if(i<=a) {
                    sum+=cnt[i][1]+cnt[i][2];
                }
                else if(i<=b) {
                    sum+=cnt[i][0]+cnt[i][2];
                }
                else {
                    sum+=cnt[i][0]+cnt[i][1];
                }
            }
            if(ans>sum) {
                ans=sum;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(ll i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll n;
    cin>>n;

    vector<ll> cnt;
    ll m=n;
    for(ll i=2;i*i<=m && n>1;i++){
        if(n%i==0){
            ll tmp=0;
            while(n%i==0){
                tmp++;
                n/=i;
            }
            cnt.push_back(tmp);
        }
    }
    ll ans=0;
    if(n>1) ans++;
    n=cnt.size();
    
    rep(i,n){
        ll k=0;
        while(((k+1)*(k+2))/2 <= cnt[i]){
            k++;
        }
        ans+=k;
    }

    cout<<ans<<endl;
    

    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
#define MAX 105
vector<int> V[MAX];

int d[MAX];

void search(int v, int t) {
	if (d[v] == -1 || d[v] > t) d[v] = t;
	else return;

	for (int i = 0; i < V[v].size(); i++) {
		search(V[v][i], t + 1);
	}
}

int main() {


	int n;
	cin >> n;
	for (int i = 1; i < n + 1; i++) {
		d[i] = -1;

		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int s;
			cin >> s;
			V[u].push_back(s);
		}
	}

	search(1, 0);

	for (int i = 1; i < n + 1; i++) {
		cout << i << ' ' << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3160
N,Q = map(int, input().split())
S = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l,r])

A = [0]*N

for i in range(N-2+1):
    if S[i]=="A" and S[i+1]=="C":
        A[i] = 1
s = [0]*(N+1)
for i in range(0,N,1):
    s[i+1] = A[i] + s[i]

for i in range(Q):
    l,r = Query[i]
    print(s[r-1]-s[l-1])



Measured memory_bytes: 25356
#include <iostream>
using namespace std;
int main()
{
	int n;
	int i;
	int a=100000;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		a = a*1.05;
		if (a % 1000 != 0)
		{
			a = a + 1000 - a % 1000;
		}
	}

	cout << a << endl;
}


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

int main(){
  string s;
  cin >> s;
  
  int count = 0;
  
  if(s[0] == '1') count++;
  if(s[1] == '1') count++;
  if(s[2] == '1') count++;
  
  cout << count << endl;
}

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

if (B - A + 1 <= K):
    for i in range(A, B + 1):
        print(i)
    exit()
else:
    L = []
    for i in range(K):
        L.append(A + i)

    for j in range(K - 1, -1, -1):
        L.append(B - j)

    for i in sorted(list(set(L))):
        print(i)


Measured memory_bytes: 3060