akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#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 MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int n;
vector<vector<int>> p;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int k,x;cin>>k>>x;
	if(500*k>=x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 3644
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[3010][3010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin >> N >> S;
    ll A[3010];
    rep(i,0,N) cin >> A[i];
    // dp[0][0] = 1;
    ll ans = 0;
    rep(i,0,N){
        rep(j,0,S+1){
            (dp[i+1][j] += dp[i][j]) %= MOD;
        }
        if(S - A[i] >= 0) ans += dp[i+1][S - A[i]] * (N-i);
        ans %= MOD;
        (dp[i+1][A[i]] += i+1) %= MOD;
        rep(j,1,S+1){
            if(j - A[i] >= 0) (dp[i+1][j] += dp[i][j - A[i]]) %= MOD;
        }
        if(A[i] == S){
            ans += (i+1) * (N-i);
            ans %= MOD;
        }
    }

    print(ans);
    

}


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

using namespace std;

int main(){
    int ans=0;
    vector<int> s(4);
    int N;
    cin >>N;
    s[0]=N/100;
    s[1]=(N/10)%10;
    s[2]=N%10;
    
    for(int i=0;i<3;i++){
        if(s[i]==1){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
program main
	implicit none
	integer :: N,c_a,c_w,c_t,c_r,i
	character(3), allocatable :: S(:)
	read(*,*) N
	allocate(S(N))
	do i=1,N
		read(*,*) S(i)
	end do
	c_a=0;c_w=0;c_t=0;c_r=0
	do i=1,N
		if(S(i)=="AC") then
			c_a=c_a+1
		else if(S(i)=="WA") then
			c_w=c_w+1
		else if(S(i)=="TLE") then
			c_t=c_t+1
		else if(S(i)=="RE") then
			c_r=c_r+1
		end if
	end do
	write(*,*) "AC x",c_a
	write(*,*) "WA x",c_w
	write(*,*) "TLE x",c_t
	write(*,*) "RE x",c_r
end program main

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

#define bit_max 70000

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    long long int t[18][18] = {};

    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j <= n; j++ ) {

	long long int in;
	cin >> in;

	t[j][i] = in;

      }
    }

    long long int ans[bit_max] = {};

    for ( long long int i = 0; i < bit_max; i++ ) {
      ans[i] = 20000000;
    }

    ans[0] = 0;

    for ( long long int b = 0; b < ( 1 << n ); b++ ) {

      bool cleared[17] = {};

      for ( long long int s = 0; s < n; s++ ) {
	const long long int sbit = ( 1 << s );
	
	if ( ( b & sbit ) != 0 ) {
	  cleared[s] = true;
	}

      }

      for ( long long int s = 0; s < n; s++ ) {
	const long long int sbit = ( 1 << s );

	if ( cleared[s] != false ) continue;

	ans[ b+sbit ] = min( ans[ b+sbit ], ans[ b ] + t[0][s] );

	for ( long long int c = 0; c < n; c++ ) {

	  if ( cleared[c] != true ) continue;

	  ans[ b+sbit ] = min( ans[ b+sbit ], ans[ b ] + t[c+1][s] );

	}

      }

    }

    cout << ans[ ( 1 << n ) - 1 ] << endl;

  }

  return 0;

}

Measured memory_bytes: 1712
#include <iostream>
#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 <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

vector<int> set_product(vector<int> v1, vector<int> v2) {
	vector<int> ret(0);
	for (int i : v1) {
		if (find(v2.begin(), v2.end(), i) != v2.end()) {
			ret.push_back(i);
		}
	}
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> K(N);
	vector<vector<int>> A(N);
	int tmp_cin;
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> tmp_cin;
			A[i].push_back(tmp_cin);
		}
		sort(A[i].begin(), A[i].end());
	}

	vector<int> ret;
	for (int i = 1; i <= 30; i++) {
		ret.push_back(i);
	}
	for (int i = 0; i < N; i++) {
		ret = set_product(A[i], ret);
	}
	cout << ret.size();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;

  vector<pair<ll,int>> a(A+B+C,make_pair(0,0));
  for(int i=0;i<A;i++){
    cin >> a[i].first;
    a[i].second=0;
  }
  for(int i=A;i<A+B;i++){
    cin >> a[i].first;
    a[i].second=1;
  }
  for(int i=A+B;i<A+B+C;i++){
    cin >> a[i].first;
    a[i].second=2;
  }

  sort(a.begin(),a.end(),[](auto l,auto r){
      return l.first>r.first;
    });

  ll p=0,q=0,r=0;
  ll ans=0;
  for(int i=0;i<A+B+C;i++){
    if(p+q+r>=X+Y) break;
    if(a[i].second==0 && p<X){
      p++; ans+=a[i].first;
    }else if(a[i].second==1 && q<Y){
      q++; ans+=a[i].first;
    }else if(a[i].second==2 && r<X+Y-p-q){
      r++; ans+=a[i].first;
    }
    //cout << p << " " << q << " " << r << " " << ans << endl;
  }

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


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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    float sum = 0;
    if (n == 1) {
      System.out.println(sc.nextInt());
      return;
    }

    for (int i = 0; i < n; i++) {
      int num = sc.nextInt();
      sum += (float)1/num;
    }
    float result = 1/sum;
    System.out.println(result);
  }
}

Measured memory_bytes: 21844
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if (cur == N):
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int max = 0;
		for(int i=0;i<(1<<N);i++){
			int[] honest = new int[N];
			int hc = 0;
			for(int j=0;j<N;j++){
				if((i >> j) % 2 == 1){
					honest[j] = 1;
					hc++;
				}
			}
			//Console.WriteLine(String.Join("",honest));
			bool contradict = false;
			for(int j=0;j<N;j++){
				if((i >> j) % 2 == 0) continue;
				for(int k=0;k<A[j];k++){
					if(Y[j][k] != honest[X[j][k]]){
						contradict = true;
					}
				}
			}
			if(!contradict) max = Math.Max(max, hc);
		}
		
		Console.WriteLine(max);
		
	}
	int N;
	int[] A;
	int[][] X,Y;
	public Sol(){
		N = ri();
		A = new int[N];
		X = new int[N][];
		Y = new int[N][];
		for(int i=0;i<N;i++){
			A[i] = ri();
			X[i] = new int[A[i]];
			Y[i] = new int[A[i]];
			for(int j=0;j<A[i];j++){
				var d = ria();
				X[i][j] = d[0] - 1;
				Y[i][j] = d[1];
			}
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int ret=INT_MAX,a,b;
	for (int i=0; i<n; i++)
		cin>>a>>b, ret=min(ret,a+b);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		if (a.length() > b.length()) {
			System.out.println("GREATER");
			return;
		}
		if (b.length() > a.length()) {
			System.out.println("LESS");
			return;
		}
		String ans = "EQUAL";
		for (int i = 0; i < a.length(); i++) {
			if (a.charAt(i) > b.charAt(i)) {
				ans = "GREATER";
				break;
			}
			if (b.charAt(i) > a.charAt(i)) {
				ans = "LESS";
				break;
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

static const int MAX = 10000;
static const int INFTY = ( 1 << 20);
static const int WHITE = 0, GRAY = 1, BLACK = 2;

int n;

vector<pair<int, int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int, int> > PQ;

  int color[MAX];
  int d[MAX];

  for(int i = 0; i < n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while(!PQ.empty()){
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;

    color[u] = BLACK;

    if(d[u] < f.first * (-1)) continue;

    for(int j = 0; j < adj[u].size(); j++){
      int v = adj[u][j].first;

      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second){
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] * (-1), v));
	color[v] = GRAY;
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

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

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();

  return 0;
}
		



Measured memory_bytes: 7988
#include <stdio.h>
int main(void){
long n;
scanf("%ld",&n);
long a[n];
long i;
for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
}
long min=a[0],max=a[0],sum=a[0];
for(i=1;i<n;i++){
    if(a[i]<min)
    min=a[i];
    
    if(a[i]>max)
    max=a[i];
    
    sum+=a[i];
}
printf("%ld %ld %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
vector<int> a;


signed main() {
    
    cin >> n;
    a.resize(n);
    for(auto&&i:a) cin >> i;

    sort(ALL(a));

    int t = a[0], s = INF;;
    for(int i = 0; i < n-1; i++) {
        if(s > abs(a[n-1] - a[i] * 2)) {
            s = abs(a[n-1] - a[i] * 2);
            t = a[i];
        }
    }
    cout << a[n-1] __ t << endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf = 1e9;
const ld eps=1e-7;
const ld pi = acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=1e5+11;
const int M=803;
const int mod=998244353;

int a[N];
int t[4*N];

void upd(int v,int tl,int tr,int pos,int val){
  if(tl==tr){
    t[v]=max(t[v],val);
    return;
  }
  int tm=(tl+tr)/2;
  if(pos<=tm)upd(v*2,tl,tm,pos,val);
  else upd(v*2+1,tm+1,tr,pos,val);
  t[v]=max(t[v*2],t[v*2+1]);
}

int get(int v,int tl,int tr,int l,int r){
  if(tl>r||l>tr)return 0;
  if(l<=tl&&tr<=r)return t[v];
  int tm=(tl+tr)/2;
  return max(get(v*2,tl,tm,l,r),get(v*2+1,tm+1,tr,l,r));
}

int main(){
  int n;
  cin>>n;
  vector<pii>v;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    v.pb(mp(a[i],i));
  }
  sort(all(v));
  int cur=1;
  a[v[0].y]=cur;
  for(int i=1;i<n;i++){
    if(v[i].x!=v[i-1].x)cur++;
    a[v[i].y]=cur;
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int val=get(1,1,cur,a[i],cur)+1;
    ans=max(ans,val);
    upd(1,1,cur,a[i],val);
  }
  cout<<ans;
  return 0;
}


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

using namespace std;

int main()
{
	string g;
	int y, m, d;
	while (cin >> g, g != "#")
	{
		cin >> y >> m >> d;
		if (y <= 30)
		{
			printf("HEISEI %d %d %d\n", y, m, d);
		}
		else if (y == 31)
		{
			if (m < 5)
				printf("HEISEI %d %d %d\n", y, m, d);
			else
				printf("? 1 %d %d\n", m, d);
		}
		else
		{
			printf("? %d %d %d\n", y - 30, m, d);
		}
	}
}


Measured memory_bytes: 3240
n = int(input())

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

ans = 0

for i in range(n):
    t = min(a[i], b[i])
    b[i] -= t
    ans += t
    t = min(a[i+1], b[i])
    a[i+1] -= t
    ans += t

print(ans)

Measured memory_bytes: 18624
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range(D)]
for i in range(D):
  count = 0
  ans = 0
  for j in range(26):
    if S[i][j] > count:
      count = S[i][j]
      ans = j+1
  print(ans)

Measured memory_bytes: 9532
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static int[] MEMO;
    
    static {
        int[] ary = new int[45];
        ary[0] = ary[1] = 1;
        MEMO = ary;
    }
    
    public static void main(String[] args) {
        System.out.println(calc(scn.nextInt()));
    }
    
    private static int calc(int n) {
        if(MEMO[n] == 0) {
            MEMO[n] = calc(n - 1) + calc(n - 2);
        }
        return MEMO[n];
    }
}

Measured memory_bytes: 26268
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int a,b; cin>>a>>b;
    int ans=0;
    if(a>b)return puts("0")*0;
    for(;;){
        a*=2;
        ans++;
        if(a>b)break;
    }
    cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  bool b[n-1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0 && a[i] > a[i-1]) b[i-1] = true;
    else if (i != 0) b[i-1] = false;
  }
  
  long long money = 1000;
  long long ticket = 0;
  for (int i = 0; i < n-1; i++) {
    if (b[i]==true) {
      ticket = money/a[i];
      money %= a[i];
      money += a[i+1]*ticket;
      ticket = 0;
    }
    else continue;
  }
  cout << money << endl;
}

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

#define endl '\n'

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

int len;
vector<char> D;
vector<double> X;
vector<double> Y;

vector<double> TX;
vector<double> TY;

void Time(double t){
	for (int i = 0; i < len; ++i) {
		if (D[i] == 'R') TX[i] = X[i] + t;
		else if (D[i] == 'L') TX[i] = X[i] - t;
		else{
			if (D[i] == 'U') TY[i] = Y[i] + t;
			if (D[i] == 'D') TY[i] = Y[i] - t;
			TX[i] = X[i];
			continue;
		}
		TY[i] = Y[i];
	}
}

double Ma(vector<double> vector){
	double maxi = vector[0];
	for (int i = 1; i < len; ++i) {
		maxi = max(vector[i],maxi);
	}
	return maxi;
}

double Mi(vector<double> vector){
	double maxi = vector[0];
	for (int i = 1; i < len; ++i) {
		maxi = min(vector[i],maxi);
	}
	return maxi;
}

double Ternary(){
	double L = 0;
	double R = pow(10,16);
	for (int i = 0; i < 400; ++i) {
		double m1 = L + (R - L)/3;
		double m2 = R - (R - L)/3;
		Time(m1);
		double d1 = (Ma(TX) - Mi(TX)) * (Ma(TY) - Mi(TY));
		Time(m2);
		double d2 = (Ma(TX) - Mi(TX)) * (Ma(TY) - Mi(TY));
		if (d1 > d2) L = m1;
		else if (d2 > d1) R = m2;
		else{
			L = m1;
			R = m2;
		}
	}
	Time(L);
//	cout << L << endl;
//	for (int j = 0; j < len; ++j) {
//		cout << TX[j] << " " << TY[j] << endl;
//	}
//	cout << endl;
//    cout << Ma(TX) << " " << Mi(TX) << " " << Ma(TY) << " " << Mi(TY) << endl;
	return (Ma(TX) - Mi(TX)) * (Ma(TY) - Mi(TY));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> len;
	D = vector<char>(len), X = vector<double>(len),Y = vector<double>(len),TX = vector<double>(len),TY = vector<double>(len);
	
	for (int i = 0; i < len; ++i) {
		cin >> X[i] >> Y[i] >> D[i];
	}
	
	cout << fixed << setprecision(12) << Ternary();
	
	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  char c; std::cin >> c;
  std::cout << char(c+1) << "\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def cal_xor(xor_list):
    ans = None
    for xi in xor_list:
        if ans is not None:
            ans = ans^xi
        else:
            ans = xi
    return ans

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

ans_str = ''

if N==2:
    print("{} {}".format(a[1], a[0]))
else:

    xors = []
    for i in range(N//2):
        xors.append(a[2*i]^a[2*i+1])

    sum_xor = cal_xor(xors)
    for i, ai in enumerate(a):
        tmp_xor = sum_xor^xors[i//2]
        if i%2==0:
            ind = i+1
        else:
            ind = i-1

        ans = tmp_xor^a[ind]
        ans_str += str(ans)+' '
    print(ans_str[:-1])


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


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> num(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		num[a[i] - 1]++;
	}

	ll n_a = 0;
	for (int i = 0; i < n; i++) {
		n_a += num[i] * (num[i] - 1) / 2;
	}

	for (int i = 0; i < n; i++) {
		ll mai = num[a[i] - 1] - 1;
		cout << n_a - mai << endl;
	}

	return 0;
}


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

int H,W;
int vx[4] = {1, 0, -1, 0};
int vy[4] = {0, 1, 0, -1};
char map[100][101];

void unite(int x,int y,char t){
    map[x][y] = 65;
    for(int k = 0; k < 4; k++){
        if( x+vx[k] >= 0 && x+vx[k] < H &&
            y+vy[k] >= 0 && y+vy[k] < W &&
            map[ x+vx[k] ][ y+vy[k] ] == t ){
            unite(x+vx[k], y+vy[k], t);
        }
    }
}

int main(){
    while( cin >> H >> W, H|W ){
        int i,j,c;
        for(i = 0; i < H; i++){
            cin >> map[i];
        }
        c = 0;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                if( map[i][j] != 65 ){
                    c++;
                    unite(i, j, map[i][j]);
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

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

int main(){
	int n;
	int bus[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		int a, b;
		scanf(" %d %d", &a, &b);
		
		if(a==0 || 5<a){ //1通りしかありえない
			int start=0, goal;
			while(bus[start] != a) start++;
			
			goal=start;
			bool flag=false;
			while(1){
				if(flag) printf(" ");
				printf("%d", bus[goal%15]);
				if(bus[goal%15] == b) break;
				goal++;
				flag=true;
			}
			printf("\n");
		}
		else{ //2通りある
			int start=0, goal, count1=0, count2=0;
			
			while(bus[start] != a) start++;
			goal=start;
			while(bus[goal%15] != b){
				goal++;
				count1++;
			}
			
			start++;
			int tmp=0;
			while(bus[start%15] != a) start++;
			goal=start;
			while(bus[goal%15] != b){
				goal++;
				count2++;
			}
			
			if(count1 < count2) goal=a;
			else goal=15-a;
			
			bool flag=false;
			while(1){
				if(flag) printf(" ");
				
				printf("%d", bus[goal%15]);
				if(bus[goal%15] == b) break;
				goal++;
				flag=true;
			}
			printf("\n");
			
		}
		
	}
	return 0;
}

Measured memory_bytes: 1192
from time import time
from random import randrange
from bisect import bisect_left
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]
start = time()
d = int(input())
c = list(map(int, input().split()))
C = sum(c)
s = [list(map(int, input().split())) for _ in range(d)]
#t = [int(input()) for _ in range(d)]
t = []
day = [[0] for _ in range(26)]
order = []

def score(t):
	res = 0
	minus = 0
	last = [0 for _ in range(26)]
	for i, x in enumerate(t):
		minus += C - c[x-1] * (i - last[x-1] + 1)
		res -= minus
		res += s[i][x-1]
		last[x-1] = i+1
		#print(res)
	return res

def tri(n):
	return n * (n-1) // 2

def change(i, to):
	diff = 0
	fr = t[i]-1
	#print(day[fr])
	#print(day[to])
	if fr == to:
		return 0
	fr_ind = bisect_left(day[fr], i+1)
	diff += (tri(day[fr][fr_ind] - day[fr][fr_ind-1]) + tri(day[fr][fr_ind+1] - day[fr][fr_ind])) * c[fr]
	diff -= (tri(day[fr][fr_ind+1] - day[fr][fr_ind-1])) * c[fr]
	diff -= s[i][fr]
	
	to_ind = bisect_left(day[to], i+1)
	diff += (tri(day[to][to_ind] - day[to][to_ind-1])) * c[to]
	diff -= (tri(day[to][to_ind] - (i+1)) + tri(i+1 - day[to][to_ind-1])) * c[to]
	diff += s[i][to]

	#if diff > 0:
	day[fr].pop(fr_ind)
	after = day[to][:to_ind] + [i+1] + day[to][to_ind:]
	day[to] = after
	t[i] = to+1
	#print("↓")
	#print(day[fr])
	#print(day[to])
	return diff
	#else:
		#return False

#score(t)
res = 0
minus = 0
last = [0 for _ in range(26)]
for i in range(d):
	minus += C
	#li = sorted(list(range(26)), key=lambda x: - c[x] * (i - last[x] + 1) - s[i][x])
	#order.append(li)
	#M_ind = li[0]
	M_ind = int(input())-1
	minus -= c[M_ind] * (i - last[M_ind] + 1)
	last[M_ind] = i+1
	res -= minus - s[i][M_ind]
	t.append(M_ind+1)
	day[M_ind].append(i+1)

for i in range(26):
	day[i].append(d+1)

#print(res)
#print(*t, sep="\n")
#print(score(t))
#print(*day, sep="\n")

for _ in range(int(input())):
	d, q = map(int, input().split())
	res += change(d-1, q-1)
	print(res)

Measured memory_bytes: 83288
#include <bits/stdc++.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          998244353
#define M2         1000000007
#define inf        100000000000000
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;
    return true;
}

int main()
{
    off;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans;
    if(a>k)
        ans = k;
    else
    {
        if(a+b>=k)
            ans = a;
        else
            ans = a - (k-(a+b));
    }
    cout<<ans;
}








Measured memory_bytes: 3652
#!/usr/bin/env python3
# coding: utf-8

class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1)}

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

dicedata = input().split()
orderdata = input()

newdice = Dice(dicedata)

[newdice.move(orderdata[idx]) for idx in range(0, len(orderdata))]

print(newdice.get_up())



Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, A, B; cin >> N >> A >> B;
  cout << A*(N/(A+B)) + min(N%(A+B), A) << endl;
}

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

using namespace std;
#define int long long
signed main(){
    int N,A,B;
    cin>>N>>A>>B;
    vector<int> X(N);

    for(int i = 0; i < N;i++) cin>>X[i];

    int ans = 0;

    for(int i = 0;i < N-1;i++) ans += min(A*(X[i+1] - X[i]),B);

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

bool solve(ll W, ll N, ll C, vector<ll> S, vector<ll> T) {
  ll l = 0, r = W;

  for (int i = N - 1; i >= 0; i--) {
    if (S[i] == +1) r--;
    if (S[i] == -1) l++;
    r = min(r, W);
    l = max(l, 0LL);

    if (l == r) return false;

    if (i - 1 >= 0) {
      if (T[i - 1] == +1) l--;
      if (T[i - 1] == -1) r++;
      r = min(r, W);
      l = max(l, 0LL);
    }
  }

  return l <= C && C < r;
}

vector<ll> row(string &S, ll N) {
  vector<ll> r(N);
  REP(i, 0, N) {
    if (S[i] == 'L') r[i] = -1;
    if (S[i] == 'R') r[i] = +1;
  }
  return r;
}

vector<ll> col(string &S, ll N) {
  vector<ll> c(N);
  REP(i, 0, N) {
    if (S[i] == 'U') c[i] = -1;
    if (S[i] == 'D') c[i] = +1;
  }
  return c;
}

int main(void) {
  ll H, W, N;
  cin >> H >> W >> N;
  ll R, C;
  cin >> R >> C, R--, C--;
  string S, T;
  cin >> S >> T;

  bool ans = true;
  ans = ans && solve(W, N, C, row(S, N), row(T, N));
  ans = ans && solve(H, N, R, col(S, N), col(T, N));
  cout << (ans ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;

    string ans = "";
    rep(i, s.length()) {
        if (s[i] == '0' || s[i] == '1') ans += s[i];
        if (s[i] == 'B' && ans != "") ans = ans.substr(0, ans.length()-1);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
const int value[6] = {1, 5, 10, 50, 100, 500};
void pay(int n) {
    int rest = 1000 - n;
    int ans = 0;
    for (int i = 5; i >= 0; i--) {
        ans += (rest / value[i]);
        rest -= rest / value[i] * value[i];
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        pay(n);
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
#include <math.h>
using namespace std;
 
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  cout << fixed << setprecision(20) << sqrt(A * A + B * B - 2 * A * B * cos(2.0 * asin(1.0) * (0.5 * M + 30 * H - 6.0 * M) / 180)) << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  sort(ALL(a));

  int ans = a.back() - a[0];

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>

int main() {
	int a;
		scanf("%d", &a);
	switch (a % 7) {
		case 0:
			printf("thu");
			break;
		case 1:
			printf("fri");
			break;
		case 2:
			printf("sat");
			break;
		case 3:
			printf("sun");
			break;
		case 4:
			printf("mon");
			break;
		case 5:
			printf("tue");
			break;
		case 6:
			printf("wed");
			break;
	}
		printf("\n");
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  
 int N, K, X;
 int Sum = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> X;
    if (0 + X < K - X) {
      Sum += X;
    }else{
      Sum += K - X;
    }
  }
  cout << Sum * 2 <<endl;
}
    

Measured memory_bytes: 3612
n=int(raw_input())
t=[list(map(int,raw_input().split())) for i in range(n)]
flag=False
if n==1:
	if (t[0][1]+t[0][2])%2!=t[0][0]%2 or t[0][0]<t[0][1]+t[0][2]:
		flag=True
else:
	for i in range(n-1):
		dt=t[i+1][0]-t[i][0]
		dx=t[i+1][1]-t[i][1]
		dy=t[i+1][2]-t[i][2]
		if (dx+dy)%2!=dt%2 or dt<dx+dy:
			flag=True
			break

print "YNeos"[flag::2]


Measured memory_bytes: 24708
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
int main()
{
    int n,k,num=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        if(num<k)
            num*=2;
        else
            num+=k;
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
# 黒板にN個の正の整数A1,…,ANが書かれています。
# 黒板に書かれている整数がすべて偶数であるとき，次の操作を行うことができます。
# 「黒板に書かれている整数すべてを，2で割ったものに置き換える。」
# 最大で何回操作を行うことができるかを求めてください。

# 整数の数を取得
n = gets.chomp.to_i

# 黒板に書かれている整数を取得
nums = gets.chomp.split
n.times do |i|
  nums[i] = nums[i].to_i
end

# 操作が出来た回数を記録する変数を定義
counter = 0

# 全て偶数であるか判定し、その場合は操作を行い、再び判定する
loop do
  
  # 奇数があるか判定するための変数を定義
  odd = false
    
  # 奇数がないか（全て偶数であるか）判定
  nums.each do |num|
    if num.odd?
      odd = true
      break
    end
  end
  
  # 奇数が含まれていないか判定
  # 含まれていなければ、操作を行い、再び判定する
  # 含まれていれば、ループを抜ける
  unless odd
    nums.map! do |num|
      num /= 2
    end
    counter += 1
  else
    break
  end
end

# 結果を出力
puts counter

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
void init(int n){
   par.resize(n);
   depth.resize(n,0);
   rep(i,n) par[i]=i;
}

int find(int n){
   if(par[n]==n) return n;
   return par[n]=find(par[n]);
}

void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(par[x]==par[y]) return;
   if(depth[x]<depth[y]) par[x]=par[y];
   else{
      par[y]=par[x];
   if(depth[x]==depth[y]) depth[x] ++;
   }
}

bool same(int x,int y){
   return find(x)==find(y);
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k,l;
    cin>>n>>k>>l;
    init(n);
    int p,q;
    rep(i,k){
       cin>>p>>q;
       p --;
       q --;
       unite(p,q);
    }
    vector<P> x(n);
    rep(i,n) x[i].first=find(i);
    init(n);
    rep(i,l){
       cin>>p>>q;
       p --;
       q --;
       unite(p,q);
    }
    rep(i,n) x[i].second=find(i);
    map<P,int> z;
    rep(i,n){
     // if(!z.count(x[i])) z[x[i]]=1;
      z[x[i]] ++;
    }
    rep(i,n) cout<<z[x[i]]<<" ";

}

Measured memory_bytes: 15104
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

ld dist(ld x1,ld y1,ld x2,ld y2)
{
	return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

ld avg(vector<int> &v,map<int,pair<ld,ld>> &m)
{

	ld dis = 0;

	forn(i,0,v.sze-1)
	{
		dis += dist(m[v[i]].ff,m[v[i]].ss,m[v[i+1]].ff,m[v[i+1]].ss);
	}
	return dis;
}

int main()
{
    fast
    pre
/*
    #ifndef ONLINE_JUDGE
        freopen("in.txt",  "r",  stdin);
        freopen("out.txt", "w", stdout);
    #endif
//*/

        
	int n;
	cin>>n;

	map<int,pair<ld,ld>> m;
	ld a,b;
	forn(i,0,n)
	{
		cin>>a>>b;
		m[i] = {a,b};
	}	
        
    vector<int> v(n);    

    forn(i,0,n) v[i] = i;
    ld total = 0;
    do
    {	
    	total += avg(v,m);
    }
    while(next_permutation(all(v)));


   	ld x = 1;

   	for(int i = 1; i <= n; i++)
   	{
   		x = x*i;
   	}


   	ld ans = ((ld)total/(ld)x);

   	cout<<ans;





    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=998244353;
#define INF 2*1e9
#define N 510000
using namespace std;

ll divide(ll y){
    ll x=y;
    if(y==0) return 0;
    while(x%2==0){
        x/=2;
    }
    return (y/x);
}
int a[100001][3];
ll ans=0,l;
void dfs(int x,int y){
    if(a[x][0]==2){
        dfs(a[x][1],y+1);
        dfs(a[x][2],y+1);
    }
    if(a[x][0]==1){
    ans^=divide(l-y);
    if(a[x][1])dfs(a[x][1],y+1);
    if(a[x][2])dfs(a[x][2],y+1);
    }
    return;
}
main(){
    ll n;
    cin>>n>>l;
    string s[100001];
    rep(i,n){
        cin>>s[i];
    }
    int pos=0,temp=0;
    rep(i,n){
        rep(j,s[i].size()){
            int t=1+(s[i][j]-'0');
            if(a[temp][t]==0){
                a[temp][0]++;
                a[temp][t]=++pos;
            }
            temp=a[temp][t];
        }
        temp=0;
    }
    dfs(0,0);
    cout<<(ans==0?"Bob":"Alice");
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#define MAX 100005
#define NIL -1
using namespace std;

struct Node{
    int p;
    int l;
    int r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

//再帰的に深さを求める
void rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p); //右の兄弟に同じ深さを設定
    if(T[u].l != NIL) rec(T[u].l, p + 1); //最も左の子に自分の深さ+1を設定
}

int main(){
    int i, j, d, v, c, l, r;
    cin >> n;
    for(i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = -1;

    for(i = 0; i < n; i++){
        cin >> v >> d;
        for(j = 0; j < d; j++){
            cin >> c;
            if(j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(i = 0; i < n; i++){
        if(T[i].p == NIL) r = i;
    }
    rec(r, 0);

    for(i = 0; i < n; i++) print(i);

    return 0;
}


Measured memory_bytes: 7764
///Suvom Som
#include<iostream>
#include<map>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;

using namespace std;

struct node{
    ll fre, f;
};

node ara[200000];

int main(void)

{
    ll n, m, i, a, p = 0, s1 = 0;
    fast;
    cin>>n>>m;
    string s;
    for(i = 0; i < m; i++){
        cin>>a>>s;
        if(s == "WA"){
            if(ara[a].f == 0){
                ara[a].fre++;
            }
        }
        else{
            if(ara[a].f == 0){
                ara[a].f = 1;
                p += ara[a].fre;
                s1++;
            }
        }
    }
    cout<<s1<< " "<<p<<endl;
    return 0;
}


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

int main() {
    
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    long long total = 1000;
    long long  stocks = 0;
    for(int i = 0;i<n-1;i++)
    {
        if(v[i] < v[i+1])
        {
            stocks = total/v[i];
            total += stocks*(v[i+1] - v[i]);
        }
    }
    
    cout<<total;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3580
// 01/06/2020  @ 12:20:00
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define pi 3.14159265
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
bool rev(int a, int b) {
    return a > b;
}
// *****************************************************************
// *****************************************************************
int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("C:/Users/Mr.Tanishq/Desktop/noc/input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("C:/Users/Mr.Tanishq/Desktop/noc/output.txt", "w", stdout);
    // #endif
    // *****************************************************************
    // *****************************************************************
    int t = 1;
    while(t--) {
        int n;
        cin >> n;
        ll dp[n][3];
        fr(i, n) {
            fr(j ,3) cin >> dp[i][j];
        }

        for(int i = n - 2; i > -1; i--) {
            for (int j = 0; j < 3; ++j) {
                int x = 0;
                if(j == 0) {
                    x = MAX(dp[i + 1][1], dp[i + 1][2]);

                }
                else if(j == 1) {
                    x = MAX(dp[i + 1][0], dp[i + 1][2]);
                }
                else {
                    x = MAX(dp[i + 1][0], dp[i + 1][1]);
                }
                dp[i][j] += x;
            }
        }
        cout << MAX(dp[0][1], MAX(dp[0][2], dp[0][0])) << "\n";



    }
    return 0;
}

Measured memory_bytes: 2560
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n", (a * n <= b) ? (a * n) : b);
	return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

flags = [True]*n

for i in range(m):
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        flags[ab[i][0]-1] = False
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        flags[ab[i][1]-1] = False
    else:
        flags[ab[i][0]-1] = False
        flags[ab[i][1]-1] = False
    # print(ab[i][0]-1, ab[i][1]-1)
    # print(h[ab[i][0]-1], h[ab[i][1]-1])
    # print(flags)
print(flags.count(True))


Measured memory_bytes: 32020