akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N,M;
  cin >> N >> M;

  /* input data */
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
  }
  
  /* count road */
  vector<int> count(N);
  for(int i=0;i<M;i++){
    for(int j=1;j<=N;j++){
      if(A.at(i)==j || B.at(i)==j)
         count.at(j-1)++;
    }
  }
  
  /* output data */
  for(int i=0;i<N;i++)
    cout << count.at(i) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

const int N = 200001;
int n, cnt;
long long x[N], y[N], d;

int main()
{
	scanf("%d%lld", &n, &d);
	for(int i = 0; i < n; ++i)
	{
		long long x, y;
		scanf("%lld %lld", &x, &y);
		cnt += x * x + y * y <= d * d;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3804
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll k, a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll ans = 0;
    for (int i = 40; i >= -1; i--) //i=-1でK==X i桁でK=1,X=0
    {
        if (i != -1 && !(k & (1LL << i)))
            continue; //Kのd桁目が0
        ll sum = 0;
        for (int j = 40; j >= 0; j--) //Xのj桁目を考える
        {
            ll mask = 1LL << j;
            int count = 0;
            for (int h = 0; h < n; h++)
            {
                if (a[h] & mask)
                    count++;
            }
            if (j > i) //KとXの数が同じ桁
            {
                if (mask & k) //j桁目が立ってるとき
                    sum += (n - count) * mask;
                else
                {
                    sum += count * mask;
                }
            }
            else if (i == j) //Kが１Xが0の桁
            {
                sum += count * mask;
            }
            else //どちらでもいい
            {
                sum += max(count, n - count) * mask;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  int ans;
  if(n==1)ans=1;
  else if(n<4)ans=2;
  else if(n<8)ans=4;
  else if(n<16)ans=8;
  else if(n<32)ans=16;
  else if(n<64)ans=32;
  else ans=64;
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    var r = -1
    Scanner(System.`in`).use {
        val n = it.nextInt()
        val t = it.nextInt()
        for (i in 0 until n) {
            val c = it.nextInt()
            if (it.nextInt() <= t && (r == -1 || c < r)) {
                r = c
            }
        }
    }
    if (r == -1) {
        println("TLE")
    } else {
        println(r)
    }
}


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

using namespace std;

int main() {
  int a[4];
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    a[i] = s[i] - '0';
  }

  for (int bit = 0; bit < (1 << 3); bit++) {
    string s = to_string(a[0]);
    int result = a[0];
    for (int i = 0; i < 3; i++) {
      if ((bit >> i) & 1) {
        result += a[i + 1];
        s += "+";
      } else {
        result -= a[i + 1];
        s += "-";
      }
      s += to_string(a[i + 1]);
    }
    if (result == 7) {
      cout << s + "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,l;
	cin >> n;
	vector<int> a(9,0);
	int ans = 0;
	int c = 0;
	for(int i = 0; i < n; i++) {
		cin >> l;
		if (l < 3200){
			a[l/400] = 1;
		}
		else{
			c++;
		}
	}
	for(int i = 0; i < 9; i++) {
		ans += a[i];
	}
	cout << max(1,ans)  << ' ' << ans + c << endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> P;
	int sum = 0;
	int p;
	while(N--) {
		cin >> p;
		P.push_back(p);
	}
	sort(P.begin(), P.end(), greater<int>());
//	for(auto x : P) cout << x << " ";
	for(int i = 0; i < P.size(); i++) {
//		cout << i << "///" << P.at(i) << endl;
		if(i == 0) sum += P.at(i) / 2;
		else sum += P.at(i);
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll tree[800009];
bool marked[800009];
void push(ll v,ll l,ll r)
{
    if(marked[v])
    {
        tree[(2*v)]=tree[v];
        ll mid=(l+r)/2;
        tree[(2*v)+1]=tree[v]+(mid-l+1);
        marked[(2*v)]=marked[(2*v)+1]=true;
        marked[v]=false;
    }
}
void update(ll v,ll tl,ll tr,ll l,ll r,ll val)
{
    if(l>r)
        return;
    if((l==tl)&&(tr==r))
    {
        tree[v]=val;
        marked[v]=true;
    }
    else
    {
        push(v,tl,tr);
        ll tm=(tl+tr)/2;
        update(2*v,tl,tm,l,min(r,tm),val);
        if(l<=tm)
        	val+=tm+1-l;
        update((2*v)+1,tm+1,tr,max(l,tm+1),r,val);
        tree[v]=min(tree[2*v],tree[(2*v)+1]);
    }
}
ll query(ll v,ll tl,ll tr,ll l,ll r)
{
	if(l>r)
        return inf;
    if((l==tl)&&(tr==r))
    {
        return tree[v];
    }
    push(v,tl,tr);
    ll tm=(tl+tr)/2;
    return min(query(2*v,tl,tm,l,min(r,tm)),query((2*v)+1,tm+1,tr,max(l,tm+1),r));
}
void solve()
{
	ll h,w;
	cin>>h>>w;
	ll x,y;
	ll st=1;
	for(ll i=0;i<h;i++)
	{
		cin>>x>>y;
		if((x<=st)&&(y>=st))
			st=y+1;
		else if(x>st)
		{
			ll a=query(1,1,w,x-1,x-1);
			update(1,1,w,x,y,a+1);
		}
		ll ans=query(1,1,w,st,w);
		if(ans>=inf)
			cout<<-1<<endl;
		else
			cout<<(ans+i+1)<<endl;
	}
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    vector<int> v(10000,-1);
    int i=0;
    int tmp;
    while(cin>>tmp)
    {
        v[i++]=tmp;
    }
    sort(v.rbegin(),v.rend());
    cout<<v[0]<<endl<<v[1]<<endl<<v[2]<<endl;
}

Measured memory_bytes: 1236
#ifndef _STD
#define _STD
#include<bits/stdc++.h>
#endif


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

using namespace std;

static const double EPS = 1e-10;
static const int INF = (const int) (1e18 + 9);
static const int Mod = (const int) (1e9 + 7);
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<pair<int,pii>> ipii;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    str s;
    int alf[26] = {0};
    cin >> s;
    for(char a : s){
        int b = a - 'a';
        alf[b] ++;
    }
    rep(i,0,26){
        if(alf[i] <= 0){
            cout << (char)(i + 'a') << endl;
            break;
        }else if(i == 25){
            cout << "None" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000003
#define maxn 1000010
#define ll long long 
using namespace std;
int pre[maxn];
int calc(int a, int k)
{
	int ans = 1;
	while (k)
	{
		if (k % 2) ans = (ll)ans * a % mod;
		a = (ll)a * a % mod;
		k /= 2;
	}
	return ans;
}
int main()
{
	pre[0] = 1;
	pre[1] = 1;
	for (int i = 2; i <= mod - 1; i++)
		pre[i] = (ll)pre[i - 1] * i % mod;
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int x, d, n, res;
		scanf("%d%d%d", &x, &d, &n);
		if (d == 0) {printf("%d\n", calc(x, n)); continue;}
		res = calc(d, n);
		x = (ll)x * calc(d, mod - 2) % mod;
		int l = x, r = x + n - 1;
		if (r >= mod || x == 0) {puts("0"); continue;}
		res = (ll)res * pre[r] % mod * calc(pre[l - 1], mod - 2) % mod;
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
using namespace std;
int n,a[100005];
int Abs(int x){
	return (x<0 ? (-x) : x);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	int ans=0;
	for(int i=1;i<=n+1;++i){
		ans+=Abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;++i){
		ans-=Abs(a[i]-a[i-1]);
		ans-=Abs(a[i]-a[i+1]);
		ans+=Abs(a[i-1]-a[i+1]);
		printf("%d\n",ans);
		ans+=Abs(a[i]-a[i-1]);
		ans+=Abs(a[i]-a[i+1]);
		ans-=Abs(a[i-1]-a[i+1]);
	}
	return 0;
}

Measured memory_bytes: 1536
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    vector<int> a(n);
    for(int &i : a)
        cin>>i;
    sort(all(a));
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int pos = lower_bound(all(a),a.at(i) + a.at(j)) - a.begin() - 1;
            ans += pos - j;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  while (true)
  {
    int answer;

    int b, r, g, c, s, t;
    cin >> b >> r >> g >> c >> s >> t;

    if (t == 0) { break; }

    int bonus = b * 5 + r * 3;
    answer = 100
      + b * 15
      + r * 15
      + bonus * 15
      + g * 7
      + c * 2
      - ((t - s - bonus) * 3)
      - (bonus * 2);

    cout << answer << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(min(b,d)-max(a,c),(llint)0)<<endl;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int N, K;
vector< vector< int > > st;

void dfs(int idx, vector< int > vs) {
  if(vs.size() > N) return;
  if(vs.size()) st.push_back(vs);
  for(int i = 1; i <= K; i++) {
    vs.push_back(i);
    dfs(idx + 1, vs);
    vs.pop_back();
  }
}

int main() {
  /*
  K = 3, N = 2;
  for(K = 1; K <= 5; K++) {
    for(N = 1; N<= 10; N++) {
      st.clear();
      dfs(0, vector< int >());
      for(auto &p: st[(st.size() + 1) / 2 - 1]) cout << p << " ";
      cout << endl;
    }
  }
   */

  int K, N;
  cin >> K >> N;
  if(K % 2 == 0) {
    cout << K / 2 << " ";
    for(int i = 0; i + 1 < N; i++) cout << K << " ";
    cout << endl;
  } else {
    vector< int > v(N, (K + 1) / 2);
    int sa = N / 2;
    for(int i = 0; i < sa; i++) {
      if(v.back() == 1) {
        v.pop_back();
      } else {
        v.back()--;
        while(v.size() < N) v.push_back(K);
      }
    }
    for(auto &x : v) cout << x << " ";
    cout << endl;
  }
}


Measured memory_bytes: 3456
#include <cstdio>
int main(){
	int n,d,x;
	scanf("%d%d%d",&n,&d,&x);
	long double D=d,X=x,ans=0;
	for (n<<=1;n;n-=2){
		ans+=D+0.5*X*(n-1);
		D+=(D*2+5*X)/n;
		X+=4*X/n;
	}
	printf("%.10f\n",(double)ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, z, w; cin >> n >> z >> w;
	vector<ll>a(n); for (auto&& x : a)cin >> x;
	ll ans = 0;
	if (n == 1)ans = abs(a[0] - w);
	else ans = max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1]));
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (k < e-a) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,ai;
	int min=1000000,max=-1000000;
	long int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&ai);
		if(min>ai){
			min=ai;
		}
		if(max<ai){
			max=ai;
		}
		sum+=ai;
	}
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}

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

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

using ll = long long;
#define INF 1e9

string S;

int main(){
  cin >> S;
  int n = S.size()+1;
  vector<int> a(n, 0);
  int x = 0;
  REP(i, n-1){
    if(S[i]=='<'){
      x++;
      a[i+1] = x;
      i++;
      while(S[i]=='<'){
        x++;
        a[i+1] = x;
        i++;
      }
      x=0;
    }
  }
  x = 0;
  REPR(i, n-2){
    if(S[i] == '>'){
      x++;
      a[i] = max(x, a[i]);
      i--;
      while(S[i] == '>'){
        x++;
        a[i] = max(x, a[i]);
        i--;
      }
      x = 0;
    }
  }
  ll sum = 0;
  REP(i, n){
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2820
INF = 10**18

N, Ma, Mb = map(int, input().split())

dp = [[[INF for k in range(401)] for j in range(401)] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    a, b, c = map(int, input().split())
    for j in range(400):
        for k in range(400):
            dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k])
            if j + a <= 400 and k + b <= 400:
                dp[i + 1][j + a][k + b] = min(dp[i + 1][j + a][k + b], dp[i][j][k] + c)

res = INF

for j in range(1, 401):
    for k in range(1, 401):
        if k * Ma == j * Mb:
            res = min(res, dp[N][j][k])

print(res if res != INF else -1)

Measured memory_bytes: 99292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int n,m,x;
   cin>>n>>m>>x;
   int c[n],a[n][m];
   for(int i=0;i<n;i++)
   {
       cin>>c[i];
       for(int j=0;j<m;j++)
       {
           cin>>a[i][j];
       }
   }
   int mn=1e18;
   for(int t=1;t<=100000;t++)
   {
       int sum[m]={0},res=0,flag=1;
       for(int i=0;i<n;i++)
       {
            int p=rand()%2;
            if(p==1)
            {
                res+=c[i];
                for(int j=0;j<m;j++)
                {
                    sum[j]+=a[i][j];
                }
            }
       }
       for(int j=0;j<m;j++)
       {
           if(sum[j]<x)
           {
               flag=-1;
               break;
           }
       }
       if(flag==1)
       {
           mn=min(mn,res);
       }
   }
   if(mn==1e18)
   {
       cout<<-1;
   }
   else
   {
       cout<<mn;
   }
}

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

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

void solve(long long X)
{
    if (X >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

// 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 X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3760
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        for(int i = 0;i < 3;i++){
            if(s.charAt(i) == '1'){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int n,m;
vector<vector<int>>adj;
vector<int>vis;
vector<int>dp;
int longest_path(int v){

	if(dp[v]!=-1)return dp[v];
	for(auto x:adj[v]){
		if(!vis[x]){
			dp[v] = max(dp[v], 1+longest_path(x));
		}
	}
	return dp[v];
}

int32_t main()
{
    IOS;
    cin>>n>>m;
    dp.clear();
    dp.resize(n+1);
    for(int i=1;i<=n;i++)dp[i] = -1;
    adj.clear();
    adj.resize(n+1);
    vis.clear();
    vis.resize(n+1);
    while(m--){
    	int x,y;
    	cin>>x>>y;
    	adj[x].pb(y);
    }
    int ans = 0 ;
    for(int i=1;i<=n;i++){
    	if(!vis[i]){
    		ans = max(ans, longest_path(i));
    	}
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 9472
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <algorithm>
#include <cfenv>
#include <cmath>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  long n;
  cin >> n;
  vector <long> t(n);
  vector <long> a(n);

  for (int i = 0; i < n; ++i) {
    cin >> t[i] >> a[i];
  }
  long ans =0;

  long a1 =0;
  long t1 =0;

  a1 = 1;
  t1 = 1;

  for (int i = 0; i < n; ++i) {
    long x = a1/a[i];
    if (a1%a[i])x++;
    long y = t1/t[i];
    if (t1%t[i])y++;

    long n = max( x , y) ;
    a1 = n*a[i];
    t1 = n*t[i];
    cerr << a1 <<" " <<t1<<endl;
  }




  cout << (a1 + t1) << endl;
  return 0;
}






Measured memory_bytes: 256
n = int(input())
s = list(input())
ENC = s

# 秘密鍵
KEY = n
plain = ""
for char in list(ENC):
    ASCII = ord(char)
    num = ASCII - 65
    num = (num + KEY) % 26
    ASCII = num + 65
    plain += chr(ASCII)

print(plain)


Measured memory_bytes: 40924
import sys
input = lambda: sys.stdin.readline().rstrip()
r,c,k=map(int,input().split())
dp=[[(c+1)*[0]for _ in range(r+1)]for _ in range(4)]
p=[c*[0]for _ in range(r)]
for _ in range(k):
  rr,cc,u=map(int,input().split())
  rr-=1
  cc-=1
  p[rr][cc]=u
ans=0
#for i in p:print(i)
for j in range(1,r+1):
  for k in range(1,c+1):
    dp[0][j][k]=max(dp[0][j-1][k],dp[0][j][k-1])
    for i in range(1,4):
      dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k],dp[i][j][k-1])
      if p[j-1][k-1]:
        dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-1]+p[j-1][k-1],dp[i][j-1][k]+p[j-1][k-1])
    for i in range(1,4):
      dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k])
      ans=max(ans,dp[i][j][k])
  for k in range(1,c+1):
    t=max(dp[0][j][k],dp[1][j][k],dp[2][j][k],dp[3][j][k])
    dp[0][j][k]=dp[1][j][k]=dp[2][j][k]=dp[3][j][k]=t
print(ans)
#for i in dp:
#  print("---")
#  for j in i:print(j)

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

int main() {
	int a,b,c;
	
	cin>>a>>b>>c;
	
	if(a==1&&b==0&&c==0){
		cout<<"Close"<<endl;
	}else if(a==0&&b==1&&c==0){
		cout<<"Close"<<endl;
	}else if(a==0&&b==0&&c==0){
		cout<<"Close"<<endl;
	}else{
		cout<<"Open"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    string SA, SB, SC;
    cin >> SA >> SB >> SC;

    auto get_next = [](const string& S, size_t& i, char c) {
        if (S.size() == i) {
            return c;
        }
        return S[i++];
    };

    size_t a = 0, b = 0, c = 0;
    char turn = 'a';
    while (true) {
        switch (turn) {
        case 'a':
            turn = get_next(SA, a, 'A');
            break;
        case 'b':
            turn = get_next(SB, b, 'B');
            break;
        case 'c':
            turn = get_next(SC, c, 'C');
            break;
        default:
            cout << turn << endl;
            return;
        }
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = np.array(list(sr()), np.int8)
length = len(S)
complete = np.arange(length) & 1
r1 = (S == complete).sum()
r2 = (S != complete).sum()
answer = min(r1, r2)
print(answer)


Measured memory_bytes: 18552
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		String s=sc.next();
		int count=0;
		for(int i=1;i<s.length();i++) {
			if(s.substring(i-1, i).equals(s.substring(i, i+1))) {
				count++;
			}
		}
		System.out.println(n-count);

	}
}



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

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int N,c,a;
    bool flag;
    cin >> N;
    flag = true;
    c = 0;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    
    while(flag){
        flag = false;
        for(int j=N-1;j>0;j--){
            if(A[j] < A[j-1]){
                swap(A[j],A[j-1]);
                flag = true;
                c++;
                
            }
        }
    }
    
    cout << A[0];
    for(int i=1;i<N;i++){
        cout << " " << A[i];
    }
    cout << endl;
    cout << c << endl;
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<endl;
  }else if(r<2800) {
    cout<<"ARC"<<endl;
  }else{
    cout<<"AGC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();
    if((a<c && b>c)||(a>c && b<c)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

using ll = long long;

int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n);
    map<int, vector<int>> pos;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        pos[a[i]].push_back(i);
    }

    vector<int> nxt(n, -1);
    vector<bool> last(n);
    for(auto const& p : pos) {
        auto const& ps = p.second;
        const int sz = ps.size();
        for(int i = 0; i < sz; ++i) {
            nxt[ps[i]] = ps[(i + 1) % sz];
        }
        last[ps.back()] = true;
    }

    vector<int> seq;
    int p = 0;
    while(true) {
        int s = p;
        while(!last[p]) {
            p = (nxt[p] + 1) % n;
            if(p == s) return 0;
        }
        if(!seq.empty() && seq[0] == p) break;
        seq.push_back(p);
        p = (nxt[p] + 1) % n;
    }

    if(k % (seq.size() + 1) == 0) { // empty
        return 0;
    }

    vector<int> ans;
    set<int> s;
    for(int i = seq[k % (seq.size() + 1) - 1]; i < n; ++i) {
        if(s.count(a[i])) {
            while(ans.back() != a[i]) {
                s.erase(ans.back());
                ans.pop_back();
            }
            ans.pop_back();
            s.erase(a[i]);
        } else {
            ans.push_back(a[i]);
            s.insert(a[i]);
        }
    }

    const int sz = ans.size();
    for(int i = 0; i < sz; ++i) {
        cout << ans[i] << " \n"[i + 1 == sz];
    }
}


Measured memory_bytes: 35956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1, str2, str3, str4, str5;
  str1 = "A";
  str2 = "T";
  str3 = "G";
  str4 = "C";
  cin >> str5;
   if (str5 == str1) {
    cout << "T" << endl;
  }
  if (str5 == str2) {
    cout << "A" << endl;
  }
  if (str5 == str3) {
    cout << "C" << endl;
  }
  if (str5 == str4) {
    cout << "G" << endl;
  }
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        a: i32,
        b: i32,
        h: i32,
        m: i32,
    }
    let a = a as f64;
    let b = b as f64;
    let h = h as f64;
    let m = m as f64;

    let (h, m) = (h / 12_f64, m / 60_f64);
    let h = 360_f64 * h + (360_f64 / 12_f64) * m;
    let m = 360_f64 * m;
    let (h, m) = (h.to_radians(), m.to_radians());
    let (hx, hy) = (a * h.cos(), a * h.sin());
    let (mx, my) = (b * m.cos(), b * m.sin());
    let (dx, dy) = ((hx - mx).abs(), (hy - my).abs());

    println!("{}", (dx.powf(2_f64) + dy.powf(2_f64)).sqrt());
}


Measured memory_bytes: 2792
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
n=int(input())
if n>=400 and n<=599:
	print(8)
elif n>=600 and n<=799:
	print(7)
elif n>=800 and n<=999:
	print(6)
elif n>=1000 and n<=1199:
	print(5)
elif n>=1200 and n<=1399:
	print(4)
elif n>=1400 and n<=1599:
	print(3)
elif n>=1600 and n<=1799:
	print(2)
else:
	print(1)































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

#define pb push_back
#define mp make_pair

using namespace std;

const int N = 200050;

int vis[N], a[N], L[N], R[N], D[N];
int n, m;
vector<pair<int, int> > g[N];

void dfs(int u){
	for(auto p : g[u]){
		if (vis[p.first]) continue;
		vis[p.first] = 1;
		a[p.first] = a[u] + p.second;
		dfs(p.first);
	}
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		scanf("%d%d%d", &L[i], &R[i], &D[i]);
		g[L[i]].pb(mp(R[i], D[i]));
		g[R[i]].pb(mp(L[i], -D[i]));
	}
	for(int i = 1; i <= n; ++i) if (!vis[i]){
		vis[i] = 1;
		dfs(i);
	}
	for(int i = 1; i <= m; ++i) if (a[L[i]] + D[i] != a[R[i]]){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

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

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

    string s = to_string(n);
    int sum = 0;
    for (int i = 0; i < s.length(); i++)
        sum += s[i] - '0';
    
    if (n%sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  if(a==b)cout<<c<<endl;
  else if(b==c)cout<<a<<endl;
  else cout<<b<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    string s, t; cin >> s >> t;
    int q; cin >> q;
    vector<pair<int, int>> cnts(s.size()+1),cntt(t.size()+1);
    cnts[0] = cntt[0] = {0,0};
    REP(i, s.size()) {
        if (s[i] == 'A') {
            cnts[i + 1] = {cnts[i].first + 1, cnts[i].second};
        }
        else {
            cnts[i + 1] = {cnts[i].first, cnts[i].second + 1};
        }
    }
    REP(i, t.size()) {
        if (t[i] == 'A') {
            cntt[i + 1] = {cntt[i].first + 1, cntt[i].second};
        }
        else {
            cntt[i + 1] = {cntt[i].first, cntt[i].second + 1};
        }
    }
    REP(i, q) {
        int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
        pair<int, int> sd = {cnts[b].first - cnts[a - 1].first,cnts[b].second - cnts[a - 1].second}; 
        pair<int, int> td = {cntt[d].first - cntt[c - 1].first,cntt[d].second - cntt[c - 1].second};
        int sc = sd.first - sd.second;
        int tc = td.first - td.second;
        if (sc > 0) {
            sc %= 3;
        }
        else {
            sc = (3 - ((-sc) % 3)) % 3;
        }
        if (tc > 0) {
            tc %= 3;
        }
        else {
            tc = (3 - ((-tc) % 3)) % 3;
        }
        if (sc == tc) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    return 0;
}

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

N,M=map(int,input().split())
PY=[[0,0,0] for _ in range(M)]
for i in range(M):
    PY[i][0],PY[i][1]=map(int,input().split())
    PY[i][2]=i

PY.sort()

ans=[None]*M

p=0
x=0
for i in range(M):
    if PY[i][0]!=p:
        p=PY[i][0]
        x=1
    else:
        x+=1
    pp=str(p)
    np=len(pp)
    xx=str(x)
    nx=len(xx)
    ans[PY[i][2]]="0"*(6-np)+pp+"0"*(6-nx)+xx
    
for i in range(M):
    print(ans[i])




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


int main(void){
    ll n,i=0,ans=0;
    cin>>n;
    vector<ll>a(n),b;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;){
        ll j=i;
        while(i<n&&a[j]==a[i])i++;
        b.push_back(a[j]);
    }
    for(i=0;i<(ll)b.size();){
        if(i==(ll)b.size()-1){
            ans++;
            break;
        }
        if(b[i]<b[i+1]){
            while(i<n&&b[i]<b[i+1])i++;
            ans++;
        }
        else{
            while(i<n&&b[i]>b[i+1])i++;
            ans++;
        }
        i++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    int n;
    cin>>n;
    int x = 0;
    int a[111111];
    for (int i = 1; i <= n; i++) {
        cin>>a[i];
        x += a[i];
        if (i % 2 == 0) x -= 2 * a[i];
    }
    for (int i = 1; i <= n; i++) {
        cout<<x<<' ';
        x = 2 * a[i] - x;
    }
    cout<<endl;
}

Measured memory_bytes: 2048
numOfShops = STDIN.gets.to_i
openclose = []
numOfShops.times do |i|
  openclose.push( STDIN.gets.split(" ").map{|x| x.to_i } )
end

profits = []
numOfShops.times do |i|
  profit = STDIN.gets.split(" ").map{|x| x.to_i }
  profits.push profit
end
shops = openclose.zip( profits )

maxJprofit = nil
a = [0,1]
a.product(a,a,a,a,a,a,a,a,a).each do |j_openclose|
  next if( j_openclose == [0,0,0,0,0,0,0,0,0,0] )

  profit = 0
  shops.each do |shop|
    c = 0
    (0..9).each do |i|
      c += 1 if j_openclose[i] == 1 && shop[0][i] == 1
    end
    profit += shop[1][c]
  end
  if (!maxJprofit || maxJprofit < profit)
    maxJprofit = profit
  end
end

puts maxJprofit.to_s


Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int n;
	cin >> n;
	if (n % 111 == 0) {
		cout << n << rt;
	}
	else {
		cout << 111 * (n / 111 + 1) << rt;
	}

	please AC;
}

Measured memory_bytes: 256
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]

dpa = [0]*n
dpb = [0]*n
dpc = [0]*n
dpa[0],dpb[0],dpc[0] = list1[0][0],list1[0][1],list1[0][2]


for i in range(1,n):
	dpa[i] = max(dpb[i-1]+list1[i][0],dpc[i-1]+list1[i][0])
	dpb[i] = max(dpa[i-1]+list1[i][1],dpc[i-1]+list1[i][1])
	dpc[i] = max(dpa[i-1]+list1[i][2],dpb[i-1]+list1[i][2])

print(max(dpa[-1],dpb[-1],dpc[-1]))


Measured memory_bytes: 66008
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[1][0])
h = int(arr_data[2][0])


print(int((a+b)*h /2))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){

    char arr[2][3];

    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    } //入力

    int i=0,k=1,l=2,flag=1;

    for(int j=0;j<3;j++){
        if(arr[i][j]==arr[k][l]){
            l--;
            //cout<<"ok"<<endl;
            if(j!=2) continue;
        }
        else {
            cout<<"NO"<<endl;
            flag--;
            break;
        }
       if(flag==1) cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)

	switch d {
	case 25:
		fmt.Println("Christmas")
	case 24:
		fmt.Println("Christmas Eve")
	case 23:
		fmt.Println("Christmas Eve Eve")
	case 22:
		fmt.Println("Christmas Eve Eve Eve")
	}
}


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

using namespace std;
#define lint long long

int main() {
    int N;
    string A, B, C;
    
    cin >> N >> A >> B >> C;
    
    int cnt = 0;
    
    for(int i = 0; i < N; ++i){
        if(A[i] == B[i] && B[i] == C[i]){
            continue;
        } else if(A[i] == B[i] | A[i] == C[i] | B[i] == C[i]){
            cnt++;
        } else {
            cnt += 2;
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Read() {
	int x = 0, f = 1; char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-')  f = -1; ch = getchar();}
	while(isdigit(ch)) {x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();}
	return x * f;
}
int d[1000005], mn[1000005], prime[1000005], isp[1000005], cnt;
void prework() {
	for(int i = 2; i <= 1000000; i++) {
		if(!isp[i])  prime[++cnt] = i, d[i] = 2, mn[i] = 1;
		for(int j = 1; j <= cnt && i * prime[j] <= 1000000; j++) {
			isp[i * prime[j]] = 1;
			d[i * prime[j]] = d[i] * 2; mn[i * prime[j]] = 1;
			if(i % prime[j] == 0) {
				d[i * prime[j]] = d[i] / (mn[i] + 1) * (mn[i] + 2);
				mn[i * prime[j]] = mn[i] + 1;
				break;
			}
		}
	}
}
signed main() {
	prework();
	int n = Read(), ans = 0; d[1] = 1;
	for(int i = 1; i < n; i++)  ans += d[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,state=1,m=1;
  string s;
  cin>>n>>k>>s;
  int a[4*n]={};
  int count=0;
  for(int i=0;i<n;++i){
    if(i==0){
      a[count]=0;
      count++;
    }
    else{
      if(!(s[i-1]==s[i])){
        a[count]=i;
        count++;
      }
    }
  }
    for(int i=count;i<3*n;++i){
      a[i]=n;
    }
  int tem;
  for(int i=0;i<count;++i){
    int b=a[i];
    if((s[b]-'0')==0){
      tem = a[i+2*k] - a[i];
    }
    else{
      tem = a[i+2*k+1] - a[i];
    }
    m=max(m,tem);
  }
  cout<<m;
  return 0;
}


Measured memory_bytes: 2048
/*
 * ABC080D.cpp
 *
 *  Created on: May 11, 2018
 *      Author: 13743
 */

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int S[100001];
int T[100001];
int Cs[100000];
int Ct[100000];

void quickSort(int l, int r, int* a, int* b) {
	if(l >= r) return;
	int piv = a[r];
	int i = l - 1;
	for(int j=l; j<r; j++) {
		if(a[j] <= piv) {
			i++;
			swap(a[i], a[j]);
			swap(b[i], b[j]);
		}
	}
	swap(a[i+1], a[r]);
	swap(b[i+1], b[r]);
	quickSort(l, i, a, b);
	quickSort(i+2, r, a, b);
}

int main() {
	int n, c;
	cin >> n >> c;
	for(int i=0; i<n; i++) {
		cin >> S[i] >> T[i] >> Cs[i];
		Ct[i] = Cs[i];
	}
	S[n] = 1000000;
	T[n] = 1000000;

	quickSort(0, n-1, S, Cs);
	quickSort(0, n-1, T, Ct);

	int maxC = 0;
	int nowC = 0;
	int si = 0, ti = 0;
	while(si < n) {
		int sN = 0, tN = 0;
		int co = 0;
		int ch = min(S[si], T[ti]);
		vector<int> chan;
		while(S[si] == ch) {
			chan.push_back(Cs[si]);
			sN++;
			si++;
		}
		while(T[ti] == ch) {
			for(int i=0; i<chan.size(); i++) {
				if(chan[i] == Ct[ti]) co++;
			}
			tN++;
			ti++;
		}
		maxC = max(nowC+sN-co, maxC);
		nowC += sN-tN;
	}

	cout << maxC << endl;
}




Measured memory_bytes: 1792
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

"""
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
"""

n = k()

for i in range(1,n):
  for j in range(n//i,0,-1):
    if 1<=i*j<=n-1:
      cnt += 1
      continue

print(cnt)

Measured memory_bytes: 72996
N = int(input())
a = list(map(int, input().strip().split()))
a.sort()
i = 0
j = 1
ans = 0

for i in range(N-1):
	if a[i] == a[i+1]:
		j += 1
	else:
		if j >= a[i]:
			ans += j - a[i]
		else:
			ans += j
		j = 1
if a[N-1] != a[N-2]:
	if a[N-1] != 1:
		ans += 1
else:
	if j >= a[i]:
		ans += j - a[i]
	else:
		ans += j
print(ans)

Measured memory_bytes: 14692
N = int(input())


COINS = [1,6,6**2,6**3,6**4,6**5,6**6,9**1,9**2,9**3,9**4,9**5]
COINS.sort(reverse=True)
inf = 2**30

A = [inf] * (N+1)
A[0] = 0;
for i in range(N+1):
	for coin in COINS:
		if i - coin >= 0:
			A[i] = min(A[i - coin]+1, A[i])
print(A[N])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main() {

    ios::sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;
    ll mx = min(a+b, a+c);
    mx = min(mx, b+c);
    cout << mx << endl;
    return 0;
}


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

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N, M; cin >> N >> M;
  int mi = 1, ma = N;
  for (int i = 0; i < M; i++) {
    int l, r; cin >> l >> r;
    mi = max(mi, l); ma = min(ma, r);
  }
  cout << max(0, ma - mi + 1) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

	int main(void) {
		int count[26] = { 0 };
                char c;
 
		while (cin >> c) {
                        
			if (c >= 65 && c <= 90)
				count[c - 'A']++;
			else if (c >= 97 && c <= 122)
                                count[c - 'a']++;

                      
		}

		for (int i = 0; i < 26; i++)
			printf("%c : %d\n", ('a' + i), count[i]);
		return 0;
	}

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

lli a, b;

int main(void){
	cin >> a >> b;
	lli c;
	if(a == 0 || b == 0){
		cout << "Zero" << endl;
		return 0;
	}

	if(a < 0 && b < 0){
		c = b-a+1;
	}else if(a < 0 && b > 0){
		cout << "Zero" << endl;
		return 0;
	}else if(a > 0 && b > 0){
		c = 0;
	}
	if(c % 2 == 0) cout << "Positive" << endl;
	else cout << "Negative" << endl;
	return 0;
}


Measured memory_bytes: 3616