akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int X, A, B;
    cin >> X >> A >> B;

    cout << (X - A) % B << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){    
  int n;
  cin >> n;
  int t[3],s[n],count=0,a;
  
  for(int i=0;i<n;i++){
    cin >> s[i];
  }

  for(int i=0;i<n-2;i++){
    a = s[i+1];
    t[0] = s[i];
    t[1] = s[i+1];
    t[2] = s[i+2];

    sort(t,t+3);
    if(t[1] == a){
      count++;
    }  
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <vector>

using namespace std;



int main()
{
	string in;
	string res = "";
	
	cin >> in;
	for (int i=0; i<in.length(); i++)
	{
		if (in[i] == 'A')
		{
			res += 'X';
		} else if (in[i] == 'B') {
			res += 'Y';
		} else if (in[i] == 'C') {
			res += 'Z';
		} else {
			res += in[i] - 3;
		}
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>

#define min(_x,_y)_y^(_x^_y)&-(_x<_y)

using namespace std;

int main(){
	
	int v[101] = {0};
	int N, M, X, A, i;
	scanf("%d %d %d", &N, &M, &X);
	for (i = 0; i < M; ++i){
		scanf("%d", &A);
		v[A]++;
	}

	int sum1, sum2;
	sum1 = sum2 = 0;
	for (i = 0; i < X; ++i)
	{
		sum1 += v[i];
	}
	for (i = X+1; i < N; ++i)
	{
		sum2 += v[i];
	}
	printf("%d\n", min(sum1, sum2));
}

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

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

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 205;
int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
        ll n;
        cin>>n;
        ll a[n];
        for(i=0; i<n; i++)
        {
            cin>>a[i];

        }

        ll cnt=0;
        set<ll>s;
        for(i=0; i<n-2; i++)
        {
            for(j=i+1; j<n-1; j++)
            {
                for(k=j+1; k<n; k++)
                {
                    s.insert(a[i]);
                    s.insert(a[j]);
                    s.insert(a[k]);
                    if(s.size()==3)
                    {
                        auto it=s.begin();
                        ll val=*it;
                        it++;
                        ll val1=*it;
                        it++;
                        ll val2=*it;
                        if(val+val1>val2)
                            cnt++;
                    }
                    s.clear();
                }
            }
        }
        cout<<cnt;
    }
    return 0;
}





Measured memory_bytes: 3616
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 計算
	    int result = max(0 ,a - 2*b);

		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<int> qlow;
    priority_queue<int, vector<int>, greater<int>> qhigh;

    int numL = 0, numR = 0;
    int Q; cin >> Q;
    int mid = 0;
    int t = 0;
    int ans = 0;
    int cnt = 0;
    while(Q--) {
        int x, a, b; cin >> x;
        if (x == 1) {
            cin >> a >> b;
            t += b;
            if (qlow.size() < qhigh.size()) qlow.push(a);
            else qhigh.push(a);
            if (qlow.size() && qlow.top() > qhigh.top()) {
                int H = qlow.top();
                int L = qhigh.top();
                qlow.pop(); qhigh.pop();
                qlow.push(L);
                qhigh.push(H);
            }
            cnt++;
        }
        int nxt = 0;
        if (qlow.size() < qhigh.size()) nxt = qhigh.top();
        else nxt = qlow.top();
        // if (qlow.size())
        //     cout << qlow.size() << " " << qhigh.size() << " " << qlow.top() << " " << qhigh.top() << endl;
        
        if (x == 1) {
            ans += abs(nxt - a);
            //cout << nxt << " " << ans + t<< " " << qhigh.size() << " " << qlow.size() << endl;
            if (mid < nxt && cnt > 1) {
                ans += (mid - nxt) * (qhigh.size() - cnt % 2);
                ans += (nxt - mid) * (qlow.size() - (cnt + 1) % 2);
            } else if (mid > nxt && cnt > 1) {
                int R = (qhigh.size() - cnt % 2);
                int L =  (qlow.size() - (cnt + 1) % 2 );
                ans += (mid - nxt) * R;
                ans += (nxt - mid) * L;
                //cout << L << " " << R << endl;
            }
        }

        mid = nxt;
        //cout << nxt << " " << ans + t<< " " << qhigh.size() << " " << qlow.size() << endl;
        if (x == 2)
            cout << nxt << " " << ans + t << endl;
    }


    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,W;
    cin >> n >> W;
    long long dp[W+1]={};
    for(int i=0;i<n;i++){
        int w,val;
        cin >> w >> val;
        for(int j=W;j>=w;j--){
            dp[j]=max(dp[j],dp[j-w]+val);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. A-WHITE.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 IN-DATA.
   03 DT-X1 PIC X(10).
   03 DT-X2 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
   03 DT-L2 PIC 9(2).
01 IN-BH    PIC 9(2).
01 IN-BW    PIC 9(2).
01 IN-SH    PIC 9(2).
01 IN-SW    PIC 9(2).
01 OUT-WHT  PIC ZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2.
  MOVE DT-X1(1:DT-L1) TO IN-BH.
  MOVE DT-X2(1:DT-L2) TO IN-BW.
 
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2.
  MOVE DT-X1(1:DT-L1) TO IN-SH.
  MOVE DT-X2(1:DT-L2) TO IN-SW.

  COMPUTE OUT-WHT = IN-BH * (IN-BW - IN-SW)  
                  + IN-SH * (IN-SW - IN-BW)

  DISPLAY OUT-WHT.

MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    long long w,h,x,y;
    double rta,mitadX,mitadY,flagX,flagY;
    bool salida;
    cin >> w >> h >> x >> y;
    flagX=(double)x;
    flagY=(double)y;
    mitadX=w/2.0;
    mitadY=h/2.0;
    rta=(w*h)/2.0;
    salida=(flagX==mitadX) && (flagY==mitadY);
    cout << fixed << setprecision(9) << rta << " " << salida << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main(void) {    

int a,b,c,i;    

int count;    

scanf("%d %d %d\n", &a, &b, &c);    

for(i=a,count=0;i<=b;i++) {        

if(c%i==0) count ++;    

}    

printf("%d\n", count);         

return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  if(S[0]!=S[1] && S[1]!=S[2] && S[0]!=S[2])
    {
      cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; ++i){
        cin >> H[i];
    }

    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(H[i] >= K){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;

namespace A___On_the_Way
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B_C = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B_C[0], B = A_B_C[1], C = A_B_C[2];

            Console.WriteLine((A < C && C < B) || (A > C && C > B)  ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for _ in range(n)]
dp[0]=l[0]
for i in range(n-1):
  for j in range(3):
    dp[i+1][j]=max(dp[i][(j+1)%3]+l[i+1][j],dp[i][(j+2)%3]+l[i+1][j])
print(max(dp[n-1]))

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

int main() {
  int n, k, i;
  int x[100] = { 0 };
  int sum = 0;
  
  cin >> n >> k;
  
  for(i = 0; i < n; i++)
    cin >> x[i];
  
  for(i = 0; i < n; i++)
  {
    if(x[i] < k - x[i])
      sum += x[i] * 2;
    else
      sum += (k - x[i]) * 2;
  }
    
  cout << sum << endl;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

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; }

#if 0
	auto possible = [&](LL t) {

		return false;
	};
	LL left = 1, right = 1000000000;
	while (right - left > 1) {
		LL mid = (left + right) / 2;
		if (possible(mid)) {
			left = mid;
		} else {
			right = mid;
		}
	}
#endif

void solve(std::string S, std::string T) {
	LL ans = 1 << 30;
	int a = S.length(), b = T.length();
	for (int i = 0; i + b <= a; ++i) {
		LL c = 0;
		for (int j = 0; j < b; ++j) {
			c += S[i + j] != T[j];
		}
		ans = min(ans, c);
	}
	cout << ans << endl;
}

int main() {
    std::string S;
	std::cin >> S;
	std::string T;
	std::cin >> T;
	solve(S, T);
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int n, k, h[maxn];
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    int n;
    while(cin >> n) {
        int H = 0, ans = 0;
        for(int i = 0; i < n; ++i) {
            cin >> h[i];
            H = max(h[i], H);
            if(h[i] >= H) ++ans;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
string s[3];
/**********************************************/

signed main(){
    REP(i, 3)cin >> s[i];
    REP(i, 3){
        cout << s[i][i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,ans;

main(){
	cin>>n;
	ans=(n/11)*2;
	n%=11;
	if(n==0)dans;
	else if(n<=6)dump(ans+1);
	else dump(ans+2);
}

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

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

	int n;
	cin >> n;

	vector<long double> dp(n + 1);
	dp[0] = 1;
	for(int i = 0; i < n; i++)
	{
		long double p;
		cin >> p;

		vector<long double> next(n + 1);
		for(int j = 0; j <= n; j++)
		{
			if(j != 0) next[j] += dp[j - 1] * p;
			next[j] += dp[j] * (1 - p);
		}

		dp = next;
	}

	long double ans = 0;
	for(int i = n / 2 + 1; i <= n; i++)
		ans += dp[i];

	cout << setprecision(10) << fixed;
	cout << ans << "\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int n;
ll a[300010];

ll mul(ll a, ll b) {
    a %= MOD; b %= MOD;
    ll ans = (a*b) % MOD;
    if (ans < 0) ans += MOD;
    return ans;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    ll sum = 0;
    rep(i, 64) {
        ll zc = 0, oc = 0;
        ll idsum = 0;
        rep(j, n) {
            if (a[j] % 2 == 0) zc++;
            else oc++;
            a[j] /= 2;
        }
        idsum = mul(mul(oc, zc), 1ll<<i);
        sum += idsum;
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

const ll C_MAX = (ll)1e18;

int main()
{
	ll A, ret;
	long double B;

	cin >> A >> B;
	ret = ((B * 1000) * A / 1000);

	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;


int main() {
    int N;
    cin>>N;
    vector<double> v(N);
    rep(i,N){cin>>v.at(i);}
    sort(v.begin(),v.end());
    double ans=v.at(0);
    rep(i,N-1){
        ans+=v.at(i+1);
        ans/=2;
    }
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	char s[10];
	int b=0;
	cin >> s;
	for(int i=0;i<3;i++){
		if(s[i]=='1'){
			b+=1;
		}
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
int function(int arr[],int initial,int final,int memo[][2],int status)
{
	if(initial>final)
	    return 0;
	if(memo[initial][status]!=-1)
	     return memo[initial][status];
	if(initial==final)
	{
		int val=arr[initial];
		if(status)
		   val*=-1;
		return val;
    }
    else
    {
		int here=arr[initial];
		if(status)
		    here*=-1;
		int val1=here+function(arr,initial+1,final,memo,0);
		int val2=-here+function(arr,initial+1,final,memo,1);
		memo[initial][status]=max(val1,val2);
		return memo[initial][status];
	}
}
int32_t main()
{
	int n;
	cin>>n;
	int j,arr[n+1];
	for(j=1;j<=n;j++)
	{
		cin>>arr[j];
	}
	int memo[n+1][2];
	int i;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<2;j++)
		{
			memo[i][j]=-1;
		}
	}
	int answer=function(arr,1,n,memo,0);
	cout<<answer<<endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        while(tmp % 2 == 0){
            ans++;
            tmp = tmp / 2;
        }
    }

    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
s = input()

ans = True

for c in s[0::2]:
    if c not in {'R', 'U', 'D'}:
        ans = False
        break

for c in s[1::2]:
    if c not in {'L', 'U', 'D'}:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')


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

import math

while True:
  try:
    ( a, b, c, d, e, f ) = map ( float, input ( ).split ( ) )
  except EOFError: break
  x = ( c * e - b * f ) / ( a * e - b * d )
  y = ( a * f - c * d ) / ( a * e - b * d )
  print ( "%.3f %.3f" % ( math.floor ( x * 1000 + 0.5 ) / 1000, math.floor ( y * 1000 + 0.5 ) / 1000 ) )

Measured memory_bytes: 6828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

ll mypow(ll a, ll b)
{
    if (b == 1)
    {
        return a;
    }
    else
    {
        return a * mypow(a, b - 1);
    }
}

signed main()
{
    string s;
    cin >> s;
    int num_of_l = 0;
    int num_of_r = 0;
    int a = 0;
    rep(i, s.size())
    {
        //        cout << "i:" << i << endl;
        num_of_l = 0;
        num_of_r = 0;
        if (s[i] == 'R')
        {
            a = i;
            rep(j, s.size() - i)
            {
                if (s[a + j] == 'R')
                {
                    if (num_of_l == 0)
                    {
                        num_of_r++;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    num_of_l++;
                }
            }
            //            cout << num_of_r << " " << num_of_l << endl;
            rep(j, num_of_r - 1)
            {
                cout << 0 << " ";
            }
            cout << (num_of_r + 1) / 2 + (num_of_l / 2) << " ";
            cout << num_of_r / 2 + (num_of_l + 1) / 2 << " ";
            rep(j, num_of_l - 1)
            {
                cout << 0 << " ";
            }
            i += num_of_l + num_of_r - 1;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3668
#!/usr/bin/perl

$s = <STDIN>;
$t = <STDIN>;

chomp $s;
chomp $t;

$result = 0;
for ( $i=0; $i<3; $i++ ) {
	if ( substr($s, $i, 1) eq substr($t, $i, 1) ) {
		$result++;
	}
}
print "$result\n";


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        cout << (char)((s[i]-'A'+n)%26+'A');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, B, digit = 1, sum = 0, C;
  cin >> N;
  
  B = N; // Nのバックアップ
  C = N; // Nのバックアップ

  //N の桁数
  
 for ( i = 0; i < N; i++) { 
   if (B / 10 > 0) {
     B = B / 10;
     digit++;
   }
   else {
     break;
   }
}

  //Nの数字一覧
  
   for ( i = 0; i < digit; i++) { 
	sum += N % 10;
     N /= 10;
   }
 
  if( C % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3604
#include <stdio.h>

#define endl '\n'

int main()
{
    int n, i, m=0;
    scanf("%d", &n);
    int ara[n];

    for(i=0; i<n; i++)
    {
        scanf("%d", &ara[i]);
        if(ara[i]-i-1) m++;
    }

    !m || m==2? printf("YES"): printf("NO");

    return 0;
}


Measured memory_bytes: 1736
# n,m,q = map(int,input().split())
# q_dic = dict()
# for i in range(1, n):
#     for j in range(i+1, n+1):
#         q_dic[(i,j)] = [0]*m
# for i in range(q):
#     a,b,c,d = map(int,input().split())
#     q_dic[(a,b)][c] = d
# dp = []
# for i in range(n+1):
#     dp.append([0]*(m+1))
# print(dp)
# for i in range(1, n):
#     for j in range(i+1, n+1):
#         tar = q_dic[(i,j)]
#         print(tar)
#         for k in range(len(tar)):
#             for l in range(m+1):
#                 dp[j][k] = dp[i][l] + tar[k]
# print(dp)
#
import itertools
def combination_with_replace_all(seq, choice):
    return list(itertools.combinations_with_replacement(seq, choice))

n,m,q = map(int,input().split())
query = []
ans = -1
for i in range(q):
    a,b,c,d = map(int,input().split())
    query.append((a,b,c,d))
cond = combination_with_replace_all([i for i in range(1,m+1)], n)
for i in range(len(cond)):
    cond_ar = cond[i]
    cnt = 0
    for j in range(q):
        if cond_ar[query[j][1]-1] - cond_ar[query[j][0]-1] == query[j][2]:
            cnt += query[j][3]
    ans = max(ans,cnt)
print(ans)





Measured memory_bytes: 85008
#include <stdio.h>

int main( ){

  int n, i, j, u, v, k, M[101][101];

  scanf("%d", &n);

  for(i=0 ; i<=n ; i++){
    for(j=0 ; j<=n ; j++){
      M[i][j] = 0;
    }
  }


  for(i=1 ; i<=n ; i++){

    scanf("%d%d", &u, &k);
    //   printf("u: %d, k: %d\n", u, k);
    for(j=0 ; j<k ; j++){
      scanf("%d", &v);
      //     printf("v: %d\n", v);
      M[u][v] = 1;
      //     printf("M[u][v]: %d\n", M[u][v]);
    }
  }


  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      printf("%d", M[i][j]);
      if(j != n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}

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

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  int count = 0;
  int ans = 0;
  
  vector<char> s(h*w);
  for(int i=0; i<h*w; i++) cin >> s[i];
  
  vector<char> reset(h*w);
  for(int i=0; i<h*w; i++) reset[i] = s[i];
  
  for(int hbit = 0; hbit<(1<<h); hbit++){
    
    for (int hi = 0; hi<h; hi++) {
      if (hbit & (1<<hi)) {
        for(int hj = hi*w; hj<(hi+1)*w; hj++){
            s[hj] = 'R';
        }
      }
    }
    
    vector<char> tempreset(h*w);
    for(int i=0; i<h*w; i++) tempreset[i] = s[i];
    
    for(int wbit = 0; wbit<(1<<w); wbit++){
   	  for (int wi = 0; wi<w; wi++) {
        if (wbit & (1<<wi)) {
          for(int wj = wi; wj<h*w; wj+=w){
              s[wj] = 'R';
          }
        }
   	  }
      
          for(int i=0; i<h*w; i++){
             if(s[i] == '#') count++;
          }
          
          if(count == k) ans++;
    
          count = 0;
          for(int i=0; i<h*w; i++) s[i] = tempreset[i];
    
      
    }
    
      for(int i=0; i<h*w; i++) s[i] = reset[i];

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



Measured memory_bytes: 3632
#include<stdio.h>

int main(){

  int S[10000],T[500],count=0,n,q,i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++) 
    scanf("%d",&S[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++) 
    scanf("%d",&T[i]);

  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
      if(S[i]==T[j]){
	count++;
	T[j]=-1;
      }
    }
   
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define str string

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n,y);
  REP(i,n+1)
    REP(j,n+1){
      int num = y - 10000*i - 5000*j;
      if(num<0)continue;
      if(i+j+num/1000 == n){
        SCOUT(i);
        SCOUT(j);
        COUT(num/1000);
        return 0;
      }
    }
  EN(-1 -1 -1);
 
  return 0;
}


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

int main() {
 int a,b;
 cin >> a >> b;
 int c = a * b;
 if(c%2 == 0){
   cout << "Even" << endl; 
  }
  else{
   cout << "Odd" << endl; 
  }
}


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

using namespace std;
typedef long long ll;

ll deep (ll v) {
    
}

int main () {
    int N, H, W;  cin >> N >> H >> W;

    int h = N - H + 1;
    int w = N - W + 1;
    int res = h * w;

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, q;
    cin >> n >> q;
    vector<P> e;
    rep(i, n){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        if(t <= 0)continue;
        else if(s < 0)s = 0;
        e.push_back(make_pair(s, x));
        e.push_back(make_pair(t, -x));
    }
    sort(e.begin(), e.end());

    vector<int> qu(q);
    rep(i, q)cin >> qu[i];
    vector<int> ans(q, -1);

    set<int> dist;
    int idx = 0;
    for(P p : e){
        int time = p.first;
        int x = p.second;
        if(idx < q){
            while(qu[idx] < time){
                if(dist.empty())ans[idx] = -1;
                else ans[idx] = *dist.lower_bound(-1);
                idx++;
                if(idx == q)break;
            }
        }
        
        if(x > 0){
            dist.insert(x);
        }else{
            dist.erase(-x);
        }
    }
    
    rep(i, q)cout << ans[i] << endl;
}

Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int x;
  int sum = 0;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x * 2 >= K){
      sum += (K - x) * 2;
    } else {
      sum += x * 2;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
import math

N, M = map(int, input().split())

def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if(N==0 and M==0):
  print("0")
elif(N==0 and M==1):
  print("0")
elif(N==1 and M==1):
  print("0")
elif(M==0 or M==1):
  print(com(N, 2))
elif(N==0):
  print(com(M, 2))
else:
  print(com(N, 2) + com(M, 2))

Measured memory_bytes: 3064
n = int(input())
alpha = "abcdefghij"
lst = []
def f(s,k):
    if len(s) == n:
        print(s) 
        return
    for i in range(k+1):
        if i == k: f(s+alpha[i],k+1)
        else: f(s+alpha[i],k)
f("",0)

Measured memory_bytes: 9172
def main(A,B,C,K):
    card=K-A
    if card <= 0:
        return K
    card-=B
    if card <= 0:
        return A
    return A-card

if __name__ == "__main__":
    A,B,C,K=map(int,input().split())
    print(main(A,B,C,K))

Measured memory_bytes: 9200
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))


n = getint()

array6 = [6]
while array6[-1] < n:
    array6.append(6 * array6[-1])

array9 = [9]
while array9[-1] < n:
    array9.append(9 * array9[-1])

cache = [-1] * (n + 1)
def solve(rest):
    res = cache[rest]
    if res >= 0:
        return res
    res = rest

    for m6 in reversed(array6):
        if m6 <= rest:
            res = min(res, solve(rest - m6) + 1)
            break
    for m9 in reversed(array9):
        if m9 <= rest:
            res = min(res, solve(rest - m9) + 1)
            break
    cache[rest] = res
    return res

print(solve(n))

Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
int main(){
    string n;cin>>n;
    vector<int> nums(n.size());
    transform(n.begin(), n.end(), nums.begin(), [](char ch) { return ch - '0';});
    int r = 754;
    for(int i = 0; i < n.length() - 2; i++){
        int aa = nums[i]*100 + nums[i + 1]*10 + nums[i + 2];
        int s = abs(753 - aa);
        if(s < r){
            r = s;
        }
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,M,a,b,c;
int dp[1<<13];

int main(){
    cin>>N>>M;
    rep(i,(1<<13)){
        dp[i]=1e9;
    }
    dp[0]=0;
    rep(i,M){
        cin>>a>>b;
        int now=0;
        rep(j,b){
            cin>>c;
            c--;
            now+=1<<c;
        }
        // out(now);
        rep(j,(1<<N)){
            // if(dp[j]==1e9)continue;
            dp[now|j]=min(dp[now|j],dp[j]+a);
        }
    }
    if(dp[(1<<N)-1]!=1e9)out(dp[(1<<N)-1]);
    else out(-1);
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


string s;
ll n;
int main()
{
        cin >> s;
        n = s.length();
        ll lst = 1;
        ll ans = 0;
        for(ll i=0;i<n;i++) {
                if(lst) {
                        lst = 0;
                        ans++;
                }else {
                        if(s[i] != s[i-1]){
                                ans++;
                        }else {
                                i += 1;
                                if(i == n){
                                        break;
                                }
                                ans++;
                                lst = 1;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;

ll one_side(ll a, ll b) { // a >= b
    if (a % b == 0) return a;
    else  return a/b * b + one_side(b, a % b);
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N, X; cin >> N >> X;
    ll ma = max(X, N - X);
    ll mi = min(X, N - X);
    ll one_unit = one_side(ma, mi);
    ll res = 3 * one_unit;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
l, r = map(int,input().split())
 
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)

Measured memory_bytes: 3060
using System;using System.Linq;
class A{
    static void Main(){
        while(true){
        var a=Console.ReadLine().Split().Select(int.Parse).ToArray();
    if(a[0]==a[1]&&a[0]==0){
        break;
    }
         var b=Console.ReadLine().Split().Select(int.Parse).ToArray();
        var c=Console.ReadLine().Split().Select(int.Parse).ToArray();
        var d=Console.ReadLine().Split().Select(int.Parse).ToArray();
        var e=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int []s=new int[5];
    s[0]=a[1]+a[0];
    s[1]=b[1]+b[0];
    s[2]=c[1]+c[0];
    s[3]=d[1]+d[0];
    s[4]=e[1]+e[0];
   int max=0;
   string guy="";
   for(int i=0;i<5;i++){
       if(max<s[i])
       {
           max=s[i];
       if(i==0)
       {guy="A";}if(i==1){guy="B";}
       if(i==2){guy="C";}
       if(i==3){guy="D";}
       if(i==4){guy="E";}}}
   Console.WriteLine(guy+" "+max.ToString());}}}

Measured memory_bytes: 9600
from sys import stdin
input = stdin.readline

N = int(input())

bin_26 = []

while N > 0:
    tmp = N % 26
    if tmp == 0:
        tmp = 26
    bin_26.append(tmp)
    N -= tmp
    N //= 26

bin_26.reverse()

# print(*bin_26)

ans = []

for b in bin_26:
    c = ord("a") + (b - 1)
    ans.append(chr(c))

print("".join(ans))


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s; cin >> s;

	vector<string>v = { "Sunny","Cloudy","Rainy","Sunny","Cloudy","Rainy" };
	cout << *(find(all(v), s) + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
int L, edge;
const ll mod = 1000000007;
vector<int> bit;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> L;
	while (L)
	{
		bit.push_back(L % 2);
		edge += L % 2;
		L /= 2;
	}
	cout << bit.size() << ' ';
	cout << edge - 1 + 2 * (bit.size() - 1) << endl;
	for (int i = 1; i < bit.size(); i++)
	{
		cout << i << ' ' << i + 1 << ' ' << 0 << endl;
		cout << i << ' ' << i + 1 << ' ' << pow(2, i - 1) << endl;
	}
	int weight = pow(2, bit.size() - 1);
	for (int i = bit.size() - 2; i >= 0; i--)
	{
		if (bit[i] == 1)
		{
			cout << i + 1 << ' ' << bit.size() << ' ' << weight << endl;
			weight += pow(2, i);
		}
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;

  ll MAX_N = 110000;
  ll dp[MAX_N];
  REP(i, MAX_N) { dp[i] = N; }
  dp[0] = 0;

  REP(n, N) {
    for (int pow6 = 1; n + pow6 <= N; pow6 *= 6) {
      dp[n + pow6] = min(dp[n + pow6], dp[n] + 1);
    }
    for (int pow9 = 1; n + pow9 <= N; pow9 *= 9) {
      dp[n + pow9] = min(dp[n + pow9], dp[n] + 1);
    }
  }

  cout << dp[N];

  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int n = 0;
    int sn = 0;
    int j = 1;

    for(int i = 0; i < s.size(); i++){
        sn += s[i] - '0';
    }
    for(int i = s.size() - 1; i >= 0; i--){
        n += (s[i] - '0') * j;
        j *= 10;
    }

    if(n % sn == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    long long int dp[n][n];
    for(int i=0;i<n;i++) dp[i][i]=a[i];
    for(int i=1;i<n;i++) for(int j=0;j+i<n;j++) dp[j][j+i]=max(a[j]-dp[j+1][j+i],a[j+i]-dp[j][j+i-1]);
    cout<<dp[0][n-1];
}

Measured memory_bytes: 49700
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M,t; cin >> N;
    map<int,int> m;
    REP(i,N){
        cin >> t;
        ++m[t];
    }
    cin >> M;
    REP(i,M){
        cin >> t;
        if(!m[t]){
            cout << "NO" << '\n';
            return 0;
        } else {
            --m[t];
        }
    }
    cout << "YES" << '\n';
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		int a = 0, b = 0, c = 0;
		int arr[5][5] = {};
		for (int i = 0; i < n; i++) {
			char d;
			cin >> a >> d >> b >> c;
			bool b00l;
			if (b <= c) {
				if (c - b <= 8)b00l = true; else b00l = false;
			}
			else {
				if (60 - b + c <= 8)b00l = true;
				else b00l = false;
			}
			if (11 <= a&&a < 15) { arr[1][2]++; if (b00l)arr[1][1]++; }
			else if (18 <= a && a < 21) { arr[2][2]++; if (b00l)arr[2][1]++; }
			else if (21 <= a || a < 2) { arr[3][2]++; if (b00l)arr[3][1]++; }
		}
		cout << "lunch ";
		if (arr[1][2] == 0) cout << "no guest\n"; else cout << 100 * arr[1][1] / arr[1][2] << endl;
		cout << "dinner ";
		if (arr[2][2] == 0) cout << "no guest\n"; else cout << 100 * arr[2][1] / arr[2][2] << endl;
		cout << "midnight ";
		if (arr[3][2] == 0)cout << "no guest\n"; else cout << 100 * arr[3][1] / arr[3][2] << endl;
	}
}

Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
long long p3(int x)
{
	return (long long)x*x*x;
}
int main()
{
	int n,k;
	long long ans=0;
	scanf("%d%d",&n,&k);
	ans+=p3(n/k);
	if(k%2==0)
		ans+=p3((n+k/2)/k);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

const LLI mod = 1e9+7;

template <int MOD> vector<vector<LLI>> binomial_pascal(int n, int k){
  vector<vector<LLI>> ret(n+1, vector<LLI>(k+1));
  ret[0][0] = 1;
  
  FORE(i,1,n){
    ret[i][0] = 1;
    
    FORE(j,1,k){
      ret[i][j] = (ret[i-1][j-1] + ret[i-1][j]) % MOD;
    }
  }

  return ret;
}

auto C = binomial_pascal<mod>(6000,6000);

LLI H(int n, int k){
  if(n == 0 and k == 0) return 1;
  if(n+k-1 < 0 or k < 0) return 0;
  return C[n+k-1][k];
}

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

  int N,K;
  while(cin >> N >> K){

    FORE(i,1,K){
      LLI x = C[K-1][i-1];
      LLI y = H(i+1,N-K-(i-1));

      LLI ans = x*y%mod;
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 281856
n=gets.to_i
a=gets.split.map &:to_i
d=0
s=a.map{|x|d=d.gcd(x)}
d=0
t=a.reverse.map{|x|d=d.gcd(x)}.reverse
p n.times.map{|i|(i>0?s[i-1]:0).gcd(i<n-1?t[i+1]:0)}.max

Measured memory_bytes: 12548
A,B,Q=map(int,input().split())
s=[]
for _ in range(A):
    s.append(int(input()))
t=[]
for _ in range(B):
    t.append(int(input()))
from bisect import bisect
infty=1e50
for _ in range(Q):
    x=int(input())
    i=bisect(s,x)
    j=bisect(t,x)
    if 0<i<A:
        sL=s[i-1]
        sR=s[i]
    elif i==0:
        sL=-infty
        sR=s[i]
    else:
        sL=s[-1]
        sR=infty
    
    if 0<j<B:
        tL=t[j-1]
        tR=t[j]
    elif j==0:
        tL=-infty
        tR=t[j]
    else:
        tL=t[-1]
        tR=infty
    sL=abs(sL-x)
    sR=abs(sR-x)
    tL=abs(tL-x)
    tR=abs(tR-x)

    print(min(max(sR,tR),max(sL,tL),sR+tL+min(sR,tL),sL+tR+min(sL,tR)))




Measured memory_bytes: 12152
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
#include <functional>
using namespace std;

int main()
{
	int N,L;
	cin >> N >> L;
	string S[110];
	for (int i = 0;i < N;i++) {
		cin >> S[i];
	}
	sort(S, S + N);
	string res;
	for (int i = 0;i < N;i++) {
		res += S[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var len = (long)Math.Ceiling(Math.Sqrt(N));
            long dis = long.MaxValue;
            for (int i = 1; i <= len; i++)
            {
                if (N % i == 0)
                {
                    long j = N / i;
                    dis = Math.Min(dis, i + j - 2);
                }
            }

            Console.WriteLine(dis);
        }
        
    }
}

Measured memory_bytes: 13140