akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
    while(1)
    {
        char c;
        cin.get(c);
        if(c == '\n')
        {
            cout << endl;
            return 0;
        }
        if(islower(c))
        {
            cout << (char)toupper(c);
        }
        else if(isupper(c))
        {
            cout << (char)tolower(c);
        }
        else
        {
            cout << c;
        }
    }
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch IronBarCutting | diff IronBarCutting.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address IronBarCutting.cpp && ./a.out

/*
 
 11/23/2019
 
 4:04-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  LL sum=accumulate(A,A+N,0LL);
  LL res=sum,cur=0;
  REP(i,N) {
    LL a=cur+A[i],b=sum-a;
    SMIN(res,abs(a-b));
    cur=a;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))
a=0
b=0
c=0
for i in P:
    if i<=A:
        a+=1
    elif i>=A+1 and i<=B:
        b+=1
    else:
        c+=1
ans=min(a,min(b,c))
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#define N 101
#define WHITE 0
#define BLACK 1
#define GRAY 10

int d[N],f[N];
int colour[N],A[N][N];
int n,time;


void visit(int r){
  int i;
  colour[r]=GRAY;
  d[r]=++time;
  for(i=0;i<n;i++){
    if(!A[r][i])continue;

    if(colour[i]==WHITE)visit(i);
  }
  colour[r]=BLACK;
  f[r]=++time;
}

void  DepthFirstSearch(){
  int i;
  for(i=0;i<n;i++)
    colour[i]=WHITE;
  time=0;
  for(i=0;i<n;i++)
    if(colour[i]==0)visit(i);
}


int main(){
  int i,j,k,c,num;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&num,&c);
    for(j=0;j<c;j++){
      scanf("%d",&k);
      A[num-1][k-1]=1;

    }
  }

  DepthFirstSearch();

  for(i=0;i<n;i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);
  

  return 0;
}



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

string tolower(string str){
	for (int i = 0; i < str.size(); i++){
		str[i] = tolower(str[i]);
	}

	return str;
}

int main() {
	string n;
	int m, h;

	while(1){
		cin >> n;
		if (n == "-") break;

		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> h;
			n = n.substr(h) + n.substr(0, h);
		}
		cout << n << endl;
	}

	return 0;
}


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

using namespace std;

struct node {
  vector <node*> children;
};

node nodes[100001];

int maxDepth(node *n) {
  int num = n->children.size();
  if (n->children.empty()) {
    return 0;
  }

  vector <int> depth;
  for (int i = 0; i < num; i++) {
    int now = maxDepth(n->children[i]);
    depth.push_back(now);
  }

  int max = 0;
  sort(depth.begin(), depth.end(), greater<int>());
  for (int i = 0; i < num; i++) {
    int now = depth[i] + i + 1;
    if (max < now) {
      max = now;
    }
  }
  return max;
}

int main() {
  int N;
  cin >> N;
  for (int i = 2; i <= N; i++) {
    int input;
    cin >> input;
    nodes[input].children.push_back(nodes + i);
  }
  cout << maxDepth(nodes + 1);
  return 0;
}


Measured memory_bytes: 15104
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;

int dp[4][111];

signed main(){
	int N,X;
	while(cin >> N >> X,N || X){
		int ans = 0;
		FOR(i,1,N+1){
			FOR(j,i+1,N+1){
				FOR(k,j+1,N+1){
					if(i + j + k == X)ans++;
				}
			}
		}
		out(ans);
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<double> s(N + 1, 0.0);
    for (int i = 0, p; i < N; i++) {
        cin >> p;
        s[i + 1] = s[i] + p * (p + 1) / 2.0 / p;
    }
    double ans = 0.0;
    for (int i = 0; i <= N - K; i++) {
        auto t = s[i + K] - s[i];
        if (t > ans) ans = t;
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int mod = 1e9+7;
int main(){
    long n,k,ans=0;
    cin >> n >> k;
    long a[n];
    rep(i,n) cin >> a[i];
    long b[n],c[n];
    rep(i,n){
        long cnt=0,cnt1=0;
        rep(j,n){
            if(i<j&&a[i]>a[j]) cnt++;
            if(j<i&&a[i]>a[j]) cnt1++;
        }
        b[i] = cnt;
        c[i] = cnt1;
    }
    long d,e;
    if(k%2){
        d = k*((k+1)/2)%mod;
        e = k*((k-1)/2)%mod;
    }
    else{
        d= (k/2)*(k+1)%mod;
        e = (k/2)*(k-1)%mod;
    }
    rep(i,n){
        ans += (d*b[i])%mod + (e*c[i]) %mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        bool flag = false;

        for (var i = 1; i <= 9; i++)
        {
            for (var j = 1; j <= 9; j++)
            {
                if(N == (i * j))
                {
                    flag = true;
                }
            }
        }

        if (flag)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	int mx = 0, mn = 1001001001;
	rep(i, n){
		int a;
		cin >> a;
		if(mx < a) mx = a;
		if(mn > a) mn = a;
	}
	cout << mx - mn << endl;
	return 0;
}

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

using namespace std;

// Mint {{{
template <long long MOD>
class ModInt {
    long long value;
public:
    inline ModInt(const ModInt& other) noexcept : value(other.value) {}
    inline ModInt(long long value = 0) noexcept :
        value((value >= MOD) ? value % MOD : (value < 0) ? (value + MOD) % MOD : value) {}

    inline ModInt inv() const noexcept { return power(value, MOD - 2); }

    inline ModInt& operator+=(const ModInt& other) noexcept {
        value = (value + other.value) % MOD; return *this;
    }
    inline ModInt& operator-=(const ModInt& other) noexcept {
        value = (MOD + value - other.value) % MOD; return *this;
    }
    inline ModInt& operator*=(const ModInt& other) noexcept {
        value = (value * other.value) % MOD; return *this;
    }
    inline ModInt& operator/=(const ModInt& other) noexcept {
        value = (value * other.inv().value) % MOD; return *this;
    }

    inline ModInt operator+(const ModInt& other) noexcept { return ModInt(*this) += other; }
    inline ModInt operator-(const ModInt& other) noexcept { return ModInt(*this) -= other; }
    inline ModInt operator*(const ModInt& other) noexcept { return ModInt(*this) *= other; }
    inline ModInt operator/(const ModInt& other) noexcept { return ModInt(*this) /= other; }

    inline bool operator==(const ModInt& other) noexcept { return value == *other; }
    inline bool operator!=(const ModInt& other) noexcept { return value != *other; }

    template <class int_>
        explicit inline operator int_() const noexcept { return static_cast<int_>(value); }

    friend ostream& operator<<(ostream &os, ModInt other) noexcept {
        os << other.value; return os;
    }

    friend istream& operator>>(istream &is, ModInt& other) noexcept {
        is >> other.value; return is;
    }

    static constexpr inline ModInt power(long long n, long long p) noexcept {
        long long ret = 1;
        for (; p > 0; p >>= 1) {
            if (p & 1) ret = (ret * n) % MOD;
            n = (n * n) % MOD;
        }
        return ret;
    }
};

using Mint = ModInt<int(1e9) + 7>;
// }}}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    Mint value1 = 0, value2 = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            value1 += (a[j] > a[i]);
        }
        for (int j = 0; j < n; ++j) {
            value2 += (a[j] > a[i]);
        }
    }
    value1 *= k;
    value2 *= ((k - 1) * k) >> 1;
    cout << value1 + value2 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

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

int main(){
    int n;
    scanf("%d", &n);
    lint c[n][n];
    rep(i, n)rep(j, n) scanf("%lld", &c[i][j]);
    lint ans = 0;
    rep(i, n)For(j, i+1, n) ans += min(c[i][j], c[j][i]);
    printf("%lld\n", ans);
}


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

using namespace std;

#define int long long
//#define cerr if(false)cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 100005
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
int mod=998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define mp make_pair

int32_t main() {
    faster;

    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3652
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

char s[105][105];
int h,w,dp[105][105];
 
int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>s[i][j];
		}
	}
	if(s[0][0]=='#')
	{
		dp[0][0]=1;
	}
	for(int i=1;i<w;i++)
	{
		dp[0][i]=dp[0][i-1]+(s[0][i-1]=='.'\
		&&s[0][i]=='#');
	}
	for(int i=1;i<w;i++)
	{
		dp[i][0]=dp[i-1][0]+(s[i-1][0]=='.'\
		&&s[i][0]=='#');
	}
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			dp[i][j]=min(dp[i][j-1]+\
			(s[i][j-1]=='.'&&s[i][j]=='#'),\
			dp[i-1][j]+(s[i-1][j]=='.'\
			&&s[i][j]=='#'));
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=2512;

int n,a,b;

int main()
{
    scanf("%d %d %d",&n,&a,&b);
    printf("%d %d",min(a,b),max(0,a+b-n));
    return 0;
}


Measured memory_bytes: 636
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int a = sc.nextInt();
		double b = a;
		a = (a+1)/2;
		double ans = a/b;
		out.print(ans);
		out.close();
	}
	
	
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;


const long long  MAX = 200000;
int main() {
    

    list <long long> l;
    long n;
    cin >>  n;
    long long x;
    string s;
    for (int i=0;i<n;i++){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            l.push_front(x);
        }else if(s == "deleteFirst"){
            l.pop_front();
        }else if(s == "deleteLast"){
            l.pop_back();
        }else{
            cin >> x;
            list <long long>::iterator p;
            for (p = l.begin();p!=l.end();p++){
                if(*p == x){
                    l.erase(p);
                    break;
                }
            }
        }
    }
    list <long long>::iterator p;
    long i=0;
    for (p=l.begin();p!=l.end();p++){
        if(i++){
            cout << " ";
        }
        cout << *p;
    }
    cout << endl;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;


int main()
{
	boost;
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll l=(x/d);
	ll ans=0;
	if(k<=l){
		x=x-k*d;
		ans=abs(x);
	}
	else{
		ll rem=(k-l)%2;
		if(rem==0){
			x=x-l*d;
			ans=abs(x);
		}
		else{
			x=x-(l+1)*d;
			ans=abs(x);
		}
	}
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cstdlib>
#include <cstring>

int main()
{
	int A,B;scanf("%d%d",&A,&B);
	for(register int C=1;C<=3;C++)
		if((A*B*C)%2!=0)
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int dp[3005];
int main()
{
    int a,b,ans=0;
    cin>>a>>b;
    for(int i=0;i<a;i++)
    {
        int n;
        cin>>n;
        for(int j=b;j-n>0;j--)
        {
            dp[j]=(dp[j]+dp[j-n])%mod;
        }
        dp[n]=(dp[n]+i+1)%mod;
        ans=(ans+dp[b])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Stack<String> seq = new Stack<String>();
		String opers = "+-/*";
		ArrayList<String> arr = new ArrayList<String>();
		Scanner out = new Scanner(System.in);
		String line = out.nextLine();
		Scanner in = new Scanner(line);
		while(in.hasNext()) {
			arr.add(in.next());
		}
		for(int i = 0; i < arr.size(); i++) {
			if(!opers.contains(arr.get(i))) seq.push(arr.get(i));
			else {
				int num = Integer.valueOf(seq.pop());
				int num1 = Integer.valueOf(seq.pop());
				if(arr.get(i).equals(opers.substring(0, 1))) {
					seq.push(String.valueOf(num1 + num));
				}
				else if(arr.get(i).equals(opers.substring(1, 2))) {
					seq.push(String.valueOf(num1 - num));
				}
				else if(arr.get(i).equals(opers.substring(2, 3))) {
					seq.push(String.valueOf(num1 / num));
				}
				else {
					seq.push(String.valueOf(num1 * num));
				}
			}
		}
		System.out.println(Integer.valueOf(seq.pop()));
	}

}


Measured memory_bytes: 26192
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
const int n = 300005;

void solve()
{
	int h, w, m;
	cin >> h >> w >> m;
	vector<int> hd(h+1, 0);
	vector<int> wd(w+1, 0);
	
	set<pair<int, int>> st;
	for(int i = 0; i<m; i++)
	{
		int x, y;
		cin >> x >> y;
		hd[x]++; wd[y]++;
		st.insert({x, y});
	}
	
	vector<int> hv;
	vector<int> wv;
	
	
	int hx = *max_element(hd.begin(), hd.end());
	int wx = *max_element(wd.begin(), wd.end());
	
	for(int i = 1; i<=h; i++)
		if(hd[i] == hx) 
			hv.push_back(i);
	for(int i = 1; i<=w; i++)
		if(wd[i] == wx)
			wv.push_back(i);
	
	for(int i :hv)
	{
		for(int j :wv)
		{
			if(st.find({i, j}) == st.end())
			{
				cout << hx+wx << "\n";
				return ;
			}
		}
	}
	
	
	cout << hx + wx -1 << "\n";
	
}

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


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

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

int check(vector<string> const& v, int x, int y, int const D) {
    int res = 0;
    if(x+D <= v[0].size()) {
        bool ok = true;
        for(int i=x; i<x+D; ++i) {
            ok &= v[y][i] == '.';
        }
        res += ok;
    }
    if(y+D <= v.size()) {
        bool ok = true;
        for(int i=y; i<y+D; ++i) {
            ok &= v[i][x] == '.';
        }
        res += ok;
    }
    return res;
}

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<string> v(h);
    for(int i=0; i<h; ++i) {
        cin >> v[i];
    }
    int res = 0;
    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            res += check(v, j, i, d);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3196
#include<stdio.h>

int main(){
        char s[100], t[100], c;
        int sl=0, tl=0;
        while((c=getchar())!='\n') s[sl++] = c;
        while((c=getchar())!='\n') t[tl++] = c;

        int flag = 0;
        for(int i=0; i<sl; i++){
                int cnt = 0;
                for(int j=0; j<tl; j++){
                        if(s[(i+j)%sl] == t[j]) cnt++;
                        else break;
                }
                if(cnt==tl) flag = 1;
        }

        if(flag) puts("Yes");
        else puts("No");
        return 0;
}


Measured memory_bytes: 2120
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    string n;
    cin >> n;
    for (auto c: n)
        if (c == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3652
export class Main {
  static main(input: string): string {
    const countList = [0, 0, 0, 0];
    const [p1, p2, p3] = input.split("\n");
    [p1, p2, p3].map(p => p.split(" ")).forEach(([a, b]) => {
      ++countList[a-1];
      ++countList[b-1];
    });
    let count1 = 0;
    let count2 = 0;
    countList.forEach(c => {
      switch (c) {
        case 1:
          ++count1;
          break;
        case 2:
          ++count2;
          break;
        default:
          break;
      }
    });
    return count1 == 2 && count2 == 2 ? "YES" : "NO";
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let ans = a + b + c - max(max(a, b), c);
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include<cstdio>
#include<set>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
set<pair<int,int> >s;
int a[222222],flag,n;
void plu(int x,int now)
{
	pair<int,int>tmp;
	if(x<1)
		flag=-1;
	tmp=*s.lower_bound(make_pair(x,0));
//	printf("%d %d %d\n",x,tmp.first,tmp.second);
	if(tmp.first!=x)
		s.insert(make_pair(x,0)),tmp=make_pair(x,0);
	else
	{
		s.erase(tmp);
		tmp.second++;
//		printf("%d\n",tmp);
		if(tmp.second>=now)
			plu(x-1,now);
		else
			s.insert(tmp);
	}
	while(1)
	{
		if(s.upper_bound(tmp)==s.end())
			break;
//		puts("*");
		tmp=*s.upper_bound(tmp);
		s.erase(tmp);
	}
}
int check(int x)
{
	int i;
	s.clear(); 
	flag=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]<=a[i-1])
		{
//			printf("%d %d|\n",x,i);
			plu(a[i],x-1);
		}
	}
	if(flag==-1)
		return 0;
	return 1;
}
int erf(int l,int r)
{
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	return l;
}
int main()
{
	int i,flag,ans; 
	scanf("%d",&n);
	flag=1;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		flag&=(a[i]>a[i-1]);
	}
	if(flag==1)
	{
		puts("1");
		return 0;
	}
//	printf("*");
	ans=erf(2,n);
	printf("%d\n",ans); 
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll n;
    cin >> n;
    set<ll> st;
    for (ll x = 1; x * x <= n; x++)
    {
        if (n % x)
            continue;
        ll m = n / x - 1;
        if (m >= 1)
        {
            if (n / m == n % m)
                st.insert(m);
        }
        m = x - 1;
        if (m >= 1)
        {
            if (n / m == n % m)
                st.insert(m);
        }
    }
    ll ret = 0;
    for (auto v : st)
        ret += v;
    cout << ret << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),M=in(),D=in();
	if(D==0){
		out((M-1)/(double)(N));
	}
	else{
		out(2.0*(M-1)*(N-D)/((double)N)/((double)N));
	}
	return 0;
}


Measured memory_bytes: 256
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

N=list(input())
#print(N[-1])
if N[-1]=="3":
    print("bon")
elif N[-1]=="0" or  N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
    print("pon")
else:
    print("hon")


    





Measured memory_bytes: 61628
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from heapq import *

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    q = [(0,S)]
    while q:
        dv, v = heappop(q)
        if dv > dist[v]:
            continue
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dv:
                continue
            dist[w] = dv
            heappush(q, (dv, w))
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dv + 1:
                    continue
                dist[w] = dv + 1
                heappush(q, (dv+1, w))
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))


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

int main() {
  int n; cin >> n;
  int a[200010];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  for (int j = n - 1; j >= 0; j -= 2)
    cout << a[j] << " ";
  
  for (int k = n % 2; k <= n - 2; k += 2)
    cout << a[k] << " ";
  
  cout << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> vec (N);
	int count = 0;
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
		count += vec.at(i) - 1;
	}
	
	cout << count << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

def main():
    N,A,B=mis()
    S = N // (A+B)
    ans = S*A
    rem = N-S*(A+B)
    if rem > A:
        ans += A
    else:
        ans += rem
    print(ans)

main()







Measured memory_bytes: 5684
// 2010/12/22 Tazoe

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int min_cost(string item, map<string, int>& items, map<string, vector<string> >& recipes)
{
	if(recipes.find(item)==recipes.end())
		return items[item];

	int cost_recipes = 0;
	for(vector<string>::iterator p=recipes[item].begin(); p<recipes[item].end(); p++)
		cost_recipes += min_cost(*p, items, recipes);

	if(cost_recipes<items[item])
		return cost_recipes;
	else
		return items[item];
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		map<string, int> items;
		for(int i=0; i<n; i++){
			string i_str;
			int p;
			cin >> i_str >> p;
			items[i_str] = p;
		}

		int m;
		cin >> m;

		map<string, vector<string> > recipes;
		for(int i=0; i<m; i++){
			string o_str;
			int k;
			cin >> o_str >> k;
			for(int j=0; j<k; j++){
				string q_str;
				cin >> q_str;
				recipes[o_str].push_back(q_str);
			}
		}

		string item;
		cin >> item;

		cout << min_cost(item, items, recipes) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll num_a,num_b;
    if(a==0){
        num_b = b/x;
        cout<<num_b+1<<endl;
    }else{
        num_a = (a-1)/x;
        num_b = b/x;
        cout<<num_b-num_a<<endl;
        
    }
    
    return 0;
}


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

string s, t;
int n, m;
const int R = 256;
vector<vector<int>> dfa;
vector<int> match;
vector<int> L;

void kmp() {
  dfa.resize(R, vector<int>(m+1));
  dfa[t[0]][0] = 1;
  for(int x = 0, j = 1; j <= m; j++) {
    for(int c = 0; c < R; c++) {
      dfa[c][j] = dfa[c][x];
    }
    dfa[t[j]][j] = (j+1)%(m+1);
    x = dfa[t[j]][x];
  }
}

int pathLength(int i) {
  if(!match[i]) return 0;
  if(L[i] != -1) return L[i];

  return L[i] = pathLength((i+m)%n) + 1;
}

bool hasLoop() {
  rep(i,m) {
    bool loop = true;
    for(int j = 0; j < n + m; j += m) {
      if(!match[(i+j)%n]) loop = false;
    }
    if(loop) return true;
  }
  return false;
}

int main () {
  cin >> s >> t;
  n = s.size(), m = t.size();
  match.resize(n);
  L.resize(n, -1);

  kmp();
  for(int i = 0, j = 0; i < n + m - 1; i++) {
    j = dfa[s[i%n]][j];
    if(j == m) match[i-m+1] = 1;
  }

  if(hasLoop()) {
    cout << - 1 << endl;
    return 0;
  }

  int ans = 0;
  rep(i,n) {
    if(match[i]) ans = max(ans, pathLength(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 508004
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb emplace_back
#define pob pop_back
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define test ll t; cin>>t; while(t--)
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,a,b,c;
    cin>>n;
    vll happy[n];
    for(i=0;i<n;i++){
    cin>>a>>b>>c;
    happy[i].pb(a);
    happy[i].pb(b);
    happy[i].pb(c);
    }
    vll dp[n+1];
    dp[0].pb(0);
    dp[0].pb(0);
    dp[0].pb(0);
    for(i=1;i<=n;i++)
    {
        ll k=0;
        dp[i].pb(happy[i-1][k++]+max(dp[i-1][1],dp[i-1][2]));
        dp[i].pb(happy[i-1][k++]+max(dp[i-1][0],dp[i-1][2]));
        dp[i].pb(happy[i-1][k++]+max(dp[i-1][0],dp[i-1][1]));
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
str s;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int k=(s.size()%2);
    k+=(s[0]==s[s.size()-1]);
    k%=2;
    if(k){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    return 0;
}




Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

typedef string::const_iterator State;
 
int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
 
int expression(State &begin){
    int ret = term(begin);
    while (1){
        if (*begin == '+'){
            begin++;
            ret += term(begin);
        }else if (*begin == '-'){
            begin++;
            ret -= term(begin);
        }else{
            break;
        }
    }
    return ret;
}
 
int term(State &begin){
    int ret = factor(begin);
    while (1){
        if (*begin == '*'){
            begin++;
            ret *= factor(begin);
        }else if (*begin == '/'){
            begin++;
            ret /= factor(begin);
        }else{
            break;
        }
    }
    return ret;
}
 
int factor(State &begin){
    if (*begin == '('){
        begin++;
        int ret = expression(begin);
        begin++;
        return ret;
    }else{
        return number(begin);
    }
}
 
int number(State &begin){
    int ret = 0;
    while (isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}

int main() {
    string s;
    int a;
    cin >> s >> a;
    State begin = s.begin();
    bool f1 = (a == expression(begin));
    int x = s[0] - '0';
    for (int i = 1; i < s.length(); i += 2){
        if (s[i] == '+') x += s[i+1] - '0';
        else x *= s[i+1] - '0';
    }
    bool f2 = (a == x);

    char ans;
    if (f1 & f2) ans = 'U';
    if (f1 & !f2) ans = 'M';
    if (!f1 & f2) ans = 'L';
    if (!f1 & !f2) ans = 'I';
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3148
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toInt()}
    val P = Array(N) { readLine()!!.split(" ").map{it.toLong()}}

    fun calc(mask: Long): Long {
        return P.filter { it[0] and mask == it[0] }
            .map {it[1]}
            .sum()
    }

    var res = calc(K.toLong())

    for (i in 1 until 30) {
        if (K and (1 shl i) == 0) {
            continue
        }

        val mask = (K and (1 shl i).inv()) or ((1 shl i) - 1)
        res = Math.max(res, calc(mask.toLong()))
    }

    println(res)
}


Measured memory_bytes: 86596
H = int(input())
h = H
d = [0]
while h > 0:
    d.append(h)
    h = h//2
d.sort()
attack = {}
attack[0] = 0
for i in range(1,len(d)):
    attack[d[i]] = 2*attack[d[i-1]] + 1
print(attack[H])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;


int main(void) {

    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S == U) A--;
    if(T == U) B--;
    
    cout << A <<  " " << B;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
vector<lli> dp(100001, INF);
vector<int> h(100001);
int N, K;

void do_dp(int n) {
	dp[0] = 0;
	rep(i, 1, N) {
		for (int j = 1; i - j >= 0; j++) {
			if (j > K)break;
			chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
}

int main(void) 
{	
	cin >> N >> K;
	rep(i, 0, N)cin >> h[i];
	do_dp(N);
	cout << dp[N-1] << endl;
}




Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 1e5 + 5;
int pr[32][MAX_N * 10], ss[MAX_N * 10];

int main(){
    int n, c; cin >> n >> c;
    for(int i=0;i<n;i++){
        int s, t, c; cin >> s >> t >> c;
        s *= 10; t *= 10;
        pr[c][s]++; pr[c][t]--;
    }

    for(int i=1;i<=c;i++){
        for(int j=0;j<MAX_N*10;j++){
            if(pr[i][j]==1) ss[j-5]++;
            else if(pr[i][j]==-1) ss[j]--;
        }
    }

    for(int i=0;i<MAX_N*10;i++) ss[i+1] += ss[i];

    cout << *max_element(ss, ss+MAX_N*10) << endl;
    return 0;
}


Measured memory_bytes: 125184
max_R = -10**9
for i in range(int(input())):
    if i == 0:
        min_R = int(input())
        continue
    R = int(input())
    if R - min_R > max_R:
        max_R = R - min_R
    if R < min_R:
        min_R = R
print(max_R)



Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int n, a[100000+10];
int main() {
    scanf("%d", &n);
    int ok = 1;
    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        if(a[i] != n-1) {
            ok = 0;
        }
    }
    if(ok) {
        printf("Yes\n");
        return 0;
    }
    int c = *max_element(a+1, a+1+n);
    
    int cnt = 0;
    for(int i=1;i<=n;i++) {
        if(c - a[i] >= 2) {
            printf("No\n");
            return 0;
        }
 
        if(c - a[i] == 1) {
            cnt ++;
        }
    }
 
    if((n-cnt) < 2*(c-cnt) || (cnt >= c)) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}

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

using namespace std;

#define N 100

int n, m, ex, ey, sum1[N + 5][N + 5], sum2[N + 5][N + 5], ans;
char s[N + 5][N + 5];
vector<vector<vector<vector<int> > > > f;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= m; ++j)
			if (s[i][j] == 'E')
				ex = i, ey = j;
	}
	f.resize(ex);
	for (int a = 0; a < ex; ++a) {
		f[a].resize(n - ex + 1);
		for (int b = 0; b <= n - ex; ++b) {
			f[a][b].resize(ey);
			for (int c = 0; c < ey; ++c)
				f[a][b][c].resize(m - ey + 1);
		}
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			sum1[i][j] = sum1[i][j - 1] + (s[i][j] == 'o');
			sum2[i][j] = sum2[i - 1][j] + (s[i][j] == 'o');
		}
	for (int a = 0; a < ex; a++)
        for (int b = 0; b <= n - ex; b++)
            for (int c = 0; c < ey; c++)
                for (int d = 0; d <= m - ey; d++) {
                	int U = b + 1, D = n - a, L = d + 1, R = m - c;
                	ans = max(ans, f[a][b][c][d]);
                	if (U < ex - a)
                		f[a + 1][b][c][d] = max(f[a + 1][b][c][d], f[a][b][c][d] + sum1[ex - a - 1][min(R, ey + d)] - sum1[ex - a - 1][max(L, ey - c) - 1]);
                	if (D > ex + b)
                		f[a][b + 1][c][d] = max(f[a][b + 1][c][d], f[a][b][c][d] + sum1[ex + b + 1][min(R, ey + d)] - sum1[ex + b + 1][max(L, ey - c) - 1]);
					if (L < ey - c)
                        f[a][b][c + 1][d] = max(f[a][b][c + 1][d], f[a][b][c][d] + sum2[min(D, ex + b)][ey - c - 1] - sum2[max(U, ex - a) - 1][ey - c - 1]);
                    if (R > ey + d)
                        f[a][b][c][d + 1] = max(f[a][b][c][d + 1], f[a][b][c][d] + sum2[min(D, ex + b)][ey + d + 1] - sum2[max(U, ex - a) - 1][ey + d + 1]);
                }
    printf("%d\n", ans);
	return 0;
}

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

using namespace std;

typedef vector<int> vi;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int n;
	while(cin >> n)
	{
		vi a(n), pos(n+1);
		for(int i=0; i<n; i++)
		{
			cin >> a[i];
			pos[a[i]] = i;
		}
		int mx = 0;
		int cnt = 1;
		for(int i=1; i<n; i++)
		{
			if(pos[i+1] > pos[i])
				cnt++;
			else
			{
				mx = max(mx,cnt);
				cnt = 1;
			}
		}
		mx = max(mx,cnt);
		cout << n - mx << endl;
	}

	return 0;
}


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

using namespace std;

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

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

using ll = long long;

int K;
vector<ll> A;

ll f(ll N) {
    rep(i, K) N -= N % A[i];
    return N;
}

template <typename F>
void bin(F ok, ll &lb, ll &ub) {
    lb = 0, ub = 1e18;
    rep(i, 100) {
        ll mid = (lb + ub) / 2;
        ll c = f(mid);
        if (ok(c)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
}

int main() {
    cin >> K;
    A.resize(K);
    rep(i, K) cin >> A[i];

    // rep(i, 20) cout << i << ", " << f(i) << endl;
    ll lb1 = 0, ub1 = 1e18;
    ll lb2 = 0, ub2 = 1e18;
    bin([](ll c) { return c < 2; }, lb1, ub1);
    bin([](ll c) { return c <= 2; }, lb2, ub2);

    if (f(ub1) == 2 && f(lb2) == 2) {
        cout << ub1 << " " << lb2 << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}


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

int main() {
	int n, nf, num, mnf, mnum;

	cin >> n;
	cin >> mnum >> mnf; n--;
	while (n--) {
		cin >> num >> nf;
		if (nf > mnf) {
			mnf = nf;
			mnum = num;
		}
		if (nf == mnf && num < mnum) mnum = num;
	}
	cout << mnum << " " << mnf << endl;

	return 0;
}

Measured memory_bytes: 1164