akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 10;
const int NBITS = 1 << MAX_N;
const int MAX_M = 10;

/* typedef */

/* global variables */

int bps[NBITS], msks[NBITS], ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int nbits = 1 << n;

  bps[0] = 0;
  for (int bits = 1, msb = 1; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bps[bits] = bps[bits ^ msb] ^ 1;
  }
  
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    msks[i] = 0;
    for (int j = 0; j < k; j++) {
      int s;
      scanf("%d", &s);
      msks[i] |= (1 << (s - 1));
    }
  }

  for (int i = 0; i < m; i++) scanf("%d", ps + i);

  int cnt = 0;
  for (int bits = 0; bits < nbits; bits++) {
    bool ok = true;
    for (int i = 0; ok && i < m; i++)
      ok = (bps[bits & msks[i]] == ps[i]);
    if (ok) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int count = 1;
  
  if (N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  while (N/K >= 1){
    N = N/K ;
    count++;
  }
  cout << count << endl;
}

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

using namespace std;

struct Day{
    int a, b, c;
};

int main() {
    int n;
    cin >> n;
    vector<Day> v(n);
    vector<vector<int> > dp(n, vector<int>(3, 0));
    for(int i = 0; i < n; i++) {
        cin >> v[i].a;
        cin >> v[i].b;
        cin >> v[i].c;
    }
    dp[0][0] = v[0].a;
    dp[0][1] = v[0].b;
    dp[0][2] = v[0].c;
    for(int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + v[i].a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + v[i].b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + v[i].c;
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 6912
a,b=map(int,input().split())
A=[]
for i in range(1,1000):
    A.append((i*(i+1))//2)

for j in range(5*(10**6)):
    if ((a+j) in A) and ((b+j) in A):
        if A.index(a+j)+1==A.index(b+j):
            print(j)
            exit()

Measured memory_bytes: 38512
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, a[100009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	vector<int> z;
	int p = 0;
	for (int i = 1; i <= n; i++) {
		if (i == n || a[i - 1] == a[i]) {
			z.push_back(i - p);
			p = i;
		}
	}
	int ret = (z.size() <= 3 ? n : 0);
	for (int i = 3; i <= z.size(); i++) {
		ret = max(ret, z[i - 3] + z[i - 2] + z[i - 1]);
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 3180
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        Input input = InputParser.perse(sn, 2);
        sn.close();

        Integer n = input.getInt(1, 1);
        List<Integer> p = input.getIntLine(2);

        int min = p.get(0);
        int count = 1;
        for (int i = 1; i < p.size(); i++) {
            if (p.get(i) <= min) {
                count++;
                min = p.get(i);
            }
        }

        System.out.println(count);
    }

    private static class InputParser {
        static Input perse(Scanner sn, int line) {
            Input result = new Input();
            while (line-- > 0) {
                String[] args = sn.nextLine().split(" ");
                result.addAll(args);
            }
            return result;
        }
    }

    private static class Input {
        private Map<Integer, Map<Integer, String>> inputs;
        private int now = 1;
        private int innerNext = 1;

        Input() {
            inputs = new LinkedHashMap<>();
            inputs.put(now, new LinkedHashMap<>());
        }

        void addAll(String[] args) {
            for (String str : args) {
                add(str);
            }
            next();
        }

        void add(String str) {
            inputs.get(now).put(innerNext++, str);
        }

        void next() {
            inputs.put(++now, new LinkedHashMap<>());
            innerNext = 1;
        }

        String getString(int i, int j) {
            return inputs.get(i).get(j);
        }

        int getInt(int i, int j) {
            return Integer.parseInt(getString(i, j));
        }

        double getDouble(int i, int j) {
            return Double.parseDouble(getString(i, j));
        }

        List<Integer> getIntLine(int i) {
            return inputs.get(i).entrySet().stream().map(e -> Integer.parseInt(e.getValue()))
                    .collect(Collectors.toList());
        }

        List<Integer> getIntVerticalLine(int line, int start, int size) {
            List<Integer> list = new ArrayList<>();
            for(int i = start; i < start + size; i++) {
                list.add(getInt(i, line));
            }
            return list;
        }
    }
}


Measured memory_bytes: 69552
def selectionSort():
    l = int(input())
    A = list(map(int, input().split(" ")))
    count = 0
    for i in range(l-1):
        mini = i
        for j in range(i, l-1):
            if (A[mini]>A[j+1]):
                mini = j+1
        if (i != mini):
            temp = A[mini]
            A[mini] = A[i]
            A[i] = temp
            count += 1
    print(" ".join(map(str, A)))
    print(count)
selectionSort()

Measured memory_bytes: 7704
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
int n,score[101],a[101][3];


bool ch(){

  int t[101]={},x[101];
  r(i,3){
    int cnt=0,pre,c2=0;
    memset(x,0,sizeof(x));
    
    vector<P> v;
    
    r(j,n)v.push_back(P(a[j][i],j));
    
    sort(v.begin(),v.end(), greater<P>() );
    
    r(k,n){
      if(!k){
	t[v[k].se]+=score[cnt];
	pre=v[k].fi;
      }
      else{
	if(pre==v[k].fi){
	  c2++;
	  t[v[k].se]+=score[cnt];
	}
	else{
	  pre=v[k].fi;
	  cnt+=c2+1;c2=0;
	  t[v[k].se]+=score[cnt];
	}
      }
    }
    
   }

  vector<P> v;
    
  r(j,n)v.push_back(P(t[j],j));
    
  sort(v.begin(),v.end(), greater<P>() );
  int cnt=0,c2=0,pre;
  r(i,n){
    if(!i){

      if(!v[i].se&&cnt<=7)return 1;
      
      pre=v[i].fi;
    }
    else{
      if(pre==v[i].fi){
        if(!v[i].se&&cnt<=7)return 1;
        pre=v[i].fi;
        c2++;
      }
       else{
        cnt+=c2+1;c2=0;
        if(!v[i].se&&cnt<=7)return 1;
        pre=v[i].fi;
      }
    }
  }
  return 0;
}




int main(){
  cin>>n;
  r(i,n)cin>>score[i];
  r(i,n)r(j,3)cin>>a[i][j];
  r(i,1000)r(j,3){
    a[0][j]+=i;
    if(ch()){
      cout<<i<<endl;
      return 0;
    }
    a[0][j]-=i;
  }
  cout<<"Saiko"<<endl;
}

Measured memory_bytes: 3104
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        String ans ="A";
        if(Math.abs(x - a) > Math.abs(x - b)) ans = "B";
        System.out.println(ans);
        }
}

Measured memory_bytes: 21204
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int c=0;
		int d=0;
		boolean[] f=new boolean[n];
		int x[]=new int[n];
		for(int i=0;i<n;i++)
			x[i]=0;
		for(int i=0;i<m;i++) {
			int p=sc.nextInt();
			String s=sc.next();
			if(!(f[p-1])&&s.equals("AC")) {
				f[p-1]=true;
				c++;
				d+=x[p-1];
			}
			if(!(f[p-1])&&s.equals("WA")) {
				x[p-1]++;
			}
		}
		System.out.println(c+" "+d);


	}

}


Measured memory_bytes: 64512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	string s, t;
	cin >> s >> t;
	int k = s.size();
	bool can = true;
	map<char, char>ma, ima;
	for (int i = 0; i < k; ++i) {
		char S = s[i], T = t[i];
		if (ma.count(S)) {
			if (ma[S] != T) {
				can = false;
			}
		}
		if (ima.count(T)) {
			if (ima[T] != S) {
				can = false;
			}
		}
		ma[S] = T; ima[T] = S;
	}
	if (can)cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
    	String S = sc.next();
    	String[] str = S.split("/");
    	
    	if( Integer.parseInt(str[0]) > 2019 ) {
    		System.out.println( "TBD" );
    	}
    	else if( Integer.parseInt(str[1]) >= 5 ) {
    		System.out.println( "TBD" );
    	}
    	else {
    		System.out.println( "Heisei" );
    	}
    	sc.close();
    }
}

Measured memory_bytes: 21844
# contest = 'agc013'
# problem = 'a'
# testcase = 3

# import sys
# import os
# current_path = os.getcwd().split('/')
# path = '/workspaces/atcoder_docker_sample/tmp/{}_{}/sample-{}.in'.format(
#     contest,problem,testcase
# )
# f = open(path, 'r')
# sys.stdin = f

n = int(input())
a = list(map(int,input().split()))

if(n<3):
    print(1)
    exit()

ans = 1
state = 0
now = a[0]
for ai in a[1:]:
    if(state==0):
        if(now == ai):
            state = 0
        elif(now > ai):
            state = -1
        else:
            state = 1
    elif(state==1):
        if(now > ai):
            state = 0
            ans += 1
    else:
        if(now < ai):
            state = 0
            ans += 1
    now = ai

print(ans)

Measured memory_bytes: 19996
#include <iostream>
using namespace std;
int main(){
	int x;
	int y;
	y = 1;
	while(true){
		cin >> x ;
		
		if( x == 0){ break;};
		cout <<"Case "<< y <<": " << x <<endl ;
		y=y+1 ;
	};
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

bool check(int num){
  repb(i, 2, int(sqrt(num))+1){
  	if(num%i==0)return false;
  }
  return true;
}

int main(){
  int x;cin>>x;
  do{
  	if(check(x)){cout<<x<<endl;break;}
  }while(x++);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	double n;
	cin >> n;
	double ans = 2 * n * M_PI;
	printf("%f\n", ans);
	return 0;
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#ifdef ONLINE_JUDGE
#define enter '\n'
#else
#define enter std::endl
#endif
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 26, mod = 1e9 + 7;
 int t[ N ], a[ N ];
 char c[ N * N ];
 void Fakemain( )
 {
  int n = rdi( );
  std::memset( t, 63, sizeof t );
  For( i, 1, n )
  {
   scanf( "%s", c );
   int len = strlen( c );
   For( i, 0, len - 1 )
    a[ c[ i ] - 'a' ]++;
   For( i, 0, 25 )
    t[ i ] = std::min( t[ i ], a[ i ] );
   std::memset( a, 0, sizeof a );
  }
  For( i, 0, 25 ) For( j, 1, t[ i ] )
   pc( 'a' + i );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define f first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010


int main(){
	IOS;
	ll n;cin>>n;
	string s;cin>>s;
	ll cnt=0;
	rep(i,0,n){
		if(i+2<n){
			if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
				cnt++;
		}
	}
	cout<<cnt;
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        X, t = map(lambda x: int(x), line.rstrip("\n").split(" ", 2))
        if X - t < 0:
            print(0)
        else:
            print(X - t)

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        UnionFind uf(2 * n);
        while (m--) {
            int u, v; cin >> u >> v; u--, v--;
            uf.unionSet(u, v + n);
            uf.unionSet(u + n, v);
        }
        map<int, int> cnt;
        for (int i = 0; i < n; i++) cnt[uf.root(i)]++;
        if (cnt.size() == 2) {
            set<int> res;
            for (auto p: cnt) if (p.second % 2 == 0) {
                res.emplace(p.second / 2);
            }
            cout << res.size() << endl;
            for (int x: res) cout << x << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

int n;
set<char> s;

void read() {
  scanf("%d", &n);
  forn(i, n) {
    char c;
    scanf(" %c", &c);
    s.insert(c);
  }
}

void solve() {
  if (s.size() == 3) {
    printf("Three\n");
  } else {
    printf("Four\n");
  }
}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    int i, a=0, b=0, c=0;

    for(i=0; i<3; i++)
    {
        if(s[i] == 'a')
            a++;
        else if(s[i] == 'b')
            b++;
        else if(s[i] == 'c')
            c++;
    }
    if(a==1 && b==1 && c==1)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	vi out;
	rep(i,s.size())if(s[i]=='?'){
		rep(j,10){
			s[i]='0'+j;
			int sum=0;
			rep(k,s.size()-1){
				if(k<5)sum+=(s[k]-'0')*(6-k);
				else sum+=(s[k]-'0')*(12-k);
			}
			sum%=11;
			if(sum<=1)sum=0;
			else sum=11-sum;
			if(s[11]-'0'==sum)out.pb(j);
		}
	}
	if(out.size()==1)cout<<out[0]<<endl;
	else cout<<"MULTIPLE"<<endl;
}

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

int main(){
    int dice[6];
    
    std::string seq;
    
    for(int i=0; i<6; i++){
        std::cin>>dice[i];
    }
    int u=dice[0];
    int bt=dice[5];
    int r=dice[2];
    int l=dice[3];
    int f=dice[1];
    int bk=dice[4];
    
    std::cin>>seq;
    
    for(int i=0; i<seq.size(); i++){
        int a;
        if(seq[i]=='N'){
            a=bk;
            bk=u;
            u=f;
            f=bt;
            r=r;
            l=l;
            bt=a;
        }
        else if(seq[i]=='S'){
            a=f;
            f=u;
            u=bk;
            bk=bt;
            r=r;
            l=l;
            bt=a;
        }
        else if(seq[i]=='E'){
            a=r;
            r=u;
            u=l;
            l=bt;
            bt=a;
            f=f;
            bk=bk;
        }
        else if(seq[i]=='W'){
            a=l;
            l=u;
            u=r;
            r=bt;
            bt=a;
            f=f;
            bk=bk;
        }
    }
    std::cout<<u<<std::endl;
    
    return 0;
}


Measured memory_bytes: 3224
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int curMaxLength = 0;
        var hash = new RollingHash(s);
        for (int i = 0; i < s.Length; i++)
            for (int j = i; j < s.Length; j++)
                while (curMaxLength < j - i && j + curMaxLength < n && hash.Slice(i, curMaxLength + 1) == hash.Slice(j, curMaxLength + 1)) curMaxLength++;
        Console.WriteLine(curMaxLength);
    }
}

class RollingHash
{
    const ulong MOD1 = 998244353;
    const ulong POSITIVIZER1 = MOD1 << 31;
    static uint Base1;
    static ulong[] powMemo1 = new ulong[500000 + 1];

    static RollingHash()
    {
        Base1 = (uint)new Random().Next(129, int.MaxValue);
        powMemo1[0] = 1;
        for (int i = 1; i < powMemo1.Length; i++)
            powMemo1[i] = (powMemo1[i - 1] * Base1) % MOD1;
    }

    ulong[] hash1;

    public RollingHash(string s)
    {
        hash1 = new ulong[s.Length + 1];
        for (int i = 0; i < s.Length; i++)
            hash1[i + 1] = (hash1[i] * Base1 + s[i]) % MOD1;
    }

    public ulong Slice(int begin, int length)
    {
        return (hash1[begin + length] + POSITIVIZER1 - hash1[begin] * powMemo1[length]) % MOD1;
    }
}


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

int a, b;

void dfs(int x, int y, string s)
{
	if (x == a && y == b){
		cout << s << endl;
		return;
	}

	if (x > a || y > b){
		return;
	}
	
	if (min(x, y) <= 3 && max(x, y) == 5){
		return;
	}

	if (min(x, y) == 4 && max(x, y) == 6){
		return;
	}

	if (x == 5 && y == 5){
		return;
	}

	dfs(x + 1, y, s + "A");
	dfs(x, y + 1, s + "B");
}

int main()
{
	cin >> a >> b;
	dfs(0, 0, "");
}

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

int main() {
    int N;
    cin>>N;
    set<string> s;
    for (int i = 0; i < N; i++){
        string si;
        cin>>si;
        s.insert(si);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 19128
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        d = {}
        for i in range(self.n):
            p = self.find(i)
            if p in d:
                d[p].append(i)
            else:
                d[p] = [i]
        return d

    def __str__(self):
        return '\n'.join('{}: {}'.format(k, v) for k, v in self.all_group_members().items())


def resolve():
    n, m, k = map(int, input().split())
    u = UnionFind(n)
    d = defaultdict(int)
    e = defaultdict(int)
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        u.union(a, b)
        d[a] += 1
        d[b] += 1
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        if u.same(a, b):
            e[a] += 1
            e[b] += 1
    ans = [0] * n
    for i, v in u.all_group_members().items():
        x = len(v) - 1
        for j in v:
            ans[j] = x-d[j] - e[j]
    print(*ans)


if __name__ == '__main__':
    resolve()


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

using namespace std;

#define X   first
#define Y   second

const int   N   = (1 << 18);

typedef pair<int,int>   ii;

ii  f[N];

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

    int n;  cin >> n;

    for(int i = 0 ; i < (1 << n) ; ++i)
        cin >> f[i].X;

    for(int i = 0 ; i < n ; ++i)
        for(int m = 0 ; m < (1 << n) ; ++m)
            if(m >> i & 1)  {
                f[m].Y = max(f[m].Y,f[m ^ (1 << i)].X);
                if (f[m].X < f[m].Y)
                    swap(f[m].X,f[m].Y);
            }

    int last = 0;

    for(int k = 1 ; k < (1 << n) ; ++k)   {
        int ans = last;
        ans = max(ans,f[k].X + f[k].Y);
        cout << ans << "\n";
        last = ans;
    }
}

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

long long cube(long long x) { return x * x * x; }

int main() {
    int n, k; cin >> n >> k;
    vector<int> cnt(k);
    for (int i = 1; i <= n; i++) cnt[i % k]++;
    if (k % 2) {
        cout << cube(cnt[0]) << endl;
    } else {
        cout << cube(cnt[0]) + cube(cnt[k / 2]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  char s[7];
  while (scanf(" %s", s) != EOF)
  {
    bool is = true;
    if (s[2] != s[3]) is = false;
    if (s[4] != s[5]) is = false;
    printf("%s\n", is ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 256
# BFS queue
import queue
import copy

import time
sss = time.time()
H, W = map(int,input().split())
b = [list(input()) for _ in range(H)]
dist = [[10**9 for _ in range(W)] for _ in range(H)]
start = (-1,-1)
qq = queue.Queue()
l = 0
# start把握
for i in range(H):
    for j in range(W):
        if b[i][j] == '.':
            qq.put((i,j))
            l += 1
if l >= H*W-(H-2):
    print(H+W-2)
    exit()
far = 0
move = [(-1,0), (0,-1), (1,0), (0,1)]
def BFS(start, bb):
    dist = [[10**9 for _ in range(W)] for _ in range(H)]
    far = 0
    q = queue.Queue()
    q.put(start)
    dist[start[0]][start[1]] = 0
    # BFS
    while 1:
        now = q.get()
        x = now[0]
        y = now[1]
        bb[x][y] == '#'
        for elem in move:
            dx = elem[0]
            dy = elem[1]
            if x+dx>=0 and x+dx<= H-1 and y+dy>=0 and y+dy<=W-1 and abs(dx-dy)==1:
                if bb[x+dx][y+dy] != '#':
                    if dist[x+dx][y+dy] > dist[x][y]:
                        dist[x+dx][y+dy] = dist[x][y] + 1
                        if dist[x+dx][y+dy] > far:
                            far = dist[x+dx][y+dy]
                        q.put((x+dx,y+dy))
        if q.empty():
            break
    return far
res = 0
while 1:
    ttt = time.time()
    if ttt-sss >= 1:
        break
    now = qq.get()
    res = max([res, BFS(now, copy.deepcopy(b))])
    if qq.empty():
        break
print(res)


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => x).ToList();
            list = list.Distinct().ToList();
            var result = list.Count == 3 ? "Three" : "Four";
            Console.WriteLine(result);
        }
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int w,a,b;
    cin>>w>>a>>b;
    int ans;
    if(a <= b && b <= a + w){
        ans = 0;
    }
    else if(a <= b + w && b + w <= a + w){
        ans = 0;
    }
    else{
        if(a+w < b){
            ans = b - (a + w);
        }
        else{
            ans = a - (b + w);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int n,m,x;
vector <int> cost;
vector <vector <int> > a;
int ans=1e9;
void cal(int i,vector <bool> &temp);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt(),m=nxt(),x=nxt();
    cost.resize(n);
    a.resize(n,vector <int> (m));
    for(int i=0;i<n;i++)
    {
        cin>>cost[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    vector <bool> temp(n,0);
    cal(0,temp);
    if(ans==1e9)
        cout<<"-1\n";
    else
        cout<<ans<<endl;
    
    
    
    return 0;   
}

void cal(int i,vector <bool> &temp)
{
    if(i==n)
    {
        bool f=1;
        for(int j=0;j<m;j++)
        {
            int s=0;
            for(int i=0;i<n;i++)
                if(temp[i])
                    s+=a[i][j];
            if(s<x)
            {
                f=0;
                break;
            }
        }
        if(f)
        {
            int p=0;
            for(int i=0;i<n;i++)
                if(temp[i])
                    p+=cost[i];
            ans=min(p,ans);
        }
    }
    else
    {
        for(int j=0;j<=1;j++)
        {
            temp[i]=j;
            cal(i+1,temp);
        }
    }
}



 
 


Measured memory_bytes: 3668
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    int n;
    int k;
    int q;
    int a;
    int cnt[100100];
    cin>>n>>k>>q;
    REP(i,100100)cnt[i]=q;
    REP(i,q){
        cin>>a;a--;
        cnt[a]--;
    }
    REP(i,n){
        cnt[i]=(k-cnt[i]);
        if(cnt[i]<=0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 1024
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
	int num = 5;
	int k = 0;
	int a[6] = { 0 };
	for (int i = 1; i <= 5; i++)
	{
		cin >> a[i];
	}
	cin >> k;
	int round = 5;

	for (int i = 1; i < num; i++)
	{
		for (int j = i + 1; j <= num; j++)
		{
			if (a[j] - a[i] > k)
			{
				cout << ":(" << endl;
		//		system("pause");
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
//	system("pause");
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	vector<int> is_prime(MAX_N, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < MAX_N; i++) {
		if (!is_prime[i]) continue;
		for (int j = i * 2; j < MAX_N; j += i) {
			is_prime[j] = 0;
		}
	}

	vector<int> a(MAX_N, 0);
	for (int i = 0; i < MAX_N; i++) {
		if (i % 2 == 0) continue;
		if (is_prime[i] && is_prime[(i + 1) / 2]) {
			a[i] = 1;
		}
	}

	vector<int> s(MAX_N + 1, 0);
	for (int i = 0; i < MAX_N; i++) {
		s[i + 1] = s[i] + a[i];
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		r++;	//[l, r)
		cout << s[r] - s[l] << endl;
	}

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if(s[i] == '1') s[i] = '9';
    else s[i] = '1';
  }
  cout << s << endl;

}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  string s,t;cin >> s >> t;
  int ans=0;
  rep(i,3){
    if(s[i]==t[i])ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N;
vl a, b, c;
// 変数定義end

void solve(){
	cin >> N;
	a.resize(N);
	b.resize(N);
	c.resize(N);
	REP(i, N){
		cin >> a[i]  >> b[i] >> c[i];
	}
	ll dp[N+1][3];
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	for(ll i = 1; i <= N; i++){
		dp[i][0] = max(dp[i-1][1] + b[i-1], dp[i-1][2] + c[i-1]);
		dp[i][1] = max(dp[i-1][0] + a[i-1], dp[i-1][2] + c[i-1]);
		dp[i][2] = max(dp[i-1][0] + a[i-1], dp[i-1][1] + b[i-1]);
	}
	cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;


void solve(){
    int n;
    cin >> n;
    int c[n+10];
    int s[n+10];
    int f[n+10];
    rep(i,n-1){
      cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n-1){
      int t=0;
      for(int j=i; j<n-1; j++){
        if(t<s[j]) t=s[j]+c[j];
        else{
          int tmp = t-s[j];
          if(tmp%f[j]!=0){
            t = s[j]+((tmp/f[j])+1)*f[j]+c[j];
          }
          else{
            t += c[j];
          }
        }
      }
      cout << t << endl;
    }
    cout << 0 << endl;
}

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


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

int main(){
  int A, B, K, a=0;
  vector<int> devide_number;
  cin >> A >> B >> K;
  
  for(int i=1; i<=A; i++){
    if (A % i==0 && B % i==0){
      devide_number.push_back(i);
    }
  }
  
  a=devide_number.size();
  cout << devide_number.at(a-K) << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
void minc(int x[],int y[],int n,int p);
void mincInf(int x[], int y[], int n);

int main() {
	int n,x[110],y[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}

	//p = 1,2,3
	minc(x, y, n, 1);
	minc(x, y, n, 2);
	minc(x, y, n, 3);
	
	//p is infinite
	mincInf(x, y, n);
	
	return 0;
}

void minc(int x[],int y[],int n,int p) {
	double d = 0.0;

	for (int i = 0; i < n; i++) {
		double z = abs(x[i] - y[i]);
		d += pow(z, p);
	}
	d = pow(d, 1.0 / p);
	cout << fixed << setprecision(6) << d << endl;
}

void mincInf(int x[], int y[], int n) {
	double max = 0;

	for (int i = 0; i < n; i++) {
		double z = abs(x[i] - y[i]);
		if (z > max) max = z;
	}
	cout << fixed << setprecision(6) << max << endl;
}

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

int main(){
  int n; 
  cin >> n;
  int ans = 1;
  while(true){
    bool can = false;
    if(2*ans > n) can = true;
    if(can) break;
    ans *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    if (n < m){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    string ans(50, 'z');
    for (int i = 0; i < n - m + 1; i++){
        bool ng = false;
        for (int j = 0; j < m; j++){
            if (s[i + j] != '?' && s[i + j] != t[j]){
                ng = true;
                break;
            }
        }

        string temp = {};
        if (!ng){
            for (int k = 0; k < n; k++){
                if (k < i || i + m <= k) temp += s[k];
                else temp += t[k - i];
            }

            ans = min(ans, temp);
        }
    }

    string ngstr(50, 'z');
    if (ans == ngstr){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int i = 0; i < n; i++){
        if (ans[i] == '?') cout << 'a';
        else cout << ans[i];
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n), f(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> f[i];
    long long sum = 0;
    for (int i = 0; i < n; ++i) sum += a[i];
    sort(a.rbegin(), a.rend());
    sort(f.begin(), f.end());
    long long l = 0, r = 0;
    for (int i = 0; i < n; ++i) r = max(r, a[i] * f[i]);
    long long target = sum - k;
    while (r - l > 0) {
        long long d = 0;
        long long m = l + (r - l) / 2;
        for (int i = 0; i < n; ++i) {
            d += min(a[i], m / f[i]);
        }
        if (d < target) {
            l = m + 1;
        } else {
            r = m;
        }
    }
    cout << l << endl;
}


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

const int MAX = 87;
vector<long long int> L(MAX);

void init_Lucas() {
	L.at(0) = 2;
	L.at(1) = 1;
	for (int i = 2; i < MAX; i++) {
		L.at(i) = L.at(i - 1) + L.at(i - 2);
	}
}

int main() {
	int N;
	cin >> N;
	init_Lucas();
	cout << L.at(N) <<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int maze[20][20];

char s[6];
char ans[100];
int sz=0;

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

char sym[]="RDLU";

int main(){
  REP(i,9){
    scanf("%s",s);
    REP(j,strlen(s)){
      if (i%2==0){
	maze[i+1][2*j+2]=s[j]-'0';
      }else{
	maze[i+1][2*j+1]=s[j]-'0';
      }
    }
  }
  ans[0]='R';
  sz++;
  int x=3,y=1;
  int dir=0;
  while (x!=1 || y!=1){
    REP(i,4){
      int d=(dir+3+i)%4;
      if (maze[y+dy[d]][x+dx[d]]){
	dir=d;
	break;
      }
    }
    x+=dx[dir]*2;
    y+=dy[dir]*2;
    ans[sz++]=sym[dir];
  }
  printf("%s\n",ans);
  return 0;
}

Measured memory_bytes: 1112
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    ll a = 2*x-y;
    ll b = 2*y-x;
    if(a<0||b<0){
        cout << 0 << endl;
        return 0;
    }
    if(a%3>0||b%3>0){
        cout << 0 << endl;
        return 0;
    }
    a = a/3;
    b = b/3;
    mint ans = mint(1);
    for(ll i =1;i<=(a+b);i++){
        ans *= mint(i);
    }
    for(ll i =1;i<=(a);i++){
        ans /= mint(i);
    }
    for(ll i =1;i<=(b);i++){
        ans /= mint(i);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int h,w,n;
  int i,j,k;
  cin>>n;
  while(n--){
    cin >> h >> w;
    string st[60];
    for(i=0;i<h;i++) cin >> st[i];
    bool f=true;
    while(f){
      f=false;
      vector<char> v;
      for(i=0;i<h;i++){
	for(j=0;j<w;j++){
	  if(st[i][j]!='.'&&st[i][j]!='?') v.push_back(st[i][j]);
	}
      }
      for(k=0;k<v.size();k++){
	int r=0,l=w,u=h,d=0;
	for(i=0;i<h;i++){
	  for(j=0;j<w;j++){
	    if(st[i][j]==v[k]){
	      r=max(r,j);
	      l=min(l,j);
	      u=min(u,i);
	      d=max(d,i);
	    }
	  }
	}
	bool e = true;
	for(i=u;i<=d;i++){
	  for(j=l;j<=r;j++){
	    if(st[i][j]!=v[k]&&st[i][j]!='?') e =false;
	  }
	}
	if(!e) continue;
	f=true;
	for(i=u;i<=d;i++){
	  for(j=l;j<=r;j++){
	    st[i][j]='?';
	  }
	}
      }
      //for(i=0;i<h;i++) cout << st[i] << endl;
    }
    vector<char> v;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(st[i][j]!='.'&&st[i][j]!='?') v.push_back(st[i][j]);
      }
    }
    if(v.size()==0) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
  }
  return 0;
}

Measured memory_bytes: 1236