akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define pi acos(-1.0)
#define mod 1000000007;
using namespace std;
int kuaisumi(int b)
{
    int ret=1;
    long long tmp=2;
    while(b)
    {    
       if(b&0x1) ret=ret*tmp%mod;
       tmp=tmp*tmp%mod;
       b>>=1;
    }
    return ret;
}

int main()
{
	int n;
	scanf("%d",&n);
	int a[100005],b[100005];
	int k;
	memset(b,0,sizeof(b));
	int maxn=9999999;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]++;
		
	}
	if(n%2)
	{
		if(b[0]!=1)
		{
			printf("0\n");
			return 0;
		}
		for(int i=2;i<n;i+=2)
		{
			if(b[i]!=2)
			{
				printf("0\n");
				return 0;
			}
		}
		k=kuaisumi((n-1)/2);
		printf("%d\n",k);
	}
	else
	{
		for(int i=1;i<n;i+=2)
		{
			if(b[i]!=2)
			{
				printf("0\n");
				return 0;
			}
		}
		k=kuaisumi(n/2);
		printf("%d\n",k);
	}
	return 0;
}

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

int arr[6][3] = {
    {0, 1, 2}, 
    {0, 2, 1},
    {1, 0, 2},
    {1, 2, 0},
    {2, 0, 1},
    {2, 1, 0}
};

vector<int> w(6, 0);
bool valid = false;

void dfs(vector<int> v){
    if(v[0] == 0 && v[1] == 1 && v[2] == 2){
        valid = true;
        return;
    }
    for(int i = 0; i < 6; i++){
        if(w[i] == 0)   continue;
        w[i]--;
        vector<int> next(3);
        for(int j = 0; j < 3; j++)  next[j] = v[arr[i][j]];
        dfs(next);
        w[i]++;
    }
}

int main(){
    int n;
    cin >> n;
    while(n-- > 0){
        vector<int> v({0, 1, 2});
        int q;  cin >> q;
        while(q-- > 0){
            int a;  cin >> a;
            if(a == 0)  swap(v[0], v[1]);
            if(a == 1)  swap(v[1], v[2]);
        }
        for(int i = 0; i < 6; i++){
            bool valid = true;
            for(int j = 0; j < 3; j++){
                valid &= arr[i][j]==v[j];
            }
            if(valid)   w[i]++;
        }
    }
    if(w[0] >= 1 || w[1] >= 2 || w[2] >= 2 || w[3] >= 3 || w[4] >= 3 || w[5] >= 2){
        valid = true;
    }else{
        for(int i = 0; i < 6; i++){
            if(w[i] == 0)   continue;
            vector<int> next(3);
            for(int j = 0; j < 3; j++)  next[j] = arr[i][j];
            w[i]--;
            dfs(next);
            w[i]++;
        }
    }
    cout << (valid ? "yes" : "no") << endl;
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,k,m,n;
int main()
{
	scanf("%d%d",&a,&b);
	e=b;
	while(e>0)
	{
		e=e/10;
		c++;
	}
	for(i=1;i<=c;++i)a=a*10;
	m=a+b;
	if(sqrt(m)==floor(sqrt(m)))printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool j=false;
  if (s.at(0) != s.at(1)) {
    if (s.at(1) != s.at(2)) {
      if (s.at(2) != s.at(0)) {
        j = true;
      }
    }
  }
  if (j) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

#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++)
typedef long long ll;

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int k; cin >> k;
    vector<bool> used(k, false);
    ll a = 0;
    rep(i, k+1) {
        a = (10 * a + 7) % k;
        if (a == 0) {
            cout << i+1 << endl;
            return 0;
        }
        if (used[a]) {
            cout << -1 << endl;
            return 0;
        }
        used[a] = true;
    }

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N,M;cin>>N>>M;
  if(N==1&&M==1)cout<<1<<endl;  
  else if(N==1||M==1)cout<<max(0LL,max(N,M)-2LL)<<endl;
  else{
    ll ans=(N-2)*(M-2);
    cout<<ans<<endl;
  }
}







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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
/*Calculate GCD, LCM =============================*/
long long GCD(long long a, long long b){
    return (b ? GCD(b, a%b) : a);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a,b);
    return (a/g) * (b/g) * g;  // オーバーフローを避ける
}


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n,k; cin >> n >> k;
    vi a(n); rep(i,n) cin >> a[i];

    /**
     * 互除法っぽさを感じる
     * Ai以下 k == GCD*pで満たすものがあればｙes
     * 差をとりまくって得られるものはGCDであり、ある二つの差はそれの倍数にしかならないことが根拠
     */

    i32 g = a[0];
    for(auto aa : a) g = GCD(g, aa);
    if(k%g == 0 && k <= *max_element(all(a))) {
        cout << "POSSIBLE" << '\n';
        return 0;
    }
    cout << "IMPOSSIBLE" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int n,i,j,cnt;

  while(scanf("%d",&n),n){
    for(i=1,cnt=0;i<=n;i++){
      for(j=i+1;j<=n;j++){
	if((j*(j+1)-i*(i-1))/2==n)cnt++;
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const ll MOD = 1000000007;
int n;
string s;
ll cnt[26];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> s;

  forn (i,n) cnt[s[i]-'a']++;

  ll res = 1;
  forn (i,26) {
    res = (res * (cnt[i]+1)) % MOD;
  }

  cout << res-1 << "\n";


  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            var s = NextInt;

            if (99 < s && s <= 1299)
            {
                if (0 < s % 100 && s % 100 <= 12) System.Console.WriteLine("AMBIGUOUS");
                else System.Console.WriteLine("MMYY");
            }
            else
            {
                if (0 < s % 100 && s % 100 <= 12) System.Console.WriteLine("YYMM");
                else System.Console.WriteLine("NA");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>

int main(void){
	int n, k;
	std::cin >> n >> k;
	std::vector<int> v(n);
	for(int i=0;i<n;i++)std::cin >> v[i];
	std::vector<int> hand(n);
	int64_t ans = 0;
	for(int popleft = 0; popleft <= k && popleft <= n; popleft++){
		for(int popright = 0; popright <= k - popleft && popleft + popright <= n; popright++){
			for(int i=0;i<popleft;i++){
				hand[i] = v[i];
			}
			for(int i=0;i<popright;i++){
				hand[i+popleft] = v[n-1 -i];
			}
			std::sort(hand.begin(), hand.begin() + popleft + popright);
			for(int push = 0; push <= k - popleft - popright; push++){
				int64_t sum = 0;
				for(int i=push;i<popleft+popright;i++){
					sum += hand[i];
				}
				ans = std::max(sum, ans);
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
 
  long int a, b, r, x, tmp;
  scanf("%ld", &a);
  scanf("%ld", &b);
 
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%ld\n", x/b);
 
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	string t = s.substr(0, (s.size() - 1) / 2), u = s.substr((s.size() + 3) / 2 - 1);
	string S = s, T = t, U = u;
	reverse(all(S)), reverse(all(T)), reverse(all(U));
	if (s == S and t == T and u == U)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
lst = []
for _ in range(H):
    s = input()
    if s.find('#') >= 0:
        lst.append(s)

lst2 = []
for tpl in zip(*lst):
    if '#' in tpl:
        lst2.append(tpl)

for tpl in zip(*lst2):
    print(''.join(tpl))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{ 
  int A,B,C;
  cin>>A>>B>>C;
  if((A+B==C)||(B+C==A)||(C+A==B))
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  return;  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long
#define mp make_pair
#define MAXN 1e6
const int mod=1e9+7;

void solve()
{
  ll a,b,n,x;
  cin>>a>>b>>n;
  if(n<b)
  {
    x=n;
    ll ans=((a*x)/b)-(a*(x/b));
    cout<<ans<<endl;
    return;
  }
  else if(n%b==0)
  {
    x=n-1;
    ll  ans=((a*x)/b)-(a*(x/b));
    cout<<ans<<endl;
    return;
  }
  x=b-1;
  ll ans=((a*x)/b)-(a*(x/b));
  cout<<ans<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <string>

const int size = 105;
const int NIL = -1;
int dp[size][size];
int ps[size];

int min_cost(int i, int j)
{
  if (dp[i][j] != NIL)
    return dp[i][j];

  int k=i;
  int min = min_cost(i,k) + min_cost(k+1,j) + ps[i-1]*ps[k]*ps[j];
  for (k=i+1; k<=j-1; ++k)
    {
      int tmp = min_cost(i,k) + min_cost(k+1,j) + ps[i-1]*ps[k]*ps[j];
      if (tmp < min) min = tmp;
    }
  dp[i][j] = min;
  return min;
}


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

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

  for (int i=0; i<size; ++i)
    for (int j=0; j<size; ++j)
      dp[i][j] = NIL;

  for (int i=1; i<=n; ++i)
    {
      dp[i][i] = 0;
    }

  std::cout << min_cost(1,n) << std::endl;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;
char op;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> op >> b;
	if(op == '+') cout << a + b << "\n";
	else cout << a - b << "\n";
	return 0;
}

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

struct SegTree {
    static const int N=1<<17;
    vector<int> score;
    vector<int> id;
    SegTree() : score(N*2, 0), id(N*2, 0) {
        rep(i, N){
            id[i+N-1]=i;
        }
    }
    void update(int x, int v){
        x += N - 1;
        score[x] += v;
        while (x){
            x = x - 1 >> 1;
            if (score[x + x + 1] >= score[x + x + 2]){
                id[x] = id[x + x + 1];
                score[x] = score[x + x + 1];
            }
            else {
                id[x] = id[x + x + 2];
                score[x] = score[x + x + 2];
            }
        }
    }
    int getMax(){ return id[0]; }
    int getMaxValue(){ return score[0]; }
};

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    SegTree st = SegTree();
    int n, r, l;
    int tv_time[100000]={};
    n = in();
    r = in();
    l = in();
    int prev_t = 0;
    rep(i, r){
        int d, t, x;
        d = in() - 1;
        t = in();
        x = in();
        tv_time[st.getMax()] += t - prev_t;
        prev_t = t;
        st.update(d, x);
    }
    tv_time[st.getMax()] += l - prev_t;
    int id = 0;
    rep(i, n){
        if (tv_time[id] < tv_time[i]) id = i;
    }
    printf("%d\n", id + 1);
    return (0);
}

Measured memory_bytes: 3384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#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 MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long x,y,z;
    scanf("%ld%ld%ld", &x,&y,&z);

    printf("%ld\n", (x-z)/(y+z));
 
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long P, string S){
  ll ans=0;
  if(P==2){
    REP(N){
      if((S[i]-'0')%2==0){
        ans+=i+1;
      }
    }
  }else if(P==5){
    REP(N){
      if(S[i]=='0'||S[i]=='5'){
        ans+=i+1;
      }
    }
  }else{
    reverse(S.begin(),S.end());
    ll tmp=1;
    map<ll,ll> m;
    vector<ll> sums(N);
    REP(N){
      ll cur=(S[i]-'0')*tmp%P;
      if(i==0){
        sums[i]=cur;
      }else{
        sums[i]=(sums[i-1]+cur)%P;
      }
      tmp=tmp*10%P;
    }
    dump(sums);
    m[0]=1;
    REP(N){
      if(m.count(sums[i])){
        ++m[sums[i]];
      }else{
        m[sums[i]]=1;
      }
      ans+=m[sums[i]]-1;
    }
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    string S;
    cin>>S;
    solve(N, P, S);
    return 0;
}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

signed main(){
    ll n,m,x=-1,y=-1,ans=1;
    cin>>n>>m;
    vector<ll> fib(n+1,0);
    fib.at(0)=1;
    fib.at(1)=1;

    for(ll i=2;i <= n;i++)
    {
        fib.at(i)=(fib.at(i-1)%mod)+(fib.at(i-2)%mod);
        fib.at(i)%=mod;
    }

    for(ll i=0;i < m;i++)
    {
        cin>>y;
        if(y==x+1){
            cout << 0 << endl;
            return 0;
        }
        ans*=fib.at(y-x-2);
        ans%=mod;
        x=y;
    }
    ans*=fib.at(n-y-1);
    ans%=mod;
    
    cout << ans%mod << endl;
}

Measured memory_bytes: 1024
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=186;
int sum[maxn][maxn],n,m,dp[2][maxn][maxn][maxn];
char s[maxn];
int que(int xl,int xr,int yl,int yr){
	int siz=(xr-xl+1)*(yr-yl+1),tot=sum[xr][yr]-sum[xl-1][yr]-sum[xr][yl-1]+sum[xl-1][yl-1];
	if(!tot||tot==siz)return 1;
	return 0;
}
void init(){
	rep(i,1,n)rep(j,i,n)for(int r=1,l=1;l<=m;l=r+1){
		r=l;
		if(!que(i,j,l,r)){
			dp[0][i][j][l]=l-1;continue;
		}
		while(r<m&&que(i,j,l,r+1))r++;
		rep(k,l,r)dp[0][i][j][k]=r;
	}
	/* for(int i=1;i<=n;++i)
        for(int j=i;j<=n;++j)
            for(int l=1,r;l<=m;l=r)
            {
                r=l;
                while(que(i,j,l,r)&&r<=m)r++;
                for(int p=l;p<r;++p)dp[0][i][j][p]=r-1;
                if(l==r)dp[0][i][j][l]=l-1,r++;
            }*/
}
int find(int c,int i,int j,int st){
	int l=i,r=j;
	int ans=0;
	while(l<r){
		int mid=(l+r)>>1;
	//	cout<<mid<<endl;
		ans=max(ans,min(dp[c][i][mid][st],dp[c][mid+1][j][st]));
		if(dp[c][i][mid][st]<dp[c][mid+1][j][st])r=mid;
		else l=mid+1;
	}
	return ans;
}
/*int find(int c,int u,int d,int L){
    int l=u,r=d-1,mid;
    int res=0;
    int v1,v2;
    while(l<=r)
    {
        mid=(l+r)/2;
        v1=dp[c][u][mid][L];
        v2=dp[c][mid+1][d][L];
        res=max(res,min(v1,v2));
        if(v1<v2)r=mid-1;
        else l=mid+1;
    }
    return res;
}*/
void go(int c){
	rep(i,1,n)rep(j,i,n)rep(l,1,m){
		//cout<<c<<' '<<i<<' '<<j<<' '<<l<<endl;
		int r=dp[c^1][i][j][l],tar;
		if(r!=m){
			tar=dp[c^1][i][j][r+1];tar=max(tar,find(c^1,i,j,l));
		}
		else tar=m;
		dp[c][i][j][l]=tar;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			sum[i][j]=(s[j]=='#');
		}
	}
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i][j-1];
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i-1][j];
	init();
	int ans=0;
	for(int i=1;dp[(i&1)^1][1][n][1]<m;i++)go(i&1),ans=i;
	printf("%d",ans);
	return 0; 
}

Measured memory_bytes: 30432
import sys
input = sys.stdin.readline

x=int(input())

import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

ANS=0
for f in FACT.values():
    i=1
    while f:
        if f>=i:
            ANS+=1
            f-=i
            i+=1
        else:
            break
print(ANS)

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] submitted = new boolean[30];
		String str = br.readLine();
		for (int i = 0; i < 30; i++)
			submitted[i] = false;
		for (int i = 0; i < 28; i++) {
			int j = Integer.parseInt(str);
			submitted[j-1] = true;
			str = br.readLine();
		}
		for (int i = 0; i < 30; i++)
			if (!submitted[i])
				System.out.println(i+1);
	}
}

Measured memory_bytes: 24288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, 0, n) {
        cin >> a[i] >> b[i];
    }
    const ll inf = 1LL << 60;
    auto dp = make_v(n, n, inf);
    REP(i, 0, n) {
        dp[i][i] = 0;
    }
    REP(k, 1, n) {
        REP(i, 0, n - k) {
            int r = i + k;
            REP (j, i, r) {
                ll cost = dp[i][j] + dp[j + 1][r] + a[i] * b[j] * a[j + 1] * b[r];
                dp[i][r] = min(dp[i][r], cost);
            }
        }
    }

    cout << dp[0][n - 1] << endl;
    return 0;
}



Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

double sq(double d) {
    return d * d;
}

double radians(double deg) {
    return deg * PI / 180;
}

double area(int a, int b, int theta) {
    return 0.5 * a * b * sin(radians(theta));
}

double perimeter(int a, int b, int theta) {
    return a + b + sqrt(sq(a) + sq(b) - 2 * a * b * cos(radians(theta)));
}

void main() {
    auto xs = readints();
    int a = xs[0];
    int b = xs[1];
    int c = xs[2];

    // 2 ??? a, b ??¨?????????????§? c ??????
    // - ??¢??? S
    // - ??¨????????? L
    // - a ???????????¨????????¨???????????? h
    // ????????????????±???????

    double h = b * sin(radians(c));

    writefln("%.6f", area(a, b, c));
    writefln("%.6f", perimeter(a, b, c));
    writefln("%.6f", h);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int wa(int n)
{
    int s = 0;
    while (n)
    {
        s += n % 10;
        n /= 10;
    }

    return s;
}

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

    int ans = 1001001001;
    rep2(a, 1, n)
    {
        int b = n - a;
        ans = min(ans, wa(a) + wa(b));
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
ll a;
double b;

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

	cin >> a >> b;

	ll m = round(b * 100);

	ll ans = (a * m) / 100;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3800
int main()
{
    int N;
    scanf("%d",&N);
    int num[105]={0};
    int n;
    for(int i=0;i<N;i++)
    {
        scanf("%d",&n);
        int j;
        for(j=0;j<=i;j++)
        {
            if(num[j]<=n)
             {
                 for(int k=i+1;k>j;k--)
              {
                 num[k]=num[k-1];
              }
                 num[j] = n;
                 break;
            }
        }

    }
    int sum = 0;
    for(int i=0;i<N;i++)
        {
            sum+=pow(-1,i)*num[i];
        }
        printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

#define  LEN 100000

struct queue
{
    char name[10];
    int t;
};

struct queue Q[LEN];
int head, tail, n, q;

void enqueue(struct queue x)
{
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

struct queue dequeue()
{
    struct queue x = Q[head];
    
    head = (head + 1) % LEN;

    return x;
}

int main()
{
    int count = 0;
    scanf("%d", &n);
    scanf("%d", &q);

    for (int i = 0; i < n; i++)
    {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    
    head = 0;
    tail = n;
    while (head != tail)
    {
        struct queue x;

        x = dequeue();
        if(x.t > q)
        {
            x.t = x.t - q;
            count = count + q;
            enqueue(x);
        } else
        {
            count = count + x.t;
            printf("%s %d\n", x.name, count);
        }
        
    }
    
    return 0;
}




Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    int x = 0;
    rep(i,n)if(s[i]=='#') ++x;

    int d = 0;
    int ans = min(x,n-x);
    for(int i=n-1; i>=0; --i){
        if(s[i]=='.') ++d;
        else --x;
        ans = min(ans, d+x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

ll x;
bool C(ll k){
    if (k % 2) return 11 * (k / 2) + 6 >= x;
    else return 11 * (k / 2) >= x;
}


int main(){
    cin >> x;
    ll ok = 1000000000000000;
    ll ng = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if (C(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    
    return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())
n = len(s)
m = len(t)
s.sort()
t.sort()
t = t[-1::-1]
a = b = ""
for i in range(n):
    a += s[i]
for i in range(m):
    b += t[i]
if a < b:
    print("Yes")
else:
    print("No")
 


Measured memory_bytes: 3060
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;cin>>n;
  double a=(n+1)/2;
  
  
  
  cout << fixed << setprecision(10);
  cout<<a/n<<endl;
}



Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b, x) = listOfInt()
    println(if (a <= x && b >= (x-a)) "YES" else "NO")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    int x = 1;
    ll ans = 0;
    rep(i, n) {
        if(a[i] > x) {
            ans += (a[i] - 1) / x;
            a[i] = 1;
        }
        // cout << a[i] << " " << x << endl;
        if (a[i] == x) x++;
    }

    /*
    cout << "-------------------" << endl;
    rep(i, n) {
        cout << a[i] << endl;
    }
    */

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
//In the name of Allah
#include <bits/stdc++.h>
using namespace std; 

const int maxN = 100 * 1000 + 100; 
int a[maxN]; 
int b[maxN]; 

int main() { 
	int n; cin >> n;
	for( int i = 0 ; i < n ; i++ ) { 
		cin >> a[i]; 
		b[i] = a[i]; 
	}
	sort( b , b + n ); 
	int B = 0 , W = 0; 
	for( int i = 0 ; i < n ;i++ ) { 
		a[i] = lower_bound( b , b + n , a[i] ) - b; 
		if( abs( a[i] - i ) % 2 == 1 ) { 
			if( i % 2 == 0 ) B++; 
			else W++; 
		}
	}
	cout << B << endl;
}


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

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

const ll INF = 1LL << 60;


int dp[3010][3010];

int main(){
    string s, t;
    cin >> s >> t;

    for(int i = 0; i<s.size(); ++i){
        for(int j = 0; j<t.size(); ++j){
            if(s[i] == t[j]){
                chmax(dp[i+1][j+1] ,dp[i][j] + 1);
            }
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }
    
    int i = (int)s.size();
    int j = (int)t.size();
    string ans = "";

    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 38928
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    a = ILI()
    return (N, a)


def solve(N, a):
    a_max = max(a)
    a_min = min(a)
    ans = ""
    if a_max - a_min > 1:
        ans = "No"
    elif a_max - a_min == 1:
        n_alone = a.count(a_min)
        n_group = a.count(a_max)
        if n_alone < a_max and 2 * (a_max - n_alone) <= n_group:
            ans = "Yes"
        else:
            ans = "No"
    elif a_max - a_min == 0:
        if a[0] == N - 1 or a[0] * 2 <= N:
            ans = "Yes"
        else:
            ans = "No"

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 15200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Map<Integer, ArrayList<Integer>> map = new TreeMap<Integer, ArrayList<Integer>>();

		for (int i = 0; i < M; i++) {
			int P = sc.nextInt();
			int Y = sc.nextInt();
			map.put(Y, new ArrayList<Integer>(Arrays.asList(P,i)));
		}
		String ans[] = new String[M];
		int cnt[] = new int[N+1];
		for (List<Integer> list : map.values()) {
			ans[list.get(1)] = String.format("%06d%06d", list.get(0), ++cnt[list.get(0)]);
		}
		for (int i = 0; i < M; i++) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 175324
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
 ll n;
 cin>>n;
 if(n==1){
	 cout<<"Hello World"<<endl;
 }
 else{
	 ll a,b;
	 cin>>a>>b;
	 cout<<a+b<<endl;
 }
}

Measured memory_bytes: 256
var
s:char;
begin
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(' ');
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(' ');
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
read(s);
write(s);
end.

Measured memory_bytes: 128
s = input()
t = input()

# next[i][c] = k : i文字目以降で最初にcが現れるのはk文字目 である (i < |s|)
N = len(s)
next = [dict() for _ in range(N)]
last = dict()
for i, c in enumerate(s + s):
    last_c = last[c] if last.get(c) is not None else -1
    for j in range(last_c + 1, min(i + 1, N)):
        next[j][c] = i % N
    last[c] = i

i = -1
for c in t:
    cur = i % N
    cur1 = (i + 1) % N
    if next[cur1].get(c) is None:
        print(-1)
        exit(0)
    n = next[cur1][c]
    if cur < n:
        i += n - cur
    elif n < cur:
        i += N - (cur - n)
    else:
        i += N
print(i + 1)


Measured memory_bytes: 435676
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll;
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define count2way(v, x) high2way(v, x) - low2way(v, x)
#define lower(v, x) low2way(v, x) - v.begin()       //1番左が0、もし見つから無いならｎを出力
#define higher(v, x) high2way(v, x) - v.begin() - 1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout << a << endl
#define putout2(a, b) \
  putout(a);          \
  putout(b)
#define putout3(a, b, c) \
  putout(a);             \
  putout(b);             \
  putout(c)
#define putout4(a, b, c, d) \
  putout(a);                \
  putout(b);                \
  putout(c);                \
  putout(d)
#define putout5(a, b, c, d, e) \
  putout(a);                   \
  putout(b);                   \
  putout(c);                   \
  putout(d);                   \
  putout(e)
#define Gput(a, b) G[a].push_back(b)
#define cin1(a) cin >> a
#define cin2(a, b) cin >> a >> b
#define cin3(a, b, c) cin >> a >> b >> c
#define cin4(a, b, c, d) cin >> a >> b >> c >> d
#define cin5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}
ll lcm(ll x, ll y)
{
  ll z = gcd(x, y);
  return x * y / z;
}
ll primejudge(ll n)
{
  if (n < 2)
    return 0;
  else if (n == 2)
    return 1;
  else if (n % 2 == 0)
    return 0;
  double sqrtn = sqrt(n);
  Loop(i, 3, sqrtn + 1)
  {
    if (n % i == 0)
    {
      return 0;
    }
    i++;
  }
  return 1;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8]={1,1,0,-1,-1,-1,0,1};
const ll dy[8]={0,1,1,1,0,-1,-1,-1};

/*
//TIMESTAMPbfs
vector<bool> seen;
vec first;
vec last;
void dfs(const Graph &G,ll v,ll &time){
  if(!(seen[v])){
  seen[v]=true;
  first[v]=time++;
  for(auto next_v:G[v]){
    if(seen[next_v])continue;
    dfs(G,next_v,time);
  }
  last[v]=time++;
  }
}
//main関数内で
  seen.assign(n, false); // 全頂点を「未訪問」に初期化
  first.resize(n);
  last.resize(n);
*/
//多次元配列の宣言名
//vector<vector<ll>> field(h, vector<ll>(w));
//記念
/*
field.assign(h, vector<ll>(w, 0));
vector<vector<ll>> field;
void dfs(ll x,ll y,ll h,ll w){
  field[x][y]=0;
  loop(i,8){
    ll next_x=x+dx[i],next_y=y+dy[i];
    if(next_x<0||next_x>=h||next_y<0||next_y>=w)continue;
    if(field[next_x][next_y]==0)continue;
    dfs(next_x,next_y,h,w);
  }
}
*/
int main(){
  vec a={198,55,152,18,23,7,8,13,11,1,1,0,0,1};
  loop(i,14)putout(a[i]);
  return 0;
}


Measured memory_bytes: 3060
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,a,n)    for(int i=a;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+d-1)/d>=(c+b-1)/b)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll a, b, n, ans = 0;
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    ans = a * x / b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
count = [1 for _ in range(N+2)]
count[-1] = 0
count[0] = 0
nextpoint = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v = map(int, input().split())
  if u > v:
    nextpoint[v].append(u)
  else:
    nextpoint[u].append(v)



#print(nextpoint)
for k in range(1, N):
  for item in nextpoint[k]:
    count[item] -= 1

#print(count)
ans = 0
for k in range(1, N):
  count[k+1] += count[k]
#print(count)
ans = sum(count) #L=1
#print(ans)
before = ans
for k in range(1, N):#L=2~N
  before -= N-k+1
  for item in nextpoint[k]:
    before += N+1-item
  ans += before
print(ans)

  

Measured memory_bytes: 43756
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  vector<lli> a; read_n(a, 3);
  cout << *max_element(begin(a),end(a))-*min_element(begin(a),end(a)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
 
int main() {
  int n;
  string s;
  cin>>n>>s;
  int b=0,w=0;
  rep(i,n){
    if(s[i]=='#') b++;
    else w++;
  }
  int ans=w;
  int lb=0,rw=w;
  rep(i,n){
    if(s[i]=='#'){
      lb++;
    }
    else{
      rw--;
    }
    ans=min(ans,lb+rw);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
H, W, k = map(int, input().split())
s = [input() for _ in range(H)]
ans = []
vacant = 0
cnt = 0
for h in range(H):
	if s[h] == "."*W:
		vacant += 1
		continue
	else:
		cnt += 1
		tmp = []
		yet = False
		for w in range(W):
			if s[h][w] == "#":
				if not yet:
					yet = True
				else:
					cnt += 1
			tmp.append(cnt)

		for _ in range(vacant+1):
			ans.append(tmp)
		vacant = 0

for _ in range(vacant):
	ans.append(ans[-1])

for a in ans:
	print(*a, sep=" ")

Measured memory_bytes: 7568
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b) * h / 2 << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		Deque<Long> deque = new ArrayDeque<Long>();
		for (long i = 1; i < 10; i++) {
			deque.add(i);
		}
		for (int i = 0; i < K - 1; i++) {
			long num = deque.poll();
			if (num%10 != 0) {
				deque.add(10 * num + num%10 - 1);
			}
			deque.add(10* num + num%10);
			if (num%10 != 9) {
				deque.add(10 * num + num%10 + 1);
			}
		}
		System.out.println(deque.poll());
	}
}

Measured memory_bytes: 31956
#include <cstdio>
int main()
{
    int a, b, c, tmp;
    scanf("%d%d%d", &a, &b, &c);
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    if (b > c)
    {
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
  int A,B;
  
  cin>>A>>B;
  
  int ans = max(max(A+B,A-B),A*B);
  
  cout<< ans <<endl;
  
  return 0;
}


Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$s[] = fgets(STDIN);
$s[] = fgets(STDIN);
$s[] = fgets(STDIN);
$sum = 0;
for($i = 0; $i < $n; $i++){
  $max = max(array_count_values([$s[0][$i], $s[1][$i], $s[2][$i]]));
  $sum += 3-$max;
}
echo $sum;


Measured memory_bytes: 4604