akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e3+5,mod=1e9+7;
int n,k;
int binom[maxn][maxn],f[maxn][maxn][2];
void upd(int &x,int y){
	x=(x+y)%mod;
}
int main(){
	read(n);read(k);
	rep(i,0,n)rep(j,0,i)binom[i][j]=!j?1:(binom[i-1][j-1]+binom[i-1][j])%mod;
	f[n][0][0]=1;
	per(i,n,1)per(j,n,0){
		upd(f[i-1][j][0],f[i][j][0]);
		upd(f[i-1][j][0],f[i][j][1]);
		upd(f[i-1][j+1][1],f[i][j][0]);
		upd(f[i-1][j+1][1],f[i][j][1]);
		if(j)upd(f[i][j-1][0],f[i][j][0]);
	}
	int res=(f[1][n-k][0]+f[1][n-k][1])%mod;
	if(n-k-1>=0)res=1ll*res*power(2,n-k-1,mod)%mod;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 47360
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }


int n, h;
vector<int> a, b;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> h;
    a.resize(n); b.resize(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    int a0 = *max_element(a.begin(), a.end());
    sort(b.rbegin(), b.rend());

    ll ans = 0;
    rep(i, n) {
        if (a0 <= b[i] && h > 0) {
            ans++;
            h -= b[i];
        }
    }
    if (h > 0) {
        ans += h / a0;
        ans += !!(h % a0);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>
#include<deque>
#include<queue>
#include<bitset>
#include<functional>
#include<utility>
#include<list>
#include<iomanip>
#include<ctime>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int INF=1e9+1;
int v0,v1,v2;
bool q=1;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		if(a%4==0) v2++;
		else if(a%2==0) v1++;
		else v0++;
	}
	if(v0+v2==n) v2++;
	v2-=v0;
	if(v2<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	//cout<<v0<<" "<<v2;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main()
{
	int a,b;cin>>a>>b;
	if(a>8||b>8)cout<<":("<<endl;
	else cout<<"Yay!"<<endl; 
	return 0;
}

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

def main():
    x, n = map(int, input().split())

    p = set(map(int, input().split()))
    diff = set(range(-1, 150)) - p

    a = [(abs(x - q), q) for q in diff]
    a.sort()
    print(a[0][1])


main()


Measured memory_bytes: 9184
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] memo = new int[n+1];		
		System.out.println(fib(n,memo));
		
		sc.close();
	}

	static int fib(int n, int[] memo) {
        if      (n == 0) return 1;
        else if (n == 1) return 1;
        else if (memo[n] != 0) return memo[n];
        else { memo[n] = fib(n - 1, memo) + fib(n - 2, memo); 
            return memo[n];
        }
    }
	
}

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

int main() {
  int N;
  cin >> N;
  
  int count = 1;//支払いに使う千円札の枚数
  
  while( 1000*count < N){
    count ++;
  }
  
  cout << 1000*count - N << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x;
  cin>>x;
  long  long  ans=100.0;
  int count=0;
  while(1){
    
    ans=ans*(1.01);
    count++;
    if(ans>=x)
    {
      cout<<count;
      return 0;
    }
  }
}

Measured memory_bytes: 3640
package main

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

/*　入力方法
１、簡単に書く
fmt.Scan
2,たくさん読む()
bufio.Scanner
(テキストを1行ずつ読み込む。fileからscannerを生成し、scan()が末尾に達してfalseを返すまで読み込む。Text()を呼ぶことで文字列として取り出すことができる)
3,長い行を読む
bufio.ReadLine
4, スペース区切りのデータを読み込む
sc.Split(bufio.ScanWords)
#########バッファの最大読み込みの数を変更するには
sc.Buffer(buf,MaxBuf)#MAXBUFのところにサイズをしていする
*/

/* 書き込み
１、接頭辞F（前）
書き込み先を指定できる
2,接頭辞S(前)
出力ではなくフォーマットした結果を文字列で返す
3,接頭辞 f（後ろ）
フォーマット（文字列型など）を指定することができる
４、接頭辞 ln（後ろ）
オペランドの間に半角スペースが入り、文字列の最後に開業が追加

・interface{}型
どのような型がくるかわからないときに演算はできないが全ての型を受ける
new(T)
任意の型

*/
/*
フォーマット文字列
%c 1文字を出力　　　%d　　整数を10進む
%s 文字列を出力

指定子	対応する型	説明	使用例
%c	char	１文字を出力する
%s	char *	文字列を出力する
%d	int, short	整数を10進で出力する
%u	unsigned int, unsigned short	符号なし整数を10進で出力する
%o	int, short,unsigned int, unsigned short	整数を8進で出力する
%x	int, short,unsigned int, unsigned short	整数を16進で出力する
%f	float	実数を出力する
%e	float	実数を指数表示で出力する
%g	float	実数を最適な形式で出力する
%ld	long	倍精度整数を10進で出力する
%lu	unsigned long	符号なし倍精度整数を10進で出力する
%lo	long, unsigned long	倍精度整数を8進で出力する
%lx	long, unsigned long	倍精度整数を16進で出力する
%lf	double	倍精度実数を出力する
*/
/*
strconvパッケージ→　文字列と基本データ型の双方向変換を実装
func Atob(str string)(value bool,err os.Error)
文字列で表されている論理値を返す。それ以外のときはエラー

func Atof(s string)(f float,err os.Error)
floatのサイズによってAtof32またはAtof64を呼ぶ

func Atoi(s string(i int,error os.Error))
戻り値がint型を返す

*/
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

/*strings.Splitで入力したものを分ける*/
func Scanner() []string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	return slice

}

/*型変換*/
func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		/*panic関数　　強制的にエラーを発生させるもの*/
		panic(err)
	}
	return i

}

/*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*/
func main() {
	n := nextInt()
	x := n * 800
	y := n / 15 * 200

	fmt.Println(x - y)

}

Measured memory_bytes: 1772
#include<stdio.h>
int main(){
  int n,k,h,count=0;
  scanf("%d %d",&n,&k);
  
  
  for(int i = 0 ; i<n ; i++){
    scanf("%d",&h);
    if(h >= k){
      count = count + 1;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
 
int main()
{
    ll N;
    cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> h(N);
    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for(ll i = 0; i <= 100; i ++) {
        for(ll j = 0; j <= 100; j++) {
            bool flag = false;
            ll H = 0;
            rep(k, N) {
                if (h[k] > 0) {
                    H = h[k] + abs(x[k] - i) + abs(y[k] - j);
                    break;
                }
            }
            rep(k, N) {
                if (h[k] != max(H - abs(x[k]-i) - abs(y[k]-j), (ll)0)) {
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                print(i << " " << j << " " << H);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);
  re(i, n) std::cin >> a[i];
  ll now = 0;
  for(int i=0;i<n;i++){
    if(a[i]==now+1) now++;
  }
  std::cout << (now==0?-1:n-now) << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  	char s[4];
  	char x[2];
  	char y[2];
  	int cnt = 0;
  	int j = 0;
  
  	scanf("%s\n",s);
  
  	x[0] = s[0];
  	for(int i = 1; i < 4; i++){
    	if(s[i] == x[0]){
        	cnt++;
        }else{
        	y[j] = s[i];
          	j++;
        }
    }

  	if(cnt == 1 && y[0] == y[1]){
    	printf("Yes\n");
    }else{
    	printf("No\n");
    }
	return 0;
}

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

int main() {
    int N;
    int a=0,b=0,c=0,d=0;
    cin >> N;
    while (N-- > 0) {
        string ss;
        cin >> ss;
        if (ss == "AC") a += 1;
        else if (ss == "WA") b += 1;
        else if (ss == "TLE") c += 1;
        else if (ss == "RE") d += 1;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
signed main(){
	int n;
	cin>>n;
	int a[210000];
	int ans=0;
	map<int,int> m;
	rep(i,n){
		cin>>a[i];
		m[a[i]]++;
	}
	sort(a,a+n);
	for(int i=n-1;i>=0;i--){
		int p=1;
		if(m[a[i]]==0)continue;
		while(p<10000000000){
			if(p<a[i]||m[p-a[i]]==0||(p-a[i]==a[i]&&m[a[i]]==1)){
				p*=2;
				continue;
			}
			ans++;
			m[a[i]]--;
			m[p-a[i]]--;
			p*=2;
			break;
		}
	}
	cout<<ans<<endl;
}

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

int n,m,a,b,c,minx,Ax,Ad,Bx,Bd;
int dp[160][1100][90];
vector<int>x[200];

int main(){
	while(true){
		for(int i=0;i<200;i++){x[i].clear();}
		minx=1500000000;
		cin>>n>>m;
		if(n==0 && m==0){break;}
		for(int i=0;i<=1000;i++){x[0].push_back(i*10000);}
		for(int i=0;i<=1000;i++){x[n+1].push_back(i*10000);}
		for(int i=1;i<=n;i++){
			cin>>a;
			for(int j=0;j<a;j++){
				cin>>b>>c;
				x[i].push_back(b*10000+c);
			}
		}
		memset(dp,127,sizeof(dp));
		for(int i=0;i<=1000;i++){
			dp[0][i][0]=0;
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<x[i].size();j++){
				for(int k=0;k<=m;k++){
					Ax=x[i][j]/10000;
					Ad=x[i][j]%10000;
					if(dp[i][Ax][k]<=1000000000){
						for(int l=0;l<x[i+1].size();l++){
							Bx=x[i+1][l]/10000;Bd=x[i+1][l]%10000;
							dp[i+1][Bx][k]=min(dp[i+1][Bx][k],dp[i][Ax][k]+(Ad+Bd)*abs(Ax-Bx));
						}
						for(int l=0;l<x[i+2].size();l++){
							Bx=x[i+2][l]/10000;Bd=x[i+2][l]%10000;
							dp[i+2][Bx][k+1]=min(dp[i+2][Bx][k+1],dp[i][Ax][k]+(Ad+Bd)*abs(Ax-Bx));
						}
					}
				}
			}
		}
		for(int i=0;i<=1000;i++){
			for(int j=0;j<=m;j++){
				minx=min(minx,dp[n+1][i][j]);
			}
		}
		cout<<minx<<endl;
	}
	return 0;
}

Measured memory_bytes: 63132
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  REP(i, 0, S.length()) { S[i] = (S[i] - 'A' + N) % 26 + 'A'; }
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 20;
int n, h[maxN], res(0);
bool c;
int main(){
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> h[i];
  for (int i = 0; i < n; ++i){
    c = true;
    for (int j = 0; j <= i; ++j){
      if (h[j] > h[i]) c = false;
    }
    res += c;
  }
  cout << res;
}


Measured memory_bytes: 3588
using System;
class Program{
        static void Main(){
            string[] s = Console.ReadLine().Split(' ');
            int a,b;
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            //Console.Write(a+" "+b);
            Console.WriteLine((a*b)+" "+(2*a+2*b));
        }
}



Measured memory_bytes: 15864
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int MOD = 998244353;

int main() {
	cin.tie(0)->sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> l(k), r(k);
	REP(i, k) cin >> l[i] >> r[i];
	vector<int> dp(n + 1, 0);
	dp[0] = 1;
	dp[1] = -1;
	// 配る DP
	REP(i, n) {
		dp[i + 1] += dp[i];
		dp[i + 1] %= MOD;
		REP(j, k) {
			if (i + l[j] < n) {
				dp[i + l[j]] += dp[i];
				dp[i + l[j]] %= MOD;
			}
			if (i + r[j] + 1 < n) {
				dp[i + r[j] + 1] -= dp[i];
				dp[i + r[j] + 1]  = ((dp[i + r[j] + 1] % MOD) + MOD) % MOD;
			}
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 3992
#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 vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;

int main() {
  int N,K,X,Y; cin >>N >>K >>X >>Y;
  int ans;
  if (N>K) {
    ans=X*K+Y*(N-K);
  } else {
    ans=X*N;
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <complex>
#include <cstdio>
using namespace std;

const double PI = acos(-1);
const double EPS = 1e-9;
typedef complex<double> P;

double fix(double x){
	while( x >=
		2 * PI ) x -= 2 * PI;
	while( x < EPS ) x += 2 * PI;
	return x;
}
int main(){
	int N;
	while(cin >> N && N){
		double ans = 0;
		vector<P> v;
		vector<bool> done(N);
		
		for(int i = 0 ; i < N ; i++){
			double x,y;
			cin >> x >> y;
			v.push_back(P(x,y));
		}
		double cx = 0 , cy = 0;
		double dir = PI / 2;
		while(count(done.begin(),done.end(),0) ){
			//cout << cx << " " << cy << " " << dir << endl;
			vector< pair<double,int> > next;
			for(int i = 0 ; i < N ; i++){
				if( done[i] ) continue;
				double ang = fix(atan2(v[i].imag()-cy,v[i].real()-cx) - dir);
				next.push_back(make_pair(ang,i));
			}
			sort(next.rbegin(),next.rend());
			int cur = 0;
			for(int i = 1 ; i < next.size() ; i++){
				if( fabs( next[i].first - next[0].first ) > EPS ){
					break;
				}
				if( abs(P(cx,cy)-v[next[i].second]) < abs(P(cx,cy)-v[next[cur].second]) ){
					cur = i;
				}
			}
			
			done[next[cur].second] = true;
			ans += abs(P(cx,cy)-v[next[cur].second]);
			dir = fix(dir += next[cur].first);
			cx = v[next[cur].second].real();
			cy = v[next[cur].second].imag();
			
		}
		
		printf("%.1lf\n",ans);
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i = 1; i < n; ++i) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << (*max_element(dp[n - 1].begin(), dp[n - 1].end())) << endl; 
}

Measured memory_bytes: 9836
#include<stdio.h>
int binarySearch();
int S[100000],T[50000],k=0,j,i,q,n;
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&T[i]);
  for(i=0;i<q;i++)binarySearch();
  printf("%d\n",k);
  return 0;
}

binarySearch(){
  int r,m,l;
  l = 0;
  r = n;

  while(l < r){
    m = (l + r) / 2;
    if(S[m] == T[i]){
      k++;
      break;
    }
    else if(T[i] < S[m])
      {
	r = m;
      }
    else{
      l = m + 1;
    }
  }
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

vector<PII> g[2010];
bool used[2010];
int n, k, s, ans = -INF, st;

int dfs(int x, int prev, int m, int cost) {
  if(m == k) {
    int tmp = 0;
    for(auto e: g[x]) if(e.first == st) tmp = e.second;
    if(3 <= k) cost += tmp;
    chmax(ans, cost);
    return cost;
  }
  int ans = INF;
  for(auto e: g[x]) {
    if(e.first == prev) continue;
    chmax(ans, dfs(e.first, x, m+1, cost + e.second));
  }
  return ans;
}

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

  while(true) {
    cin >> n >> k >> s;
    if(!n) break;
    VI x(n), y(n), z(n);
    REP(i, n) cin >> x[i] >> y[i] >> z[i];

    REP(i, 2010) g[i].clear();
    REP(i, n) FOR(j, i+1, n) {
      // (i,j)が重複していたらその分の面積の重みの辺を張る
      int dx = abs(x[i] - x[j]), dy = abs(y[i] - y[j]), dz = abs(z[i] - z[j]);
      if(dx <= s && dy <= s && dz <= s) {
        int cost = 2 * ((s-dx)*(s-dy) + (s-dy)*(s-dz) + (s-dz)*(s-dx));
        g[i].PB({j, cost});
        g[j].PB({i, cost});
        // cout << i << " " << j << " " << cost << endl;
      }
    }

    ans = -INF;
    REP(i, n) {
      // iからk個取る
      memset(used, 0, sizeof(used));
      st = i;
      dfs(i, -1, 1, 0);
    }

    // cout << s*s*6*k << " " << ans << endl;
    if(ans == -INF) cout << -1 << endl;
    else cout << s*s*6*k - ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3268
def f(a, n, i):
    if n % 2 == 0:
        x = n//2
    else:
        x = 3*n+1

    if x in a:
        print(i)
        return
    else:
        a.append(x)
        return f(a, x, i+1)


s = int(input())
a = [s]
f(a, s, 2)

Measured memory_bytes: 3060
/**
6 3 -> 75
ababab
*/
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int n, k;
vector<int> d, f;

void add(int &x,int y) {
	x += y;
	if (x >= mod) x -= mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i * i <= n; ++i) if (n % i == 0) {
		d.push_back(i);
		if (i < (n / i)) d.push_back(n / i);	
	}
	sort(d.begin(), d.end());
	f.resize(d.size());
	int ans = 0;
	for (int i = 0; i < d.size(); ++i) {
		f[i] = pw(k, (d[i] + 1) >> 1);
		for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) {
			add(f[i], mod - f[j]);
		} 
		add(ans, 1ll * f[i] * (d[i] & 1 ? d[i] : d[i] >> 1) % mod);
	}
	cout << ans << '\n';
}

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

int main(){
	int a, b, k;
	std::cin>>a>>b>>k;

	int beg= std::min(a, b);
	int num=0;
	int ans=0;

	for(int i= beg; i>0; i--){
		if(a%i==0 && b%i==0)
			num++;

		if(num==k){
			ans=i;
			break;
		}
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int num, len;
    cin >> num >> len;
    vector<int> arr(len);
    for(int i = 0; i < len; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    int ans = arr[len - 1] - arr[0];
    if(num == 1) {
        cout << ans;
        return 0;
    }
    vector<int> diffs;
    for(int i = 0; i < len - 1; i++) {
        diffs.push_back(arr[i + 1] - arr[i]);
    }
    sort(diffs.begin(), diffs.end());
    int counter = 0;
    for(int i = diffs.size() - 1; i >= 0; i--) {
        if(counter == num - 1) {
            break;
        }
        ans -= diffs[i];
        counter++;
    }
    cout << ans;
}

Measured memory_bytes: 4184
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
int n;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x,n;
    cin >> n >> x;
    int ans = 1;
    long long q = 0;
    for (int i = 0; i < n; i++) {
        long long p;
        cin >> p;
        q += p;
        if (q > x) {
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;



int main(){
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  vector<int> dp(N, 0);
  FOR(i, 1, N){
    if(S[i-1]=='A' && S[i]=='C'){
      dp[i]=dp[i-1]+1;
    }
    else{
      dp[i]=dp[i-1];
    }
  }
  vector<int> l(Q), r(Q);
  REP(i, Q){
    cin >> l[i] >> r[i];
    l[i]--; r[i]--;
    cout << dp[r[i]]-dp[l[i]] << endl;
  }

  return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	string T = "keyence";
	for (int i = 0; i <= 7; i++) {
		int j = 7 - i;
		string s = S.substr(0, i) + S.substr(S.size() - j, j);
		if (s == T) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
e=[1]*(10**6+1)
from collections import Counter
d=Counter(a)
if d[0]==1:exit(print(1))
if d[0]>1:exit(print(0))
ans=0
for i in a:
  if d[i]==1 and e[i]==1:ans+=1
  if e[i]==1:
    for j in range(i,10**6+1,i):e[j]=0
print(ans)

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

int main() {
  int A, B, C, D;
  cin>>A>>B>>C>>D;
  
  while(true){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3632
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
// #include "boost/multi_array.hpp"

//名前空間
using namespace std;
typedef long long ll;

//マクロ
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)  //range(a, b, 1)と対応 aからb回iter
#define FORD(i, a, b) for (ll i = (a); i > (b); i--) //range(a, b, -1)と対応 aからb回iter
#define REP(i, b) FOR(i, 0, b)
#define REPD(i, a) FOR(i, a, 0)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
#define CC(x) cout << (x) << endl

signed main()
{
    string S;
    ll Q, t, f, parity;
    string a0, a1, c;

    cin >> S >> Q;
    FOR(i, 0, Q)
    {
        cin >> t;
        if (t == 1)
        {
            parity++;
            continue;
        }
        else
        {
            cin >> f >> c;
            if ((parity + f) % 2 == 0)
            {
                a0 += c;
            }
            else
            {
                a1 += c;
            }
        }
    }

    if (parity % 2 == 0)
    {
        reverse(a1.begin(), a1.end());

        cout << a1 << S << a0 << endl;
    }
    else
    {
        reverse(S.begin(), S.end());
        reverse(a0.begin(), a0.end());
        cout << a0 << S << a1 << endl;
    }
    //cout << a0 << a1 << endl;
}

Measured memory_bytes: 1088
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){

    double r;
    double a, b;

    cin >> r;

    a = r*r*M_PI;
    b = 2*r*M_PI;

    printf("%.5f %.5f", a, b);

    return 0; 
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

LL l, n = 20;
vector<array<LL, 3>> v;

int main() {
	cin >> l;
	
	inc(i, n - 1) {
		if(i < n - 2) {
			v.PB({ i, i + 1, 0 });
			v.PB({ i, i + 1, (1 << i) });
		} else {
			if(! bit(l, i + 1)) { continue; }
			v.PB({ i, i + 1, (l & ((1 << (i + 1)) - 1)) });
			v.PB({ i, i + 1, (l & ((1 << (i + 1)) - 1)) + (1 << i) });
		}
	}
	inc(i, n - 1) {
		if(bit(l, i)) { v.PB({ i, n - 1, l & ((1 << i) - 1) }); }
	}
	
	int m = v.size();
	cout << n << " " << m << "\n";
	inc(i, m) { cout << v[i][0] + 1 << " " << v[i][1] + 1 << " " << v[i][2] << "\n"; }
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,k,i,j,tmp;
	int x[1000];

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

	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(x[j-1]>x[j]){
				tmp = x[j-1];
				x[j-1] = x[j];
				x[j] = tmp;
			}
		}
	}

	int s=0;
	for(i=0;i<k;i++) s += x[i];

	printf("%d\n",s);

	return 0;
}



Measured memory_bytes: 1704
#include <iostream>
using namespace std;
int main()
{
  	int N;
	cin >> N;
	
	int g;

	int input;

	for (int i = 0; i < N; ++i)
	{
		cin >> input;
		if (g == 0)
			g = input;
		else
		{
			int a, b,r;
			a = (input > g) ? input : g;
			b = (input > g) ? g : input;
			
			r = a % b;
			while (r != 0)
			{
				a = b;
				b = r;
				r = a % b;
			}
			g = b;
		}
	}

	cout << g << endl;

 return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double T, X;
  cin >> T >> X;
  cout << fixed << setprecision(12) << T / X << '\n';
  return 0;
}


Measured memory_bytes: 3660
import sys
import copy

sys.setrecursionlimit(10**6)

def solve():
    S = input()
    lst = [int(S)]
    print(sum(func(S, 1, lst)))
    
def func(s, insertInd, lst):
    if insertInd == len(s):
        return lst
    
    else:
        copied = s
        inserted = copied[:insertInd] + '+' + copied[insertInd:]
        lst.append(evalsum(inserted))
        a = func(inserted, insertInd + 2, lst) 

        inserted = copied[:insertInd] + ' ' + copied[insertInd:]
        if inserted in '+':
            lst.append(evalsum(inserted))
        func(inserted, insertInd + 2, lst)
        
        return a

def evalsum(s):
    s = s.replace(' ', '')
    return sum(list(map(int, s.split('+'))))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=100010, inf=2e9;

int n, X[MX], z, k;
ll ans=2e18;
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>X[i];
	for(int i=1; i+k-1<=n; i++){
		ll now=inf;
		if(0<=X[i]) now=X[i+k-1];
		if(X[i+k-1]<=0) now=-X[i];
		if(X[i]<0 && 0<X[i+k-1]) now=(X[i+k-1]-X[i])*2-max(X[i+k-1],-X[i]);
		ans=min(ans, now);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void kansu(int &count, int n, int x){
    for (int a=1; a<=n-2; a++){
        for (int b=a+1; b<=n-1; b++){
            for (int c=b+1; c<=n; c++){
                if (a+b+c==x){
                    count += 1;
                }
            }
        }
    }
    return ;
}

int main(){
    int n, x, count;
    while (1){
        count = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        else{
        kansu(count, n, x);
        cout << count << endl;
        }
    }
    return 0;
}


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

int main(){
    int n, ans;
    ans = 0;
    cin >> n;
    for(int i = 2; i <= n; i++){
        int pow = i * i;
        while(pow <= n){
            ans = max(ans, pow);
            pow *= i;
        }
    }
    if(n == 1) cout << 1 << endl;
    else cout << ans << endl;
    return 0;
}

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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    int answer = 0;
    answer = max(x - z, 0) / (y + z);
    cout << answer << endl;
}

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

void direction(char d, int dice[])
{
    int temp;
    switch(d)
    {
        case 'E': temp    = dice[1];
                  dice[1] = dice[4];
                  dice[4] = dice[6];
                  dice[6] = dice[3];
                  dice[3] = temp;
                  break;
        case 'S': temp    = dice[1];
                  dice[1] = dice[5];
                  dice[5] = dice[6];
                  dice[6] = dice[2];
                  dice[2] = temp;
                  break;
        case 'W': temp    = dice[1];
                  dice[1] = dice[3];
                  dice[3] = dice[6];
                  dice[6] = dice[4];
                  dice[4] = temp;
                  break;
        case 'N': temp    = dice[1];
                  dice[1] = dice[2];
                  dice[2] = dice[6];
                  dice[6] = dice[5];
                  dice[5] = temp;
                  break;
        case 'R': temp    = dice[2];
                  dice[2] = dice[3];
                  dice[3] = dice[5];
                  dice[5] = dice[4];
                  dice[4] = temp;
                  break;
    }
    return;
}

int main ()
{
    int dice1[7], dice2[7], same = true;
    for (int i = 1;i <= 6;i++) cin >> dice1[i];
    for (int i = 1;i <= 6;i++) cin >> dice2[i];
    
    for(int i = 1;i <= 4;i++)
    {
        if (dice2[1] != dice1[1])
        {
            direction('N', dice2);
        }
        else break;
    }
    if (dice2[1] != dice1[1])
    {
        if (dice2[3] == dice1[1]) direction('W', dice2);
        else if (dice2[4] == dice1[1]) direction('E', dice2);
        else same = false;
    }
    
    if (same)
    {
        for(int i = 1;i <= 4;i++)
        {
            if (dice2[2] != dice1[2])
            {
                direction('R', dice2);
            }
            else break;
        }
        for(int i = 1;i <= 3;i++)
        {
            if (dice2[i] != dice1[i])
            {
                same = false;
                break;
            }
        }
    }
    
    if (same) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3108
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String no=sc.next();
        String s=sc.next();
        String noo=sc.next();
        out.println("A"+s.charAt(0)+"C");
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double ans=0;
		for (int i=0; i<N; i++) {
			double num = sc.nextDouble();
			String type = sc.next();
			if(type.equals("BTC")) num*=380000.0;
			ans+=num;
		}
		System.out.println(ans);
	}
}


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

int main(){
  int i,A,B,C,D,countC=0,countA=0;
  cin >> A >> B >> C >> D;
  //Aによる攻撃
  while(C>0){
    C=C-B;
    countC++;
  }
  
  while(A>0){
    A=A-D;
    countA++;
  }
  if(countA>=countC)cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int yukinnko(const void* tomatu, const void* iguti) {
	int haruka = *(const int*)tomatu, yuka = *(const int*)iguti;
	return haruka < yuka ? -1 : haruka > yuka;
}

int mimorinCount;
int mimorin[128];

/* シャロは「みもりん」、シャロのCVは内田真礼 */
int utidamaaya(int hayamin) {
	int l = 0, r = mimorinCount - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (mimorin[m] == hayamin) return m;
		else if (mimorin[m] < hayamin) l = m + 1;
		else r = m - 1;
	}
	return 127;
}

int N, K;
int x[64], y[64];

int ten[128][128];

int main(void) {
	int i, j, k, eru;
	int64_t asumikana = -1;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &x[i], &y[i]) != 2) return 1;
		mimorin[i * 2] = x[i];
		mimorin[i * 2 + 1] = y[i];
	}
	mimorin[N * 2] = -1111111111;
	qsort(mimorin, N * 2 + 1, sizeof(*mimorin), yukinnko);
	mimorinCount = 1;
	for (i = 1; i < N * 2 + 1; i++) {
		if (mimorin[mimorinCount - 1] != mimorin[i]) {
			mimorin[mimorinCount++] = mimorin[i];
		}
	}
	for (i = 0; i < N; i++) {
		ten[utidamaaya(y[i])][utidamaaya(x[i])] = 1;
	}
	for (i = 1; i < mimorinCount; i++) {
		for (j = 0; j < mimorinCount; j++) {
			ten[i][j] += ten[i - 1][j];
		}
	}
	for (i = 0; i < mimorinCount; i++) {
		for (j = 1; j < mimorinCount; j++) {
			ten[i][j] += ten[i][j - 1];
		}
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			for (k = 0; k < N; k++) {
				for (eru = k + 1; eru < N; eru++) {
					int l = x[i], r = x[j], t = y[k], b = y[eru];
					int li, ri, ti, bi;
					if (l > r) { int p = l; l = r; r = p; }
					if (t > b) { int p = t; t = b; b = p; }
					li = utidamaaya(l) - 1;
					ri = utidamaaya(r);
					ti = utidamaaya(t) - 1;
					bi = utidamaaya(b);
					if (ten[bi][ri] - ten[bi][li] - ten[ti][ri] + ten[ti][li] >= K) {
						int64_t score = (int64_t)(r - l) * (int64_t)(b - t);
						if (asumikana < 0 || score < asumikana) asumikana = score;
					}
				}
			}
		}
	}
	printf("%" PRId64 "\n", asumikana);
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int ans = 700;
    ans += 100*((s[0]=='o')+(s[1]=='o')+(s[2]=='o'));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

ll MOD = 998244353;
const ll INF = 1e18;
const ld E = 1e-18;
const ld PI=acos(-1);
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 37, p3 = 7, p4 = rnd() % 100 + 1, md1 = MOD, md2 = 998244353, md3 = 998244357, md4 = rnd() % 1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, k;


ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l%=md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

void solve()
{
    cin >> n >> m;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    string s;
    cin >> s;
    bool tr=0, tw=0;
    for (int i = 0; i < s.size(); i++)
    {
        tr|=(s[i]=='R');
        tw|=(s[i]=='W');
    }
    if (!(tr && tw)) {cout << "0\n";return 0;}
    s=' '+s;
    ll r=n;
    while (s[r]!='R')r--;
    ll ans=0;
    for (int i = 1; i < r; i++)
    {
        if (s[i]=='W') swap(s[i],s[r]), ans++;
        while (s[r]!='R' && r>i)r--;
    }
    cout << ans << "\n";
    return 0;
}

/*
a-b=k
a+b=m
a=(m+k)/2;
b=(m-k)/2;
*/


Measured memory_bytes: 3872
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

class graph
{
	int v;
	list <int> *adj;
	vector <int> vec;
	int ma(int);
public:
	graph(int v);
	int cal();
	void addedge(int ,int );
};
graph::graph(int n)
{
	v=n;
	adj=new list <int> [v];
	for (int i=0;i<v;i++)
		vec.push_back(-1);
}
void graph::addedge(int u,int v)
{
	adj[u].push_back(v);
}
int graph::ma(int i)
{
	if (vec[i]!=-1)
		return vec[i];
	if (adj[i].empty())
		vec[i]=0;
	else
	{
		
		for (auto j: adj[i])
			vec[i]=max(vec[i],ma(j));
		vec[i]+=1;
	}
	return vec[i];
}

int graph::cal()
{
	for (int i=0;i<vec.size();i++)
	{
		if (vec[i]==-1)
			int r=ma(i);
	}
	return *max_element(vec.begin(),vec.end());
}

signed main()
{
   faster;
   //#ifndef ONLINE_JUDGE
     //'/freopen("ip.txt", "r", stdin);
     //freopen("op.txt", "w", stdout);
   //#endif
    // int t;cin>>t;
     //while(t--)
     {   int n,m,u,v;
     	cin>>n>>m;
     	graph g(n);
     	while (m--)
     	{
     		cin>>u>>v;
     		g.addedge(u-1,v-1);
     	}
      cout<<g.cal();
     }
}

Measured memory_bytes: 8056
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
int main()
{
  int n;
  int ans=0;
  cin >> n;

  vector<long> vec(n);
  rep(i,n) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  for(int i=0; i<(n-1); ++i){
    if(vec.at(i) == vec.at(i+1)){
      ans = 1;
      break;
    }
  }
      
	if(ans==0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

int main() {
	fastio();

	long long n, x; cin >> n >> x;
	vector<long long> h(n + 1, 0), s(n + 1, 0);
	for (long long i = 1; i <= n; i++) cin >> h[i] >> s[i];

	vector<long long> dp(x + 1, 0);

	for (long long i = 1; i <= n; i++) {
		for (long long j = x; j >= h[i]; j--) dp[j] = max(dp[j], dp[j - h[i]] + s[i]);
	}

	cout << *max_element(dp.begin(), dp.end());

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    bool jg = true;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        int b = a % 2;
        int c = a % 3;
        int d = a % 5;
        if (b == 1)
            continue;
        else if (b == 0 && (c == 0 || d == 0))
            continue;
        else
        {
            jg = false;
            break;
        }
    }

    if (jg == true)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
}

Measured memory_bytes: 3540