akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

string S;
int cnt;
const int MAX = 9999;

bool asc(char c){
  if( S[cnt] != c ) return false;
  cnt++; return true;
}

bool valnum(int n){
  return 0 <= n && n <= MAX;
}

int num(){
  int ret = 0;
  while( isdigit( S[cnt] ) ){
    char c = S[cnt]; asc(c);
    ret *= 10;
    ret += c-'0';
    if( !valnum( ret ) ) throw 1;
  }
  return ret;
}


string ops = "+-*";
bool valop(char op){
  for( char c :ops )
    if( op == c ) return true;
  return false;      
}

int calc( int r1,int r2, char op){
  if( op == '+' )
    return r1+r2;
  if( op == '-' )
    return r1-r2;
  if( op == '*' )
    return r1*r2;
  throw 4;
}


int calc(){
  int R1 = num();
  for(;;){
    char op = S[cnt];
    if (op == '=') break;
    if (!valop(op)) throw 2;
    asc(op);
    int R2 = num();
    R1 = calc(R1,R2,op);
    if( !valnum(R1) ) throw 5;
  }
  asc('=');
  if( !valnum(R1) ) throw 3;
  return R1;
}

void solve(){
  cnt = 0;
  try {
    cout << calc() << endl;
  } catch (int e){
    cout << "E" << endl;
  }
}

int main(){
  while( cin >> S ){
    solve();
  }
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define pb push_back
#define eb emplace_back
const  int MAX=1000000;

int main()
{

    ll t;

   t=1;


    while(t--)
    {

    string str;

    cin>>str;


    ll cnt=0,ans=0;
    for(ll i=0;str[i];i++)
    {
        if(str[i]=='R')cnt++;
        else {

            ans=max(cnt,ans);
            cnt=0;
        }


    }
       ans=max(cnt,ans);


       cout<<ans<<endl;


    }
}




Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N;
    int buf,A=0,B=0;
    vector<int> a;

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&buf);
        a.push_back(buf);
    }
    
    sort(a.begin(),a.end(),greater<int>());

    for(int i=0;i<N;i++){
        if(i%2==0)
            A+=a[i];
        else
            B+=a[i];
    }

    printf("%d\n",A-B);
    return 0;
}


Measured memory_bytes: 256
def max_zero(t, n):
    if n % 2 == 1:
        n = (n-1) / 2
        t += 1
        return(max_zero(t, n))
    else:
        return t


d, g = [int(_) for _ in input().split()]
l = [0] * d
for i in range(d):
    p, c = [int(_) for _ in input().split()]
    all_score = (i+1)*100*p + c
    l[i] = [p, all_score]

n = 2**d
ans = float('inf')
for i in range(n):
    total = 0
    p_total = 0
    st = '0' + str(d) + 'b'
    n_bin = format(i, st)
    for j in range(d):
        if n_bin[j] == '1':
            total += l[j][1]
            p_total += l[j][0]
    if total >= g:
        ans = min(ans, p_total)
    else:
        b = g - total
        y = max_zero(0, i)
        a = d * 100 - 100 * y
        if b % a == 0:
            u = b // a
        else:
            u = (b // a) + 1
        if u <= l[d-1-y][0]-1:
            ans = min(ans, p_total + u)
print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N,K;
    cin >> N;
    set<ll> A;
    for(int i = 0;i< N;i++){
        ll a;
        cin >> a;
        A.insert(a);
    }
    if(A.size() == N){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD1 = 998244353;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
const int nul = 0;
const int SIZE = 1e6 * 3;



signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    int q;
    q = 1;
    while (q--) {
        int n;
        cin >> n;
        vector<int> a(n), b(n);
        for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
        int sum = 0;
        int ans = 0;
        for (int i = n - 1; i >= 0; i--) {
            a[i] += sum;
            int res = (b[i] - a[i] % b[i]) % b[i];
            ans += res;
            sum += res;
            //cout << res << " " << endl;
        }
        cout << ans << endl;
    }
}












Measured memory_bytes: 4768
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    a_list = li()
    b_list = li()

    monster = 0
    for index in range(n):
        monster_add = min(a_list[index], b_list[index])
        monster = monster + monster_add
        a_list[index] = a_list[index] - monster_add
        b_list[index] = b_list[index] - monster_add

        monster_add = min(a_list[index + 1], b_list[index])
        monster = monster + monster_add
        a_list[index + 1] = a_list[index + 1] - monster_add
        b_list[index] = b_list[index] - monster_add
    print(monster)


Measured memory_bytes: 82148
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int x = 0;
        int y = 0;
        int t = 0;
        int N = ReadLineParseInt();
        for(int i = 0; i < N; i++)
        {
            int[] txy = ReadLineParseIntArray();
            t = txy[0] - t;
            x = Abs(txy[1] - x);
            y = Abs(txy[2] - y);
            if(x + y > t ||
                (x + y) % 2 != t % 2)
            {
                for (int j = i + 1; j < N; j++)
                    ReadLine();
                WriteLine("No");

                return;
            }
        }
        WriteLine("Yes");
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

int main() {
  // 標準ライブラリからstackを使用
  stack<int> S;
  int a, b;
  string s;

  while( cin >> s ){
    if ( s[0] == '+' ) {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }else if ( s[0] == '-' ) {
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    } else if ( s[0] == '*' ) {
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    } else {
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int n,a,s[7];
int main()
{
	cin>>n;
	for(int i=0;i<=7;i++)
		s[i]=pow(2,i);	
	for(int i=0;i<=7;i++)
	{
		if(s[i]>n)
		{
			cout<<s[i-1]<<endl;
			return 0;
		}	
	}
	return 0;
}

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

using namespace std;

class Dice
{
public:
	static const int SURFACE_NUM = 6; // ?????????????????¢??°
	static const int DIR_NUM = 4; // ?????¢?????????????????°
	static const int ROUND_NUM = 4; // ?????¢????????¢?????°
	enum DIR { N, W, S, E }; // ?????¢??????
private:
	static const int rotate_table[DIR_NUM][ROUND_NUM]; // ?????¢??¨????????¢????????\???????????????
	static const int front_rotate_table[ROUND_NUM]; // ?????¢??¨?????¢????????????
	int surface_numbers[SURFACE_NUM]; // ??¢?????°???

public:
	Dice(int number[SURFACE_NUM])
	{
		// ??¢?????°???????????????
		for (int i = 0; i < SURFACE_NUM; i++)
			surface_numbers[i] = number[i];
	}
private:
	void rotate(const int table[ROUND_NUM])
	{
		// ????????????????????§????????¢????????¢?????????
		int backup = surface_numbers[table[0]];
		for (int i = 0; i < ROUND_NUM - 1; i++)
			surface_numbers[table[i]] = surface_numbers[table[i + 1]];
		surface_numbers[table[ROUND_NUM - 1]] = backup;
	}
public:
	void rotate(DIR direction)
	{
		// ?????¢????????\????????????????????§?????????
		rotate(rotate_table[direction]);
	}
	int answerLeftSurface(int top_number, int front_number)
	{
		// ?????¢?????°?????????????????§?????¢????????¢?????????
		for (int i = 0; i < ROUND_NUM; i++) {
			// ????????¢
			if (getTopNumber() == top_number) break;
			rotate(N);
		}
		if (getTopNumber() != top_number) {
			for (int i = 0; i < ROUND_NUM; i++) {
				// ?¨??????¢
				if (getTopNumber() == top_number) break;
				rotate(W);
			}
		}
		// ?????¢?????°?????????????????§?????¢????????¢?????????
		for (int i = 0; i < ROUND_NUM; i++) {
			if (surface_numbers[1] == front_number) break;
			rotate(front_rotate_table);
		}
		// ??´??¢???????????????
		return surface_numbers[2];
	}
	int getTopNumber() { return surface_numbers[0]; }
};
// ?????¢???????????????????????¢????????¢????????????????????????????????????(?????¢??¨)
const int Dice::rotate_table[DIR_NUM][ROUND_NUM]
{
	{ 0, 1, 5, 4 },
	{ 0, 2, 5, 3 },
	{ 0, 4, 5, 1 },
	{ 0, 3, 5, 2 }
};
// ????????¢????????¢????????????????????????????????????(?????¢??¨)
const int Dice::front_rotate_table[ROUND_NUM] { 1, 2, 4, 3 };
int main()
{
	int nums[Dice::SURFACE_NUM] = { 0 };
	for (int i = 0; i < Dice::SURFACE_NUM; i++)
		cin >> nums[i];
	Dice dice(nums);
	
	int q = 0, top = 0, front = 0;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> top >> front;
		cout << dice.answerLeftSurface(top, front) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll a,b;
	cin>>a>>b;
	if(b==1)
		cout<<0<<endl;
	else{
		ll ans=0;
		b=b-a;
		a--;
		while(b>0){
			b=b-a;
			ans++;
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libnum {{{*/
void amax(N, Args...)(ref N x, Args y) {
  x = x.max(y);
}
void amin(N, Args...)(ref N x, Args y) {
  x = x.min(y);
}
auto maxE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amax(y);
  return x;
}
auto minE(R)(R r) if (isInputRange!R) {
  ElementType!R x = r.front;
  r.popFront();
  foreach (y; r) x.amin(y);
  return x;
}
/*}}}*/


/+---test
2 4
0 9 9 9 9 9 9 9 9 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 9 9 9 9 9 9
9 9 9 9 0 9 9 9 9 2
9 9 9 9 9 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 9 9 0 9 9
9 9 9 9 2 9 9 9 0 9
9 2 9 9 9 9 9 9 9 0
-1 -1 -1 -1
8 1 1 8
---+/
/+---test
5 5
0 999 999 999 999 999 999 999 999 999
999 0 999 999 999 999 999 999 999 999
999 999 0 999 999 999 999 999 999 999
999 999 999 0 999 999 999 999 999 999
999 999 999 999 0 999 999 999 999 999
999 999 999 999 999 0 999 999 999 999
999 999 999 999 999 999 0 999 999 999
999 999 999 999 999 999 999 0 999 999
999 999 999 999 999 999 999 999 0 999
999 999 999 999 999 999 999 999 999 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
---+/
/+---test
3 5
0 4 3 6 2 7 2 5 3 3
4 0 5 3 7 5 3 7 2 7
5 7 0 7 2 9 3 2 9 1
3 6 2 0 2 4 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 3 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
3 5 2 6 1
2 5 3 2 1
6 9 2 5 6
---+/

void main(string[] args) {
  long H, W;
  readf(" %d %d ", &H, &W);

  auto sc = new long[][](10, 10);
  foreach (ref row; sc) {
    row = readln.split.map!(to!long).array;
  }

  auto changed = true;
  while (changed) {
    changed = false;
    foreach (x; 0..10) foreach (y; 0..10) foreach (z; 0..10) {
      const temp = sc[x][y];
      sc[x][y].amin(sc[x][z] + sc[z][y]);
      changed |= sc[x][y] != temp;
    }
  }

  long ans;
  foreach (y; 0..H) {
    foreach (a; readln.split.map!(to!long)) {
      if (a >= 0) ans += sc[a][1];
    }
  }
  ans.writeln;
}


Measured memory_bytes: 3964
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

vector<vector<int> > T;

int ans, K, now;

void dfs(int p, int crt, int d) {
	if (d > K / 2) return;
	if (d <= K / 2) ans++;
	for (int i = 0;i < T[crt].size();i++) {
		if (p == T[crt][i]) continue;
		dfs(crt, T[crt][i], d + 1);
	}
	return;
}

void dfs2(int p, int crt, int d) {
	if (d > K / 2) return;
	if (d == K / 2) ans++;
	for (int i = 0;i < T[crt].size();i++) {
		if (p == T[crt][i]) continue;
		dfs2(crt, T[crt][i], d + 1);
	}
	return;
}

void process(int crt) {
	now = 0;
	for (int i = 0;i < T[crt].size();i++) {
		ans = 0;
		dfs2(crt, T[crt][i], 0);
		now = max(now, ans);
	}
	return;
}

int main() {
    ios::sync_with_stdio(false);
    T.clear();
    int N;
    cin >> N >> K;
    T.resize(N + 1);
    for (int i = 0;i < N - 1;i++) {
    	int a, b;
    	cin >> a >> b;
    	T[a].push_back(b);
    	T[b].push_back(a);
    }
    int res = 0;
    for (int i = 1;i <= N;i++) {
    	ans = 0;
    	dfs(-1, i, 0);
    	if (K % 2 == 1) {
    		int tmp = ans;
    		process(i);
    		tmp += now;
    		ans = tmp;
    	}
    	res = max(res, ans);
    }
    cout << N - res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int a,b,c,x;
  x=0;
  scanf("%d %d %d",&a,&b,&c);
  for (a; a <= b; a++){
    if (c%a == 0){
      x++;
    }
  }
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

bool isNeeded(int id, int K, int M, vector<int> &b){
    vector<bool> dp(5001, 0);
    dp[0] = true;
    for(int i=0; i<M; i++){
        if(i == id) continue;
        for(int j=5000; j>=b[i]; j--)
            if(dp[j-b[i]]) dp[j] = true;
    }

    for(int i=K - b[id]; i<K; i++){
        if(dp[i]) return true;
    }

    return false;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    vector<int> b;
    for(int i=0; i<N; i++)
        if(a[i] < K) b.push_back(a[i]);

    int M = b.size();
    if(M == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(b.begin(), b.end());

    int lb = 0;
    int ub = M - 1;
    if(!isNeeded(ub, K, M, b)){
        cout << M << endl;
        return 0;
    }
    if(isNeeded(lb, K, M, b)){
        cout << 0 << endl;
        return 0;
    }

    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        if(!isNeeded(mid, K, M, b)) lb = mid;
        else ub = mid;
    }
    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

int main(void){
  char s[1010];
  scanf("%s",s);

  int len = strlen(s);

  if(s[len-1] == 's'){
    printf("%ses\n",s);
  }

  else{
    printf("%ss\n",s);
  }

  return 0;
}

Measured memory_bytes: 1728
import math

#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

#[0, n]の範囲で素数を列挙
def prime_table(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return is_prime

q = int(input())
l = [-1] * q
r = [-1] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

table = prime_table(max(r))
s = [0] * (max(r)+1)
for i in range(1, max(r)+1):
    if table[i] == 1 and is_prime((i+1)//2):
        s[i] = s[i-1] + 1
    else:
        s[i] = s[i-1]
#print(table)
#print(s)
for i in range(q):
    ans = s[r[i]] - s[l[i]-1]
    print(ans)



Measured memory_bytes: 13348
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner s = new Scanner(System.in);
        int hiki = s.nextInt();
        int asi = s.nextInt();
        int sum = hiki * 2;
        if( sum > asi || asi % 2 == 0 || sum * 2 < asi){
            for(int i = 0; i <= hiki; i++){
                if(i != 0) sum += 2;
            
                if(sum == asi){
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No"); 
    }
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
int digit(int n){
    int cnt = 0;
    while(n){
        n/=10;
        cnt++;
    }
    return cnt;
}
signed main(void){
    int n; cin>>n;
    int ans = 0;
    for(int i=1;i<n+1;i++){
        if(digit(i) %2 == 1) ans++;
    }
    cout<<ans<<endl;
}


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_N 100000

int main(void) {
  std::int64_t N, K;
  std::cin >> N >> K;

  std::priority_queue<int,
		      std::vector<std::pair<int, int>>,
		      std::greater<std::pair<int, int>>> que;
  rep(i, N) {
    std::pair<int, int> data;
    std::cin >> data.first >> data.second;
    que.push(data);
  }

  std::int64_t ANS;
  std::int64_t NUM = 0;
  rep(i, K) {
    std::pair<int, int> data;
    data = que.top();
    //std::cout << "A=" << data.first << " B=" << data.second << std::endl;
    NUM += data.second;
    if(NUM >= K) {
      ANS = data.first;
      break;
    }
    que.pop();
  }
  std::cout << ANS << std::endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string S;
    cin >> S;
    
    if (S == "SUN") cout << 7 << endl;
    if (S == "MON") cout << 6 << endl;
    if (S == "TUE") cout << 5 << endl;
    if (S == "WED") cout << 4 << endl;
    if (S == "THU") cout << 3 << endl;
    if (S == "FRI") cout << 2 << endl;
    if (S == "SAT") cout << 1 << endl;





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

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

int s, n, t, m, p;

bool minutes[7 * 24 * 60];

int wbits, tbits;

double ck(int start){
  int cnt = 0;
  for(int i = 0; i < m; i++, start += t){
    bool flag = true;
    for(int j = 0; j <= s; j++){
      if(!minutes[(start + j) % (7 * 24 * 60)]){
        flag = false;
        break;
      }
    }
    cnt += flag;
  }
  return( 1.0 - pow( 1.0 - 1.0/p, (double)cnt * n));
}


inline int todays(int i){
  return(i / (24 * 60));
}
inline bool totime(int i){
  return((i/360+1)&4>>1);
}

int main(){
  string weekday, time ;
  while( cin >> s >> n >> t >> weekday >> time >> p >> m, m){
    if(weekday == "All") wbits = (1 << 7) - 1;
    else wbits = 1 ;
    if(time == "Night") tbits = 1;
    else if(time == "Day") tbits = 2;
    else tbits = 3; 

    double ans = 0.0;
    for(int i = 7 * 24 * 60 - 1; i >= 0; i--){
      minutes[i] = 
        wbits >> todays(i) & 1 && (tbits >>totime(i)) & 1;
    }

    for(int i = 24 * 60 - 1; i >= 0; i--){
      ans = max( ans, ck(i));
    }
    cout << fixed << setprecision(16) << ans << endl;
  }
}

Measured memory_bytes: 1340
n, m = map(int, input().split())
if max(n, m) - min(n, m) > 1:
    p = 0
elif max(n, m) - min(n, m) == 1:
    p = 1
else:
    p = 2
xn, xm = 1, 1
for i in range(1, n + 1):
    xn = (xn * i) % (10 ** 9 + 7)
for i in range(1, m + 1):
    xm = (xm * i) % (10 ** 9 + 7)
ans = (xn * xm * p) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>
#include <string.h>

char input[200];
int count;
int target;
char result;

void go_next(int repeat,int start,int end) {
	int repeating;
	int i,j,k;
	int kakko_nest;
	int next_repeat;
	for(repeating=0;repeating<repeat && count<target;repeating++) {
		for(i=start;i<end && count<target;i++) {
			if(isdigit(input[i])) {
				next_repeat=input[i]-'0';
				for(j=i+1;j<end && isdigit(input[j]);j++) {
					next_repeat=next_repeat*10+(input[j]-'0');
				}
				if(input[j]=='(') {
					for(k=j+1,kakko_nest=1;k<end && kakko_nest>0;k++) {
						if(input[k]=='(')kakko_nest++;
						else if(input[k]==')')kakko_nest--;
					}
					go_next(next_repeat,j+1,k-1);
					i=k-1;
				} else {
					k=j+1;
					go_next(next_repeat,j,j+1);
					i=j;
				}
			} else {
				count++;
				if(count>=target)result=input[i];
			}
		}
	}
}

int main(void) {
	while(1) {
		scanf("%s%d",input,&target);
		if(strcmp(input,"0")==0 && target==0)break;
		result='0';
		count=-1;
		go_next(1,0,strlen(input));
		printf("%c\n",result);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(n + 1, 0), r(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  reverse(l.begin(), l.end());
  long long ret = 0;
  for (int i = 0; i < n; i++) {
    int d = l[i] - r[i];
    if (d <= 0) break;
    ret += 2 * d;
  }
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a,b,c,d,e,f;
  double x,y;
	int number;

	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
  x=(float)(1.0/(a*e-b*d))*(c*e-f*b);
  y=(float)(1.0/(a*e-b*d))*(-d*c+f*a);

  if(x>=-0.00005){
    x=x+0.00005;
  }
  if(y>=-0.00005){
    y=y+0.00005;
  }

  printf("%.3f %.3f\n",x,y);
    }
  return 0;
}

Measured memory_bytes: 640
N = int(input())
ans = 0
for x in range(1,10):
    if N >= x:
        ans = ans + 1
for g in range(100,1000):
    if N >= g:
        ans = ans + 1
for m in range(10000,100000):
    if N >= m:
        ans = ans + 1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char t[4010];
int a[4010];
int s[5][4010];
int u[5];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", &t);
    for(int i = 1; i <= n; i++) {
        if(t[i - 1] == 'R') a[i] = 0;
        if(t[i - 1] == 'G') a[i] = 1;
        if(t[i - 1] == 'B') a[i] = 2;
    }
    for(int i = n; i >= 1; i--) {
        for(int j = 0; j < 3; j++) s[j][i] = s[j][i + 1];
        s[a[i]][i] = s[a[i]][i + 1] + 1;
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(a[i] == a[j]) continue;
            memset(u, 0, sizeof(u));
            u[a[i]] = 1;
            u[a[j]] = 1;
            int x;
            for(int k = 0; k < 3; k++) {
                if(u[k] == 0) x = k;
            }
            //printf("%d %d %d\n", i, j, s[x][j + 1]);
            ans += s[x][j + 1];
            if(j + j - i <= n && a[j + j - i] == x) {

            //printf("%d %d\n", x, a[j + j - i]);
                ans--;
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};

ll GCD (ll a, ll b) { return b ? GCD(b, a%b) : a;}

ll LCM (ll a, ll b) {
    ll g = GCD (a, b);
    return a * b / g;
}

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

    ll N, K;
    cin >> N >> K;

    mint ans(0);

    vector<mint> used(1e5+1, mint(0)), cnt(1e5+1, mint(0));

    for (ll g = 1e5; g >= 1; g--) {
        mint tmp(K/g);
        tmp = tmp.pow(N);
        cnt[g] = tmp - used[g];
        // if (g <= 5) cout << g << " " << tmp << endl;
        for (ll i = 1; i*i <= g; i++) {
            if (g%i == 0) {
                used[i] += cnt[g];
                if (g/i != i) used[g/i] += cnt[g];
            }
        }
        ans += mint(g) * cnt[g];
        // if (g < 5) Rep (i, 5) {
        //     cout << used[i] << " \n"[i==4];
        // }
    }

    // Rep (i, 5) {
    //     cout << i << " " << cnt[i] << " " << used[i] << "\n";
    // }

    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    
    int cnt = 0;
    bool f=1;
    while(f){
        f=0;
        for(int j=n-1;j>=1;j--){
            if(a[j]<a[j-1]) swap(a[j],a[j-1]),cnt++,f=1;
        }
    }
    cout << a[0];
    for(int i=1;i<n;i++) cout << " " << a[i];
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   signed long long a,b,c,d,x,y,z,w; cin>>a>>b>>c>>d;
    w=a*c;z=a*d;x=b*c;y=b*d;
    w=max(w,z);x=max(x,y); cout<<max(w,x);
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

b = []

l = range(n)[::-2]
if n % 2 == 0:
    r = range(n)[::2]
else:
    r = range(n)[1::2]

for i in l:
    b.append(str(a[i]))
for i in r:
    b.append(str(a[i]))
    
print(" ".join(b))

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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e9;

int call(int i) {
	cout << i << endl;
	string s;
	cin >> s;
	if (s == "Vacant") {
		exit(0);
	}
	if (s == "Male") {
		return 1;
	}
	if (s == "Female") {
		return 0;
	}
}

int n;
int u;

int mid(int l, int r) {
	int t;

	if (l < r) {
		t = (l + (r - l) / 2) % n;
		u = (r - l) / 2;
	} else {
		t = (l + ((n - l) + r) / 2) % n;
		u = ((n - l) + r) / 2;
	}

	if (l + 1 == t) return t;
	if (r - 1 == t) return t;

	if (l + (t - l) * 2 == r) {
		u += 1;
		return t + 1;
	} else {
		return t;
	}
}

signed main() {
	cin >> n;

	int l = 0;
	int r = n;
	int s = call(l);

	rep(_, 20) {
		int m = mid(l, r);
		int p;
		if (u % 2) {
			p = !s;
		} else {
			p = s;
		}

		int rs = call(m);
		if (p == rs) {
			l = m;
			s = rs;
		} else {
			r = m;
		}
	}

	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int main () {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n,avg=0,total= 0;
  cin >> n;
  a.resize(n);
  for (auto &i : a) cin >> i, avg += i;
  avg = round(avg*1.0/n);
  for (int i : a) total += (i-avg)*(i-avg);
  cout << total << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (100 * (n - m) + 1900 * m) * (int)pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int n,m;
vector<int> g[100001];
int v[100001],d[100001],c[100001];
int dp[100001][11];
void dfs(int vx,int ds,int idx){
    if(dp[vx][ds]>0) return;
    if(ds==0) {
        dp[vx][ds]=idx;
        return;
    }
    else{
        dfs(vx,ds-1,idx);
        rep(i,g[vx].size()){
            dfs(g[vx][i],ds-1,idx);
        }
    }
    dp[vx][ds]=idx;
    return;
}
int main(){
    int ai,bi;
    cin>>n>>m;
    rep(i,m){
        cin>>ai>>bi;
        --ai,--bi;
        g[ai].pb(bi);
        g[bi].pb(ai);
    }
    int q;
    cin>>q;
    rep(i,q){
        cin>>v[q-i-1]>>d[q-i-1]>>c[i+1];
        --v[q-i-1];
    }
    rep(i,q) dfs(v[i],d[i],q-i);
    rep(i,n) cout<<c[dp[i][0]]<<endl;
    return 0;
}

Measured memory_bytes: 12024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, M, Q; cin >> N >> M >> Q;
  int a[Q], b[Q], c[Q], d[Q];
  rep(i,Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i];
  }

  vector<vector<int>> U;

  queue<vector<int>> q;
  reps(i,M) q.push(vector<int>(1,i));

  while (!q.empty()){
    auto vec = q.front(); q.pop();
    // cout << vec.size() << endl;
    if (vec.size()==N) {
      U.push_back(vec);
      continue;
    }
    int l = vec.back();
    for (int j=l;j<=M;j++){
      auto vec_c = vec;
      vec_c.push_back(j);
      q.push(vec_c);
    }
  }


  ll ans = 0;
  for (auto vec : U){
    ll tmp = 0;
    rep(i,Q){
      if (vec[b[i]] - vec[a[i]]==c[i]) tmp += d[i];
    }
    chmax(ans, tmp);
  }
  cout << ans << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 12932
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
		int inpt = int.Parse(Reader.ReadLine());

		long ans = 1;
		for (int i = 2; i <= 1000; i++) {
			long tmp = i;
			for (int j = 2; j <= 1000; j++) {
				tmp = tmp * i;
				if(tmp>inpt) {
					break;
				}
				ans = Math.Max(ans, tmp);
			}
		}
		Console.WriteLine(ans);


    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



10




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int n,sum;
int main()
{
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        sum+=a[i][1]-a[i][0]+1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M;
ll a[100000];
LP p[100000];
ll s[100000];

void solve()
{
    sort(a, a+N);
    sort(p, p+M, greater<P>());
    s[0] = a[0];
    FOR(i, 1, N) s[i] = s[i-1] + a[i];
    ll ret = s[N-1];
    ll cur = 0;
    //cout << ret << endl;
    REP(i, M){
        auto c = lower_bound(a+cur, a+N, p[i].fi);
        //cout << p[i].fi << "," << p[i].se << endl;
        //cout << "[" << c << " " << a  << " " << (ll)(c-a) << "]" << endl;
        ll num = min(p[i].se, (ll)(c - (a+cur)));
        ret += max(p[i].fi * num - (s[cur+num-1] - (cur == 0 ? 0 : s[cur-1])), 0ll);
        cur = cur + num;
        //cout << cur << " " << num << " " << ret << endl;
    }
    cout << ret << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, N) cin >> a[i];
    REP(i, M){
        cin >> p[i].se >> p[i].fi;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] S=sc.next().split("");
		int ans=0;

		for(int i=0;i<S.length/2;i++) {
			if(!(S[i].equals(S[S.length-(i+1)]))) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int X = 0;
    int N;
    string S;
    cin >> N >> S;

    int max_X = 0;
    rep(i, N) {
        switch(S.at(i)) {
            case 'I':
                X++;
                break;
            case 'D':
                X--;
                break;
            default:
                break;
        }
        max_X = max(max_X, X);
    }

    cout << max_X << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextLine()
    println(
      n.foldLeft(0)(
        (b:Int, c :Char) =>
          b + (if(c == '2') 1 else 0)
      )
    )
  }
}

Measured memory_bytes: 25552
def main():
    N = int(input())
    S = input()

    if N % 2 == 1:
        print('No')
        return

    half = S[:N//2]
    half2 = S[N//2:]

    if half == half2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9

int add(int x) {
	int sum = 0;
	for (int i = 1;i <= x;i++)
		sum += i;
	return sum;
}


int main() {
	int a, b;
	cin >> a >> b;
	int a1, b1;
	a1 = add(b - a);
	cout << a1 - b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 200005;

int w[1005], B[1005], L[100005], flag[1005];

int main(){
	int n, ans = 0, Min = INF;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> w[i];
		B[i] = w[i];
		Min = min(Min, w[i]);
	}
	sort(B, B + n);
	for(int i = 0; i < n; i++)	
		L[B[i]] = i;
	for(int i = 0; i < n; i++){
		if(flag[i])
			continue;
		int temp = i, S = INF, m = 0, cnt = 0;
		while(!flag[temp]){
			cnt++;
			flag[temp] = 1;
			S = min(S, w[temp]);
			m += w[temp];
			temp = L[w[temp]];
		}
		ans += min(m + (cnt - 2) * S, m + (cnt + 1) * Min + S);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B>>M>>K;
    ll ma = max({A,B,M});
    H = 1;
    rep(i,K) H *= 2;
    cout<<A+B+M+ma*(H-1)<<endl;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split()) #入力された数字から空を除く
numbers = [A, B, C] #入力された数字をnumbersリストに代入する
numbers.sort()
a = numbers[0]
b = numbers[1]
c = numbers[2]
#print(a, b, c)
if a == 5 and b == 5 and c == 7 :
    print("YES")
else :
    print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int h, w;
	char a[100][100];
	char d[100][100];
	cin >> h >> w;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> a[i][j];
		}
	}
	bool flag=true;
	bool b[100], c[100];
	for(int i=0; i<100; i++){
		b[i]=true, c[i]=true;
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(a[i][j]=='#'){
				flag=false;
			}
		}
		if(!flag){
			b[i]=false;
		}
		flag=true;
	}
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(a[j][i]=='#'){
				flag=false;
			}
		}
		if(!flag){
			c[i]=false;
		}
		flag=true;
	}
	for(int i=0; i<h; i++){
		if(b[i]){
			continue;
		}
		for(int j=0; j<w; j++){
			if(!b[i] && !c[j]){
				cout << a[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def solve():
    dp = {}

    def execute(h):
        if h == 1:
            return 1
        if h in dp:
            return dp[h]
        ans = 1 + execute(h // 2) * 2
        dp[h] = ans
        return ans

    return execute


H = int(input())
solver = solve()
print(solver(H))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
      string s;

  int gcd(int a,int b)
  {
    if(b==0)
    {
      return a;
    }
    return gcd(b,a%b);
  }

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }

  bool vis[10000][10000];

  int n;
  int currx=0,curry=0;

  void dfs(int x,int y,bool dir,int idx)
  {

    if(idx==n)
    {
      return;
    }

    currx=x;
    curry=y;

      vis[x][y]=1;
      if(s[idx]=='F')
      {
        if(dir==0)
        {
          currx++;
        }
        else
        {
          curry++;
        }

        dfs(currx,curry,dir,idx+1);
        return;
      }
      else
      {
        dfs(currx,curry,!dir,idx+1);
        dfs(currx,curry,dir,idx+1);
        
          return;
      } 

      return;
  }


  int digsum(int n)
  {
    int ans=0;
    while(n)
    {
      ans+=(n%10);
      n/=10;
    }

    return ans;
  }
  int32_t main()
  {         
    

      IOS

        
        
      int n,a,b;
      cin>>n>>a>>b;
      
      int ans=0;

      for(int i=1;i<=n;i++)
      {
        int x=digsum(i);
        if(x>=a and x<=b)
        {
          ans+=i;
        }
      }

      cout<<ans;


      return 0;
  }           

Measured memory_bytes: 256
#include <iostream>
#include<cstring>
using namespace std;
int main(void){
    // Here your code !
    char s[100];
    int n[100];
    int cnt;
    cin >>s;
    for(int j=0;j<28;j++){
        cnt=0;
        for( int i=0;i<strlen(s);i++){
            if(s[i]==(char)('a'+j))cnt++;
            if(cnt>=2){
                cout <<"no"<<endl;
                return 0;
            }
        }
        
    }
    
    cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main()
{
  double x,h,answer;
  while (1) {
    scanf("%lf%lf", &x, &h);
    if ( x == 0 && h == 0 ) { break; }
    answer = pow(x,2) + (sqrt(pow(h,2) + pow((x/2), 2)) * x / 2 * 4);
    printf("%.6f\n", answer);
  }
  return 0;
}

Measured memory_bytes: 2600
<?php

class Magic
{
    public $d;
    public $c;
}

sscanf(fgets(STDIN), "%d %d", $h, $n);

$mag = [];
for ($i = 0; $i < $n; $i++) {
    sscanf(fgets(STDIN), "%d %d", $d, $c);
    $m = new Magic();
    $m->d = $d;
    $m->c = $c;
    $mag[] = $m; 
}

$arr[0] = 0;

for ($i = 0; $i < $h; $i++) {
    if (!isset($arr[$i])) continue;
    
    $prev = $arr[$i];
    foreach ($mag as $magic) {
        $idx = min($h, $i + $magic->d);
        
        if (!isset($arr[$idx]))
            $arr[$idx] = $prev + $magic->c;
        else
            $arr[$idx] = min($prev + $magic->c, $arr[$idx]);
    }
}

echo $arr[$h];

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

int H, W;

int main()
{
    string S, T;
		cin >> S;
		int len = S.length();
		T = S;
		reverse(T.begin(), T.end());
		if(S == T){
			string a = S.substr(0, (len - 1) / 2);
			string b = a;
			reverse(b.begin(), b.end());
			if(a == b){
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			cout << "No" << endl;
		}
    return 0;
}


Measured memory_bytes: 256