akhauriyash/Code-Regression huggingface dataset:
//#include <atcoder/all>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>


#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
//using namespace atcoder;
struct Segtree{
	typedef int sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF=0; // min:+inf,max:-inf,0 
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return max(l, r);}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)
	//void disp(){ for(auto x :seg) cout<<x<<", "; puts("");}
	int getpos(sgT v, int l, int r ){ //vの最左位置を二分探で求める
		int lo=l-1, hi=r;
		while(hi - lo >1){
			int md = (hi + lo) >> 1;
			if( query(lo, md+1) == v ) hi = md; else lo = md; 
		}
		return hi;
	}
};

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 +7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	const int zsz = 301000;
	int n, k;
	cin >>n >>k;
	VI a(n);
	rep(i, n) cin >>a[i];
	Segtree sg;
	sg.init(zsz+1);
	rep(i, n){
		int cr = sg.query(max(0, a[i]-k), min(zsz, a[i]+k+1))+1 ;
		sg.update(a[i], cr);
		
	}
	cout << sg.query(0, zsz) <<"\n";
	return 0;
}



Measured memory_bytes: 8484
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector<int> l(2*N);
  for(int i=0;i<2*N;i++){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<N;i++){
    ans += l[2*i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	sort(v.begin(), v.end());
	int sum = 0;
	rep(i, n - 1)sum += v[i];
	cout << (*(v.end() - 1) < sum ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	
	int i=0;
	
	//パーティーに参加している友人の数
	int n=0;
	
	//ケーキを持ってきた友人の数
	int c=0;
	
	//p[i]さんが持ってきたケーキの個数
	int p[100];
	
	//ケーキの総数
	int total=0;
	
	//1人当たりがもらえるケーキの数を格納
	int count=0;
	
	//ケーキの剰余
	int Surplus=0;
	
	
	//0で一括初期化
	for(i=0;i<100;i++)
	{
		p[i]=0;
	}
	
	//パーティに参加している友人の数n(私は含めない)
	//ケーキを持ってきてくれた友人の数c(入力する回数)
	scanf("%d %d",&n,&c);
	
	
	//友人p[i]が持ってきてくれたケーキの個数の入力 & ケーキの総数totalの算出
	//ケーキを持ってきてくれた友人の数だけ入力する
	for(i=0;i<c;i++)
	{
		scanf("%d",&p[i]);
		total=total+p[i];
	}
	
	//1人当たりがもらえるケーキの数count
	//ケーキの総数total÷参加者の総数
	//参加者の総数=友人の数n＋私1人
	count=total/(n+1);
	
	//ケーキの余り
	//剰余の計算は%を使う
	Surplus=total%(n+1);
	
	//余りが出なかった場合
	if(Surplus==0)
	{
		printf("%d\n",count);
	}
	
	//ケーキが余った場合
	else
	{
		printf("%d\n",count+1);
	}
	
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
 
int main()
{
	int N;
	cin >> N;
	int H[N];
	int max = 0;
	int count = 1;
	REP(i, N)
	{
		int h;
		cin >> h;
		if(i==0){
			max = h;
		}else{
			if(h>=max){
				count++;
				max = h;
			}
		}
	}

	cout << count << endl;

	return 0;
}

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

int main() {

	int n;
	double m; cin >> n >> m;

	vector<double> a(n);
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	double v = sum / (4 * m);
	int cnt = 0;
	for (int i = 0; i < n; i++) {

		if (v <= a[i]){	
			cnt++;
		}		

	}

	if (m <= cnt) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;

}

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == "?":
        break
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        print(a // b)


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

int main()
{
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i <= N; i += 2)
    {
        int yakusuu = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
                yakusuu++;
        }
        if (yakusuu == 8)
            cnt++;
    }
    cout << cnt << endl;
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

int n,c;
ll dp[111][MAX];
ll w[111];
ll v[111];


int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);





     cin>>n>>c;
     for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
     }

     for(int k=1;k<=n;k++){
        for(int q=1;q<=c;q++){
            if(q>=w[k]){
                dp[k][q]=max(dp[k-1][q-w[k]]+v[k],dp[k-1][q]);
            }
            else{
                dp[k][q]=dp[k-1][q];
            }
        }
     }

     cout<<dp[n][c];






     return 0;

}


Measured memory_bytes: 81796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}

int cnt[28];
int dp[30];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<n;i++) cnt[s[i]-'a'+1]++;
	dp[0]=1;
	for(int i=1;i<=26;i++)
	{
		dp[i]=mult(dp[i-1],cnt[i]+1);
	}
	cout<<add(dp[26],MOD-1)<<'\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    multiset<int> ms;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        ms.insert(a);
    }

    int l = *ms.begin();
    if(ms.count(l) > 2)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    if(l == 1)
    {
        if(ms.count(1)==2 && n == 2)
        {
            cout << "Possible" << endl;
            return 0;
        }
        if(ms.count(l) == 1 && ms.count(2) == n-1)
        {
            cout << "Possible" << endl;
        }
        else
        {
            cout << "Impossible" << endl;
        }
        return 0;
    }

    int r = *ms.rbegin();
    if(r > l * 2 || r >= n)
    {
        cout << "Impossible" << endl;
    }
    else if(r % 2 == 0 && ms.count(l) == 2)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        auto itr = ms.begin();
        int now = *itr;
        int s = ms.count(*itr);
        int nowc = s;
        while(s) //count(*itr) = 1 is ok
        {
            itr++;
            s--;
        }
        int next = *itr;
        int nextc = ms.count(next);
        while(itr != ms.end())
        {
            if(ms.count(*itr) < 2 || next != now+1)
            {
                cout << "Impossible" << endl;
                return 0;
            }
            int size = ms.count(*itr);
            while(size)
            {
                itr++;
                size--;
            }
            now = next;
            next = *itr;
            nowc = nextc;
            nextc = ms.count(next);
        }
        cout << "Possible" << endl;
    }
}

Measured memory_bytes: 256
//
// Created by 和田邦彦 on 2020/02/16.
//

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

using namespace std;

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

    vector<unsigned> a(n);
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a[i] = tmp;
    }

    sort(a.begin(), a.end());
    int cur = a[0];
    for (int i = 1; i < n; i++) {
        if (cur == a[i]) {
            cout << "NO" << endl;
            return 0;
        }
        cur = a[i];
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ull N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> ab(M);
  for (auto i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    ab[i] = make_pair(min(a, b), max(a, b));
  }
  sort(ab.begin(), ab.end());

  ll prev = -1;
  ll res = 0;
  for (auto i = 0; i < M; i++) {
    auto a = ab[i].first;
    auto b = ab[i].second;
    if (prev == -1) {
      prev = b;
    } else if (b < prev) {
      prev = b;
    } else if (a < prev) {

    } else {
      // prev < a
      prev = b;
      res++;
    }
  }
  if (prev != -1) res++;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nab = IO.RSLong;
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];

            long min = a * (n - 1) + b;
            long max = b * (n - 1) + a;
            WriteLine(Max(max - min + 1, 0));
        }
    }

    public struct Pair
    {
        public Pair(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
        public int a;
        public int b;
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main() {
  int N;
  cin >> N;
  map<char,int> mode, as;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    int k = s.size();
    if (i == 0) {
      for (int j = 0; j < k; j++) mode[s[j]] += 1;
      continue;
    }
    for (int j = 0; j < k; j++) as[s[j]] += 1;
    for (auto m : mode) mode[m.first] = min(m.second,as[m.first]);
    as.clear();
  }
  
  string s;
  for (auto m : mode) {
    for (int i = 0; i < m.second; i++) {
      s += m.first;
    }
  }
  sort(s.begin(),s.end());
  cout << s << endl;
}

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

using namespace std;

const int MAXN = 200010;

int n;
int qtdBall;

int v[MAXN];

bool hasBall[MAXN];

void add(int i)
{
	qtdBall++;
	hasBall[ i ] = true;
}

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	for(int i = n ; i > 0 ; i--)
	{
		bool flag = v[i];

		for(int j = 2*i ; j <= n ; j += i)
			flag = flag^hasBall[j];

		if( flag ) add( i );
	}

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

	for(int i = 1 ; i <= n ; i++)
		if( hasBall[i] ) printf("%d ",i);
}

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

int main(){
  int n;
  cin>>n;
  int count=0;
  for(int i=1;i<=n;i++){
    int j=i;
    int c=0;
    while(j>0){
     c++;
     j=(j-j%10)/10;
    }
    if(c%2==1){
      count++;
    }
  }
  cout<<count<<endl;
}
      

Measured memory_bytes: 256
// Aizu 0359: Day of Week
// 2017.9.19 bal4u@uu
#include <stdio.h>
char *w[7] = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
int main()
{
	int d;
	scanf("%d", &d);
	printf("%s\n", w[(d+4)%7]);
	return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;




// Generated by 1.1.6 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);
    //vector<string> S(N);
    int ans=0;
    string tmp="";
    unordered_map<string, int> mp;

    for(int i = 0 ; i < N ; i++){
        cin>>tmp;
       if(mp[tmp]==0){
           ans++;
           mp[tmp]=1;
       }
    }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 2019;

int main(){
    ll l, r;
    cin >> l >> r;
    if (l==0 || r/2019-(l-1)/2019>0) cout << 0 << endl;
    else {
        l %= mod;
        r %= mod;
        if (r < l) r += mod;
        ll ans = mod;
        for (int i=l; i<=r; ++i) for (int j=i+1; j<=r; ++j) {
            ans = min(ans, i*j%mod);
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+1



//time complexity will be O(N^2*V) space complexity will be O(N^2*V)

class item{
    public:
    int val;
    int wt;
};

int N,W;
item arr[105];

int solve(){
    //dp[n][w]  max_val that we can obtain by having n number of items and max_capacity of knapsack is w

    //first look at the base cases
    int dp[2][W+1];

    for(int w=0;w<=W;w++) {
        //if the max_capacity of knapsack is less than the wt of the first item then the only option left is to exclude that item
        if(arr[0].wt>w) dp[0][w]=0;
        //otherwise just take that item and our max_val that we can obtain is equal to the val of the first item
        else dp[0][w]=arr[0].val;
    }
    int i;
    for( i=1;i<N;i++){
        for(int w=0;w<=W;w++){

            /*dp[i][w]=dp[i-1][w];
            if(arr[i].wt>w) continue;
            dp[i][w]=max(dp[i][w],arr[i].val+dp[i-1][w-arr[i].wt]);*/

            if(i&1){
                dp[1][w]=dp[0][w];
                if(arr[i].wt>w) continue;
                dp[1][w]=max(dp[1][w],arr[i].val+dp[0][w-arr[i].wt]);
                
            }

            else{
                dp[0][w]=dp[1][w];
                if(arr[i].wt>w) continue;
                dp[0][w]=max(dp[0][w],arr[i].val+dp[1][w-arr[i].wt]);

            }
        }

    }
    if((N-1)&1) return dp[1][W];
    return dp[0][W];
}

int32_t main(){
    cin>>N>>W;
    for(int i=0;i<N;i++) cin>>arr[i].wt>>arr[i].val;
    cout<<solve()<<endl;
}

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

int main() {
  int H, W;
  char a;
  cin >> H >> W;
  
  for(int i=0;i < H+2;i++){
    for(int j=0;j < W+2;j++){
      if(i==0 || i==H+1)
        cout << '#';
      else{
        if(j==0 || j==W+1)
          cout << '#';
        else{
          cin >> a;
          cout << a;
        }
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        vector<int> a(3);
        for (int i = 0; i < 3; i ++) {
                scanf("%d", &a[i]);
        }
        int ans = 0;
        for (;;) {
                if (a[0] == a[1] && a[1] == a[2]) {
                        break;
                }
                sort(a.begin(), a.end());
                if (a[1] < a[2]) {
                        a[0] ++;
                        a[1] ++;
                } else {
                        a[0] += 2;
                }
                ans ++;
        }
        printf("%d\n", ans);
        return 0;
}



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

#define lint long long
#define P pair<int, int>


int main() {
    int N, K;

    cin >> N >> K;

    string S;
    cin >> S;

    for(int i = 0; i < N; ++i){
        if(i != K - 1){
            cout << S[i];
        } else {
            if(S[i] == 'A'){
                cout << 'a';
            }
            if(S[i] == 'B'){
                cout << 'b';
            }
            if(S[i] == 'C'){
                cout << 'c';
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k - 1; i <= n; i++){
        ll mn = (i * (i + 1) / 2), mx = (n * (n + 1) / 2) - (n - i - 1) * (n - i) / 2;
        ans = (ans + (mx - mn + 1)) % mod;
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    --n;
    LL ans = 0;

    loop(i,1,n+1)
    {
        ans += (n / i);
    }

    cout<<ans<<'\n';

    return 0;
}


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

using namespace std;

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> in(501, vector<int>(501, 0));
	for (int i = 0; i < m; i++)
	{
		int l, r;
		cin >> l >> r;
		in[l][r]++;
	}
	vector<vector<int>> data(501, vector<int>(501, 0));
	for (int i = 1; i < 501; i++)
		for (int j = 1; j < 501; j++)
			data[i][j] = data[i][j - 1] + in[i][j];
	for (int qu = 0; qu < q; qu++)
	{
		int l, r;
		cin >> l >> r;
		int ans = 0;
		for (int i = l; i <= r; i++)
			ans += data[i][r] - data[i][l - 1];
		cout << ans << endl;
	}

	return 0;
}


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

#define MAX 1000
#define TRUE 1
#define FALSE 0

int S[MAX];
int top;

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int main(){
  int a,b,x,flog=0;
  char s;
  initialize();
  while(1){
    if((s = getchar()) == '\n') break;
    if((int)s>=48 && (int)s<=57){
      x=(int)s-48;
      if(flog==1){
	a=pop();
	push(a*10+x);
      }
      else push(x);
      flog=1;
    }
    else if(s=='+'){
      flog=0;
      b=pop();
      a=pop();
      push(a+b);
    }
    else if(s=='-'){
      flog=0;
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s=='*'){
      flog=0;
      b=pop();
      a=pop();
      push(a*b);
    }
    else{
      flog=0;
      continue;
    }
  }
  printf("%d\n",pop());
  return 0;
}

void initialize(){
  top=0;
}

int isEmpty(){
  if(top==0) return TRUE;
  else return FALSE;
}

int isFull(){
  if(top>=MAX-1) return TRUE;
  else return FALSE;
}

void push(int x){
  if(isFull()==1){
    fprintf(stderr,"ERROR!");
    exit(1);
  }
  top++;
  S[top]=x;
}

int pop(){
  if(isEmpty()==1){
    fprintf(stderr,"ERROR!");
    exit(1);
  }
  top--;
  return S[top+1];
}

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

int N,M,X;
int A[100];

void solve(){
  int right=0,left=0;
  for(int i=0; i<M; i++){
    if(A[i]<X)  left++;
    else if(A[i]>X) right++;
  }
  cout << min(right,left) << endl;
}

int main(){
  cin >> N >> M >> X;
  for(int i=0; i<M; i++){
    cin >> A[i];
  }

  solve();
}

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

using namespace std;

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

  vector<char> a, b;

  for (unsigned i = 0; i < s.size(); i++) {
    a.push_back(s[i]);
  }
  for (unsigned i = 0; i < t.size(); i++) {
    b.push_back(t[i]);
  }

  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());

  for (unsigned i = 0; i < a.size(); i++) {
    s[i] = a[i];
  }
  for (unsigned i = 0; i < b.size(); i++) {
    t[i] = b[i];
  }

  string answer = s < t ? "Yes" : "No";

  cout << answer << endl;
}


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

//領域を増やすプロ

int main(){

    int n, m; cin >> n >> m;
    vector<int> X;
    vector<int> Y;
    vector<int> x(n);
    vector<int> y(n);
    
    //点の追加
    for(int i = 0; i < n; i++){
        int x1, y1; cin >> x1 >> y1;
        x[i] = x1;
        y[i] = y1;

        X.push_back(x1);
        Y.push_back(y1);
        //X.push_back(x2);
        //Y.push_back(y2);        
    }

    

    //座標の始点、終点を追加
    //X.push_back(0);
    //Y.push_back(0);
    //X.push_back(w);
    //Y.push_back(h);

    //定石
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    // X = {0, 1, 1, 4, 4, 6, 9, 9, 10, 10, 10, 10}
    // Y = {0, 1, 1, 4, 4, 5, 6, 8, 8, 10, 10, 10}


    X.erase(unique(X.begin(),X.end()),X.end());
    Y.erase(unique(Y.begin(),Y.end()),Y.end());
    // X = {0, 1, 4, 6, 9, 10}
    // Y = {0, 1, 4, 5, 6, 8, 10}
    
    //cout << endl;
    int h = 0, w = 0;
    //cout << "x1 y2" << endl;
    for(int i = 0; i < n; i++){

        x[i] = lower_bound(X.begin(),X.end(),x[i]) - X.begin();
        w = max(w, x[i]);
        //int x2 = lower_bound(X.begin(),X.end(),xe[i]) - X.begin();

        y[i] = lower_bound(Y.begin(),Y.end(),y[i]) - Y.begin();
        h = max(h, y[i]);
        //int y2 = lower_bound(Y.begin(),Y.end(),ye[i]) - Y.begin();

        //cout <<"(" << x[i] << " " << y[i] << ")" << endl;
    }

    

    //cout << h << " " << w << endl;
    vector<vector<int> > imos(h + 2, vector<int> (w + 2, 0));
    for(int i = 0; i < n; i++){
        //cout << x[i] << "  " << y[i] << endl;
        imos[y[i] + 1][x[i] + 1]++;
    }

    

    for(int j = 0; j <= w + 1; j++){
        for(int i = 1; i <= h + 1; i++){
            imos[i][j] += imos[i - 1][j];
        }
    }

    for(int i = 0; i <= h + 1; i++){
        for(int j = 1; j <= w + 1; j++){
            imos[i][j] += imos[i][j - 1];
        }
    }

    
    /*for(int i = 0; i < X.size(); i++){
        cout << X[i] << endl;
    }*/
    
    for(int i = 0; i < m; i++){
        int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
        x1 = lower_bound(X.begin(),X.end(),x1) - X.begin() + 1;
        x2 = upper_bound(X.begin(),X.end(),x2) - X.begin();

        y1 = lower_bound(Y.begin(),Y.end(),y1) - Y.begin() + 1;
        y2 = upper_bound(Y.begin(),Y.end(),y2) - Y.begin();
        //if(x2 == -1) x2 = 0;
        //if(y2 == -1) y2 = 0;
        //cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
        int sum = imos[y2][x2];
        if(x1 > 0) sum -= imos[y2][x1 - 1];
        if(y1 > 0) sum -= imos[y1 - 1][x2];
        if(x1 > 0 && y1 > 0) sum += imos[y1 - 1][x1 - 1];
        cout << sum << endl;
    }
    return 0;
    
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	string str;
	cin>>str;
	if((int)str.size()>n)
	{
		str.resize(n);
		str+="...";
	}
	cout<<str<<'\n';
}


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

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

void solve(int N) {
  string s1, s2;
  bool to_right = true;
  while(1) {
    bool right = false;
    REP(i,4) {
      string tmp1, tmp2;
      if(to_right) {
        tmp1 = s1 + ((i / 2 == 1) ? "#" : ".");
        tmp2 = s2 + ((i % 2 == 1) ? "#" : ".");
      }else{
        tmp1 = ((i / 2 == 1) ? "#" : ".") + s1;
        tmp2 = ((i % 2 == 1) ? "#" : ".") + s2;
      }
      printf("%s\n%s\n", tmp1.c_str(), tmp2.c_str()); fflush(stdout);
      string r;
      cin >> r;
      if(r == "end"){
        return;
      }else if(r == "T") {
        s1 = tmp1;
        s2 = tmp2;
        if(to_right) right = true;
        break;
      }
    }
    if(!right) {
      to_right = false;
    }
  }
}

int main(){
  int N;
  cin >> N;
  solve(N);
  return 0;
}



Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	while(1){
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) return 0;
		//??°?????????????????¨????????±???
		vector<string> data(n);//??\?????????????????\??????
		set<string> num;//k???????????§??§?????????????????\??????
		rep(i, n) cin >> data[i];
		
		sort(data.begin(), data.end());//?????????????????????
		//next_permutaion??§??¨???????????????
		do{
			string tmp;
			//??????????????????k???????????£?????????
			rep(i, k){
				tmp += data[i];
			}
			//set?????\???????????¨??§??????????????????????????????????????????????????????
			num.insert(tmp);
		}while(next_permutation(data.begin(), data.end()));
		printf("%lu\n", num.size());//?????°?????¨???
	}
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;


int main() {
	long long h, n, sum = 0, a;
	cin >> h >> n;
	for(int i = 0; i < n; ++i){
		cin >> a;
		sum += a;
	}
	cout << ((h <= sum)? "Yes":"No");
}

Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
A = list(map(int, input().split()))

IA = [(i,A[i]) for i in range(N)]
IA.sort(key=lambda a: a[1])
I = [str(ia[0]+1) for ia in IA]
print(' '.join(I))


Measured memory_bytes: 67564
n = int(input())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i],b[i] = map(int,input().split())
a = a[::-1]
b = b[::-1]
ans = 0
for i in range(n):
    if (ans+a[i])%b[i]:
        ans += b[i]-((ans+a[i])%b[i])
print(ans)

Measured memory_bytes: 17640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

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


int main() {
    ios::sync_with_stdio(false);
    
    int a, b;
    
    cin >> a >> b;
    cout <<  gcd(a, b) << endl;
    
    return 0;
}


Measured memory_bytes: 3152
n = int(input())
l = list(map(int,input().split(" ")))
l.sort()
cnt = 0 
import bisect
for i in range(0,n-2):
    a = l[i]
    for j in range(i+1,n-1):
        b = l[j]
        target = a + b 
  #      print("#",a,b)
        f1 = bisect.bisect_left(l,target,j+1,n)
        cnt+= f1 - 1- j
   #     print("cnt: ",cnt)
print(cnt)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	if(A%2 && B%2 && C%2)
		cout<<min({A*B,B*C,C*A})<<endl;
	else
		cout<<0<<endl;
	return 0;
}

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

int main() {
	int k ; cin >> k ; https://ideone.com/myrecent
	string s ; int n ;
	cin >>n >> s ;
	for(int i  = 0 ; i < s.size() ; i++){
		if(i+1 == n){
			s[i] = tolower(s[i]) ;
		}
	}
	cout << s ;
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10**20
N, M = map(int, input().split())
G = [[]for i in range(N)]
for i in range(1, N):
    G[i].append([i-1, 0])

for i in range(M):
    L, R, C = map(int, input().split())
    G[L-1].append([R-1, C])

S = 0

def dijkstra(N, S):
    d = [INF for i in range(N)]

    que = []
    d[S] = 0
    heapq.heappush(que, [0, S])

    while not(len(que) == 0):
        q = heapq.heappop(que)
        ver = q[1] # ノード
        dis = q[0] # 過去に更新された最短距離

        # vまで2番目に短い距離（最新）　＜　過去最短距離　の時、
        # キューから取り出した過去のものを無視する
        if d[ver] < dis:
            continue

        # 隣接リストに対してループ
        for i in range(len(G[ver])):
            e = G[ver][i]
            if d[e[0]] > d[ver] + e[1]:
                d[e[0]] = d[ver] + e[1]
                heapq.heappush(que, [d[e[0]], e[0]])

    return d[N-1]

ans = dijkstra(N, S)
if ans == INF:
    print(-1)
else:
    print(dijkstra(N, S))

Measured memory_bytes: 112688
import numpy as np
from itertools import product

n = int(input())
f = [np.array(list(map(int, input().split())), dtype=bool) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

# print(n, f, p)

allcase = np.array(list(product([0, 1], repeat=10)), dtype=bool)

# print(allcase, allcase.shape)

ans = -(10 ** 9)

for a in allcase:
    if sum(a) == 0:
        # print(a)
        continue
    profit = 0
    for shop in range(n):
        # idx = np.count_nonzero(np.logical_and(f[shop], a))
        idx = np.count_nonzero(np.logical_and(f[shop], a))

        profit += p[shop][idx]
    ans = max(ans, profit)

print(ans)


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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

char text[4] = {'A', 'G', 'C', 'T'};
int n;
string s;

int main(){
    getline(cin, s);
    n = s.length();
    int cnt=0, ans=-1;
    rep(i, n){
        bool flag = true;
        rep(j, 4){
            if(s[i] == text[j]){
                cnt++;
                flag = true;
                break;
            } else {
                flag = false;
            }
        }
        if(!flag){
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}



set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}


// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------
struct day
{
	int a, b, c;
};

int func(int n, int arr [][3], int act)
{
	if (n == 0)
		return 0;


	int r = 0;
	for (int i = 0; i < 3; i++)
	{
		if (i != act)
		{
			r = max(r, arr[n - 1][i] + func(n - 1, arr, i));
		}
	}
	return r;

}
int32_t main()
{
	FIO;
	// c_p_c();
//--------------------------------------------------


	int n;
	cin >> n;
	vector<int> dp(3, 0);
	for (int day = 0; day < n; day++)
	{
		vector<int> newdp(3, 0);
		vector<int> c(3);
		for (int i = 0; i < 3; i++)
			cin >> c[i];
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (i != j)
				{
					newdp[j] = max(newdp[j], dp[i] + c[j] );
				}
			}
		}
		dp = newdp;
	}

	cout << max(dp[0], max(dp[1], dp[2])) << endl;


}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(j%2==1)
	    {
	      if(i%2==1)printf("#");
	      else printf(".");
	    }
	  else 
	    {
              if(i%2==1)printf(".");
	      else printf("#");
	    }
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 1000000000000 + 10
using namespace std;
string s;
ll len;
ll ans;
void solve(ll start, ll sum, ll flag)
{
    ll i;
    ll f = 0;
    ll cnt = 1;
    char r = s[start];
    for (i = start + 1; i < len; i++)
    {
        if (s[i] == r)
            cnt++;
        else
        {
            if (r == '<' && s[i] == '>')
                f = 1;
            break;
        }
    }
    if (flag == 1)
    {
        if (cnt > sum)
        {
            if (cnt > 1)
            {
                ans += (cnt + 1) * cnt / 2;
                ans -= sum;
            }
            else
            {
                ans += 1;
                ans -= sum;
            }
        }
        else
        {
            if (cnt > 1)
            {
                ans += (cnt + 1) * cnt / 2;
                ans -= cnt;
            }
            else
            {
                ans += 1;
                ans -= cnt;
            }
        }
        if (i >= len)
            return;
        return solve(i, cnt, f);
    }
    else
    {
        if (cnt > 1)
            ans += (cnt + 1) * cnt / 2;
        else
        {
            ans += 1;
        }
        if (i >= len)
            return;
        return solve(i, cnt, f);
    }
}
int main()
{
    ans = 0;
    cin >> s;
    len = s.size();
    solve(0, 0, 0);
    cout << ans << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int a;
  vector<int> towns(N);
  
  for (int i = 0; i < 2*M; i++){
    cin >> a;
    towns.at(a-1)++;
  }
  
  for (int i = 0; i < N; i++){
    cout << towns.at(i) << endl;
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
  int main() {
    int a,b;
    cin >> a >>b;
    int c,d,e;
    c =a+b;
    d =a-b;
    e=a*b;
    vector<int> vec ={c,d,e};
    sort(vec.begin(),vec.end());
    cout << vec.at(2) <<endl;
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  public static void main(String args[]){
	  	Scanner sc = new Scanner(System.in);
	    int x = sc.nextInt();
	    
	    int larger = x/500;
	    
	    int smaller = x - larger*500;
	    
	    int yens = smaller/5;
	    
	    System.out.println((larger * 1000) + (yens * 5));
	  }
	}


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

int main() {
	long long a, b, x, ans = 0, remove = 0;
	cin >> a >> b >> x;
	ans = b / x;
	if (a % x == 0) {
		remove = a / x;
		ans -= (remove - 1);
	}
	else {
		remove = a / x;
		ans -= remove;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
b = 0
for hi in h:
    if hi > b:
        cnt=0
    else:
        cnt+=1
    if cnt > ans:
        ans=cnt
    b = hi
print(ans)

Measured memory_bytes: 14252
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);


    while(1){
        int n; cin >> n;

        if (n == 0) break;
        vector<int> s(250100, 0);

        REP(i, n) {
            string l, r; cin >> l >> r;

            int li = 0, ri = 0;
            REP(j, 8) {
                if (j == 2 || j == 5) continue;
                li *= 10;
                li += l[j] - '0';

                ri *= 10;
                ri += r[j] - '0';
            }

            s[li]++;
            s[ri]--;
        }

        FOR(i, 1, s.size()) s[i] += s[i - 1];

        print(*max_element(ALL(s)));
    }

}


Measured memory_bytes: 4168
import itertools
import math
n = input()

chars = ["3", "5", "7"]
ndigits = int(math.log10(n)) + 1

count = 0
for digit in range(3, ndigits + 1):
    for string in itertools.product(chars, repeat=digit):
        if(string.count("3") == 0):
            continue
        if(string.count("5") == 0):
            continue
        if(string.count("7") == 0):
            continue
        if n >= int("".join(string)):
            count += 1

print(count)


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    string A[N];
    vector<tuple<int,char>> a(N),b(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        get<0>(a.at(i))=A[i].at(1)-'0';
        get<1>(a.at(i))=A[i].at(0);
        get<0>(b.at(i))=A[i].at(1)-'0';
        get<1>(b.at(i))=A[i].at(0);
    }
    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(get<0>(a.at(j))<get<0>(a.at(j-1))){
                swap(a.at(j),a.at(j-1));
            }
        }
    }
    for(int i=0;i<N;i++){
        cout<<get<1>(a.at(i))<<get<0>(a.at(i));
        if(i==N-1) cout<<endl;
        else cout<<' ';
    }
    cout<<"Stable"<<endl;


    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(get<0>(b.at(j))<get<0>(b.at(minj))){
                minj=j;
            }
        }
        swap(b.at(i),b.at(minj));
    }
    for(int i=0;i<N;i++){
        cout<<get<1>(b.at(i))<<get<0>(b.at(i));
        if(i==N-1) cout<<endl;
        else cout<<' ';
    }
    bool judge=true;
    for(int i=0;i<N;i++){
        if(get<0>(a.at(i))!=get<0>(b.at(i))||get<1>(a.at(i))!=get<1>(b.at(i))){
            judge=false;
        }
    }
    if(judge) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  map<int,int> m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    m[a[i]]++;
  }
  sort(a,a+n);
  int max=a[n-1];
 	for(int i=0;i<n;i++){
      	for(int j=2;j*a[i]<=max;j++){
        	m[j*a[i]]=-1;
      	}
    }
  	int count=0;
  	for(int i=0;i<n;i++){
      if(m[a[i]]==1)count++;
    }
  	printf("%d",count);
  return 0;
}


Measured memory_bytes: 51192
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

bool dp[110][10110];

int main () {
  int n;
  cin >> n;
  vi s(n);
  rep(i,n) cin >> s[i];
  
  dp[0][0] = true;
  rep(i,n+1) {// n+1をnにしないように注意！
    rep(j,10001) {
      if (i-1 >= 0 && dp[i-1][j]) {
        dp[i][j] = dp[i-1][j];
      }
      if (i-1 >= 0 && j-s[i-1] >= 0 && dp[i-1][j-s[i-1]]) {
        dp[i][j] = dp[i-1][j-s[i-1]]; // sの中身もi-1になることに注意！
      }
    }
  }

  int ans = 0;
  rep(i,10001) {
    if (dp[n][i] && i%10 != 0) {
      chmax(ans,i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024