akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y,z;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n >> m;
    lli hh[n+1];
    rep(i,1,n+1)	cin >> hh[i];
    vector<vector<lli> >adj(MAX);
    while(m--){
    	cin >> a >> b;
    	adj[a].pb(b);
    	adj[b].pb(a);
	}
	bool ok;
	for(i=1;i<=n;i++){
		d=hh[i];
		ok=true;
		for(j=0;j<adj[i].size();j++){
			k=adj[i][j];
			if(hh[k]>=d)	ok=false;
		}
		if(ok)	ans++;
	}
	cout<<ans;
    
    
}












int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

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

int main(){
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  
  int c0=0,c1=0,c2=0,c3=0;
  for(int i=0;i<N;i++){
    if(vec[i]=="AC"){
      c0++;
    }
    if(vec[i]=="WA"){
      c1++;
    }
    if(vec[i]=="TLE"){
      c2++;
    }
    if(vec[i]=="RE"){
      c3++;
    }
  }
  cout <<"AC"<< " " << 'x' << " " <<c0<<endl;
  cout <<"WA"<< " " << 'x' << " " <<c1<<endl;
  cout <<"TLE"<< " " << 'x' << " " <<c2<<endl;
  cout <<"RE"<< " " << 'x' << " " <<c3<<endl;
}

  

Measured memory_bytes: 6428
#coding: UTF-8
import itertools
import copy
 
A,B,C = map(int, input().split())
K = int(input())


L = list(itertools.product(range(3), repeat=K))
#print(A)
flag = 0
for l in L:
  if flag ==1:
    break
  a = copy.deepcopy(A)
  b = copy.deepcopy(B)
  c = copy.deepcopy(C)
  for k in range(K):
    #k回目の処理
    if l[k] ==0:
      a *=2
    elif l[k] ==1:
      b *=2
    else:
      c *=2
    
    #判定
    if a<b and b<c:
      #print(l,a,b,c)
      print("Yes")
      flag = 1
      break
    
  
if flag ==0:
  print("No")

Measured memory_bytes: 9344
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
        cout << "infinity" << endl;
    } else if (t1 * a1 + t2 * a2 > t1 * b1 + t2 * b2) {
        if (a1 > b1) {
            cout << 0 << endl;
        } else {
            int diff1 = t1 * (b1 - a1);
            int diff2 = t2 * (a2 - b2);
            int just = (diff1 % (diff2 - diff1) == 0) ? 1 : 0;
            cout << 1 + 2 * (diff1 / (diff2 - diff1)) - just << endl;
        }
    } else {
        if (b1 > a1) {
            cout << 0 << endl;
        } else {
            int diff1 = t1 * (a1 - b1);
            int diff2 = t2 * (b2 - a2);
            int just = (diff1 % (diff2 - diff1) == 0) ? 1 : 0;
            cout << 1 + 2 * (diff1 / (diff2 - diff1)) - just << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	string n;
	cin >> n;
	if(n[n.size() - 1] == '3') puts("bon");
	else if(n[n.size() - 1] == '0' || n[n.size() - 1] == '1' || n[n.size() - 1] == '6' || n[n.size() - 1] == '8') puts("pon");
	else puts("hon");
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX*3];
  ll cnt[77]={};
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    ll t=a[i];
    ll k=0;
    for(ll k=0; t>0; k++, t>>=1) {
      cnt[k]+=t&1;
    }
  }
  
  ll ans=0;
  for(i=0; i<70; i++) {
    moC(ans, +, moP(2, i)*cnt[i]%MOD*(N-cnt[i])%MOD);
  }
  
  pt(ans);
}



Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<set>

using namespace std;

int main() {
  set<string> d;
  int n, a;
  string o, b;
  cin >> n;
  for (a = 1; a <= n; a++) {
    cin >> o >> b;
    if (o == "insert") {
      d.insert(b);
    } else {
      decltype(d)::iterator it = d.find(b);
      if (it != d.end()) { // 見つかった
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}
return 0;
}




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

int main(){
  char c;
  int a[4];
  int b[2];
  for(int i=0; i<4; i++){
    cin >> c;
    a[i] = (int)c-48;
  }
    
  b[0] = a[0]*10+a[1];
  b[1] = a[2]*10+a[3];
  
  if((b[0]>12 || b[0]==0) && (b[1]>12 || b[1]==0)){cout << "NA";}
  else if(b[0]>12 || b[0]==0){cout << "YYMM";}
  else if(b[1]>12 || b[1]==0){cout << "MMYY";}
  else {cout << "AMBIGUOUS";}
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);
    static int a;
    static int b;
    static int c;
    static int x;

    public static void main(String[] args) {
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        x = sc.nextInt();
        System.out.println(solve());
    }

    private static int solve() {
        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    int sum = i * 500 + j * 100 + k * 50;
                    if (sum == x) {
                        count++;
                    }
                }
            }
        }
        return count;
    }
}


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

int main(){
    int N;
    cin >> N;
    map<string,int> mp;
    for(int i = 0; i < N;i++){
        string S;cin >> S;
        mp[S]++;
    }
    vector<string> ans = {"AC","WA","TLE","RE"};
    
    for(auto a:ans){
        cout << a << " x " << mp[a] << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[500005],R[500005];
void make(){
	F[0] = 1;
	for(int i=1;i<500005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<500005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
ll n,a,b,k;
int main(){
 	cin>>n>>a>>b>>k;
 	ll ans = 0; make();
 	for(ll i=0;i<=n;i++){
 		ll zan = k-i*a;
 		if(zan<0 || zan%b!=0){
 			continue;
 		}
 		ll j = zan/b;
 		if(j > n) continue;
 		ans += C(n,i)*C(n,j)%mod;
 	}
 	cout<<ans%mod<<endl;
 }

Measured memory_bytes: 8064
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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


amb = "AMBIGUOUS"
s = input()

a = int(s[:2])
b = int(s[2:])

if a > 12 or a == 0:
    if b != 0 and b <= 12:
        print("YYMM")
    else:
        print("NA")
else:
    if 1 <= b and b <= 12:
        print(amb)
    else:
        print("MMYY")



Measured memory_bytes: 3060
s = list(input())
t1 = []
t2 = []
for i in range(len(s)):
  if i % 2 == 0:
    t1.append('0')
    t2.append('1')
  else:
    t1.append('1')
    t2.append('0')

cnt1 = 0
cnt2 = 0
for i in range(len(s)):
  if s[i] != t1[i]:
    cnt1 += 1
  if s[i] != t2[i]:
    cnt2 += 1
    
print(min(cnt1,cnt2))

Measured memory_bytes: 5528
# coding: utf-8

num = int(input())
total = 0
number = input().split(" ")
table = list(number)
x = [int(i) for i in table]
list.sort(x, reverse=True)
max = x[0]
for i in range(1, num):
    total += x[i]

if max < total:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
import math
#数値ひとつ
#I = int(input())
#数値欲しいとき
#H, W = map(int, input().split())
#文字欲しいとき

N = input()
listA = list(N)

A = listA[0]
B = listA[1]
C = listA[2]

bool = False

if A == '7':
    bool = True

elif B == '7':
    bool = True

elif C == '7':
    bool = True


if bool == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int d=n/500;     //number of 500 yen coins...
    int e=n%500;      //  reminder
    int f=e/5;          //number of 5 yen coins....
    cout<<d*1000+f*5<<endl;       //multiples of yen for happiness...
}
                     //Alhamdulilla...


Measured memory_bytes: 256
use std::io;

fn atcgsize(s: &String, i: usize) -> usize {
    let mut len = 0;
    for c in s.chars().skip(i) {
        if c == 'A' || c == 'T' || c == 'C' || c == 'G' {
            len += 1;
        } else {
            break;
        }
    }
    len
}

fn solve(s: &String) -> usize {
    (0..s.len()).map(|i| atcgsize(s, i)).max().unwrap()
}

#[test]
fn test_solve() {
    assert_eq!(solve(&String::from("ATCODER")), 3);
    assert_eq!(solve(&String::from("HATAGAYA")), 5);
    assert_eq!(solve(&String::from("SHINJUKU")), 0);
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    println!("{}", solve(&input));
}


Measured memory_bytes: 4352
S=input()
L=len(S)
x=[1]*len(S)
for i in range(L-2):
    if S[i] == S[i+1] == "R":
        x[i+2] += x[i]
        x[i]=0
for i in range(L-1,-1,-1):
    if S[i] == S[i-1] =="L":
        x[i-2] += x[i]
        x[i]=0
#kotae=[int(s) for s in x]

print(' '.join(map(str, x)))

Measured memory_bytes: 10484
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int ans = 0;
    int l_to_r = 0, r_to_l = 0;
    // if(S[0]=='L') r_to_l++;
    // if(S[N-1]=='R') l_to_r++;
    for(int i=0; i<=N-1; i++) {
        if((S[i]=='R' && S[i+1]=='R')||(i>=1 && S[i]=='L' && S[i-1]=='L')) ans++;
        if(S[i]=='L' && S[i+1]=='R') l_to_r++;
        else if(S[i]=='R' && S[i+1]=='L') r_to_l++;
    }

    // cerr << "debug" << endl;
    // cerr << ans << endl;
    // cerr << l_to_r << " " << r_to_l << endl;
    while(K>0 && (l_to_r > 0 || r_to_l > 0 )) {
        if(l_to_r > 0 && r_to_l > 0){
            ans+=2;
            l_to_r--;
            r_to_l--;
        }
        else if(l_to_r>0 && r_to_l == 0) {
            l_to_r--;
            ans++;
        }
        else if(r_to_l>0){
            r_to_l--;
            ans++;
        }
        K--;
    }

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

Measured memory_bytes: 512
<?php
$stdin = file_get_contents('php://stdin');
$stdin = explode("\n", trim($stdin));
list($x, $n) = explode(' ', $stdin[0]);
$p = explode(' ', $stdin[1]);
$max = max($p);
$min = min($p);
$max = max($x, $max) + 1;
$min = min($x, $min) - 1;
$ansv = NULL;
$ans = NULL;

for ($i = $min; $i <= $max; $i++) {
  if (in_array($i, $p)) {
    continue;
  }
  $abs = abs($i - $x);
  if ($ansv === NULL || $ansv > $abs) {
    $ansv = $abs;
    $ans = $i;
  }
}
echo $ans;

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

using ll=int64_t;

int main() {
  int N,M; cin >>N >>M;
  vector<bool> check(N);
  bool flag=false;
  rep(i,0,M) {
    int a,b; cin >>a >>b;
    if (a==1) {
      if (check[b-1]) flag=true;
      check[b-1]=true;
    }
    if (b==N) {
      if (check[a-1]) flag=true;
      check[a-1]=true;
    }
  }
  cout <<(flag ? "POSSIBLE":"IMPOSSIBLE") <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll k, s;
  cin>>k>>s;
  ll res = 0;
  for(ll x = 0; x <= min(s, k); x++){
	  ll t = s-x;
    if(t>2*k) continue;
    if(t<=k) res += t+1;
    else res += k-(t-k)+1;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 20; j++) {
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

#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 FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n;
  cin>>n;
  int d[n];
  REP(i,n){
    cin>>d[i];
  }
  sort(d,d+n);
  n=n/2;
  //cout<<d[n-1]<<" "<<d[n]<<endl;
  int x=d[n-1];
  int y=d[n];
  cout<<y-x<<endl;
}


Measured memory_bytes: 640
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (x, y) = readIntList()

    val res = if ((0..x).any { turu ->
        val kame = x - turu
        kame * 4 + turu * 2 == y
    }) {
        "Yes"
    } else {
        "No"
    }

    println(res)
}

Measured memory_bytes: 36516
#include<stdio.h>
#define MAX 30

struct NODE { int parent, left, right; };

struct NODE Tree[MAX];

void Preorder(int N, int id) {
	printf(" %d", id);
	if (Tree[id].left != -1)Preorder(N, Tree[id].left);
	if (Tree[id].right != -1)Preorder(N, Tree[id].right);
}

void Inorder(int N, int id) {
	if (Tree[id].left != -1)Inorder(N, Tree[id].left);
	printf(" %d", id);
	if (Tree[id].right != -1)Inorder(N, Tree[id].right);
}

void Postorder(int N, int id) {
	if (Tree[id].left != -1)Postorder(N, Tree[id].left);
	if (Tree[id].right != -1)Postorder(N, Tree[id].right);
	printf(" %d", id);
}

int main() {
	int N;
	int id, l, r;
	int root;
	for (int i = 0; i < 30; i++) {
		Tree[i].parent = -1; Tree[i].left = -1; Tree[i].right = -1;
	}
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &id, &l, &r);
		if (l != -1) {
			Tree[id].left = l;
			Tree[l].parent = id;
		}
		if (r != -1) {
			Tree[id].right = r;
			Tree[r].parent = id;
		}
	}
	for (int i = 0; i < N; i++) {
		if (Tree[i].parent == -1) {
			root = i;
			break;
		}
	}
	printf("Preorder\n");
	Preorder(N, root); printf("\n");
	printf("Inorder\n");
	Inorder(N, root); printf("\n");
	printf("Postorder\n");
	Postorder(N, root); printf("\n");
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
  long n, k;
  cin >> n >> k;

  vector<long> h;
  for(int i = 0; i< n; i++){
    long tmp;
    cin >> tmp;
    h.push_back(tmp);
  }
  sort(h.begin(), h.end());

  size_t ret;
  if(n <= k){
   ret = 0;
  }else {
   ret = accumulate(h.begin(), h.end() -k, 0LL);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 5340
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	static final long MOD = 998244353L;
	//static final long INF = -1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		int[] nums = new int[N];
		for (int i = 0; i < N; i++) {
			nums[i] = sc.ni();
		}
		int cur = 0;
		for (int i = 0; i < N; i++) {
			if (nums[i] == cur+1) {
				cur++;
			}
		}
		if (cur == 0) {
			pw.println(-1);
		} else {
			pw.println(N-cur);
		}
		pw.close();
	}
	
	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) { 
		long ans = 1;
		x %= m;
		while (y > 0) { 
			if(y % 2 == 1) 
				ans = (ans * x) % m; 
			y /= 2;  
			x = (x * x) % m;
		} 
		return ans; 
	}
	
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] arr1, int[] arr2) {
				  return arr1[0]-arr2[0]; //ascending order
	          }
		});
		return array;
	}
    
    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] arr1, long[] arr2) {
				  return 0;
	          }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int a1 = min(a, b);
    int a2 = max(-(n - a - b), 0);
    printf("%d %d\n", a1, a2);

}


Measured memory_bytes: 256
//
//
//
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
const int a[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
vector<int> solve(int n){
	vector<int> ans;
	int res = n;
	while(res != 0){
		for (int i = 0; i < 10; i++) {
			if(n - a[i] < 0){
				continue;
			}
			if((n - a[i]) < res) {
				res = n - a[i];
			}
		}
		ans.push_back(n - res);
		n = res;
	}
	return ans;
}
int main(void) {
	vector<int> ans;
	int n;
	while(cin >> n) {
		ans = solve(n);
		while(ans.size() > 1){
			cout << ans.back() << " ";
			ans.pop_back();
		}
		cout << ans.back() << endl;
	}
	return 0;
}

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

int main() {
	int N, x, * a, ans = 0;

	cin >> N >> x;

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

	sort(a, a + N, less<int>());

	for (int i = 0 ; i < N; i++) {
		if (x - a[i] > 0) {
			x = x - a[i];
			ans = i;
		}
		else if (x == a[i]) {
			ans = i + 1;
			break;
		}
		else {
			ans = i; 
			break;
		}
	}
	cout << ans;

	return 0;
}

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

int main()
{
    std::string S;
    std::cin >> S;
    if(S=="Sunny"){
        std::cout << "Cloudy" << std::endl;
    }
    if(S=="Cloudy"){
        std::cout << "Rainy" << std::endl;
    }
    if(S=="Rainy"){
        std::cout << "Sunny" << std::endl;
    }
    return 0;
}

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

int V, E;
long long int cost[100][100]; //cost[from][to] -> cost
const long long int INF = 999999999999;

void warshallFloyd()
{
	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			for (int k = 0; k < V; k++)
			{
				if (cost[j][i] == INF || cost[i][k] == INF) continue;
				cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
			}
		}
	}
}

int main()
{
	cin >> V >> E;

	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			if (i == j) cost[i][j] = 0;
			else cost[i][j] = INF;
		}
	}
	for (int i = 0; i < E; i++)
	{
		int from, to, c;
		cin >> from >> to >> c;
		cost[from][to] = c;
	}

	warshallFloyd();

	for (int i = 0; i < V; i++)
	{
		if (cost[i][i] < 0)
		{
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for (int i = 0; i < V; i++)
	{
		for (int j = 0; j < V; j++)
		{
			if (cost[i][j] == INF) cout << "INF";
			else cout << cost[i][j];
			if (j != V - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3192
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    printf("%d\n",a*b);
    return 0;
}

Measured memory_bytes: 3824
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n):
  q = input().split()
  if q[0]=="0":
    d[q[1]] = int(q[2])
  elif q[0]=="1":
    print(d[q[1]])
  elif q[0]=="2":
    d[q[1]] = 0


Measured memory_bytes: 37904
#include<stdio.h>
int main(void)
{
	char b;
	scanf("%s",&b);
	if('A' == b){
		printf("T");
	}else if('T' == b){
		printf("A");
	}else if('C' == b){
		printf("G");
	}else if('G' == b){
		printf("C");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
bool a[101][101], b[101][101];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h, w;
    cin >> h >> w;

    for(int i = 1; i <= h; i++){
        string line; cin >> line;
        for(int j = 0; j < w; j++){
            a[i][j+1] = (line[j] == '#' ? 1 : 0);
        }
    }
    for(int i = 1; i <= w; i++){
        bool bad = 1;
        for(int j = 1; j <= h; j++){
            if(a[j][i])bad = 0;
        }
        if(bad){
            for(int j = 1; j <= h; j++)b[j][i] = 1;
        }
    }
    for(int i = 1; i <= h; i++){
        bool row = 0; string line = "";
        for(int j = 1; j <= w; j++){
            if(a[i][j]){
                row = 1;
            }
        }
        if(!row)continue;
        for(int j = 1; j <= w; j++){
            if(b[i][j])continue;
            if(a[i][j])line += "#";
            else line += ".";
        }
        cout << line << endl;
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    long long A[N];
    long long sum = 0;

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

    for(int i = 0; i < N - 1; i++){
        if(A[i] < 0){
            A[i] *= -1;
            A[i+1] *= -1;
        }
    }

    if(A[N-1] >= 0){
        for(int i = 0; i < N; i++){
            sum += A[i];
        }
    }

    else{
        A[N-1] = -A[N-1];
        long long m = A[0];
        for(int i = 0; i < N; i++){
            m = min(m, A[i]);
            sum += A[i];
        } 
        sum -= 2 * m;
    }

    cout << sum << endl;
}

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

using namespace std;

int main(){
    string S;
    cin>>S;
    bool ok=true;

    for (int i = 1; i <= S.size(); i++)
    {
        ok=false;
        if(i%2==1&&S[i-1]=='R')ok=true;
        if(i%2==0&&S[i-1]=='L')ok=true;
        if(S[i-1]=='U')ok=true;
        if(S[i-1]=='D')ok=true;
        if(!ok){
            cout<<"No"<<endl;
            return 0;
        }
    }
    

    cout<<"Yes"<<endl;

    
}

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

int main(){
  string S;
  cin >> S;
  int sum=0;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      sum++;
    }
    else{
      sum--;
    }
  }
  cout << sum << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long X, long long Y, long long Z)
{
    cout << Z << " " << X << " " << Y << endl;
}

int main()
{
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long Z;
    scanf("%lld", &Z);
    solve(X, Y, Z);
    return 0;
}


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

using namespace std;

using ll = long long;

int n;
vector<int> arr;
vector<vector<ll>> dp;

ll solve(int x, int y){
    if(x > y) return 0;
    if(x == y) return arr[x];
    if(dp[x][y] != -1) return dp[x][y];
    ll u = solve(x+1, y);
    ll v = solve(x, y-1);
    return dp[x][y] = max(arr[x] - u, arr[y] - v);
}

int main(){
    cin>>n;
    arr.resize(n);
    dp.resize(n, vector<ll>(n, -1));
    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    // ll res = solve(0, n-1);
    ll res;
    for(int i = n - 1; i >= 0; i--){
        for(int j = i; j < n; j++){
            if(i == j){
                dp[i][j] = arr[i];
            }else{
                dp[i][j] = max(arr[i] - dp[i+1][j], arr[j] - dp[i][j-1]);
            }
        }
    }
    res = dp[0][n-1];
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 70656
from collections import defaultdict
N,K = map(int,input().split())
N_List = list(map(int,input().split()))

N_Dict = defaultdict(int)
N_Dict[1] = 1
Pos = N_List[0]
for i in range(N):
    N_Dict[Pos] += 1
    if N_Dict[Pos] == 2:
        break
    else:
        Pos = N_List[Pos - 1]

##ループ始点がPosに入っている状態
##ループがどのくらいの長さか知りたい
CPos = Pos
flg = 0
Loop_List = [CPos]
while flg == 0:
    CPos = N_List[CPos-1]
    if CPos != Pos:
        Loop_List.append(CPos)
    else:
        flg = 1

##ループの始点に至るまでの長さを求める
FL = len(N_Dict) - len(Loop_List) 
if FL <= K:
    ans = Loop_List[(K - FL) % len(Loop_List)]
else:
    ans =list(N_Dict.keys())[K]
print(ans)


Measured memory_bytes: 35816
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
int gcd(int x,int y){ 
  if(y==0){
    return x;
  }else{
   return gcd(y,x%y);
  }
}
 
bool next(string &s){
  if(s[0]=='h'){
    s=s.substr(5);
    return 1;
  }
  s=s.substr(4);
  return 0;
}
 
int main(){
  string n;
  while(cin>>n){
    int above=0;
    int under=1;
    if(n=="#")break;
    reverse(n.begin(), n.end());
    if(!next(n))above=90;
    while(!n.empty()){
      under=under<<1;
      if(!next(n)){
    above=2*above + 90;
      }else{
    above=2*above - 90;
      }
    }
    int g=gcd(above,under);
    cout << above/g;
    if(under/g!=1){
      cout << "/" << under/g << endl;
    }else{
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
N, P = map(int, input().split())
a_li = list(map(int, input().split()))
ans = 0
o = 0
for a in a_li:
    if a % 2 != 0:
        o += 1
if o == 0:
    if P == 1:
        ans = 0
    else:
        ans = 2 ** N
else:
    ans = 2 ** (N - 1)
print(ans)


Measured memory_bytes: 61868
import java.util.Scanner;

public class Main{

    public static void main(String[] args){


        Scanner scanNum = new Scanner(System.in);

        String inputNum = scanNum.next();

        scanNum.close();

        char[] charArray = inputNum.toCharArray();

        String print = "";

        for(int i=0; i < inputNum.length() ; i++){
            if(charArray[i] == '1'){
                charArray[i] = '9';
                print = print + 9;
            }
            else{
                charArray[i] = '1';
                print = print + 1;
            }
        }


        System.out.print(print);
    }
}

Measured memory_bytes: 23764
a1 = input().split()
a2 = input().split()
a3 = input().split()
n = int(input())
ans = "No"
x = [0] * 9
for i in range(n):
    b = input()
    if b in a1:
        x[a1.index(b)] = 1
    if b in a2:
        x[a2.index(b)+3] = 1
    if b in a3:
        x[a3.index(b)+6] = 1

if x[0]+x[1]+x[2]==3 or x[3]+x[4]+x[5]==3 or x[6]+x[7]+x[8]==3 or x[0]+x[3]+x[6]==3 or x[1]+x[4]+x[7]==3 or x[2]+x[5]+x[8]==3 or x[0] + x[4] + x[8] == 3 or x[2]+x[4]+x[6]==3:
    ans = "Yes"
    
print(ans)


Measured memory_bytes: 38384
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string str;
int main()
{
	cin>>str;
	int w;
	scanf("%d",&w);
	for(int i=0;i<str.size();i+=w)
		printf("%c",str[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }

db pi = 3.1415926535;

void solve()
{
	int n; cin >> n;
	//db j = 180 - ((n - 2) * 180 / n);
	//j /= 2;
	n *= 2;
	db res = 0;
	db j = (n - 2) * 180 / n - 90;
	for (int i = 0; i < n / 8; i++)
	{
		if (i % 2 == 0) res += cos(j / 180.0 * pi);
		else res += sin(j / 180.0 * pi);
	}
	res *= 2;
	printf("%.9f", res + 1);
	cout << endl;
}

int main()
{
	/*std::ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(0);*/
	//cout << tan(45 * pi / 180) << endl;
	//int t; cin >> t;
	/*while (t--)
	{
		solve();
	}
	//solve();*/
	int n; cin >> n;
	string a; cin >> a;
	if (a.size() <= n) cout << a;
	else
	{
		for (int i = 0; i < n; i++) cout << a[i];
		cout << "...";
	}
	return 0;
}
/*

*/

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

namespace ITP1_11_B
{
    class Dice
    {
        int[] srf_current;
        int[] srf_first;

        public Dice(int[] x) { srf_current = srf_first = x; }

        public void turn(char vct)
        {
            int[] sub = new int[6];

            for (int i = 0; i < 6; i++)
                sub[i] = srf_current[i];

            switch (vct)
            {
                case 'S':
                    srf_current[0] = sub[4];
                    srf_current[1] = sub[0];
                    srf_current[5] = sub[1];
                    srf_current[4] = sub[5];
                    break;
                case 'N':
                    srf_current[0] = sub[1];
                    srf_current[1] = sub[5];
                    srf_current[5] = sub[4];
                    srf_current[4] = sub[0];
                    break;
                case 'W':
                    srf_current[0] = sub[2];
                    srf_current[2] = sub[5];
                    srf_current[5] = sub[3];
                    srf_current[3] = sub[0];
                    break;
                case 'E':
                    srf_current[0] = sub[3];
                    srf_current[2] = sub[0];
                    srf_current[5] = sub[2];
                    srf_current[3] = sub[5];
                    break;
                default:
                    break;
            }
        }

        public int search(int top,int front)
        {
            if (srf_current[0] != top)
            {
                if (srf_current[1] == top) turn('N');
                else if (srf_current[4] == top) turn('S');
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (srf_current[0] == top) break;
                        else turn('E');
                    }
                }
            }
            if (srf_current[1] == front) return srf_current[2];
            else if (srf_current[2] == front) return srf_current[4];
            else if (srf_current[4] == front) return srf_current[3];
            else return srf_current[1];
        }

        public void reset()
        {
            for (int i = 0; i < 6; i++)
                srf_current[i] = srf_first[i];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var result = new List<int>();

            string d = Console.ReadLine();
            Dice dice = new Dice(d.Split(' ').Select(x => Convert.ToInt32(x)).ToArray());

            int times = int.Parse(Console.ReadLine());

            for(int i = 0; i < times; i++)
            {
                string[] input = Console.ReadLine().Split(' ');

                int top = int.Parse(input[0]);
                int front = int.Parse(input[1]);

                result.Add(dice.search(top, front));

                dice.reset();
            }
            foreach (var r in result)
                Console.WriteLine(r);          
        }
    }
}

Measured memory_bytes: 9632
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int n;
ll OO=1000000000000;
int a[3000];
ll mem[3007][3007];
ll solve(int i,int j){
     if(i==j) {
            return a[i];
     }
     if(mem[i][j]!=OO)return mem[i][j];

        mem[i][j]=max(a[i]-solve(i+1,j),a[j]-solve(i,j-1));
        return mem[i][j];
}
int main()
{
    for(int i=0;i<3007;i++){
        for(int j=0;j<3007;j++){
            mem[i][j]=OO;
        }
    }
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<solve(0,n-1);
}


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

int main() {
  int a, b;
  string s;

  cin >> a >> b >> s;

  if (a + b + 1 != (int)s.size()) {
    cout << "No";
    return 0;
  }

  for (int i = 0; i < (int)s.size(); i++) {
    if (i == a) {
      if (s[i] != '-') {
        cout << "No";
        return 0;
      }
    } else {
      if (s[i] < 48 || s[i] > 57) {
        cout << "No";
        return 0;
      }
    }
  }

  cout << "Yes";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k;
ll ans,mod=1000000007,c[100010],a[100010],f[100010];
ll po(ll x,ll p)
{
    if(p==0)
    {
        return 1;
    }
    ll ret=1;
    if(p%2)
    {
        ret=x;
        ret%=mod;
    }
    ll tem=po(x,p/2);
    ret*=tem;
    ret%=mod;
    ret*=tem;
    ret%=mod;
    return ret;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    f[0]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",a+i);
        f[i]=f[i-1]*i;
        f[i]%=mod;
    }
    sort(a+1,a+n+1);
    /*for(ll i=k-1;i<=n;i++)
    {
        c[i]=f[i]*po(f[k-1],mod-2);
        c[i]%=mod;
        c[i]*=po(f[i-k+1],mod-2);
        c[i]%=mod;
    }*/
    c[k-1]=1;
    for(ll i=k;i<=n;i++)
    {
        c[i]=c[i-1]*i;
        c[i]%=mod;
        c[i]*=po(i-k+1,mod-2);
        c[i]%=mod;
    }
    for(int i=1;i<=n;i++)
    {
        ans-=c[n-i]*a[i];
        ans+=mod*1000000000;
        ans%=mod;
        ans+=c[i-1]*a[i];
        ans%=mod;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 2176
object Main extends App {
	var S = scala.io.StdIn.readLine.toList.map(_.toString)
	val q = scala.io.StdIn.readInt

	var front = List[String]()
	var back  = List[String]()

	var reverse_flag = false

	for(i<-0 until q){
		val a = scala.io.StdIn.readLine.split(" ")

		if(a(0).toInt == 1){
			reverse_flag = !reverse_flag
		}else{

			if(reverse_flag){
				if(a(1).toInt == 2) front = a(2) :: front
				else back = a(2) :: back
			}else{
				if(a(1).toInt == 1) front = a(2) :: front
				else back = a(2) :: back				
			}
		}
	}

	val frontString = front.mkString
	val SString     = S.mkString
	val backString  = back.mkString.reverse

	val ans = frontString + SString + backString

	if(reverse_flag){
		println(ans.reverse)
	}else{
		println(ans)
	}

}

Measured memory_bytes: 102444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int a; cin>>a;
  string s; cin>>s;
  cout << (a >=	3200 ? s : "red") << endl;
  return 0;
}


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

const int MAXN = 1e5 + 5;

int main()
{
    int n = MAXN;
    bool prime[MAXN + 1];
    for (int i = 0; i <= MAXN; ++i)
        prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= n; ++i)
        if (prime[i])
            if (i * 1ll * i <= n)
                for (int j = i * i; j <= n; j += i)
                    prime[j] = false;
    bool prime17[MAXN + 1];
    for (int i = 0; i <= MAXN; ++i)
    {
        if (prime[i] && prime[(i + 1) / 2])
            prime17[i] = true;
        else
            prime17[i] = false;
    }

    int cnt[MAXN + 1], k = 0;
    for (int i = 0; i <= MAXN; ++i)
    {
        k += (prime17[i] ? 1 : 0);
        cnt[i] = k;
    }
    int q, l, r;
    cin >> q;
    int ans[MAXN];
    for (int i = 0; i < q; ++i)
    {
        cin >> l >> r;
        ans[i] = cnt[r] - cnt[l - 1];
    }
    for (int i = 0; i < q; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int sum=n-1;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
            sum--;
    }
    cout<<min(n-1,sum+2*k);

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
using namespace std;
typedef pair<int*, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
#define adde(x, y) { e[++z].v = y; e[z].nxt = h[x]; h[x] = &e[z]; }
#define addrev(u, v) { adde(u, v); adde(v, u); }
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define FO(x) { freopen("#x.in", "r", stdin); freopen("#x.out", "w", stdout); }
inline int read() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x >= 0
{
	if(x < 10)
	{
		putchar(x + '0');
		return ;
	}
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 200100
int n, m;
bool f[maxn];
struct node
{
	int v;
	node *nxt;
} e[2 * maxn], *h[maxn];
int z;
int t[maxn][2];
class cmp
{
	public: bool operator () (pii a, pii b)
	{
		return min(a.first[0], a.first[1]) > min(b.first[0], b.first[1]);
	}
};
priority_queue<pii, cmp> pq;
bool vis[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	string s;
	cin >> s;
	for(int i = 1; i <= n; i ++)
		f[i] = s[i - 1] == 'A';
	for(int i = 0, u, v; i < m; i ++)
	{
		cin >> u >> v;
		addrev(u, v);
		t[u][f[v]] ++;
		t[v][f[u]] ++;
	}
	for(int i = 1; i <= n; i ++)
		pq.push(pii(t[i], i));
	while(!pq.empty())
	{
		int x = pq.top().second;
		pq.pop();
		if(vis[x])
			continue;
		vis[x] = true;
		if(min(t[x][0], t[x][1]) != 0)
			break;
		ae(x)
		{
			t[p->v][f[x]] --;
			if(!vis[p->v])
			{
				pq.push(pii(t[p->v], p->v));
			}
		}
	}
	cout << (pq.empty() ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 19604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll n,ANS;
bool insrt[11];
bool b=0;
ll check(){
	ll bans=0,ans=0;
	for(ll i=0;i<s.size();i++){
		if(insrt[i]){
			bans+=ans;
			ans=0;
		}
		ans=ans*10+s[i]-'0';
	}
	bans+=ans;
	return bans;
}
void dfs(ll a){
	if(a>s.size()-1){
		ANS+=check();
		return;
	}
	insrt[a]=0;
	dfs(a+1);
	insrt[a]=1;
	dfs(a+1);
	
}
int main(){
	cin>>s;
	insrt[0]=1;
	dfs(1);
	cout<<ANS;
}

Measured memory_bytes: 256