akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <queue>

using namespace std;
typedef long long int llint;

priority_queue<int> q;
int n,m;

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        q.push(tmp);
    }
    for(int i=0;i<m;i++)
    {
        q.push(q.top()/2);
        q.pop();
    }
    llint ans=0;
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len=strlen(str);
    vector<int> cnt(len);

    int i;
    for(i=0; i<len; i++) {
        int k=i;
        while(str[k]=='R') {
            k++;
        }
        int m=k;
        while(str[m]=='L') {
            m++;
        }

        int j;
        for(j=i; j<m; j++) {
            if(abs(j-k)%2==0) {
                cnt[k]++;
            }
            else {
                cnt[k-1]++;
            }
        }
        i=m-1;
    }
    for(i=0; i<len; i++) {
        printf("%d ", cnt[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 896
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		boolean x = true;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		for(int i = 0; i < N-1; i++) {
			if(A[i] == A[i+1]) {
				x = false;
			}
		}
		if(x == true) {
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 64496
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e14;

int dp[3003][3003];
string a,b;

string solve(int x,int y){
    string res="";
    while(x && y){
        if(a[x-1]==b[y-1]){
            res+=a[x-1];
            x--;y--;
        }else{
            if(dp[x][y-1]>dp[x-1][y])y--;
            else x--;
        }
    }
    reverse(res.begin(),res.end());
    return res;
}

int main() {
    fastio

    cin>>a>>b;
    int n=a.size(),m=b.size();
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]!=b[j-1])dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j-1]+1);
        }
    }
    cout<<solve(n,m);
	return 0;
}


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

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if(a+b>c+d)
  	cout<<"Left"<<endl;
  else if(a+b<c+d)
  	cout<<"Right"<<endl;
  else
  	cout<<"Balanced"<<endl;



}


Measured memory_bytes: 256
import itertools


def main():
    N, M, X = map(int, input().split())
    books = [None] * N
    costs = [0] * N
    for i in range(N):
        tmp = list(map(int, input().split()))
        costs[i] = tmp[0]
        books[i] = tmp[1:]
    ans = float("inf")
    for pattern in itertools.product([True, False], repeat=N):
        skills = [0] * M
        cost = 0
        for i in range(N):
            if pattern[i]:
                for j in range(M):
                    skills[j] += books[i][j]
                cost += costs[i]
        if min(skills) >= X:
            ans = min(ans, cost)
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68828
#include<bits/stdc++.h>
using namespace std;
#define inr(a,b) (x>=0 && x<n && y>=0 && y<m)
char mat[100][100];
int n,m;
int dx[]={0,-1,1};
int dy[]={0,-1,1};
int cal(int x,int y)
{
	int cnt=0;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(i==0 && j==0) continue;
			if(inr(x+dx[i],y+dy[j]) && mat[x+dx[i]][y+dy[j]]=='#')
			cnt++;
		}
	}
	return cnt;
}
int main() {
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		cin>>mat[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
		  if(mat[i][j]=='.')
		  cout<<cal(i,j);
		  else
		  cout<<mat[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n;
char a[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int cnt=0;
	for(int i=1;i<=n;i++)
	if(a[i]=='W')cnt++;
	int res=0;
	for(int i=n-cnt+1;i<=n;i++){
		if(a[i]!='W')res++;
	}
	cout<<res<<endl;
}



Measured memory_bytes: 3780
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: isize = iterator.next().unwrap().parse().unwrap();
    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();

    if (x - a).abs() < (x - b).abs() {
        "A".to_string()
    } else {
        "B".to_string()
    }
}


Measured memory_bytes: 2064
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: MarathonForces #1

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
int n;
vector<int> a;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n;
	a.resize(n);
	for(auto& e:a) cin >> e;
	int ans = 2e9;
	rep(i,1,n) {
		a[i] += a[i-1];
	}
	
	rep(i,1,n) {
		ans = min(ans, abs((a[n-1]-a[i]) - a[i]));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3644
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vector<vector<pair<int, int>>> s(D, vector<pair<int, int>>());
    int buff;
    REP(i, D) {
        REP(j, 26) {
            cin >> buff;
            s[i].push_back({buff, j + 1});
        }
    }

    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            vector<pair<int, int>> sss = s[count];
            sort(ALL(sss), greater<pair<int, int>>());
            int a = 1;
            REP(k, 26) {
                if (set26.count(sss[k].second)) {
                    if (rand() % 10 == 0) {
                        continue;
                    }
                    a = sss[k].second;
                    debug(sss[k].second);
                    break;
                }
            }

            cout << a << "\n";
            set26.erase(a);
            debug(a);
            count++;
            if (count >= D) {
                return;
            }
        }
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	LL n,a[1000]={0},q;
	 string s;
	 cin>>n;
	 cin>>s;
	 cin>>q;
	 while(q--)
	 {LL DMnum=0,Dnum=0,Mnum=0,DMCnum=0,k;
	 cin>>k;
	 	  for(LL i=0;i<s.length();i++)
	  {if(i-k>=0&&s[i-k]=='D')
		   {
		   	Dnum--;
		   	DMnum-=Mnum;
		   }
		   if(i-k>=0&&s[i-k]=='M')
		   {
		   	Mnum--;
		   	
		   }
		   
	  	 if(s[i]=='D')Dnum++;
	  	 if(s[i]=='M')
	  	 {
	  	 	Mnum++;
	  	 	DMnum+=Dnum;
		   }
		   if(s[i]=='C')
		   {
		   	DMCnum+=DMnum;
		   }
		   
	  	 
	  }
	  cout<<DMCnum<<"\n";
	 }
}

Measured memory_bytes: 1412
import os, sys, re, math

N = int(input())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

s = 0
for i in range(N):
    s += B[A[i] - 1]
    if i > 0 and A[i - 1] == A[i] - 1:
        s += C[A[i - 1] - 1]

print(s)


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

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];
        var k = long.Parse(Console.ReadLine());

        for(int i1 = 0; i1 <= k; i1++)
        {
            for(int i2 = 0; i2 <= k; i2++)
            {
                for(int i3 = 0; i3 <= k; i3++)
                {
                    if (i1 + i2 + i3 != k) continue;

                    var red = a;
                    for (int tmp = 0; tmp < i1; tmp++) red *= 2;
                    var green = b;
                    for (int tmp = 0; tmp < i2; tmp++) green *= 2;
                    var blue = c;
                    for (int tmp = 0; tmp < i3; tmp++) blue *= 2;

                    if(green > red && blue > green)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
        }

        Console.WriteLine("No");
        return;
    }
}

Measured memory_bytes: 28224
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int yy,mm,dd;
int geg[][3] ={{-9999,1,1},{1868,9,8},{1912,7,30},{1926,12,25},{1989,1,8},{9999,12,31}};
	string gen[] ={"pre-meiji","meiji","taisho","showa","heisei"};
	while(cin >>yy >>mm >>dd){
		if( cin.eof()) break;
		string disgen = ""; int disnen;
		rep2(i,1,6){
			int yymm =  geg[i][0] * 12 + geg[i][1];
			if(yy * 12 + mm < yymm ||
			yy * 12 + mm == yymm && dd < geg[i][2] ){
				disgen =  gen[i-1];
				disnen = yy - geg[i-1][0] + 1;
				break;
			}
		}
		if(disgen == "pre-meiji") cout << disgen << endl;
		else cout << disgen << " "<< disnen << " " << mm << " " << dd << endl;
	}
	return 0;
	
}

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

using namespace std;

int main()
{
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n>=s.length()){
      cout<<s<<endl;
  }
  else{
      for(int i=0;i<n;i++){
          cout<<s[i];
      }
      cout<<"..."<<endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string S;
  cin >> S;
  int L=S.length();
  for(int i=0;i<L;i+=2) cout << S[i];
}

Measured memory_bytes: 592
import collections

N,K = map(int, input().split())
A = list(map(int, input().split()))
C = collections.Counter(A)
_,mostV =zip(*C.most_common())
changeV = len(mostV) - K
if changeV >0:
    cnt = 0
    for i in range(1,changeV+1):
        cnt += mostV[-i]
    print(cnt)
else:
    print(0)




Measured memory_bytes: 130632
import sys
input = sys.stdin.readline
def divisor(n):
    divisors=[]
    for i in range(1,int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n=int(input())

s=divisor(n)
from bisect import bisect_left as bl
a=bl(s,n**0.5)
print(len(str(s[a])))


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int main()
{


    int w,h,n;
    cin>>w>>h>>n;
    int area = w*h;

    int ww=w,hh=h;

    set<int>a1,a2,a3,a4;

    int a1s=a1.size();
    int a2s=a2.size();
    int a3s=a3.size();
    int a4s=a4.size();

    int aa1,aa2,aa3,aa4;
    aa1=aa2=aa3=aa4=0;


    for(int i=0;i<n;i++)
    {
        int x,y,a;
        cin>>x>>y>>a;

        if(a==1)
        {
            /*a1.insert(x);

            if(a1s<a1.size())
            {
                a1s = a1.size();
                ww = ww-x;
            }*/

            aa1 = max(aa1,x);


        }else if(a==2)
        {
            /* a2.insert(x);

            if(a2s<a2.size())
            {
                a2s = a2.size();
                ww = ww-(w-x);
            }*/

            aa2 = max(aa2,(w-x));



        }else if(a==3)
        {
            /*a3.insert(y);

            if(a3s<a3.size())
            {
                a3s = a3.size();
                hh = hh-y;

            }*/

            aa3= max(aa3,y);



        }else if(a==4)
        {
            /*a4.insert(y);

            if(a4s<a4.size())
            {
                a4s = a4.size();
                hh = hh-(h-y);
            }*/

            aa4 = max(aa4,(h-y));



        }

       // cout<<ww<<"  "<<hh<<endl;
    }

    //cout<<aa1<<"  "<<aa2<<"  "<<aa3<<"  "<<aa4<<endl;
    ww = w-aa1;
   // cout<<ww<<"  "<<hh<<endl;
    ww = ww-aa2;
   // cout<<ww<<"  "<<hh<<endl;
    hh = h-aa3;
    //cout<<ww<<"  "<<hh<<endl;
    hh = hh - aa4;
   // cout<<ww<<"  "<<hh<<endl;

    if(hh<0 || ww<0)cout<<"0"<<endl;
    else cout<<hh*ww<<endl;


    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n;
    	ll t=0;
    	while(n!=0)
    	{
    		ll x=n%10;
    		n=n/10;
    		if(x==7)
    			t=1;
    	}
    	if(t)
    		cout<<"Yes\n";
    	else
    		cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
typedef pair<int64, int64> P;
map<P, int64> p;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

int64 lcm(int64 a, int64 b) {
		return a / gcd(a, b) * b;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

P f(int64 n) {
	int a = n % 10;
	int b;
	while (n > 0) {
		b = n % 10;
		n /= 10;
	}
	return P(b, a);
}


void solve() {
		int64 n; cin >> n;
		map<P, int> freq;
		for (int i = 1; i <= n; ++i) {
			P p = f(i);
			freq[p]++;
		}
		int64 ans = 0;
    for (int i = 1; i <= n; ++i) {
			P p = f(i);
			P q(p.second, p.first);	
			ans += freq[q];
		}
		cout << ans << endl;
		return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	cin>>n;
	int se[100010], nu[100010];
	int sei = 6, nuev = 9, sec = 1, nuv = 1;
	fore(i, 0, 100010)
	{
		if(i >= sec * 6)
			sec *= 6;
		se[i] = sec;
		if(i >= nuv * 9)
			nuv *= 9;
		nu[i] = nuv;
	}
	int res = 10000,ax, con;
	fore(i, 0, (1<<23))
	{
		con = 0;
		ax = n;
		fore(j, 0, 23)
		{
			if(ax > 0)
			{
				if(i & (1<<j))
					ax -= se[ax];
				else
					ax -= nu[ax];
				con++;
			}
		}
		con += ax;
		res = min(res, con);
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s)
        cout << a - 1 << " " << b << endl;
    else
        cout << a << " " << b - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
m = n
primes = {}

for i in range(2, int(n**0.5+2)):
  while m % i == 0:
    m //= i
    if i not in primes:
      primes[i] = 1
    else:
      primes[i] += 1
  if i > m:
    break

if m != 1:
  primes[m] = 1

cnt = 0
num = 0
flag = True

while flag == True:
  num += 1
  flag = False
  for i in primes:
    if 0 < primes[i] <= num*2:
      cnt += 1
      primes[i] = 0
    elif primes[i] > num*2:
      cnt += 1
      flag = True
      primes[i] -= num

print(cnt)

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

int main(){
	char ch;
	int cnt[26] = {0};
	while(cin >> ch){
		if(isupper(ch)) cnt[ch - 'A']++;
		else if(islower(ch)) cnt[ch - 'a']++;
	}
	for(int i=0;i<26;i++){
		cout << char(i +'a') << " : " << cnt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,X,sum;
  cin>>N>>D>>X;
  sum=X;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  for(int i=0; i<N; i++){
    for(int a=0; a<D; a++){
    if(D>=1+A[i]*a){
      sum++;
    }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n:u32 = sc.read();
    let mut v:Vec<String> = Vec::new();
    let mut is_fair:bool = true;

    for i in 0..n {
        let now_answer:String = sc.read();
        if i == 0 {
            v.push(now_answer);
        }else {
            if v.contains(&now_answer) {
                is_fair = false;
            }
            if &v.last().unwrap()[v.last().unwrap().chars().count()-1..] != &now_answer[..1] {
                is_fair = false;
            }
            v.push(now_answer);
        }
    }
    if is_fair {
        println!("Yes");
    }else {
        println!("No");
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int x = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    
    if(b <= a) Console.WriteLine("delicious");
    else if(b <= a + x) Console.WriteLine("safe");
    else Console.WriteLine("dangerous");
  }
}

Measured memory_bytes: 13140
N = int(input())
abc = []
for i in range(N):
    abc.append(list(map(int, input().split())))

dp = [[0]*3 for i in range(N)]
dp[0] = abc[0]
for i in range(1, N):
    for j in range(3):
        for next_j in range(3):
            if j != next_j:
                dp[i][next_j] = max(dp[i][next_j], dp[i-1][j] + abc[i][next_j])

print(max(dp[-1]))

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

using namespace std;

int main() {
    int n, q;  cin >> n >> q;
    string s;   cin >> s;
    int *t = new int[n];
    for (int i = 0; i < n; i++)
        t[i] = 0;

    for (int i = 0; i < n; i++) {
        t[i+1] = t[i];
        if (i+1 < n && s[i] == 'A' && s[i+1] == 'C') {
            t[i+1] += 1;
        }
    }
    int *r = new int[q];
    int *l = new int[q];
    for (int i = 0; i < q; i++)
        cin >> l[i] >> r[i];

    for (int i = 0; i < q; i++)
        cout << t[r[i]-1] - t[l[i]-1] << endl;

    return 0;
}

Measured memory_bytes: 2240
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
#include<algorithm>
using namespace std;


int main(int argc,char** argv)
{

	int a,b;
	cin >> a >> b;
	char c[a][b];
	int gyou[a];
	int retu[b];

	//初期化
	for(int i = 0; i < a; i++){
		gyou[i] = 0;
	}
	for(int i = 0; i < b; i++){
		retu[i] = 0;
	}

	//代入＆値の確認
	for(int i = 0; i < a; i++){
		for(int j = 0; j < b; j++){
			cin >> c[i][j];
			if(c[i][j] == '.'){
				gyou[i]++;
				retu[j]++;
			}
		}
	}

	int f=0;
	for(int k = 0; k < a; k++){
		for(int m = 0; m < b; m++){
			if (gyou[k] == b || retu[m] == a){
				//
			}
			else{
				cout << c[k][m];
				f++;
			}
		}
		if(f!=0){
			cout << endl;
		}
		f=0;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m,c;
  cin>>n>>m>>c;
  int b[20];
  int a[20];
  int ans=0;
  rep(i,m) cin>>b[i];
  rep(i,n){
    int check=c;
    rep(j,m){
      cin>>a[j];
      check+=(a[j]*b[j]);
    }
    if(check>0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using usize = std::size_t;
using namespace std;

#define rep(i, max) for(i32 i = 0; i < (i32)max; ++i)
#define loop while(true)
#define allOf(collection) collection.begin(), collection.end()

unique_ptr<string> readLine() { unique_ptr<string> line(new string()); getline(cin, *line); return line; }
template<typename T1, typename T2> pair<T1, T2> readPair() { T1 res1; cin >> res1; T2 res2; cin >> res2; readLine(); return make_pair(res1, res2);}
template<typename T> unique_ptr<vector<T>> readVector(usize num) { unique_ptr<vector<T>> list(new vector<T>(num)); rep(i, num) cin >> (*list)[i]; readLine(); return list; }
void readValues() { readLine(); }
template<typename H, typename... T> void readValues(H& head, T&&... tails){ H a; cin >> a; head = a; readValues(forward<T>(tails)...); }
void writeLine() { cout << endl; }
template<typename T> void write(const T& arg) { cout << arg; }
template<typename T> void writeLine(const vector<T>& arg){ if(arg.empty()) { writeLine(); return; } write(arg[0]); for(int i = 1; i < arg.size(); ++i){ write(" "); write(arg[i]); } writeLine(); }
template<typename T> void writeLine(const T& arg) { cout << arg << endl; }
void recursiveCombination(vector<i32>& indexes, i32 s, i32 rest, function<void(vector<i32>&)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursiveCombination(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursiveCombination(indexes, s - 1, rest - 1, f); } }
void foreachWithCombination(i32 n, i32 k, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(k); recursiveCombination(indexes, n - 1, k, f); }
void foreachWithPermutaton(i32 n, function<void(vector<i32>&)> f) { auto indexes = vector<i32>(); indexes.reserve(n); rep(i, (usize)n) indexes.push_back(i); do f(indexes); while (next_permutation(allOf(indexes))); }
void foreachWithPermutaton(i32 n, i32 k, function<void(vector<i32>&)> f){ foreachWithCombination(n, k, [=](vector<i32>& combIndexes){ foreachWithPermutaton(k, [=](vector<i32>& permIndexes){ auto indexes = vector<i32>(); indexes.reserve(k); rep(i, (usize)k){ indexes.push_back(combIndexes[permIndexes[i]]); } f(indexes); }); }); }
void program();
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    program();
}

void program() {
    auto s = *readLine();
    i32 count = 0;
    i32 maxi = 0;
    rep(i, s.size()) {
        if(s[i] == 'R') ++count;
        else{
            maxi = max(maxi, count);
            count = 0;
        } 
    }
    maxi = max(maxi, count);
    writeLine(maxi);
}

Measured memory_bytes: 3608
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
string s;
int main()
{
  cin>>s;
  sort(s.begin(),s.end());
  if(s=="abc") puts("Yes");
  else puts("No");
  return 0;
}

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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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



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

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U)
    {
        A--;
    }
    else
    {
        B--;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
inf = float('inf')
# ベルマンフォード法 計算量(VE)
# [引数]: 隣接リスト, 始点, 終点
class Bellmanford:
    def __init__(self, to : list, start : int, goal : int):
        self.N = len(to)
        self.to = [s[:] for s in to]
        self.start = start
        self.goal = goal
        self.dist = [inf] * self.N
        self.dist[start] = 0
    
    # self.distを更新
    def update(self) -> None:
        for _ in range(self.N - 1):
            for v, s in enumerate(self.to):
                if not s: continue
                for nv, w in s:
                    if self.dist[nv] > self.dist[v] + w:
                        self.dist[nv] = self.dist[v] + w
    
    # グラフの負閉路検出
    def detection(self) -> bool:
        exists_negative_cycle = False
        for v, s in enumerate(self.to):
            if not s: continue
            for nv, w in s:
                if self.dist[nv] > self.dist[v] + w:
                    self.dist[nv] = self.dist[v] + w
                    exists_negative_cycle = True
        return exists_negative_cycle
    
    # スタートからゴールまでのパスの負閉路検出
    def detection_stog(self) -> bool:
        exists_negative_cycle_stog = False
        is_updated = [False] * self.N
        for _ in range(self.N):
            for v, s in enumerate(self.to):
                if not s: continue
                for nv, w in s:
                    if self.dist[nv] > self.dist[v] + w:
                        self.dist[nv] = self.dist[v] + w
                        is_updated[nv] = True
                    if is_updated[v] is True:
                        is_updated[nv] = True
        exists_negative_cycle_stog = is_updated[self.goal]
        return exists_negative_cycle_stog

N, M, P = map(int,input().split())
to = [[] for _ in range(N)]
for _ in range(M):
    A, B, C = map(int,input().split())
    A -= 1; B -= 1
    C -= P
    to[A].append((B, -C))

BF = Bellmanford(to, 0, N-1)
BF.update()

if BF.detection_stog():
    ans = -1
else:
    ans = max(-BF.dist[N-1], 0)

print(ans)

Measured memory_bytes: 58328
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> mi(n);
    vector<int> ma(n);
    for (int i = 0; i < n; ++i) {
        mi[i] = 1;
        ma[i] = M;
    }
    for (int i = 0; i < n; ++i) {
        if (i == 0 || t[i - 1] < t[i]) {
            mi[i] = max(mi[i], t[i]);
            ma[i] = min(ma[i], t[i]);
        }
        else {
            ma[i] = min(ma[i], t[i]);
        }
    }
    for (int i = n - 1; i >= 0; --i) {
        if (i == n - 1 || a[i + 1] < a[i]) {
            mi[i] = max(mi[i], a[i]);
            ma[i] = min(ma[i], a[i]);
        }
        else {
            ma[i] = min(ma[i], a[i]);
        }
    }
    long long ans = 1;
    for (int i = 0; i < n; ++i) {
        ans = (ans * max(ma[i] - mi[i] + 1, 0)) % M;
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int count=0;
  for(int i=1;i<=N;i++){
    if(i%2!=0){
      count++;
    }
  }
  double ans=(count/(double)N);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,P = LMIIS()
    S = input()[::-1]
    R = [0]*P
    R[0] = 1
    b = 1
    r = 0


    if P == 2 or P == 5:
        ans = 0
        for i,c in enumerate(S):
            if int(c) % P == 0:
                ans += N-i
        print(ans)
        return

    for c in S:
        r += b * int(c)
        r %= P
        R[r] += 1
        b *= 10
        b %= P
    ans = 0

    for r in R:
        ans += r*(r-1)//2
    print(ans)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 41968
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin>>h>>w;
    VV A(h,V(w));
    rep(i,h)rep(j,w)cin>>A[i][j];
    VV B(h,V(w));
    rep(i,h)rep(j,w)cin>>B[i][j];
    bool dp[h+1][w+1][2*80*(h+w)+1];
    rep(i,h+1)rep(j,w+1)rep(k,2*80*(h+w)+1)dp[i][j][k]=false;
    dp[0][0][80*(h+w)+A[0][0]-B[0][0]]=true;
    dp[0][0][80*(h+w)+B[0][0]-A[0][0]]=true;
    rep(i,h){
        rep(j,w){
            rep(k,2*80*(h+w)+1){
                if(!dp[i][j][k])continue;
               // cout<<i<<" "<<j<<" "<<(80*(h+w)-k)<<endl;
                if(i+1<h){
                    dp[i+1][j][k+A[i+1][j]-B[i+1][j]]=true;
                    dp[i+1][j][k+B[i+1][j]-A[i+1][j]]=true;
                }
                if(j+1<w){
                    dp[i][j+1][k-A[i][j+1]+B[i][j+1]]=true;
                    dp[i][j+1][k+A[i][j+1]-B[i][j+1]]=true;
                }
            }
        }
    }
    
    rep(i,2*80*(h+w)+1){
        if(dp[h-1][w-1][abs(80*(h+w)-i)]){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 164352
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
    using namespace std;
    
    static const int INPUT_MIN = -1000;
    static const int INPUT_MAX =  1000;
    int input_num1 = 0;
    int input_num2 = 0;
    cin >> input_num1;
    cin >> input_num2;
      
    assert(INPUT_MIN <= input_num1 && input_num1 <= INPUT_MAX); /* Precondition */
    assert(INPUT_MIN <= input_num2 && input_num2 <= INPUT_MAX); /* Precondition */
    
    /* Comparison */
    if(input_num1 < input_num2){
        cout << "a < b" << endl;
    }
    else if(input_num1 > input_num2){
        cout << "a > b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3084
let b = stdin.ReadLine()

stdin.ReadLine().ToCharArray()
|> Array.toList
|> List.rev
|> (fun (x :: xx) -> xx)
|> List.rev
|> List.toArray
|> System.String
|> (fun x -> if x = b then "Yes" else "No")
|> printfn "%s"


Measured memory_bytes: 29608
#include<stdio.h>
#include<stdlib.h>

int g(char*s,char*t){
	int i=0;
	while(s[i]!='\0'&&t[i]!='\0')
		if(s[i]!=t[i++])return 0;
	if(s[i]=='\0'&&t[i]!='\0')return 0;
	return 1;
}

int f(char*s){
	if(s[0]=='\0'){printf("YES\n");exit(0);}
	if(g(s,"dream"))f(&s[5]);
	if(g(s,"dreamer"))f(&s[7]);
	if(g(s,"erase"))f(&s[5]);
	if(g(s,"eraser"))f(&s[6]);
}


int main(void){
	char s[100000];
	scanf("%s",s);
	int i=0;
	f(s);
	printf("NO\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  string s ;
  cin >> s ;
  vector<int> vec(4) ;
  REP(i,4){
    vec.at(i) = s.at(i)-'0' ;
  }
    //hogeeeeeは配列のサイズを入れる(定数)
  for (int bitt = 0; bitt < (1 << 3); bitt++) {
    bitset<3> bits(bitt); 
    int che = vec.at(0) ;
    for (int i = 0; i <3; i++) {
      if (bits.test(i)) {
        che += vec.at(i+1) ;
      }
      else{
        che -= vec.at(i+1) ;
      }
    }
    if(che==7){
      cout << vec.at(0);
      for (int i = 0; i <3; i++){
        if (bits.test(i)) {
          cout <<"+";
        }
        else{
          cout <<"-";
        }
        cout << vec.at(i+1) ;
      }
      cout <<"=7"<<endl ;
      return 0 ;
    }
  }

  return 0 ;
}

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

int main()
{
	int n, m;
	cin>>n>>m;
	int a,b;
	a = min(n, m);
	b = max(n, m);
	
	for(int i=0;i<b;i++){
		if(i==b-1){
			cout<<a<<endl;
		}else{
			cout<<a;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    int sum=0;
    for(int i=1;;i++){
        sum+=i;
        if(sum>=x){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


const string YES = "Yes";
const string NO = "No";

void func(long long a, long long b, long long c){

    vector<lli> d(3);
    d[0]=a;
    d[1]=b;
    d[2]=c;
    sort(d.begin(),d.end());
    if(d[0]+d[1]==d[2])cout<<YES<<endl;
    else cout<<NO<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    func(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

void solve() {
    ll a, b;
    cin >> a >> b;
    if(a == b) {
        print((a - 1) * 2);
        return;
    }
    ll root = sqrt(a * b);
    if(root * root == a * b) {
        print(root * 2 - 3);
    } else if(root * root < a * b - root) {
        print(root * 2 - 1);
    } else {
        print(root * 2 - 2);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    while(q--) {
        solve();
    }
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

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

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

bool comp(const string& f, const string& s){
    return f.size() < s.size();
}
int main(void){
    ll x;
    cin >> x;

    ll i = 0;
    ll now = 0;
    ll ans = 0;
    while(1){
        now += i;
        if(now > x){
            ans = i;
            break;
        } else if(now == x){
            ans = i;
            break;
        }
        i++;
    }
    cout << ans << endl;
}

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

#define ll long long
#define N 200010
char s[N];

int main()
{
	while (scanf("%s", s + 1) != EOF)
	{
		ll res = 0;
		int len = strlen(s + 1); int last = len;
		for (int i = len; i >= 1; --i)
		{
			if (s[i] == 'B') 
			{
				res += last - i;
				--last;
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

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

  int one=0;
  int two=0;
  int four=0;
  for(int i=0;i<N;i++){
    if(a[i]%4==0)four++;
    else if(a[i]%2==0)two++;
    else one++;
  }
  if(two>0)one++;

  if(one==0)cout<<"Yes"<<endl;
  else if(abs(one-four)>1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main(){
int r,d,x;
cin >>  r >> d >> x;
vector<long long > a(11);
a.at(0)=x;
for(int i=1;i<11;i++){
    a.at(i)=r*a.at(i-1)-d;
    cout << a.at(i) << endl;
}

}

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

using namespace std;

int main(void) {
	int a[3] = { 0 }, n[3], i;
	for (i = 0; i < 3; i++)
		cin >> n[i];
	if (n[0] == n[1] && n[1] == n[2]) {
		if (n[0] & 1)
			printf("0\n");
		else
			printf("-1\n");
	}
	else {
		for (i = 0; i < 3; i++) {
			while ((n[i] & 1) == 0) {
				a[i]++;
				n[i] >>= 1;
			}
		}
		i = min(min(a[0], a[1]), a[2]);
		if (a[0] == a[1] && a[1] == a[2])
			i++;
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 896