akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    for (int d = 60; d >= -1; --d) {
        if (d != -1 && !(k & (1LL<<d))) continue;
        ll tmp = 0;
        for (int e = 60; e >= 0; --e) {
            ll mask = 1LL << e;
            ll num = 0;
            rep(i, n) if (a[i] & mask) ++num;
            if (e > d) {
                if (k & mask) {
                    tmp += mask * (n - num);
                }
                else {
                    tmp += mask * num;
                }
            }
            else if (e == d) {
                tmp += mask * num; 
            }
            else {
                tmp += mask * max(num, n-num);
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3980
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
    int x,y,bj=0;
    cin>>x>>y;
    for(int i=0;i<=x;i++)
        if((2*i)+(x-i)*4==y)
            bj=1;
    if(bj==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  int mx=a[0];
  int mn=a[0];
  int ans=0;

  for(int i=0;i<N;i++){
    if(a[i]<=mn) ans++;
    mx=max(a[i],mx);
    mn=min(a[i],mn);
  }
cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int K;
	cin >> K;

	priority_queue<P, vector<P>, greater<P>> que;
	vector<int> min_cost(K, -1);
	for(int i=1;i<10;i++) {
		que.emplace(i, i % K);
		min_cost[i % K] = i;
	}

	while(!que.empty()) {
		auto p = que.top();
		que.pop();
		int cost = p.first;
		int m = p.second;
		if (min_cost[m] < cost) continue;

		if(m == 0) {
			cout << cost << endl;
			return 0;
		}
		{
			int next_m = m;
			while (true) {
				next_m = (m * 10) % K;
				if (min_cost[next_m] == -1 || min_cost[next_m] > cost) {
					min_cost[next_m] = cost;
					que.emplace(cost, next_m);
				} else {
					break;
				}
			}
		}
		for(int i=1;i<10;i++) {
			int next_cost = cost + i;
			int next_m = (m * 10 + i) % K;
			if (min_cost[next_m] == -1 || min_cost[next_m] > next_cost) {
				min_cost[next_m] = next_cost;
				que.emplace(next_cost, next_m);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2804
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

A, B, C, K = ds_in()


if K % 2 == 0:
    print(A-B)
else:
    print(B-A)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>


using namespace std;

const int maxn = 1e5 + 5;

int r,c,n;
int x[maxn][2],y[maxn][2];

int id(int x,int y){
    if(x == 0) return 1;
    if(y == c) return 2;
    if(x == r) return 3;
    if(y == 0) return 4;
    return 0;
}

struct Point{
    int x,y;
    int i;
    Point(int x = 0,int y = 0,int i = 0):x(x),y(y),i(i){}
    bool operator < (const Point & rhs)const{
        int id1 = id(x,y);
        int id2 = id(rhs.x,rhs.y);
        if(id1 != id2)return id1 < id2;
        if(id1 == id2){
            if(id1 == 1){
                return y < rhs.y;
            }else if(id1 == 2){
                return x < rhs.x;
            }else if(id1 == 3){
                return y > rhs.y;
            }else return x > rhs.x;
        }
        return 1;
    }
}p[maxn * 2];


int main(){
    cin >> r >> c >> n;
    int tot = 0;
    for(int i = 1;i <= n;i++){
        scanf("%d%d%d%d",&x[i][0],&y[i][0],&x[i][1],&y[i][1]);
        if(id(x[i][0],y[i][0]) > 0 && id(x[i][1],y[i][1]) > 0){
           // cout << i << endl;
            p[tot++] = Point(x[i][0],y[i][0],i);
            p[tot++] = Point(x[i][1],y[i][1],i);
        }
    }
    sort(p,p + tot);
    stack<int> S;
    for(int i = 0;i < tot;i++){
        int t = p[i].i;
        if(!S.empty() && S.top() == t) S.pop();
        else S.push(t);
    }
    if(S.size() == 0)
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int n;
string s[1024];

int main(){
	
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			string t;
			cin>>t;
			for(int j=0;i;j++){
				if(t[j+1]!='.'){
					t[j]='+';
					break;
				}
				t[j]=' ';
			}
			s[i]=t;
		}
		for(int i=n-1;i>0;i--){
			int j;
			for(j=0;true;j++)if(s[i][j]=='+')break;
			for(int k=i-1;s[k][j]==' ';k--)s[k][j]='|';
		}
		for(int i=0;i<n;i++)cout<<s[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1804
a, b, c, k = map(int, input().split())
res = 0

if k <= a:
  res += k * 1
  print(res)
else:
  res += a * 1
  k -= a
  if k <= b:
    res += k * 0
    print(res)
  else:
    res += b * 0
    k -= b
    res += k * -1
    print(res)
    

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

int main() {
  int a,b,count;
  count = 0;
  string str;
  cin >> a >> b;
  for(a;a<=b;a++){
    str = to_string(a);
    if ((str[0]==str[4])&&(str[1]==str[3])){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
string a = "ACGT", b = "TGCA";
signed main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			int flg = 0;
			for (int k = i; k <= j; k++) {
				int flg2 = 0;
				rep(l, 4) {
					if (s[k] == a[l])flg2++;
				}
				if (!flg2)flg++;
			}
			if (!flg)ans = max(ans, j-i + 1);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){
    string S;
    int p = 700;
    cin >> S;

    if(S[0] == 'o'){
        p += 100;
    }
    if(S[1] == 'o'){
        p += 100;
    }
    if(S[2] == 'o'){
        p += 100;
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n: u32 = read();
    let res = vec![1,2,4,8,16,32,64];
    let ans = (1..n+1).filter(|x| res.contains(&x)).max().unwrap();
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, q;
    cin >> n >> q;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    ll x[q];
    rep(i, q) {
        cin >> x[i];
    }
    reverse(a, a + n);
    ll sum[n + 1] = {}, sumeven[n + 1] = {};
    rep(i, n) {
        sum[i + 1] = sum[i] + a[i];
        sumeven[i + 1] = sumeven[i] + (i % 2 == 0 ? a[i] : 0);
    }
    rep(i, q) {
        auto isOK = [&](int w) {
            if (w >= (n + 1) / 2) return true;
            return 2 * x[i] - a[w] - a[2 * w] > 0;
        };
        int ng = 0, ok = INF;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (isOK(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        cout << sum[ok] + (2 * ok < n ? sumeven[n] - sumeven[2 * ok] : 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<pair<ll, ll>> pq;
    for(int i = 0; i < n; i++){
        int a;
        cin>>a;
        pq.push(make_pair(a, 1));
    }
    for(int i = 0; i < m; i++){
        int b,c;
        cin>>b>>c;
        pq.push(make_pair(c,b));
    }
    ll ans = 0LL;
    while(n--){
        pair<int,int> p = pq.top();
        pq.pop();
        ans += p.first;
        if(p.second>1){
            p.second--;
            pq.push(p);
        }
    }
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;

    map<char, vector<int>> m;
    for(int i=0; i<=13; ++i) m['S'].push_back(0);
    for(int i=0; i<=13; ++i) m['H'].push_back(0);
    for(int i=0; i<=13; ++i) m['C'].push_back(0);
    for(int i=0; i<=13; ++i) m['D'].push_back(0);

    for(int i=0; i<n; ++i) {
        char s;
        int x;
        cin >> s >> x;
        m[s][x] = 1;
    }

    for(int i=1; i<=13; ++i) {
        if (m['S'][i] == 0) cout << 'S' << " " << i << endl;
    }
    for(int i=1; i<=13; ++i) {
        if (m['H'][i] == 0) cout << 'H' << " " << i << endl;
    }
    for(int i=1; i<=13; ++i) {
        if (m['C'][i] == 0) cout << 'C' << " " << i << endl;
    }
    for(int i=1; i<=13; ++i) {
        if (m['D'][i] == 0) cout << 'D' << " " << i << endl;
    }

    return 0;
}


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

class WeLoveWolf
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var number = Console.ReadLine().Split(' ');
        var ans = "NG";

        for(var i =int.Parse(number[0]); i <= int.Parse(number[1]);i++)
        {
            if(i % input == 0)
            {
                ans = "OK";
                break;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17900
import java.util.*;

// ARC 86-D
// https://beta.atcoder.jp/contests/arc086/tasks/arc086_b

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] cost = new int[N];
		int[] start = new int[N];
		int[] freq = new int[N];
		
		for (int i = 0; i < N - 1; i++) {
			cost[i] = in.nextInt();
			start[i] = in.nextInt();
			freq[i] = in.nextInt();
		}
		
		long[] answer = new long[N];
		for (int i = 0; i < N - 1; i++) {
			long sec = start[i] + cost[i];
			for (int j = i + 1; j < N - 1; j++) {
				if (sec <= start[j]) {
					sec = start[j] + cost[j];
				} else {
					int n = 1;
					while (start[j] + n * freq[j] < sec) {
						n++;
					}
					sec = start[j] + n * freq[j];
					sec += cost[j];
				}
			}
			answer[i] = sec;
		}
		
//		int[] distance = new int[N];
//		for (int i = N - 2; i >= 0; i--) {
//			if (i == N - 2) {
//				distance[i] = cost[i];
//			} else {
//				int sec = cost[i];
//				// Check how long it has to wait at the next station
//				while (sec % freq[i + 1] != 0) {
//					sec++;
//				}
//				distance[i] = sec + distance[i + 1];
//			}
//		}
//		
//		System.out.println("distance");
//		for (int i = 0; i < N; i++) {
//			System.out.printf("%d => %d: %d\n", i + 1, N, distance[i]);
//		}
//		
////		int[] answer = new int[N];
//		
//		for (int i = N - 2; i >= 0; i--) {
//			if (i == N - 2) {
//				answer[i] = cost[i] + start[i];
//			} else {
//				if (start[i] + cost[i] <= start[i + 1]) {
//					answer[i] = answer[i + 1];
//				} else {
//					int a = start[i] + cost[i];
//					int n = 1;
//					while (start[i + 1] + n * freq[i + 1] < a) {
//						n++;
//					}
//					answer[i] = start[i + 1] + n * freq[i + 1] + distance[i + 1];
//				}
//			}
//		}
		
		for (int i = 0; i < N; i++) {
			System.out.println(answer[i]);
		}
	}
}


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

int main() {
  string S; cin >> S;
  /*
  stack<string> T;
  T.push(S);
  while (!T.empty()) {
    string t = T.top();
    if (t == "") {
      cout << "YES" << endl;
      return 0;
    } else {
      T.pop();
      if (t.substr(0, 5) == "dream")
        T.push(t.substr(5));
      if (t.substr(0, 7) == "dreamer")
        T.push(t.substr(7));
      if (t.substr(0, 5) == "erase")
        T.push(t.substr(5));
      if (t.substr(0, 6) == "eraser")
        T.push(t.substr(6));
    }
  }
  cout << "NO" << endl;
  */
  while (S.length() >= 5) {
    if (S.substr(S.length()-5) == "dream")
      S = S.substr(0, S.length()-5);
    else if (S.substr(S.length()-5) == "erase")
      S = S.substr(0, S.length()-5);
    else if (S.length() >= 7 && S.substr(S.length()-7) == "dreamer")
      S = S.substr(0, S.length()-7);
    else if (S.length() >= 6 && S.substr(S.length()-6) == "eraser")
      S = S.substr(0, S.length()-6);
    else
      break;
  }
  if (S == "")
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

string s;
ll a[22];
ll dp[22][5][2][10];

int main(){
  cin>>s;
  ll n=s.size();
  rep(i,n)a[i]=s[i]-'0';
  dp[0][0][0][0]=1;
  rep(i,n){
    rep(j,5){
      rep(k,2){
        rep(l,10){
          rep(d,k==0?(a[i]+1):10){
            if(j==0){
              if(d==5){
                dp[i+1][j+1][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }else{
                dp[i+1][0][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }
            }else if(j==1){
              if(d==1){
                dp[i+1][j+1][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }else{
                dp[i+1][d==5][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }
            }else if(j==2){
              dp[i+1][j+1][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
            }else if(j==3){
              if(d==3){
                dp[i+1][j+1][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }else if(l==5&&d==1){
                dp[i+1][2][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }else{
                dp[i+1][d==5][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
              }
            }else if(j==4){
              dp[i+1][j][!(k==0&&(d==a[i]))][d]+=dp[i][j][k][l];
            }
          }
        }
      }
    }
  }
  ll res=0;
  rep(i,10)res+=(dp[n][4][0][i]+dp[n][4][1][i]);
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
long long n, m, ans;
long long gcd(long long a, long long b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	cin >> n >> m;
	m= gcd(n, m);
	for(long long i= 2; i * i <= m; i++) {
		if(m % i == 0) {
			++ans;
			while(m % i == 0) m/= i;
		}
	}
	if(m > 1) ++ans;
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	lint a, b, c; cin >> a >> b >> c;
	YES(!((100 * a + 10 * b + c) % 4));
	gc();
}

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

using namespace std;

int main()
{
    int x;
    cin >> x;

    std::set<int> values;
    for (int i = 1; i <= 9; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            values.insert(i * j);
        }
    }

    cout << (values.find(x) == values.end() ? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
for line in sys.stdin:
    a,b,c,d,e,f = map(int,line.strip().split(' '))
    x = (c*e - b*f) / (a*e - b*d)
    y = (c*d - a*f) / (b*d - a*e)
    print("{:.3f} {:.3f}".format(x+0, y+0))

Measured memory_bytes: 7576
#include<iostream>
using namespace std;
int main()
{
int a,i,j,k,l,m,n,o;
int A[5];
for(i=0;i<5;i++)
{
	cin>>A[i];
	}	
	for(j=0;j<5;j++)
	{
		if(A[j]>A[0])
		{
			a=A[0];
			A[0]=A[j];
			A[j]=a;
			a=0;
		}
	}
	for(k=1;k<5;k++)
	{
	if(A[k]>A[1])
		{
			a=A[1];
			A[1]=A[k];
			A[k]=a;
			a=0;
		}	
	}
	for(l=2;l<5;l++)
	{
	if(A[l]>A[2])
		{
			a=A[2];
			A[2]=A[l];
			A[l]=a;
			a=0;
		}	
	}
	for(m=3;m<5;m++)
	{
	if(A[m]>A[3])
		{
			a=A[3];
			A[3]=A[m];
			A[m]=a;
			a=0;
		}	
	}
	for(n=4;n<5;n++)
	{
	if(A[i]>A[4])
		{
			a=A[4];
			A[4]=A[n];
			A[n]=a;
			a=0;
		}	
	}
	for(o=0;o<4;o++)
	{
	cout<<A[o]<<" ";
	}
	cout<<A[4]<<endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int main()
{
	ll x,y; int c=0;
	cin>>x>>y;
	for(ll r=x;r<=y;r*=2) ++c;
	printf("%d\n",c);
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string S; cin>>S;
  string list="NSWE";
  vector<int> vec(4,0);
  for(auto cha:S) rep(i,4) if(cha==list[i]) vec[i]=1;
  
  ll sum=0;
  rep(i,4) sum+=vec[i];
  if(sum%2==1) {cout<<"No"<<'\n'; return 0;}
  if(sum==4) {cout<<"Yes"<<'\n'; return 0;}
  if(vec[0]&&vec[1]) {cout<<"Yes"<<'\n'; return 0;}
  if(vec[2]&&vec[3]) {cout<<"Yes"<<'\n'; return 0;}
  cout<<"No"<<'\n';
  return 0;
}

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


#define EPS (1e-10)
#define equal(a,b) (fabs((a)-(b)) < EPS)

class Point {
  public:

  double x,y;
  
  Point (double x = 0, double y = 0) : x(x),y(y) {}
 
  Point operator + (Point p) {
    return Point( x+p.x , y+p.y );
  }
  Point operator - (Point p) {
    return Point( x-p.x , y-p.y );
  }
  Point operator * (double a) {
    return Point( a*x , a*y );
  }
 
  double abs() {
    return sqrt(norm());
  }
  double norm() {
    return x*x+y*y;
  }
 
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
 
  bool operator == (const Point &p) const {
    return equal( x,p.x )&& equal( y,p.y );
  }
};

typedef Point Vector;
 
double dot(Vector a,Vector b) {
  return a.x*b.x + a.y*b.y;
}
 
double cross(Vector a,Vector b) {
  return a.x*b.y - b.x*a.y;
}

Vector rotation(Vector vec,double si,double co){
  Vector res;
  res.x = vec.x*co - vec.y*si;
  res.y = vec.x*si + vec.y*co;
  return res;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
 
int ccw( Point p0 , Point p1 , Point p2 ) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a,b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a,b) < -EPS ) return CLOCKWISE;
  if( dot(a,b) < -EPS ) return ONLINE_BACK;
  if( a.norm() < b.norm() ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

class Segment{
    public:
    Point p1, p2;
    Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};
typedef Segment Line;

Point getCrossPointLL(Line l1,Line l2){
  Point p1=l1.p1,p2=l1.p2;
  Point q1=l2.p1,q2=l2.p2;
  Point res;
  res= p1+(p2-p1)*( cross(q2-q1,q1-p1)/cross(q2-q1,p2-p1) );
  return res;
}

double calcArea(vector<Point> &po){
  int size=po.size();
  if(size<3)return 0.0;
  double res=0.0;
  for(int i=1;i+1<size;i++){
    res+=fabs(cross(po[i]-po[0],po[i+1]-po[0]));
  }
  return res*0.5;
}

double cutC(vector<Point> &t,Line li){
  int n=t.size();
  vector<Point> u;
  int A[200];
 
  for(int i=0;i<n;i++)A[i]=ccw(li.p1,li.p2,t[i]);
 
  for(int i=0;i<n;i++){
    if(A[i]!=CLOCKWISE)u.push_back(t[i]);
    int j=(i+1)%n;
    if(A[i]==COUNTER_CLOCKWISE
       &&A[j]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
    else if(A[j]==COUNTER_CLOCKWISE
            &&A[i]==CLOCKWISE)
      u.push_back( getCrossPointLL(Line(t[i],t[j]),li));
  }
  
  return calcArea(u);
}


int n,m;
double d,V;
vector<Point> G;


int main(){
  cin>>n;
  G.resize(n);
  for(int i=0;i<n;i++)cin>>G[i].x>>G[i].y;
  Segment se;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>se.p1.x>>se.p1.y>>se.p2.x>>se.p2.y;
    printf("%.10f\n",cutC(G,se));
  }
  return 0;
}

Measured memory_bytes: 1256
package main

import (
  "fmt"
)

func main(){
  var x int
  fmt.Scan(&x)

  i := 100
  var c int
  for i<=x {
    if i >= x {
      break
    }
    c++
    i = int(float64(i) * 1.01)
  }
  fmt.Println(c)
}


Measured memory_bytes: 1756
#include<iostream>
#include<cstring>
#include<map>
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;

int h[100100];
P wpar[100100];
int rank[1000100];

void init_wuf(int n){
  for(int i=0;i<n;i++)wpar[i] = P(i,0);
}
 
P wfind(int a){
  if(wpar[a].fs == a)return wpar[a];
  P tmp = wfind(wpar[a].fs);
  return wpar[a] = P(tmp.fs,tmp.sc + wpar[a].sc);
}
 
bool wsame(int a,int b){
  return (wfind(a).fs == wfind(b).fs);
}
 
bool wunite(int a,int b,int cost){
  P x = wfind(a);
  P y = wfind(b);
   
  if(wsame(x.fs,y.fs)){
    if(y.sc - x.sc != cost)return false;
  }else{
    if(rank[x.fs]<rank[y.fs]){
      wpar[x.fs] = P(y.fs,y.sc-x.sc-cost-h[a]+h[b]);
    }else{
      wpar[y.fs] = P(x.fs,x.sc-y.sc+cost+h[a]-h[b]);
      if(rank[x.fs] == rank[y.fs])rank[x.fs]++;
    }
  }
  return true;
}

int wdis(int a, int b){
  return wfind(b).sc - wfind(a).sc;
}

int main(){
  int n,q,a,b,c;
  string com;
  cin >> n >> q;
  memset(h,0,sizeof(h));
  init_wuf(n+1);

  for(int i=0;i<q;i++){
    cin >> com;
    if(com=="IN"){
      cin >> a >> b >> c;
      h[a] += c; h[b] += c;
      wunite(a,b,c);
    }else{
      cin >> a >> b;
      if(!wsame(a,b)){
	cout << "WARNING\n";
      }else{
	cout << wdis(a,b)+h[b]-h[a] << endl;
      }
    }
  }
}

Measured memory_bytes: 4656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    string s[n];
    int t[n];
    rep(i, n) cin>>s[i]>>t[i];
    string x;
    cin>>x;
    rep(i, n)if(s[i]==x){
        int ans=0;
        For(j, i+1, n) ans+=t[j];
        printf("%d\n", ans);
        return 0;
    }
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  int su = 0;
  for(int i=1;i<=n;++i) {
    su+=i;
    // if(i % 2 == 1 && su % 2 == 1) cout << i * (i+1) / 2 << endl;
  }

  int d = -1;
  for(int i=2;i*i<=su;++i) {
    if(su % i == 0) {
      d = i;
      break;
    }
  }

  // cout << d << endl;

  vector<vector<int>> ans(d);
  vector<int> tmp(d, su/d);

  for(int i=n;i>=1;--i) {
    for(int j=0;j<d;++j) {
      // cout << i << ":" << j << endl;
      if(tmp[j] - i >= 0) {
        ans[j].push_back(i);
        tmp[j] -= i;
        break;
      }
    }
  }

  // cout << d << endl;

  int sz = 0;
  for(int i=0;i<d;++i) {
    for(int j=i+1;j<d;++j) {
      // cout << sz << endl;
      sz += ans[i].size() * ans[j].size();
    }
  }
  cout << sz << endl;

  for(int i=0;i<d;++i) {
    for(int j=i+1;j<d;++j) {
      for(int k=0;k<(int)(ans[i].size());++k) {
        for(int l=0;l<(int)(ans[j].size());++l) {
          cout << ans[i][k] << " " << ans[j][l] << endl;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int A[100005];
int main() {
	int K;
	scanf("%d", &K);
	for (int i = 0; i < K; ++i) scanf("%d", &A[i]);
	ll lo = 2, hi = 2;
	for (int i = K - 1; i >= 0; --i) {
		ll mlo = (lo + A[i] - 1) / A[i] * A[i];
		ll mhi = hi / A[i] * A[i];
		if (mlo <= hi) {
			lo = mlo;
			hi = mhi + A[i] - 1;
		} else {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n", lo, hi);
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
string S[18] = { "","Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts" };
int N, M;
int X[100];
void mul(int N){
	int Y[100];
	for (int i = 0; i < 100; i++)Y[i] = X[i]*N;
	int ku = 0;
	int co = 0;
	while (ku < 100){
		Y[ku] += co;
		co = Y[ku] / 10;
		Y[ku] %= 10;
		ku++;
	}
	for (int i = 0; i < 100; i++)X[i] = Y[i];
}
int main()
{
	while (true){
		for (int i = 0; i < 100; i++)X[i] = 0;
		scanf("%d%d", &M, &N);
		if (M == 0 && N == 0)break;
		if (M < 10)X[0] = M;
		else{
			X[0] = M % 10;
			X[1] = M / 10;
		}
		for (int i = 1; i < N; i++)mul(M);
		for (int i = 71; i >= 3; i -= 4){
			int Sum = X[i] * 1000 + X[i - 1] * 100 + X[i - 2] * 10 + X[i - 3];
			if (Sum != 0){
				if (i == 3)printf("%d", Sum);
				else{
					printf("%d", Sum);
					cout << S[i / 4] ;
				}
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1232
n, k = map(int, input().split())

ans1 = (n//k)**3
ans2 = 0
if k % 2 == 0:
    if n % k >= k // 2:
        ans2 = (n//k+1)**3
    else:
        ans2 = (n//k)**3
print(ans1+ans2)

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    int n;
    std::cin >> n;
    int a[n] = {};

    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    int mini;
    int op = 0;
    for (int i = 0; i < n; ++i) {
        mini = i;
        for (int j = i; j < n; ++j) {
            if (a[j] < a[mini]) {
                mini = j;
            }
        }
        if (i != mini) {
            std::swap(a[i], a[mini]);
            op++;
        }
    }

    for (int i = 0; i < n; ++i) {
        std::cout << a[i];
        if (i == (n -1)) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }

    std::cout << op << std::endl;

    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	vi a(3);
	rep(i, 3) cin >> a[i];
	int k;
	cin >> k;

	priority_queue<int> pq;
	rep(i, 3) pq.push(a[i]);

	rep(i, k)
	{
		int n = pq.top();
		pq.pop();
		pq.push(n * 2);
	}
	int ans = 0;
	rep(i, 3)
	{
		ans += pq.top();
		cerr << pq.top() << endl;
		pq.pop();
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a*c <= b)
    {
        cout << c << endl;
    }
    else
    {
        cout << b/a << endl;
    }
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int MOD = 1000000007;
const int INF = 1000000007;

struct Query
{
    int a, b, c, d;
};

int n, m, q;

int ans;

Query queries[51];

void gen(int index, int sum, string s)
{
    if(index == m)
    {
        int t = 0;
        int arr[n];
        int ind = 0;
        for(int i=0; i<m; i++)
        {
            int x = s[i] - '0';
            for(int j=0; j<x; j++)
            {
                arr[ind] = i+1;
                ind++;
            }
        }
//        for(int i=0; i<n; i++)
//        {
//            cout << arr[i] << " ";
//        }
//        cout << "\n";
        for(int i=0; i<q; i++)
        {
            int y = queries[i].b;
            int x = queries[i].a;
            if(arr[y] - arr[x] == queries[i].c)
            {
                t += queries[i].d;
            }
        }
        ans = max(t, ans);
        return;
    }
    if(index == m-1)
    {
        int need = n-sum;
        s += (need + '0');
        gen(index+1, 0, s);
        s.pop_back();
        return;
    }

    for(int i=0; i<=n-sum; i++)
    {
        s += (i + '0');
        gen(index+1, i+sum, s);
        s.pop_back();
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> q;
    for(int i=0; i<q; i++)
    {
        cin >> queries[i].a >> queries[i].b >> queries[i].c >> queries[i].d;
        queries[i].a--;
        queries[i].b--;
    }
    gen(0, 0, "");
    cout << ans;

    return 0;
}


Measured memory_bytes: 3592
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long M = 1e9 + 7;
const int lg = 21;

ll n, k, ans;

ll f(ll b){
	ll now = k, ans = 0;
	while(now <= n){
		ll nxt = now + (b - 1 - k);		
		nxt = min(nxt, n);
		ans += (nxt - now + 1);
		now = nxt + 1;
		now += k;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	if(k == 0)
		return cout << (ll)n * n << endl, 0;
	for(int b = k + 1; b <= n; b++)
		ans += f(b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);

	if (a < b)

		if (b < c)
			printf("Yes\n");
		else
			printf("No\n");
	else
		printf("No\n");


	return 0;
}

Measured memory_bytes: 1008
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
static const int MAX_N = 300;

int N;
int num[3];
double memo[MAX_N + 1][MAX_N + 1][MAX_N + 1];

double rec(int a, int b, int c){
	if(a == 0 && b == 0 && c == 0) return 0.0;
	if(memo[a][b][c] > -1.0) return memo[a][b][c];
	double add = (double)N / (double)(a + b + c);
	double ret = 0.0;
	if(a > 0) ret += (rec(a - 1, b, c) + add) * (double)a / (double)(a + b + c);
	if(b > 0) ret += (rec(a + 1, b - 1, c) + add) * (double)b / (double)(a + b + c);
	if(c > 0) ret += (rec(a, b + 1, c - 1) + add) * (double)c / (double)(a + b + c);
	return memo[a][b][c] = ret;
}
int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		a--;
		num[a]++;
	}
	fill(memo[0][0], memo[N + 1][0], -1.0);
	printf("%.10lf\n", rec(num[0], num[1], num[2]));
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);

    int cnt = 0;
    int mh = h.at(0);
    for(int i=0; i<n; i++){
        if(mh<=h.at(i)){
            mh = h.at(i);
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

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

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Solve s = new Solve();
		s.solve();
	}
}

class Solve{
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()) {
			int n = in.nextInt();
			if(n == 0) return;
			ArrayList<ArrayList<Integer>> al = new ArrayList<ArrayList<Integer>>();
			for(int i = 0; i< n; i++) {
				int m = in.nextInt();
				ArrayList<Integer> a = new ArrayList<Integer>();
				for(int j = 0 ; j < m; j++) {
					int t = in.nextInt();
					a.add(t);
				} 
				al.add(a);
			}
			int k = in.nextInt();
			boolean[] f = new boolean[1001];
			for(int i = 0; i < k; i++){
				int t = in.nextInt();
				f[t] = true;
			}
			int ans = 0;
			for(int i = 0; i < n; i++){
				int cnt = 0;
				for(int j = 0; j < al.get(i).size(); j++){
					if(f[al.get(i).get(j)]) cnt++;
				}
				if(cnt == k){
					if(ans == 0) ans = i + 1;
					else ans = -1;
				}
			}
			if(ans == 0) ans = -1;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 70320
#include <bits/stdc++.h>
using namespace std;
unordered_map <int,int> mp;
int n,x;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        mp[x]++;
        if(mp[x]>1)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 8520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static class Dice {
		private String top;
		private String bottom;
		private String front;
		private String back;
		private String left;
		private String right;

		public Dice(
				String top,
				String front,
				String right,
				String left,
				String back,
				String bottom)
		{
			this.top = top;
			this.front = front;
			this.right = right;
			this.left = left;
			this.back = back;
			this.bottom = bottom;
		}

		public String operationE() {
			String tmp = this.top;
			this.top = this.left;
			this.left = this.bottom;
			this.bottom = this.right;
			this.right = tmp;

			return this.top;
		}

		public String operationN() {
			String tmp = this.top;
			this.top = this.front;
			this.front = this.bottom;
			this.bottom = this.back;
			this.back = tmp;

			return this.top;
		}

		public String operationS() {
			String tmp = this.top;
			this.top = this.back;
			this.back = this.bottom;
			this.bottom = this.front;
			this.front = tmp;

			return this.top;
		}

		public String operationW() {
			String tmp = this.top;
			this.top = this.right;
			this.right = this.bottom;
			this.bottom = this.left;
			this.left = tmp;

			return this.top;
		}

		public String getTop() {
			return top;
		}

		public String getBottom() {
			return bottom;
		}

		public String getFront() {
			return front;
		}

		public String getBack() {
			return back;
		}

		public String getLeft() {
			return left;
		}

		public String getRight() {
			return right;
		}

	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] label1 = br.readLine().split(" ");
		String[] label2 = br.readLine().split(" ");

		Dice dice1 = new Dice(label1[0], label1[1], label1[2], label1[3], label1[4], label1[5]);
		Dice dice2 = new Dice(label2[0], label2[1], label2[2], label2[3], label2[4], label2[5]);

		for (int i = 0; i < 4; i++) {

			dice2.operationS();

			for (int j = 0; j < 4; j++) {

				dice2.operationW();

				if (dice1.getTop().equals(dice2.getTop()) &&
					dice1.getBottom().equals(dice2.getBottom()) &&
					dice1.getFront().equals(dice2.getFront()) &&
					dice1.getBack().equals(dice2.getBack()) &&
					dice1.getRight().equals(dice2.getRight()) &&
					dice1.getLeft().equals(dice2.getLeft()))
				{

					System.out.println("Yes");
					return;

				}
			}
		}

		dice2.operationW();

		for (int i = 0; i < 4; i++) {

			dice2.operationS();

			for (int j = 0; j < 4; j++) {

				dice2.operationW();

				if (dice1.getTop().equals(dice2.getTop()) &&
					dice1.getBottom().equals(dice2.getBottom()) &&
					dice1.getFront().equals(dice2.getFront()) &&
					dice1.getBack().equals(dice2.getBack()) &&
					dice1.getRight().equals(dice2.getRight()) &&
					dice1.getLeft().equals(dice2.getLeft()))
				{

					System.out.println("Yes");
					return;

				}
			}
		}

		System.out.println("No");

	}
}

Measured memory_bytes: 24420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

const double PI = 3.14159265358979;

long long SUM = 0;

void printArr(int a[], int len) {

	for (int i = 0; i < len; i++)
	{
		if (i == 0) cout << a[0];
		else cout << " " << a[i];
	}
	cout << endl;
}


int solve(int a[], int len, int MINX, int MAXX) {

	bool* visited = new bool[len];
	int* b = new int[len];
	for (int i = 0; i < len; i++) {
		b[i] = a[i];
		visited[i] = false;
	}
	sort(b, b + len);

	int* book = new int[MAXX + 1];
	for (int i = 0; i < len; i++) {
		book[b[i]] = i;
	}

	int res = 0;
	for (int i = 0; i < len; i++) {
		if (visited[i]) continue;

		int sum = 0;
		int minw = INT_MAX;
		int next = i;
		int count = 0;
		while (!visited[next]) {		// 一个圈
			visited[next] = true;
			int weight = a[next];
			next = book[a[next]];

			if (minw > weight) minw = weight;
			sum += weight;
			count++;
		}
		res += min(sum + (count - 2) * minw, sum + minw + (count + 1) * MINX);
	}
	

	delete[] b;
	delete[] visited;
	delete[] book;
	return res;
}

int main() {

	int n; cin >> n;

	int* a = new int[n];
	int MINX = INT_MAX;
	int MAXX = INT_MIN;
	for (int i = 0; i < n; i++)	{
		scanf("%d", &a[i]);
		if (MINX > a[i]) MINX = a[i];
		if (MAXX < a[i]) MAXX = a[i];
	}

	int res = solve(a, n, MINX, MAXX);

	cout << res << endl;
	
	delete[] a;
	return 0;
}



Measured memory_bytes: 3248
n,k = map(int, raw_input().split())
score,d,cd = 0,None,0
s = raw_input()
for i,l in enumerate(s):
	if d != l:
		cd +=1
		d = l
	if i and s[i-1] == s[i]:  score += 1


if cd > 2:
	t = min(k,((cd - 2)+1)/2)
	k -= t
	score += 2 * t 
	cd -= 2 * t
if cd == 2 and k:
	score +=1
	cd -= 1
print score


Measured memory_bytes: 32540
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, C, D; cin >> A >> B >> C >> D;
    cout << ((C + B - 1) / B > (A + D - 1) / D ? "No" : "Yes") << "\n";
}

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

int main ()
{
    stack<int> Polish;
    string str;
    int op1, op2;
    while(cin >> str)
    {
        if (str != "+" && str != "-" && str != "*" && str != "/")
        {
            int num = 0;
            for (int i = 0;i < str.size();i++)
            {
                num *= 10;
                num += str[i] - '0';
            }
            Polish.push(num);
        }
        else
        {
            op2 = Polish.top();
            Polish.pop();
            op1 = Polish.top();
            Polish.pop();
            switch (str[0])
            {
                case '+': op1 += op2; break;
                case '-': op1 -= op2; break;
                case '*': op1 *= op2; break;
                case '/': op1 /= op2; break;
            }
            Polish.push(op1);
        }
    }
    
    op1 = Polish.top();
    Polish.pop();
    cout << op1 << endl;
    return 0;
}


Measured memory_bytes: 3172
def digit(a,b):
    a = str(a)
    b = str(b)
    return max(len(a),len(b))

def makedivisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n//i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
l = makedivisors(n)
m = 10**9
for a in range(len(l)):
    for b in range(len(l)):
        if l[a] * l[b] == n:
            m = min(m,digit(l[a],l[b]))
print(m)
    


Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
using ll = long long;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=int(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1000000007;
using namespace std;

int main() {
    string s, t; cin >> s >> t;
    int n = s.size();
    int m = t.size();
    bool flag = false;
    for(int i=n-m+1; i>=0; --i){
        if(s[i]==t[0]||s[i]=='?'){
            int index = 0;
            while(s[i+index]==t[index]||s[i+index]=='?'){
                index++;
                if(index==m) {
                    flag = true;
                    break;
                }
            }
            if(flag){
                for(int j=0; j<index; ++j) s[i+j]=t[j];
                break;
            }
        }
    }
    if(flag){
        for(int i=0; i<n; ++i){
            if(s[i]=='?') cout << "a";
            else cout << s[i];
        }
        cout << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }           
	return 0;
}

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

int main()
{
  int N;
  char c[101];
  bool res=false;
  cin >> N;

  rep(i,N) cin >> c[i];

  rep(i,N){
    if(c[i]=='Y') res=true;
  }

  if(res) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256