akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <fstream>

#define endl "\n"
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(),(x).end()
#define rect return 0
#define pause cout << endl; system("pause")
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define Pi acos(-1.0)
#define bitcount __builtin_popcountll

#define TupleGet(name, index) std::get<(index)>(name)
#define FOR(a, b, c) for(int (a) = (b); (a) < (c); ++(a))
#define FORs(a, b, c) for(int (a) = (b); (a) <= (c); ++(a))
#define revFOR(a, b, c) for(int (a) = (b); (a) > (c); --(a))
#define revFORs(a, b, c) for(int (a) = (b); (a) >= (c); --(a))
#define foreach(it, a) for(auto it = (a).begin(); it != (a).end(); it++)

using namespace std;

// *** TYPEDEF'S, CONSTANTS AND FUNCTIONS *** //
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tii;
typedef vector<vector<int> > vvi;

/* |T| |I| |P| |S|
@ string abc = "abcdefghijklmnopqrstuvwxyz";
@ 'char' - 'a' ::: порядковый номер латинской буквы
@ 'digit' - '0' or 'digit' - 48 ::: (char) ---> (int)
@ 'A' = dec 65 'Z' = dec 90
  'a' = dec 97 'z' = dec 122
  '0' = dec 48 '9' = dec 57
@ Если страдает скорость ввода:
1) ios::sync_with_stdio(0);
   cin.tie(0);
2) юзать сканф
@ для стринга перевод i-того символа в другой регистр: a[i] = char (a[i] +- 32)  :::  32 == 'a' - 'A'
@ int n (m знаков) :::  n[1] = n / 10^(m-1) ; n[m] = n % 10 ; n[m-1] = (n % 100)/10 ; n[m-2] = (n % 1000)/100...
@ cout << fixed << setprecision(n) ::: n знаков после запятой, без "fixed" - всего n знаков
@ abs(x-y) < EPS ::: равентсво вещественных чисел x и y по точности EPS
@ x + EPS < y  или  x - EPS < y ::: сравнение больше-меньше для вещественных чисел по точности EPS
@ если цифру можешь записать из головы - так и пиши в программе, иначе - пиши ФОРМУЛУ
@ «экспонента» - целое число, показывающее, на сколько надо сдвинуть десятичную запятую в числе ::: 123e2 = 12300 , 123e-4 = 0.0123
@ если задача плохо решается при нумерации с единицы, иногда оказывается намного проще перейти к нумерации с нуля.
  Особенно задачах, где явно надо делить на равные части.
@ while(cin >>)  |||  while (getline(cin, )) ::: считывание, пока даются данные
@ ctrl+Z ::: конец файла в консоли
@ Глобальные массивы, чтобы не было ошибок; размер брать с запасом
@ Количество цифр N числа X в b-ичной записи, N = floor[ log[b](X) ] + 1
@ ios::sync_with_stdio(0); //ввод
@ cin.tie(0); cout.tie(0); //могут быть проблемы в интерактивных задачах (частый ввод-вывод)
*/

void A() {
    int n;
    cin >> n;

    for (int i = 0; i <= 1000; i++) {
        if (n - 7 * i < 0) {
            cout << "No";
            return;
        }
        if ((n - 7 * i) % 4 == 0) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

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

Measured memory_bytes: 256
import math

class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def roll_east(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def roll_north(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def roll_south(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def roll_west(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp


a, b, c, d, e, f = map(int, input().split())
dice = Dice(a, b, c, d, e, f)
command = input()
for c in command:
    if c == 'E':
        dice.roll_east()
    elif c == 'N':
        dice.roll_north()
    elif c == 'S':
        dice.roll_south()
    elif c == 'W':
        dice.roll_west()
print(dice.top)



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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll V[105];
ll U[105];

ll dp[105][10005];

int main()
{
    ll N, W;
    cin >> N >> W;
    memset(dp, 0, sizeof(dp));
    REP(i, N)
    {
        cin >> V[i] >> U[i];
    }

    REP(i, N)
    {
        REP(j, W + 1)
        {
            dp[i + 1][j] = dp[i][j];
            if (j - U[i] < 0)
                continue;
            dp[i + 1][j] = std::max(dp[i + 1][j], dp[i + 1][j - U[i]] + V[i]);
        }
    }

    ll max = 0;
    REP(i, W + 1)
    {
        max = std::max(max, dp[N][i]);
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 11316
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N):
        a = int(input())
        for j in range(a):
            x, y = (int(i) for i in input().split())
            G[i].append((x-1, y))
            # 人iは人xのことをyと言っている
    ans = 0
    for bit in range(1 << N):
        cur = 0
        good = True  # 矛盾がない
        for i in range(N):
            if bit & (1 << i):
                # 人iは正直者
                # 人iが言う人xの真偽に矛盾があればgood = False
                # 正直者iが嘘をついたらFalse
                cur += 1
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 0:
                        good = False
                        break
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
                        break
        # print(bit, ":", good)
        if good:
            ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46192
#include <iostream>
using namespace std;
string s;
long long dfs(int n,long long nw,long long tmp){
  if(s.size()-1 == n){
    return (long long)nw+tmp*10+(s[n]-'0');
  }
  return (long long)dfs(n+1,nw+tmp*10+(s[n]-'0'),0)+dfs(n+1,nw,tmp*10+(s[n]-'0'));

}
int main(){
  cin>>s;
  cout << (long long)dfs(0,0,0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int n;
   cin >> n;
   ll a[n];
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }
   ll tmp = 0;
   ll sum = 0;
   for (int i = 0; i < n; i++) {
      sum += a[i];
      if (i % 2 == 0) {
         if (sum > 0) continue;
         else {
            tmp += 1 - sum;
            sum = 1;
         }
      } else {
         if (sum < 0) continue;
         else {
            tmp += sum + 1;
            sum = -1;
         }
      }
   }
   ll ans = tmp;
   tmp = 0;
   sum = 0;
   for (int i = 0; i < n; i++) {
      sum += a[i];
      if (i % 2 == 1) {
         if (sum > 0) continue;
         else {
            tmp += 1 - sum;
            sum = 1;
         }
      } else {
         if (sum < 0) continue;
         else {
            tmp += sum + 1;
            sum = -1;
         }
      }
   }
   chmin(ans, tmp);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

int field[114][114]={};

main(){
    int w,h,n;
    cin >> w >> h >> n;
    REP(i,n){
        int x,y,a;
        scanf("%d%d%d",&x,&y,&a);
        switch(a){
            case 1:
                REP(i,h) REP(j,x) field[i][j] = 1; break;
            case 2:
                REP(i,h) FOR(j,x,w) field[i][j] = 1; break;
            case 3:
                REP(j,w) REP(i,y) field[i][j] = 1; break;
            case 4:
                REP(j,w) FOR(i,y,h) field[i][j] = 1; break;
        }
    }
    
    int ans = 0;
    REP(i,h) REP(j,w) if(!field[i][j]) ans++;
    printf("%d\n",ans);

    return 0;
}


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


int main(){


    long long l, r, i, j;

    long long t = 2019;


    cin >> l >> r;


    if( r - l >= 2019 ) t = 0;


    else for( i = l ; i < r ; i = i + 1 ){

              for( j = l + 1 ; j <= r ; j = j + 1 ){

                   t = min( t, ( ( i % 2019 ) * ( j % 2019 ) ) % 2019 );

                   }

              }


    cout << t << endl;

    
    return 0;


    }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
const ll MOD = 1000000007;
const ll INF = 1000000000;
const int MAX = 10000000;

int V;
vector<int> G[210];  
int match[210];     
bool used[210];      

void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
}


bool dfs(int v){
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++){
        int u = G[v][i], w = match[u];
        if (w < 0 || !used[w] && dfs(w)){ 
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res = 0;
    memset(match, -1, sizeof(match));
    for (int v = 0; v < V; v++){
        if (match[v] < 0){
            memset(used, 0, sizeof(used));
            if (dfs(v)){
                res++;
            }
        }
    }
    return res;
}

int ax[110], ay[110], bx[110], by[110];

int main() {
    cin >> V;
    for (int i = 0; i < V; i++){
        cin >> ax[i] >> ay[i];
    }
    for (int i = 0; i < V; i++){
        cin >> bx[i] >> by[i];
    }
    for (int i = 0; i < V; i++){
        for (int j = 0; j < V; j++){
            if (ax[i] < bx[j] && ay[i] < by[j]){
                add_edge(i, V + j);
            }
        }
    }

    V *= 2;
    cout << bipartite_matching() << endl;

}

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

bool checkP(int K, vector<unsigned int> &weight, unsigned int p) {
    int track = 1;
    int track_w = 0;
    
    for(int i=0; i<weight.size(); i++) {
        if (track > K) {
            return false;
        }
        if (track_w + weight[i] > p) {
            track++;
            track_w = 0;
            i--;
            continue;
        }
        track_w += weight[i];
    }

    return (track <= K);
}

unsigned int getP(int K, vector<unsigned int> &weight, unsigned int min_p, unsigned int max_p) {
    if (max_p - min_p == 1) {
        return max_p;
    }
    unsigned int p = (min_p + max_p) / 2;
    
    if(checkP(K, weight, p)) {
        return getP(K, weight, min_p, p);
    }else {
        return getP(K, weight, p, max_p);
    }
}

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

    vector<unsigned int> weight = vector<unsigned int>(N, 0);
    unsigned int maxWeight = 0;
    for (int i=0; i<N; i++) {
        cin >> weight[i];
        if(weight[i] > maxWeight) {
            maxWeight = weight[i];  
        }
    }

    unsigned int min_p = 0;
    unsigned int max_p = maxWeight*N/K + 1;
    
    cout << getP(K, weight, min_p, max_p) << endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,a[N],b[N],c[N];
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    for(ri int i=1;i<=n;i++) b[i]=read();
    for(ri int i=1;i<=n;i++) c[i]=read();
    sort(a+1,a+1+n), sort(b+1,b+1+n), sort(c+1,c+1+n);
    int res=0;
    for(ri int i=1;i<=n;i++)
    {
        int p=lower_bound(a+1,a+1+n,b[i])-a;
        int q=upper_bound(c+1,c+1+n,b[i])-c;
        res+=(n-q+1)*(p-1);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 6064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007

int main()
{
    int n,i,j,k,l,p;
    cin >> n;
    vector<double> prob(n);
    vector< vector< double > > dp(n + 1, vector<double>(n + 1, 0));

    dp[0][0] = 1;
    for(auto &i : prob)cin >> i;

    for(j = 0; j <= n; j++){
        for(i = 0; i < n; i++){
            dp[i + 1][j] = dp[i][j] * (1 - prob[i]);
            if(j)
                dp[i + 1][j] += dp[i][j - 1] * prob[i];
        }
    }

    double ans = 0;
    for(i = n / 2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    cout<<setprecision((20));
    cout << ans << endl;
}


Measured memory_bytes: 73648
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  fscanf(STDIN, "%s", $s);
  $map[$i] = $s."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j <= $W; $j++){
    if($map[$i][$j] === "#"){
      for($k = 0; $k < $h; $k++){
        $p[$i][$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j <= $H; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $pp = $p[$j - 1 - $k][$i] + $h;
        if($max < $pp)$max = $pp;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
echo $max - 1;

Measured memory_bytes: 154104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h;
	while(cin >> h and h > 0) {
		int b[h][6] = {};
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < 5; ++j) {
				cin >> b[i][j];
			}
		}
		int ans = 0;
		while(true) {
			bool flg = false;
			for(int y = 0; y < h; ++y) {
				int pre = -1;
				int cnt = 0;
				for(int x = 0; x <= 5; ++x) {
					if(b[y][x] != pre) {
						if(pre > 0 and cnt >= 3) {
							flg = true;
							for(int k = 1; k <= cnt; ++k) {
								ans += b[y][x - k];
								b[y][x - k] = 0;
							}
						}
						pre = b[y][x];
						cnt = 1;
					} else {
						++cnt;
					}
				}
			}
			if(not flg) break;
			for(int x = 0; x < 5; ++x) {
				for(int y = h - 2; y >= 0; --y) {
					for(int i = y; i + 1 < h; ++i) {
						if(b[i + 1][x] == 0) swap(b[i][x], b[i + 1][x]);
					}
				}
			}
		}
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii ,ii> iii;
typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)cin>>v[i];
       long long  int mx=v[0];
        long long int sum=0;
        for(int i=1;i<n;i++)
        {
            if(mx>v[i])
                {
                sum+=(mx-v[i]);
                }
            else
            {
                mx=v[i];

            }
        }
        cout<<sum;



}


Measured memory_bytes: 4780
#include<stdio.h>
#include <string.h>
int main(){
    char a[3], b[]="AAA", c[]="BBB";
    scanf("%s",a);
    //printf("%s\n%s\n%s",a,b,c);
    if(strcmp(a,b)==0||strcmp(a,c)==0){ printf("No"); return 0; }
    printf("Yes");
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int X;
    cin >> X;

    int ans;
    if(X >= 400 && X < 600) {
        ans = 8;
    }
    else if(X >= 600 && X < 800) {
        ans = 7;
    }
    else if(X >= 800 && X < 1000) {
        ans = 6;
    }
    else if(X >= 1000 && X < 1200) {
        ans = 5;
    }
    else if(X >= 1200 && X < 1400) {
        ans = 4;
    }
    else if(X >= 1400 && X < 1600) {
        ans = 3;
    }
    else if(X >= 1600 && X < 1800) {
        ans = 2;
    }
    else if(X >= 1800 && X < 2000) {
        ans = 1;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            long l, r;
            ReadLong(out l, out r);

            int ans = int.MaxValue;

            for (long left = l; left <= l + 2019; left++)
            {
                for (long right = left + 1; right <= Min(left + 2019, r); right++)
                {
                    ans = Min(ans, (int)((left * right) % 2019));
                }
            }

            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, c, k;
	cin >> n >> c >> k;
	vll t(n);
	for (ll i = 0; i < n; i++) cin >> t[i];
	sort(all(t));

  ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = i; j < n; j++) {
			if (j - i + 1 == c || (j < n - 1 && t[j + 1] - t[i] > k) || j == n - 1) {
				ans++;
				i = j;
				break;
			}
		}
	}
	cout << ans << endl;
}


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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int hoge(int H, int W) {
	int a = (H / 3) * W;
	int b = (H - H / 3) * (W / 2);
	int c = (H - H / 3) * (W / 2 + (W % 2));
	return (max({ a,b,c }) - min({ a,b,c }));
}
int fuga(int H, int W) {
	int a = (H / 3 + !!(H % 3)) * W;
	int b = (H - H / 3 - !!(H % 3)) * (W / 2);
	int c = (H - H / 3 - !!(H % 3)) * (W / 2 + (W % 2));
	return (max({ a,b,c }) - min({ a,b,c }));
}
int piyo(int H, int W) {
	int a = (H / 3 + (H % 3)) * W;
	int b = (H - H / 3 - (H % 3)) * (W / 2);
	int c = (H - H / 3 - (H % 3)) * (W / 2 + (W % 2));
	return (max({ a,b,c }) - min({ a,b,c }));
}

void calc() {
	int H, W; cin >> H >> W;
	int x = min(!!(H % 3) * W, !!(W % 3) * H);

	int y = min({ hoge(H,W), fuga(H,W), piyo(H,W) });
	int z = min({ hoge(W,H), fuga(W,H), piyo(W,H) });
	
	cout << min({ x,y,z }) << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int a[200100],n;
bool check(int x){
    for(int i=0;i<=n-1;i++){
        if((a[n-i]<x&&a[n-i-1]<x)||(a[n+i]<x&&a[n+i+1]<x))
            return false;
        if((a[n-i]>=x&&a[n-i-1]>=x)||(a[n+i]>=x&&a[n+i+1]>=x))
            return true;
    }
    return a[2*n-1]>=x;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++){
        scanf("%d",&a[i]);
    }
    int l=1,r=2*n-1,ans=0;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid))
            l=mid+1,ans=mid;
        else
            r=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int h,w,n;
  int ans=0;
  cin >> h;
  cin >> w;
  cin >> n;
  if(h>=w){
    if(n>h && n%h!=0){
      ans=n/h;
      ans++;
    }else if(n<h){
      ans=1;
    }else if(n%h==0){
      ans=n/h;
    }
  }else{
    if(n>w && n%w!=0){
      ans=n/w;
      ans++;
    }else if(n<w){
      ans=1;
    }else if(n%w==0){
      ans=n/w;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n,m;
        cin>>n>>m;
        string s[n];
        ll dp[n][m];
        for(int i=0;i<n;i++) cin>>s[i];
        for(int i=0;i<n;i++) for(int j=0;j<m;j++) dp[i][j]=0;
        dp[n-1][m-1] = 1;
        for(int i=n-1;i>=0;i--){
            for(int j=m-1;j>=0;j--){
               if(s[i][j]!='#'){
                if(i!=0){
                    if(s[i-1][j]!='#'){ 
                    dp[i-1][j] = (dp[i][j] + dp[i-1][j])%mod;}
                }
                 if(j!=0){
                     if(s[i][j-1]!='#'){
                    dp[i][j-1] = (dp[i][j] + dp[i][j-1])%mod;}
                }
               }
            }
        }
       // for(int i=0;i<n;i++) for(int j=0;j<m;j++) cout<<dp[i][j]<<" \n"[j==m-1];
        cout<<dp[0][0];
        return 0;
    } 

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;




int main(void){
    int n,k;
    cin>>n>>k;
    vector<int>l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end(),greater<int>());
    int ans=0;
    for(int i=0;i<k;i++)ans+=l[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100005];
int main()
{
	int n,num;
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>num;
		a[num]=i;
	}
	for(int i=1;i<=n;++i)
	{
		cout<<a[i]<<' ';
	}	
	cout<<endl;
	return 0;
 } 

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	cout<<string(tx-sx,'R')+string(ty-sy,'U')+string(tx-sx,'L')+string(ty-sy+1,'D')+string(tx-sx+1,'R')+string(ty-sy+1,'U')+'L'+'U'+string(tx-sx+1,'L')+string(ty-sy+1,'D')+'R'<<endl;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int dai=max({a,b,c});
  int shou=min({a,b,c});
  int naka=a+b+c-dai-shou;
  if((2*dai-shou-naka)%2==0){
    cout<<(2*dai-shou-naka)/2<<endl;
  }else{
    cout<<(2*dai-shou-naka)/2+2<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#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>;

const ll MOD = 1e9 + 7;

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = modpow(10, n, MOD) - 2 * modpow(9, n, MOD) + modpow(8, n, MOD);
  ans %= MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
ans=0
for i in range(n):
  if b[i]>=a[i]+a[i+1]:
    ans+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
  elif b[i]>a[i] and b[i]<a[i]+a[i+1]:
    ans+=b[i]
    a[i+1]=a[i+1]-(b[i]-a[i])
    a[i]=0
  elif b[i]<=a[i]:
    ans+=b[i]
    a[i]-=b[i]
print(ans)

Measured memory_bytes: 25604
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static string replaceCommand(string targetString, string[] input)
        {
            var a = int.Parse(input[1]);
            var b = int.Parse(input[2]);
            var len = b - a + 1;
            var p = input[3].ToCharArray();
            var target = targetString.ToCharArray();

            if (false
                || (len != p.Length)
                || (targetString.Length < p.Length)
                )
            {
                throw new Exception("invalid replace input");
            }

            for (int i = 0; i < p.Length; ++i)
            {
                target[i + a] = p[i];
            }

            return string.Join("", target);
        }
        static string reverseCommand(string targetString, string[] input)
        {
            var a = int.Parse(input[1]);
            var b = int.Parse(input[2]);
            var len = b - a + 1;
            var target = targetString.ToCharArray();

            if (false
                || (targetString.Length < len)
                )
            {
                throw new Exception("invalid reverse input");
            }

            while (a < b)
            {
                var tmp = target[a];
                target[a] = target[b];
                target[b] = tmp;

                ++a;
                --b;
            }

            return string.Join("", target);
        }
        static string printCommand(string targetString, string[] input)
        {
            var a = int.Parse(input[1]);
            var b = int.Parse(input[2]);
            var len = b - a + 1;
            var target = targetString.ToCharArray();

            if (false
                || (targetString.Length < len)
                )
            {
                throw new Exception("invalid print input");
            }

            var subChars = new char[len];
            Array.Copy(target, a, subChars, 0, len);
            var outString = string.Join("", subChars);

            Console.Out.WriteLine(outString);

            return targetString;
        }

        static void Main(string[] args)
        {
            var targetString = Console.In.ReadLine();
            var countString = Console.In.ReadLine();
            var count = int.Parse(countString);

            Dictionary<string, Func<string, string[], string>> commands = new Dictionary<string, Func<string, string[], string>>();
            commands["replace"] = replaceCommand;
            commands["reverse"] = reverseCommand;
            commands["print"] = printCommand;

            for (int i = 0; i < count; ++i)
            {
                var command = Console.In.ReadLine();
                var splitStrings = command.Split(' ');
                targetString = commands[splitStrings[0]](targetString, splitStrings);
            }
        }
    }
}



Measured memory_bytes: 17864
N=int(input())
xyh=[]
for _ in range(N):
  xyh.append(list(map(int,input().split())))
xyh.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
  for cy in range(101):
    x,y,h=xyh[0]
    H=abs(x-cx)+abs(y-cy)+h
    d=0
    for x,y,h in xyh:
      if h>0:
        if H!=abs(x-cx)+abs(y-cy)+h:
          break
      else:
        if H>abs(x-cx)+abs(y-cy):
          break
      d+=1
    if d==N:
      print(cx,cy,H)
      exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int N = n * (n - 1) / 2;
  vector<pair<int, int>> edg;
  vector<pair<int, int>> cmp;
  int a = 1, b = n - a;
  assert(a + b == n);
  for (int i = 0; i < a; i++) {
    for (int j = a; j < a + b; j++) {
      edg.emplace_back(i, j);
    }
  }
  auto insert = [&] (int l, int r) {
    for (int i = l; i < r; i++) {
      for (int j = i + 1; j < r; j++) {
        cmp.emplace_back(i, j);
      }
    }
  };
  insert(0, a);
  insert(a, a + b);
  assert((int)edg.size() + (int)cmp.size() == N);
  int now = cmp.size();
  if (k > now) err();
  while (k < now) {
    auto p = cmp.front();
    cmp.erase(cmp.begin());
    edg.insert(edg.end(), p);
    now--;
  }
  assert(k == now);
  assert(k == (int)cmp.size());
  assert((int)edg.size() + (int)cmp.size() == N);
  cout << N - k << endl;
  for (auto p : edg) {
    int u, v; tie(u, v) = p;
    u++; v++;
    cout << u << " " << v << endl;
  }
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  if(A1 + A2 + A3 > 21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}
bool a[4];

int main(){
    ll b[3];
    rep(i,0,1){
        cin>>b[i];
        a[b[i]]=true;
    }
    rep(i,1,3){
        if(a[i]==false){
            cout<<i<<endl;
        }
    }
    
    
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		int n1 = Integer.parseInt(inArray[0]);
		int n2 = Integer.parseInt(inArray[1]);
		int n3 = Integer.parseInt(inArray[2]);

		int na = Math.abs(n2 - n1);
		int nb = Math.abs(n3 - n1);
		if (na < nb) {
			System.out.println("A");
		} else {
			System.out.println("B");

		}
	}


}

Measured memory_bytes: 21076
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 n = sc.nextInt();
		String s = sc.next();

		// 計算
	    int result = 0;
	    char pre = s.charAt(0);
	    for(int i = 1; i < n; i++){
		    if(s.charAt(i) != pre){
		        result++;
		        pre = s.charAt(i);
		    }
		}
		result++;

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


Measured memory_bytes: 24736
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
  //↓見なくていいよ！ここから------------------------------------------
  static public class InputIterator{
    ArrayList<String> inputLine = new ArrayList<String>(1024);
    int index = 0; int max;
    InputIterator(){
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      while(true){
        String read;
        try{
          read = br.readLine();
        }catch(IOException e){
          read = null;
        }
        if(read != null){
          inputLine.add(read);
        }else{
          break;
        }
      }
      max = inputLine.size();
    }
    public boolean hasNext(){return (index < max);}
    public String next(){
      if(hasNext()){
        String returnStr = inputLine.get(index);
        index++;
        return returnStr;
      }else{
        throw new IndexOutOfBoundsException("これ以上入力はないよ。");
      }
    }
  }
  
  static InputIterator ii = new InputIterator();//リアクティブでは使えないので諦めてScanner使うこと
  static PrintWriter out = new PrintWriter(System.out);
  static void flush(){out.flush();}
  static void myout(Object t){out.println(t);}
  static void myerr(Object t){System.err.println(t);}
  static String next(){return ii.next();}
  static int nextInt(){return Integer.parseInt(next());}
  static long nextLong(){return Long.parseLong(next());}
  static ArrayList<String> nextStrArray(){return myHanSpSplit(next());}
  static ArrayList<String> myHanSpSplit(String str){return new ArrayList<String>(Arrays.asList(str.split(" ")));}
  static ArrayList<String> nextCharArray(){return mySingleSplit(next());}
  static ArrayList<String> mySingleSplit(String str){return new ArrayList<String>(Arrays.asList(str.split("")));}
  static ArrayList<Integer> nextIntArray(){
    ArrayList<Integer> ret = new ArrayList<Integer>();
    ArrayList<String> input = nextStrArray();
    for(int i = 0; i < input.size(); i++){
      ret.add(Integer.parseInt(input.get(i)));
    }
    return ret;
  }
  static ArrayList<Long> nextLongArray(){
    ArrayList<Long> ret = new ArrayList<Long>();
    ArrayList<String> input = nextStrArray();
    for(int i = 0; i < input.size(); i++){
      ret.add(Long.parseLong(input.get(i)));
    }
    return ret;
  }
  static String kaigyoToStr(String[] list){return String.join("\n",list);}
  static String kaigyoToStr(ArrayList<String> list){return String.join("\n",list);}
  static String hanSpToStr(String[] list){return String.join(" ",list);}
  static String hanSpToStr(ArrayList<String> list){return String.join(" ",list);}
  public static void main(String[] args){
    solve();
    flush();
  }
  //↑見なくていいよ！ここまで------------------------------------------
  static public void solve(){//ここがメイン関数代わり
    ArrayList<String> tmp = nextStrArray();
    BigDecimal A = new BigDecimal(tmp.get(0));
    BigDecimal B = new BigDecimal(tmp.get(1));
    A = A.multiply(B);
    Long output = A.longValue();
    myout(output);
    
  }
  //Method addition frame start

  //Method addition frame end
}


Measured memory_bytes: 33444
#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>;
 
 
int main() {  
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i,s.size()){
        if(s.at(i)!=t.at(i)) ans++;
    } 
    cout << ans << endl;
}


Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#define ll long long
const int maxn = 100005;
using namespace std;

main()
{
    int N;
    scanf("%d",&N);
    int a;
    int str[maxn] = {0};
    int max;
    while(N--)
    {
        scanf("%d",&a);
            str[a]++;
            str[a+1]++;
            str[a-1]++;

    }
        max = str[0];
        for(int i = 0; i < maxn; i++)
            if(max < str[i])
                max = str[i];
    printf("%d\n",max);
    return 0;
}


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

int main(){
	int x,y,t;
	do{
		cin >> x >> y;
		if(x==0 && y==0){
			break;
		}
                else if(x>y){
			t=x;
			x=y;
			y=t;
		}
		cout << x << " " <<y <<"\n";
	}while(true);
	return 0;
}


Measured memory_bytes: 3084
h1, m1, h2, m2, k = gets.split(" ").map(&:to_i)
 
if m2 - m1 < 0
  puts (h2 - (h1 + 1)) * 60 + (60 - (m1 - m2) - k)
else
  puts (h2 - h1) * 60 + m2 - m1 - k
end

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;

struct UnionFind {
private:
    const int n;
public:
    vector<int> uf, sz;
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), uf(_n), sz(_n, 1) {
        iota(uf.begin(), uf.end(), 0);
    }
    // find (木の根を求める)
    int find(int x) {
        return (uf[x] == x) ? x : find(uf[x]);
    }
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x と y の属する集合を併合
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        uf[y] = x;
        return true;
    }
    void set(int x, int k, int s) {
        uf[x] = k;
        sz[x] = s;
    }
};

int main() {
    int N, Q; cin >> N >> Q;
    UnionFind uf(N);
    while(Q--) {
        int t, x, y; cin >> t >> x >> y;
        if(t == 0) uf.unite(x, y);
        if(t == 1) cout << (uf.same(x, y) ? 1 : 0) << endl;
    }
}



Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        if A[i + 1] >= B[i] - A[i]:
            ans += B[i]
            A[i + 1] -= B[i] - A[i]
        else:
            ans += A[i] + A[i + 1]
            A[i + 1] = 0
print(ans)


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if(n >= 2) {
    ans += n * (n -1) / 2;
  }
  if(m >= 2) {
    ans += m * (m - 1) /2;
  }
  cout << ans << endl;
}


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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

struct Program{
    ll st;
    ll en;
    ll ch;
};

bool isOk(int numMachine, vec<Program>& progs){
    vec<pair<ll, ll>> ends(numMachine, {-1, -1});
    // 
    for(auto iter: progs){

        // printf("Program (%d, %d) on ch%d\n", iter.st, iter.en, iter.ch);
        // for(int i=0; i < ends.size(); i++){
        //     printf("[S]Ends at %d, using channnel %d\n", ends.at(i).first, ends.at(i).second);
        // }

        bool ok = false;
        // つかえる機械があるからべる。同じチャンネルのがあるなら優先してそっちをつかう。
        for(int i=0; i < ends.size(); i++){
            if((ends.at(i).second == iter.ch && ends.at(i).first <= iter.en)){
                // つかえる
                ends.at(i) = pair<ll, ll>{iter.en, iter.ch};
                ok = true;
                goto HOGE;
            }
        }
        for(int i=0; i < ends.size(); i++){
            if(ends.at(i).first < iter.st){
                // つかえる
                ends.at(i) = pair<ll, ll>{iter.en, iter.ch};
                ok = true;
                goto HOGE;
            }
        }
        HOGE:
        if(ok == false){
            return false;
        }

        // for(int i=0; i < ends.size(); i++){
        //     printf("[E]Ends at %d, using channnel %d\n", ends.at(i).first, ends.at(i).second);
        // }
    }
    return true;
}

void solve(long long N, long long C, std::vector<long long> s, std::vector<long long> t, std::vector<long long> c){
    vec<Program> progs;
    for(int i=0; i < N; i++){
        progs.push_back({s.at(i), t.at(i), c.at(i)});
    }

    auto cmp = [](Program& a, Program& b){return a.st < b.st;};
    sort(progs.begin(), progs.end(), cmp);

    for(int i=1; i <= C; i++){
        if(isOk(i, progs)){
            cout << i << endl;
            return;
        }
    }

    assert(false);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> s(N);
    std::vector<long long> t(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, C, std::move(s), std::move(t), std::move(c));
    return 0;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string input;
  cin >> input;
  int a = stoi(input);
  int b = 0;
  for (int i = 0; i < input.size(); i++) {
    b += (int)input[i] - '0';
  }
  
  if (a % b == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define loi long int

using namespace std;

// Problem https://atcoder.jp/contests/abc046/tasks/abc046_b

loi solver(int BALL,int PAINTCOLOR){
    loi result;
    result = 0;
    result = PAINTCOLOR * pow(PAINTCOLOR-1,BALL-1);
    return result;
}

int main(void){
    loi answer;
    answer = 0;
    int N,K;
    cin >> N >> K;
    answer = solver(N,K);
    cout << answer << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int len=0;
ll a[100004],d[100004];
ll N;
ll M;
int vis[100004],st;
int main(){
	len=1;
	cin>>N>>a[1]>>M;
	d[1]=a[1];
	while(1){
		len++;
		a[len]=a[len-1]*a[len-1]%M;
		if(vis[a[len]]){
			st=vis[a[len]];
			len--;
			break;
		}
		vis[a[len]]=len;
		d[len]=d[len-1]+a[len];
	}
	ll ans=0;
	for(int i=1;i<st;i++){
		N--;
		ans+=a[i];
	}
	int lenl=len-st+1;
	ans+=N/lenl*(d[len]-d[st-1]);
	cout<<ans+d[N%lenl+st-1]-d[st-1];
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;

int main(){
    long long A,B,K;
    cin >> A >> B >> K;
    if(A >= K){
        A -= K;
    }else{
        K -= A;
        A = 0;
        if(B >= K){
            B -= K;
        }else{
            B = 0;
        }
    }

    cout << A << " " << B << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001


int main(){

int n;
scanf("%d",&n);
int i;
for(i=0;i*i<=n;i++)
    ;
printf("%d\n",(i-1)*(i-1));

}


Measured memory_bytes: 128