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

typedef long long ll;
typedef long double ld;
typedef pair<double,double> dd;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<ii> > vvip;
typedef vector<ii> vii;
typedef map<int,int> mpi;
#define pb push_back
#define F first
#define S second
//#define MOD 1000000007
#define NA -1
#define ALL(v) v.begin(),v.end()
#define mp make_pair
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout<<#a<<" :";FOR(i123,x,y)cout<<setw(4)<<(a)[i123];cout<<endl;}
#define foreach(e, x) for (__typeof(x.begin()) e = x.begin(); e != x.end(); e++) 
#define clr(x) memset(x,0,sizeof(x));
#define sz(x) int((x).size())
#define endl '\n'
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
#define sc(t) scanf("%d",&t)
// vector<string> split(const string &s, char delim) {
//     stringstream ss(s);
//     string item;
//     vector<string> tokens;
//     while (getline(ss, item, delim)) {
//         tokens.push_back(item);
//     }
//     return tokens;
// }

typedef pair<pll,ll> ppll;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
#define re return
#define MAX 100

 // struct compare  
 // {  
 //   bool operator()(const ii& a, const ii& b)  
 //   {  
 //       re (a.S-a.F+1 < b.S-b.F+1) || (a.S-a.F+1 == b.S-b.F+1 && a.F>b.F);
 //   }
 // };

	
int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	//     freopen("output.txt","w",stdout);;
	// #endif
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0);
	string a,b,c;
	cin>>a>>b>>c;
	cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll n;cin>>n;
    	vl vec(n);
    	rep(i, n)	{cin>>vec[i];--vec[i];}
    	vl v1(n), v2(n);
    	rep(i, n){
    		v1[i] = i+1, v2[i] = n-i;
    	}
    	ll cur =0 ;
    	rep(i, n){
    		ll u = vec[i];
    		if(v1[u] + v2[u] <= cur){
    			ll del = cur - v1[u] - v2[u] + 1;
    			foi(j, u, n)	v1[j] += del;
    			fod(j, u, 0)	v2[j] += del;
    		}
    		cur = v1[u] + v2[u];
    	}
    	for(ll u : v1)	cout<<u<<" ";cout<<endl;
    	for(ll u : v2)	cout<<u<<" ";cout<<endl;
    }
}

Measured memory_bytes: 3744
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    a=(n+999)//1000
    print(a*1000-n)

main()

Measured memory_bytes: 9184
N = int(input()) 
b = [int(i) for i in input().split()]

r =[]
flag = True
blen = len(b) + 1
while b != []:
    if blen == len(b):
        flag = False
        break
    else:
        blen = len(b)
            
    for i in range(len(b)):
#        print("raw", len(b) - i)
#        print("b", b[len(b) - 1 - i])
        if (len(b) - i == b[len(b) - 1 - i]):
            r.append(b.pop(len(b) - i - 1))
            forflag = True
            break

if flag == True:
    for i in reversed(r):
        print(i)
else:
    print("-1")

Measured memory_bytes: 38896
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

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};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N, K;
	cin >> N >> K;
	
	int cur = (N-1) * (N-2) / 2;
	
	if (cur < K) {
		puts("-1");
		return 0;
	}
	
	using pii = pair< int, int >;
	set< pii > used;
	set< pii > edge;
	for (int a=1; a<N; ++a) used.insert(pii(a,N));
	for (int a=1; a<N; ++a) for (int b=a+1; b<N; ++b) edge.insert(pii(a,b));
	
	while (K < cur) {
		pii p = *edge.begin();
		used.insert(p);
		edge.erase(p);
		--cur;
	}
	
	cout << used.size() << endl;
	for (pii p : used) cout << p.first << " " << p.second << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 640
n,k=map(int,input().split())

b=[]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for i in range(len(a)):
        if a[i] not in b:
            b.append(a[i])
#print(b)
print(n-len(b))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  if (str.at(0) == 'a') {
    cout << "vowel" << endl;
  }else if(str.at(0) == 'u'){
    cout << "vowel" << endl;
  }else if(str.at(0) == 'o'){
    cout << "vowel" << endl;
    }else if(str.at(0) == 'e'){
    cout << "vowel" << endl;
  }else if(str.at(0) == 'i'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}

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

using namespace std;

typedef long long ll;
#define N 3005
const int mod = 998244353;

int n, a[N], S;

ll ans = 0, f[N];

int main()
{
	scanf("%d%d", &n, &S);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++)	
	{
		f[0]++;
		if(a[i] > S) continue;
		(ans += 1ll * (n - i + 1) * f[S - a[i]]) %= mod;
		for(int j = S; j >= a[i]; j--) (f[j] += f[j - a[i]]) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <set>
#include <algorithm> 
#include <iostream>
#include <bits/stdc++.h>
 
//------------------------------------------------------------------------------
 
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod 1000000007
#define ll long long
#define pb emplace_back
#define mp make_pair
#define sf scanf
#define pf printf
#define F first
#define S second
 
//------------------------------------------------------------------------------
using namespace std;
 
 
ll int n,k,dp[100010];

ll int find(ll int a[],ll int i)
{
    if(dp[i]!=-1) return dp[i];
   // if(i==n-1) return a[n-1];
    if(i+1>=n && i+2>=n) return 0;
    
    ll int aa[k+1]={0}, mm=999999999999;
    
    for(ll int j=1;j<=k;j++){
        if(i+j<n){
          aa[j]=abs(a[i]-a[i+j])+find(a,i+j);
          if(aa[j]<mm) mm=aa[j];
        }
    }
    
return dp[i]=mm;
}
 
 
int main() 
{
	fio;
	memset(dp,-1,sizeof(dp));
	ll int x,a[100010]={0};
	cin>>n>>k;
	
	for(ll int i=0;i<n;i++)
	  cin>>a[i];
	
	x=find(a,0);
	
	cout<<x<<endl;
    
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26, 0);
    char x;
    for (int i = 0; i < h * w; i++) cin >> x, cnt[x - 'a']++;
    int one = 0;
    for (int i = 0; i < 26; i++){
        if (cnt[i] % 2) one++, cnt[i]--;
    }
    if ((h * w % 2 == 0 && one) || one > 1){
        cout << "No" << endl;
        return 0;
    }
    int two = 0;
    if (h % 2) two += w / 2;
    if (w % 2) two += h / 2;
    int four = (h * w - (h * w % 2) - two * 2) / 4;
    for (int i = 0; i < 26; i++) four -= cnt[i] / 4;
    if (four > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(vv) vv.begin(), vv.end()
 
using namespace std;
const ll maxn=1e6+100,inf=1e18,LOG=23,mod=1e9 + 7;
 
#define int ll

int n, m, l[maxn], r[maxn], v[maxn], dp[maxn], dpbez[maxn], t[4*maxn], p[4*maxn];
vector <pair <int, int> > vec[maxn];

void push(int v)
{
	if(p[v])
	{
		t[v * 2] += p[v];
		t[v * 2 + 1] += p[v];
		p[v * 2] += p[v];
		p[v * 2 + 1] += p[v];
		p[v] = 0;
	}
}

void upd(int v, int tl, int tr, int l, int r, int cost)
{
	if(l <= tl && tr <= r)
	{
		t[v] += cost;
		p[v] += cost;
		return;
	}
	if(l > tr || r < tl)
	{
		return;
	}
	push(v);
	upd(v * 2, tl, (tl + tr) / 2, l, r, cost);
	upd(v * 2 + 1, (tl + tr) / 2 + 1, tr, l, r, cost);
	t[v] = min(t[v * 2], t[v * 2 + 1]);
}

int get(int v, int tl, int tr, int l, int r)
{
	if(l <= tl && tr <= r)
	{
		return t[v];
	}
	if(l > tr || r < tl)
	{
		return 1e18;
	}
	push(v);
	return min(get(v * 2, tl, (tl + tr) / 2, l, r), get(v * 2 + 1, (tl + tr) / 2 + 1, tr, l, r));
}

main()
{
	IOS
	cin >> n >> m;
	int sum = 0;
	forn(1, i, m)
	{
		cin >> l[i] >> r[i] >> v[i];
		sum += v[i];
		vec[r[i]].pb(mp(l[i], v[i]));
	}
	++n;
	forn(1, i, n)
	{
		/*forn(1, j, n)
		{	
			upd(1, 1, n, j, j, 0);
			cout << get(1, 1, n, j, j) << " ";
		}
		cout << endl;
		*/
		dp[i] = get(1, 1, n, 1, i);
		dpbez[i] = min(dp[i], min(dp[i - 1], dpbez[i - 1]));
		sort(all(vec[i]));
		FOR(0, j, vec[i].size())
		{
			int cost = vec[i][j].s;
			while(j < vec[i].size() - 1 && vec[i][j].f == vec[i][j + 1].f)
			{
				++j;
				cost += vec[i][j].s;
			}
			upd(1, 1, n, 1, vec[i][j].f, cost);
		}
		upd(1, 1, n, i + 1, i + 1, dp[i]);
	}
	cout << sum - get(1, 1, n, 1, n);
}

Measured memory_bytes: 59776
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

//mapの使い方
#include <map>

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  vi a(n);
  REP(i,n) cin>>a[i];
  map<long long, long long> nums;

  vi b(n);

  ans=0;
  REP(i,n)
  {
    b[i]=(ans+a[i])%k;
    ans=b[i];
  }

  REP(i,n)
  {
    b[i]=((b[i]-i-1)%k+k)%k;
  }

  
  REP(i,n)
  {
    if (i==k-1)break;
    nums[b[i]]+=1;
  }








  

  ans=0;
  ll sm=0;
  REP(i,n){
    if (nums.find(sm)!=nums.end()){//存在すれば
      ans+=nums[sm];
      //cout<<i<<" "<<sm<<" "<<nums[sm]<<endl;
    }
    //nums野中を全部a[0]引いて1たす
    //num内のb[0]を消す
    //numにb[5]-a[0]+1を追加
    nums[b[i]]--;
    
    sm+=a[i]-1;
    sm%=k;

    if ((i+k-1)<n){
      //b[i+k-1]=(b[i+k-1]-sm+k)%k;
      nums[b[i+k-1]]++;
    }




  }






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

Measured memory_bytes: 15872
ans = 0


def dfs(n, f1, f2, f3):
    if N < n:
        return

    global ans
    ans += 1 if f1 and f2 and f3 else 0

    dfs(n * 10 + 7, True, f2, f3)
    dfs(n * 10 + 5, f1, True, f3)
    dfs(n * 10 + 3, f1, f2, True)


N = int(input())

dfs(0, False, False, False)

print(ans)


Measured memory_bytes: 3060
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

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


fun main() {
    val N = nextInt()
    val A = nextLongList()
    val ans = (A + A).sortedDescending().take(N).sum() - A.max()!!
    println(ans)
}

Measured memory_bytes: 75324
#include <stdio.h>

int
main(void)
{
	char s[20];
	scanf("%s", s);

	int i;
	for (i = 0; i < 19; i++)
		if (s[i] == ',')
			putchar(' ');
		else
			putchar(s[i]);

	puts("");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();
  
//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(k);
        vector<int> a;
        int a_max = 0;
        forr(i,0,n) {
            readint(aa); a.push_back(aa);
            a_max = max(a_max, aa);
        }

        ll ret = binary_search([&a, k](ll x) {
            int no_cuts = 0;
            for(int l : a) {
                int temp = l/x;
                if (temp*x==l) {  temp--;  }
                no_cuts += temp;
            }
            return (no_cuts <= k);
        }, 1, a_max+1);

        cout << ret << endl;

    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 4344
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		//int c=scan.nextInt();
		//int d=scan.nextInt();
		//int f=scan.nextInt();
		//String str=scan.next();
		boolean bool=false;
		int ans=0;
		System.out.println(a-b+1);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VVI vector<vector<ll>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define lb(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define ub(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define pb push_back
#define pf push_front
#define m_p make_pair
#define fi first
#define se second
#define sz size()
#define sort(v) sort(v.begin(),v.end())
ll n,k;
VI v;
ll dp[100005]; 
ll abss(ll x)
    {   if(x<0)
            return -1*x;
        else
            return x;
    }
ll fun(ll ind)
    {   if(ind>=n)
            return 0;
        if(dp[ind]!=-1)
            return dp[ind];
        ll mini=INT_MAX;
        lf(i,1,k)
        {   if(ind+i>n)
                break;
            mini=min(mini,abss(v[ind]-v[ind+i])+fun(ind+i));
        }
        return dp[ind]=mini;
    }
int main()
{   cin>>n>>k;
    v=VI(n+1);
    lf(i,1,n)
    {   cin>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<fun(1)<<endl;    
}

Measured memory_bytes: 9600
N = int(input())
A = list(map(int, input().split()))
kind = 0
cnt = 0
used = [False]*8
for a in A:
    tmp = a//400
    if tmp < 8 and not used[tmp]:
        kind += 1
        used[tmp] = True
    elif tmp >= 8:
        cnt += 1
print(kind if kind > 0 else 1, kind+cnt)


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut a_vec = vec![];
  for _ in 0..n {
    a_vec.push(read::<i64>())
  }

  a_vec.sort();
  println!("{}", a_vec[a_vec.len() -1] - a_vec[0]);
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while((x->left) != NIL)
    x = x->left;
  return x;

}

Node treeMaximum(Node x){
  while((x->right) != NIL)
    x = x->right;
  return x;
  
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == (u->key))
    return u;
  if(k < (u->key))
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  
  if((x->right) != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == (y->right)){
    x = y;
    y = y->parent;
  }

  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if((z->left) == NIL || (z->right) == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if((y->left) != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if((y->parent) == NIL)
    root = x;
  else if(y == ((y->parent)->left))
    (y->parent)->left = x;
  else
    (y->parent)->right = x;
    
  if(y != z)
    z->key = y->key;


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL ){
    y = x;
    if((z->key) < (x->key))
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;
  
  if(y == NIL)
    root = z;
  else
    if((z->key) < (y->key))
    y->left = z;
  else
    y->right = z;

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  string s;
  cin >> s;

  bool is_c = false;
  bool is_f = false;

  rep(i, s.length()){
    if(s[i]=='C'){
      is_c = true;
    }
    if(s[i]=='F' && is_c){
      is_f = true;
    }
  }

  if(is_f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,ll> mp;
int main(){
  string s;
  cin>>s;
  ll cnt_S=0,ans=0;
  for(int i=0;i<s.size();i++){
      if(s.at(i)=='S')cnt_S++;
      else{
          if(cnt_S==0)ans++;
          else cnt_S--;
      }
  }
  cout<<ans+cnt_S<<endl;
}


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

using namespace std;

#define int long long

#define N 200005

int freq[40][2];
int pref[40];

map < pair < int , int > , int > me;

int find_ans(int ind,int k)
{
    if(ind<0)
        return 0;
    
    if(me.find({ind,k})!=me.end())
        return me[{ind,k}];
    int p=pow(2,ind);
    if(k<p)
    {
        int temp=freq[ind][1]*p + find_ans(ind-1,k);
        me[{ind,k}]=temp;
        return temp;
    }

    int temp=freq[ind][1]*p;
    if(ind>0)
        temp+=pref[ind-1];

    int temp1=freq[ind][0]*p + find_ans(ind-1,k-p);
    me[{ind,k}]=max(temp,temp1);
    return max(temp,temp1);
}


int32_t main()
{
   // ios_base::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;

    vector < int > a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        int temp=a[i];
        for(int j=0;j<40;j++)
        {
            int d=temp%2;
            temp/=2;
            freq[j][d]++;
        }
    }

    for(int i=0;i<40;i++)
    {
        if(i>0)
            pref[i]=pref[i-1];
        int d=pow(2,i);
        pref[i]+=max(freq[i][0],freq[i][1])*d;
    }

    cout<<find_ans(39,k)<<endl;



    return 0;
}

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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
const int INF = 0x3f3f3f3f;
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

bool cmpf(int a, int b){
    return a>b?true:false;
}

class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//descend
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    int np,ns;
    int2(np,ns);
    vector<vi > arr(np); 
    fors(i,np){
        fors(j,ns){
            int temp;
            int1(temp);
            temp--;
            (arr[i]).pb(temp);
        }
    }
    int ans=INF;
    
    fors(k,ns){
        vi cntarr(ns);
        //Set(cntarr, 0);
        fill(cntarr.bg,cntarr.ed, 0);
        int maxp=0;
        int idx;
        fors(i,np){
            //cntarr[arr[i][0]]++;
            maxp = max(maxp,++cntarr[arr[i][0]]);
            if(maxp == cntarr[arr[i][0]]) idx=arr[i][0];
        }
        
        ans = min(maxp,ans);
        fors(i,np){
            int ind;
            fors(j,ns-k){
                if(arr[i][j]==idx) {ind = j; break;}  
            }
            (arr[i]).erase((arr[i]).bg+ind);
        }
    }
    pint(ans);
    return 0;    
}



Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,x,t;
    cin >> n>>x>>t;
    int b=n/x;
    if(n%x!=0) b++;
    cout << b*t << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,n,bx,by,tx,ty;
    string s,t;
    cin>>h>>w>>n>>bx>>by;
    cin>>s>>t;
    tx=bx;
    ty=by;
    for(int i=0;i<s.size();i++){
        if(s[i]=='U'){
            tx--;
        }
        if(tx==0){
            cout<<"NO";
            return 0;
        }
        if((t[i]=='D')&&(tx<h)){
            tx++;
        }

    }
    //cout<<tx<<" "<<ty<<endl;
    tx=bx;
    ty=by;
    for(int i=0;i<s.size();i++){
        if(s[i]=='L'){
            ty--;
        }
        if(ty==0){
            cout<<"NO";
            return 0;
        }
        if((t[i]=='R')&&(ty<w)){
            ty++;
        }

    }
    //cout<<tx<<" "<<ty<<endl;
    tx=bx;
    ty=by;
    for(int i=0;i<s.size();i++){
        if(s[i]=='D'){
            tx++;
        }
        if(tx>h){
            cout<<"NO";
            return 0;
        }
        if((t[i]=='U')&&(tx>1)){
            tx--;
        }

    }
    //cout<<tx<<" "<<ty<<endl;
    tx=bx;
    ty=by;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            ty++;
        }
        if(ty>w){
            cout<<"NO";
            return 0;
        }
        if((t[i]=='L')&&(ty>1)){
            ty--;
        }

    }
   // cout<<tx<<" "<<ty<<endl;
    cout<<"YES";
}


Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;

int main() {


  while(1){
  long long a[10001] ={};
  int n;
  cin >> n;
  assert(n<=10000);
  if(n == 0) break;
  for(int i=0;i<n;i++) {
    cin >> a[i];
    assert(a[i] <= 60);
  }
  
  sort(a,a+n);

  long long ans  = a[0];
  for(int i=1;i<n-1;i++) {
    a[i] += a[i-1];
    ans += a[i];
  }
  if(n == 1) ans = 0;
  cout << ans <<endl;
  }

  return 0;
}

Measured memory_bytes: 1264
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const mod = 1e9 + 7

func main() {
	b := [26 + 'a']int{}
	rd := bufio.NewReader(os.Stdin)
	var (
		by  byte
		err error
	)
	for err != io.EOF {
		by, err = rd.ReadByte()
		b[by]++
	}

	r := 1
	for i := 'a'; i < 26+'a'; i++ {
		r = r * (b[i] + 1) % mod
	}
	fmt.Println(r - 1)
}

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

int main(){
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    if(i==5 || i==13) cout << ' ';
    else cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
//#include<map>
using namespace std;
typedef long long int llint;
typedef int beet;
#define ween tuple
#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 izryt bool
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e9+1e8;
const llint red=0xE869120;
const llint pro=1002001;

int main(void){
	int a,b,c;
	cin>>a>>b>>c;
	if(a-b==b-c){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    string str;
    cin >> str;
    LL n = str.size();

    bool check = true;

    if(str[n-1] == '1' || str[0] == '0' || str[n-2] == '0'){
        check = false;
    }
    for(int i = 1; i <= (n-1)/2; i++){
        if(str[i] != str[n-i-2]){
            check = false;
        }
    }

    vector<pair<LL,LL>> edge;

    LL front = 1;
    
    for(int i = 0; i < n-1; i++){
        if(str[i] == '1'){
            edge.push_back(make_pair(front,i+2));
            front = i+2;
        }else{
            edge.push_back(make_pair(front,i+2));
        }
    }

    if(check){
        for(int i = 0; i < edge.size(); i++){
            cout << edge[i].first << " ";
            cout << edge[i].second << endl;
        }
    }else{
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3264
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize,
        s: chars,
    }
    let is_ok = s.len() == a + b + 1
        && s[a] == '-'
        && s[0..a].iter().all(|c| c.is_digit(10))
        && s[(a + 1)..].iter().all(|c| c.is_digit(10));
    println!("{}", if is_ok { "Yes" } else { "No" });
}


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

void insertionsort(int *,int);
void output(int *,int);

int main(void){

  int datanum;
  int* databuff;

  cin >> datanum;
  databuff = new int[datanum];

  for(int i = 0 ; i < datanum ; i++ ){
    cin >> databuff[i];
  }

  insertionsort(databuff,datanum);

  return 0;
}

void insertionsort(int *databuff,int datanum){

  output(databuff,datanum);

  for (int i = 1 ; i < datanum ; i++){
    int temp;
    int j;

    temp = databuff[i];
    j = i - 1;

    while( j >= 0 && databuff[j] > temp){
      databuff[j+1] = databuff[j];
      j--;
    }

    databuff[j+1] = temp;

    output(databuff,datanum);
  }
}

void output(int *databuff,int datanum){
  for( int k = 0 ; k < datanum ; k++){
    cout << databuff[k];

    if ( k < datanum -1 ){
      cout << " ";
    }else{
      cout << endl;
    }
  }
}

Measured memory_bytes: 3056
n = int(input())
keta = len(str(n))
if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(9 + n-99)
elif keta == 4:
    print(909)
elif keta == 5:
    print(909 + n - 9999)
elif keta == 6:
    print(90909)

Measured memory_bytes: 3060
y=[]
x=input()
l=len(x)
for i in range(l):
    y.append(x[i])
s=[]
k=y.count('K')
u=y.count('U')
p=y.count('P')
c=y.count('C')
s.append(k)
s.append(u)
s.append(p)
s.append(c)
t=min(s)
print(t)


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

 
int main() {
  int N;
  LL T=0;
  bool ans = true;
  cin >> N;
  vector<PII> P;
  REP(i,N) {
    int A,B;
    cin >> A >> B;
    PII C;
    C = MP(B,A);
    P.PB(C);
  }
  SORT(P);
  REP(i,N) {
    int D=P.at(i).second, E=P.at(i).first;
    if(T+D <= E) {
      T += D;
    }
    else {
      ans = false;
    }
  }
  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
static const int N = 100;

int main(){
  int M[N][N];
  int i,j;
  int n,u,k,v; 
 

  scanf("%d", &n);

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



Measured memory_bytes: 2112
r, g, b, n = gets.split.map(&:to_i)
r, g, b = [r, g, b].sort!

ans = 0

0.upto(n) do |x|
  balls = r * x

  next if balls > n
  if balls == n
    ans += 1
    next
  end

  0.upto(n) do |y|
    balls = r * x + g * y

    next if balls > n
    if balls == n
      ans += 1
      next
    end

    rest = n - balls
    ans += 1 if rest % b == 0
  end
end

puts ans


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(k<=a)cout<<k;
    else{
        if(k-a<=b)cout<<a;
        else{
            cout<<a-((k-a-b));
        }
    }
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


# See:
# http://terukizm.hatenablog.com/entry/20120505/1336218368
def ceil(src, range):
    return ((int)(src / range) + 1) * range


if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    tmp = (n - 1) % (k - 1)

    if tmp == 0:
        print((n - 1) // (k - 1))
    else:
        print(ceil((n - 1) / (k - 1), 1))


Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  if (10%p == 0) {
    ll ans = 0;
    drep(i,n) {
      if ((s[i]-'0')%p == 0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }

  vi csum(n+1);
  int ten = 1;
  drep(i,n) {
    csum[i] = ((s[i]-'0')%p) * ten + csum[i+1];
    csum[i] %= p;
    ten = (ten*10)%p;
  }
  ll ans = 0;
  vl cnt(p);
  drep(i,n+1) {
    ans += cnt[csum[i]];
    cnt[csum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

S = input()

for i in range(3):
    if S[i] == S[i+1]:
        print("Bad")
        break
else:
    print("Good")

Measured memory_bytes: 38444
#include <iostream>

using namespace std;

int main(){

    int a, b, k;
    cin >> a >> b;

    k = ( (a + b) % 2);

    if(k == 0){
        cout << ((a + b) / 2) << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class66
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int count = 0;
            for(int i = 0; i < N-1; )
            {
                if (A[i] == A[i + 1])
                {
                    i++;
                    continue;
                }
                else if (A[i] > A[i + 1])
                {
                    for (; i < N - 1; i++)
                    {
                        if (A[i] < A[i + 1]) { count++;break; }
                    }
                    i++;
                }
                else
                {
                    for (; i < N - 1; i++)
                    {
                        if (A[i] > A[i + 1]) { count++;break; }
                    }
                    i++;
                }
            }
            Console.WriteLine(++count);
        }
    }
}


Measured memory_bytes: 19680
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
     ll n;
     cin >> n;
    
     vector<pair<ll,int>> fs;
     for (ll i = 2; i*i <= n; ++i) {
       int x = 0;
       while (n%i == 0) {
         n /= i;
         ++x;
       }
       fs.emplace_back(i,x);
     }
     if (n != 1) fs.emplace_back(n,1);
    
     int ans = 0;
     for (auto p : fs) {
       int x = p.second;
       int b = 1;
       while (b <= x) {
         x -= b;
         b++;
         ++ans;
       }
     }
     cout << ans << endl;
     return 0;
}

Measured memory_bytes: 19708
#include<stdio.h>

int main(void) {
	int a, b, c, d, e, f;
	double x, y;
	while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF) {
		if (b*d - a*e == 0)y = 0;
		else y = (double)(c*d - a*f) / (b*d - a*e);
		if (c*e - b*f == 0)x = 0;
		else x = (double)(c*e - b*f) / (a*e - b*d);

		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

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

int calc(int n, int d) {
    int cnt = 0;
    int day = 1;
    while (day <= d) {
        cnt++;
        day += n;
    }
    return cnt;
}

int main() {
    int N, D, X, temp; // N:people D:days X:choco-remain
    std::cin >> N >> D >> X;
    
    std::vector<int> A;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        A.push_back(temp);
    }
    
    int choco = 0;
    for (auto itr=A.begin(); itr!=A.end(); itr++) {
        choco += calc(*itr, D);
    }
    std::cout << choco + X << std::endl;
}

Measured memory_bytes: 256
/*  ex7_3
    kosaq   */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height, width;
    int *row_memori, *column_memori;
    char **square;

    scanf("%d %d", &height, &width);

    //ここから各メモリの動的確保squareは二次元配列であるのでsquare[i]についてfor文を回す。
    square = (char**)calloc(height, sizeof(char*));
    if(square == NULL){
        exit(1);
    }
    for(int i = 0; i < height; i++){
        square[i] = (char*)calloc(width, sizeof(char));
        if(square[i] == NULL){
            exit(1);
        }
    }

    row_memori = (int*)calloc(height, sizeof(int));
    if(row_memori == NULL){
        exit(1);
    }

    column_memori = (int*)calloc(width, sizeof(int));
    if(column_memori == NULL){
        exit(1);
    }

    //二次元配列の入力
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            scanf(" %c", &square[i][j]);
        }
    }

    //ここから、各行について中でjをループさせ一つずつ黒があるか確認する。黒があった時には先程定義した配列row_memoriに１を代入する。
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            if(square[i][j] == '#'){
                row_memori[i] = 1;
                break;
            }
        }
    }

    //ここから、各列について中でiをループさせ一つずつ黒があるか確認する。黒があった時には先程定義した配列column_memoriに１を代入する。
    for(int j = 0; j < width; j++){
        for(int i = 0; i < height; i++){
            if(square[i][j] == '#'){
                column_memori[j] = 1;
                break;
            }
        }
    }

    //最後に黒が１つでも存在した行、列について書き出す。
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
            if(row_memori[i] == 1 && column_memori[j] == 1){
                printf("%c", square[i][j]);
            }
        }
        printf("\n");//各行を書くごとに改行する
    }

    //各メモリを解放
    free(row_memori);
    free(column_memori);
    for(int i = 0; i < height; i++){
        free(square[i]);
    }
    free(square);

    return 0;
}

Measured memory_bytes: 1640