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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

#define MOD 1000000007

ull
fibo(ull n)
{
  ull f0 = 0, f1 = 1, f2 = 1;
  REP(i, n) {
    f2 = (f0 + f1) % MOD;
    f0 = f1;
    f1 = f2;
  }
  return f2 % MOD;
}

int
main()
{
  CIN2(N, M);

  if (M == 0) {
    ANS(fibo(N));
    return 0;
  }

  CINVEC(V, M);

  REP(i, V.size() - 1) {
    if (V.at(i) + 1 == V.at(i + 1)) { 
      ANS(0);
      return 0;
    }
  }

  ull ans = 1;
  int ichi = 0;
  REP(i, V.size()) {
    ans *= fibo(V.at(i) - 1 - ichi);
    ichi = V.at(i) + 1;

    ans %= MOD;
  }
  ans *= fibo(N - ichi);

  ANS(ans % MOD);

  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
    ll n,m,wa=0,ac=0;
    cin>>n>>m;
    vl no(m);
    vs acwa(m);
    vb acno(n+1,false);
    vl wac(n,0);
    rep(i,m){
        cin>>no[i]>>acwa[i];
    }
    rep(i,m){
        if(acno[no[i]-1]==false){//未ACなら
            if(acwa[i]=="WA"){//WAなら
                wa++;
                wac[no[i]-1]++;//全WAの時に引く
            }
            if(acwa[i]=="AC"){//ACなら
                ac++;
                acno[no[i]-1]=true;
                
            }//cout<<i<<no[i]<<acno[no[i]-1]<<endl;
        }
    }
    
    //cout<<ac<<" "<<wa<<endl;
    rep(i,n){
        //cout<<i<<" "<<wac[i]<<" "<<acno[i]<<endl;
        if(acno[i]==false){
            wa-=wac[i];
            //cout<<i<<" WA "<<wa<<endl;
        }
    }
    
    cout<<ac<<" "<<wa<<endl;
}


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


typedef int64_t I;
const I M = 1000000007;

I inv(I a, I b) {
  I x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b != 0) {
    I q = a / b, nb = a % b;
    a = b;
    b = nb;
    I nx1 = x0 - q * x1, ny1 = y0 - q * y1;
    x0 = x1;
    x1 = nx1;
    y0 = y1;
    y1 = ny1;
  }
  while (x0 < 0) {
    x0 += M;
  }
  return x0;
}

I comb(I n, I k) {
  I r1 = 1;
  I r2 = 1;
  for (I i = 0; i < k; i++) {
    r1 = (r1 * (n - i)) % M;
    r2 = (r2 * (i + 1)) % M;
  }
  return (r1 * inv(r2, M)) % M;
}

I h(I n, I k) {
  return comb(n + k - 1, k);
}

I solve(I n, I k) {
  if (k >= n) return h(n, n);
  I r = 0, r1 = 1, r2 = 1, r3 = 1;
  for (I i = 0; i < k + 1; i++) {
    r = (r + (r1 * inv(r2, M) % M) * (r3 * inv(r2, M) % M)) % M;
    r1 = r1 * (n - i) % M;
    r2 = r2 * (i + 1) % M;
    r3 = r3 * (n - 1 - i) % M;
  }
  while (r < 0) {
    r += M;
  }
  return r;
}

int main() {
  I n, k;
  cin >> n >> k;
  cout << solve(n, k) << endl;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	double ret = 0;
	do {
		for(int i=1;i<a.size();i++) {
			ret += sqrt((a[i].second-a[i-1].second)*(a[i].second-a[i-1].second)+(a[i].first-a[i-1].first)*(a[i].first-a[i-1].first));
		}
	}while(next_permutation(a.begin(), a.end()));
	for(int i=1;i<=n;i++) ret/=i;
	cout << fixed << setprecision(6);
	cout << ret;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();

            var countOdd = 0L;
            var countEven = 0L;
            for(var i=0;i<S.Length;++i)
            {
                if (i % 2 == 0) { if ('0' == S[i]) ++countEven; }
                else { if ('0' == S[i]) ++countOdd; }
            }
            WriteLine(Min(countEven + (S.Length / 2 - countOdd), ((S.Length + 1) / 2 - countEven) + countOdd));

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13116
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<=b && c<=d){
        printf("%d\n",a+c);
    }
    else if(b<=a && c<=d){
        printf("%d\n",b+c);
    }
    else if(a<=b && d<=c){
        printf("%d\n",a+d);
    }
    else printf("%d\n",b+d);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    #ifdef UJJWAL_HOME
        freopen("000.txt","r",stdin);
    #endif

    ll n,i,j,k,t;

    string s;

    cin>>s;
    n=s.length();
    ll a[26]={0};
    fo(i,s.length())
        a[s[i]-'a']++;

    ll ans=n*(n-1)/2+1;

    fo(i,26)
        ans-=(a[i]*(a[i]-1)/2);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 848
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W, A, B;

int main()
{
	scanf("%d%d%d%d", &H, &W, &A, &B);
	int dA = W - 2 * A, dB = H - 2 * B;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			printf("%d", (i < B ? 1 : 0) ^ (j < A ? 1 : 0));
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
int f(){
   int n, x, t;
   cin >> n >> x >> t;
   int shou;
  
   shou = n / x;
   if(n % x != 0)
     shou++;
  
   cout << t*shou << endl;
   return 0;
}

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

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

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> s;
    string sharp(W+2,'#');
    s.push_back(sharp);
    for(int i=0; i<H; i++){
        string tmp;
        cin >> tmp;
        s.push_back('#'+tmp+'#');
    }
    s.push_back(sharp);

    for(int i=0; i<H+2; i++){
        cout << s.at(i) <<endl;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] == 'S'&&s[i] == 'T') {
			s.erase(s.begin() + i - 1, s.begin() + i + 1);
			if (i - 2 > 0)i -= 3;
			else i = 0;
		}
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
map<int,int>Q;
int main(){
	int n;
	cin>>n;
	Q.clear();
	int tmp;
	for(int j=0;j<n;j++){
		cin>>tmp;
		Q[tmp]++;
	}
	int m;
	cin>>m;
	int flag=0;
	for(int j=0;j<m;j++){
		cin>>tmp;
		if(Q[tmp]>0)
			Q[tmp]--;
		else flag=1;
	}
	if(flag)
		cout<<"NO";
	else cout<<"YES";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int X;
  cin >> X;
  cout << 10-X/200 << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b && b==c && c==a){
    cout << "No" << endl;
  }
  else if(a!=b && b!=c && c!=a){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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

	int d,a;
	cin>>d;
	vector<int>c(27);
	vector<vector<int>> s(d+1, vector<int>(27));
	vector<int>t(d+1);
	vector<int>last(27);
	for(int i=0;i<=27;i++)last[i]=0;
	for(int i=1;i<=26;i++) cin>>c[i];
	for (int i = 1; i <= d; i++) {
	    for (int j = 1; j <= 26; j++) {
	      cin >> s.at(i).at(j);
	    //  cout<< s.at(i).at(j)<<endl;
	    }
	  }
	int tt,sum=0;
	for(int i=1;i<=d;i++){
		cin>>tt;
		sum+=s[i][tt];
		last[tt]=i;
		for(int j=1;j<=26;j++){
			sum-=c[j]*(i-last[j]);
		}
		cout<<sum<<endl;
	}

	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll k,n;
cin>>k>>n;
vector<ll>a(n);
rep(i,n){
    cin>>a[i];
}

ll max_l=0;
reps(i,n,1){
    ll L=a[i]-a[i-1];
    max_l=max(max_l,L);
}
ll L=k-a[n-1]+a[0];
max_l=max(max_l,L);
cout<<k-max_l<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int r = input<int>();
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, ans int
	fmt.Scan(&n)
	pre := -1

	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a == pre {
			ans++
			pre = -1
		} else {
			pre = a
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int main(void)
{

	int n, k;
	cin >> n >> k;
	int d;
	vector<bool> sunuke(n, false);
	for (int i = 0; i < k; i++)
	{
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int tmp;
			cin >> tmp;
			sunuke[tmp - 1] = true;
		}
	}
	
	int count = 0;
	for (auto &&i : sunuke)
	{
		if (!i) count++;
	}
	
	cout << count << endl;
	
	return 0;
	
}

Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Numbers on a Circle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

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

/* global variables */

int as[MAX_N], bs[MAX_N];

/* subroutines */

inline int prvi(int n, int i) { return ((i - 1 + n) % n); }
inline int nxti(int n, int i) { return ((i + 1) % n); }

inline bool check(int n, int i) {
  return (bs[i] > as[i] && bs[i] > bs[prvi(n, i)] + bs[nxti(n, i)]);
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", bs + i);

  priority_queue<pii> q;
  for (int i = 0; i < n; i++)
    if (check(n, i)) q.push(pii(bs[i] - as[i], i));

  ll cnt = 0;
  while (! q.empty()) {
    pii u = q.top(); q.pop();
    int &ud = u.first, &ui = u.second;
    if (ud != bs[ui] - as[ui]) continue;

    int i0 = prvi(n, ui), i1 = nxti(n, ui);
    int ac = bs[i0] + bs[i1];
    int k = min(ud / ac, (bs[ui] - 1) / ac);
    if (k > 0) {
      cnt += k;
      bs[ui] -= k * ac;
      if (check(n, i0)) q.push(pii(bs[i0] - as[i0], i0));
      if (check(n, i1)) q.push(pii(bs[i1] - as[i1], i1));
    }
  }

  for (int i = 0; i < n; i++)
    if (bs[i] != as[i]) {
      puts("-1");
      return 0;
    }

  printf("%lld\n", cnt);
  return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-10;
int INF=1e9;
static const int MEM_SIZE=1000000;
struct edge{int to,cost;};
struct dat{
      int s,cost,num;
      dat(int s,int cost,int num):s(s),cost(cost),num(num){}
      bool operator<(const dat& a)const{return cost<a.cost;}
};
vector<edge> G[100];
int dist[100][11];
int n,c;
void dijkstra(int s){
      REP(i,100)REP(j,11)dist[i][j]=INF;
      priority_queue<dat>Q;
      Q.push(dat(s,0,0));
      dist[s][0]=0;
      while(!Q.empty()){
            dat p=Q.top();Q.pop();
            if(p.cost>dist[p.s][p.num])continue;
            REP(i,G[p.s].size()){
                  edge e=G[p.s][i];
                  if(p.num<c){
                        if(dist[p.s][p.num]+e.cost/2<dist[e.to][p.num+1]){
                              dist[e.to][p.num+1]=dist[p.s][p.num]+e.cost/2;
                              Q.push(dat(e.to,dist[e.to][p.num+1],p.num+1));
                        }
                  }
                  if(dist[p.s][p.num]+e.cost<dist[e.to][p.num]){
                        dist[e.to][p.num]=dist[p.s][p.num]+e.cost;
                        Q.push(dat(e.to,dist[e.to][p.num],p.num));
                  }
            }
      }
}
int main(){
      int m,s,d;
      while(cin>>c>>n>>m>>s>>d&&(c||n||m||s||d)){
            s--;d--;
            REP(i,100)G[i].clear();
            REP(i,m){
                  int a,b,f;
                  cin>>a>>b>>f;
                  a--;b--;
                  G[a].PB((edge){b,f});
                  G[b].PB((edge){a,f});
            }
            dijkstra(s);
            int ans=INF;
            /*REP(i,n){
                  REP(j,c+1){
                        cout<<dist[i][j];
                        if(j==c-1)cout<<endl;
                        else cout<<" ";
                        //cout<<i<<" "<<j<<endl;
                  }
            }*/
            REP(i,c+1)ans=min(ans,dist[d][i]);
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int N, p[100], ans, cnt;
int main()
{
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> p[i];
	}
	for(int i = 0; i < 101; i++)
	{
		cnt = 0;
		for(int j = 0; j < N; j++)
		{
			if(i <= p[j])
				cnt++;
		}
		if(cnt >= i)
		{
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll mod=1e9+7;

int main(){
   string s,t;
   cin >> s >> t;
   vector<vector<int>> dp(s.size()+1,vector<int> (t.size()+1,0));
   rep(i,s.size()){
      rep(j,t.size()){
         if (s[i]==t[j]) dp[i+1][j+1]=max({dp[i][j]+1,dp[i+1][j],dp[i][j+1]});
         else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
      }
   }
   string ans="";
   int x,y;
   x=s.size(); y=t.size();
   while( x > 0 && y > 0){
      if (dp[x][y]==dp[x][y-1]) y--;
      else if (dp[x][y] == dp[x-1][y]) x--;
      else{
         ans= s[x-1] + ans;
         x--;y--;
      }
   }
   //rep(i,s.size()+1){
   //    rep(j,t.size()+1) cout << dp[i][j] << " ";
   //    printf("\n");
   //}


   //cout << dp[s.size()][t.size()] << endl;
   cout  << ans << endl;

   
   return 0;
}



Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    //input
    int n; cin >> n;
    long long p_total = 0;
    long long zero = 0;
    vector<long long> a(n + 1);
    vector<long long> b(n + 1);
    for(int i = 1; i < n + 1; i++) cin >> a[i] >> b[i];;
    
    //compute
    reverse(a.begin() + 1 , a.end());
    reverse(b.begin() + 1 , b.end());

    for(int i = 1; i < n + 1; i++){
        p_total += max( zero, (b[i] - ((a[i] + p_total) % b[i])) % b[i]);
    } 

    //output
    cout << p_total << endl;

}

Measured memory_bytes: 4848
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
   ｜  ―――  ｜      ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

#include <bits/stdc++.h>
using namespace std;
 
//#define int ll

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

signed main(){
    char field[99][100];
    REP(i,99) REP(j,100) field[i][j] = '#';

    REP(i,99){
        if(i%6>=3){
            REP(j,99) field[i][j] = '.';
        }
    }

    REP(i,99) field[i][0] = '.';

    int b,w;
    cin >> w >> b;

    int cur = 102;
    while(--w>0){
        field[cur/100][cur%100] = '.';
        cur += cur%100==98?504:2;
    }

    cur = 401;
    while(--b>0){
        field[cur/100][cur%100] = '#';
        cur += cur%100==97?504:2;
    }

    puts("99 100");
    REP(i,99){
        REP(j,100) printf("%c",field[i][j]);
        puts("");
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	int cnt=1;
	while(cin>>n>>m,n+m){
		vi in(m+1);
		in[0]=n;
		int out=1;
		while(1){
			vi tmp=in;
			int c=0;
			for(int i=m;i>=1;i--){
				tmp[i]+=tmp[i-1]/2;
				c+=tmp[i-1]/2;
				tmp[i-1]-=tmp[i-1]/2*2;
			}
			tmp[0]+=c;
			in=tmp;
			if(in[m])break;
			out++;
		}
		cout<<"Case "<<cnt<<": "<<out<<endl;;
		cnt++;
	}
}

Measured memory_bytes: 1216
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,K,P,C,N,X,n;

    long double kh,km,A,B;

    string S;
    map<long double, ll> m;

    cin >>n;
    vector<int> aa;
	ll num = n;
    int ans=0;
    bool flag=false;
    ll count;

	for (int i = 2; i <= sqrt(n)+4; i++) {
		count=0;
        while (num%i == 0) {
            count++;
            flag=true;
			num /= i;
		}
        if(flag==true){
        aa.push_back(count);
        flag=false;
        }
	}
    
    rep(i,aa.size()){
        repr(j,1,n){
            if(aa[i]>=j){
                ans++;
                aa[i]=aa[i]-j;
            }else{
                break;
            }
        }
    }

	if(num!=1 && n!=1){
        ans+=1;
        //cout<<"A";
    }else if(n==1){
        ans=0;
    }else if(n==num){
        ans=1;
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();

		int [] seikai = new int [N];

		for (int index=0; index<Q; index++) {
			seikai[sc.nextInt()-1]++;
		}

		for (int index=0; index<N; index++) {
			if (K-(Q-seikai[index])>0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 56316
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let a = is
        .split_whitespace()
        .map(|e| e.parse::<i64>().unwrap())
        .position(|e| e == 0)
        .unwrap()
        + 1;
    println!("{}", a);
}


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

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int L, R, d;
    int ans = 0;

    cin >> L >> R >> d;

    for(int i = L; i <= R; i++){

        if (i % d == 0) ans++;

    }

    cout << ans;

}


Measured memory_bytes: 3184
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()

    l = [0] * M
    for i in range(N):
        K, *A = MAP()
        for j in range(K):
            l[A[j]-1] += 1

    ans = 0
    for i in range(M):
        if l[i] == N: ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
def uneven_num(n):
    count = 0
    for i in range(n,0,-1):
        tmp = i
        keta = 0
        while True:
            tmp = tmp/10
            if tmp < 1:
                keta += 1
                break
            else:
                keta += 1

        if keta % 2 != 0:
            count += 1

    return count

if __name__ == '__main__':
    n = int(input())

    a = uneven_num(n)
    print("%d" %a)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace あああああああああ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int res = 0;

            for (int i = 0; i < n; ++i)
            {
                if (s[i] == 'A' && i + 2 < n)
                {
                    if (s[i + 1] == 'B' && s[i + 2] == 'C')
                    {
                        ++res;
                        i += 2;
                    }
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
    double A, B;
    char* result;
    scanf("%lf%lf", &A,&B);
  if(A>B){
      result ="GREATER";
  }else if(A<B){
      result ="LESS";
  }else if(A==B){
      result ="EQUAL";
  }
    printf("%s",result);
    return 0;
}

Measured memory_bytes: 128
from itertools import product
n,m = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in product(range(2), repeat=n):
    for j in range(m):
        total = 0
        for k in ks[j][1:]:
            total += i[k-1]
        if total%2!=p[j]:
            break
    else: ans+=1
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	char s[100001];
	scanf("%s", s);
	int i;
	for (i = 0; s[i] != '\0'; i++) {
		if (i % 2 == 0) {
			putchar(s[i]);
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <cstring>

using namespace std;

char dx[] = {1,0,-1,0};
char dy[] = {0,1,0,-1};

int main(){
	int n; 
	int color[40000];
	while(cin >> n, n){
		int x, y; char c;
		vector< pair<int,int> > vp;
		map< pair<int,int>, int > futon;
		for(int i=0;i<n;i++){
			cin >> x >> y >> c;
			vp.push_back(make_pair(x         ,y         ));
			vp.push_back(make_pair(x+(c=='x'),y+(c=='y')));
			futon.insert(make_pair(vp[2*i  ],2*i  ));
			futon.insert(make_pair(vp[2*i+1],2*i+1));
		}
		memset(color,-1,sizeof(color));
		bool flag = true;
		map< pair<int,int>, int >::iterator it;
		for(it=futon.begin();it!=futon.end()&&flag;it++){
			if(color[(*it).second]!=-1) continue;
			color[(*it).second] = 0;
			queue<int> qu; qu.push((*it).second);
			while(!qu.empty()&&flag){
				int pos = qu.front(); qu.pop();
				int x = vp[pos].first, y = vp[pos].second;
				for(int i=0;i<4;i++){
					int nx = x+dx[i], ny = y+dy[i];
					if(futon.count(make_pair(nx,ny)) != 0){
						int next = futon[make_pair(nx,ny)];
						if(color[next]!=-1){
							if(color[next] != (color[pos]+(next/2==pos/2))%2) flag = false;
						} else {
							color[next] = (color[pos]+(next/2==pos/2))%2;
							qu.push(next);
						}
					}
				}
			}
		}
		cout << (flag ? "Yes" : "No") << endl;
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  string he;
  for (int i = 0; i < W + 2; i++) {
    he += '#';
  }
  cout << he << endl;

  for (int j = 0; j < H; j++) {
    cin >> vec.at(j);
    cout << "#" << vec.at(j) << "#" << endl;
  }

  cout << he << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 2019;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.length();
  ll mul = 1;
  vector<int> cnt(mod);
  int sum = 0;
  int ans = 0;
  rep(i, n) {
    cnt[sum]++;
    (sum += (s[i] - '0') * mul) %= mod;
    ans += cnt[sum];    
    (mul *= 10) %= mod;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll dp[MAXn],w[MAXn],v[MAXn];
int main(){
  IOS();
  ll n,W;
  cin >> n >> W;
  REP (i,n) cin >> w[i] >> v[i];
  REP (i,MAXn) dp[i] = INF;

  dp[0] = 0;
  REP (i,n) {
    for (ll j=100002;j>=v[i];j--) {
      dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
    }
  }

  ll ans = 0;
  REP (i,MAXn) if (dp[i] <= W) ans = max(ans,i);
  cout << ans << endl;
}


Measured memory_bytes: 1152
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

ans = 0
for i in 0..a do
  for j in 0..b do
    for k in 0..c do
      ans += 1 if 500 * i + 100 * j + 50 * k == x
    end
  end
end

puts ans

Measured memory_bytes: 1788
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define all(v) v.begin(), v.end()

signed main() {
	std::string s,t;
	std::cin >> s >> t;
	std::vector<std::vector<int> > dp(s.size()+1,std::vector<int>(t.size()+1,0));
	rep(i,s.size())rep(j,t.size()) {
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
	}
	std::string lcs = "";
	int x = s.size();
	int y = t.size();
	while(true) {
		if(dp[x][y]==0) break;
		if(s[x-1]==t[y-1]) {
			lcs = s[x-1] + lcs;
			x--; y--;
		} else {
			if(dp[x-1][y]>=dp[x][y-1]) {
				x--;
			} else {
				y--;
			}
		}
	}
	print(lcs);
  return 0;
}


Measured memory_bytes: 35584
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



int inv_mod(int a, int m)
{
	int b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N;
	vector<int> A, SA;
	cin >> N;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		A.PSB(tmp);
	}
	SA = A;
	sort(ALL(SA));

	int ans = 0;
	REP(i, N) {
		auto it = lower_bound(ALL(SA), A[i]);
		ans += abs((it - SA.begin()) - i) % 2;
	}
	cout << ans / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 1144
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 12;
const ll MAXM = 1010;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, m, A[MAXM], B[MAXM], C[MAXM][MAXN], val[MAXM], dp[(1LL << MAXN)];

int main() {
    fast_io;

    cin >> n >> m;
    for (ll i = 1; i <= m; i++) {
        cin >> A[i] >> B[i];
        for (ll j = 0; j < B[i]; j++) {
            cin >> C[i][j];
            val[i] |= (1LL << (C[i][j] - 1));
        }
    }

    fill(dp, dp + (1LL << MAXN), INF);
    dp[0] = 0;
    for (ll i = 1; i <= m; i++) {
        for (ll j = 0; j < (1LL << n); j++) {
            dp[j | val[i]] = min(dp[j | val[i]], dp[j] + A[i]);
        }
    }

    ll t = (1 << n) - 1;
    if (dp[t] == INF) return cout << -1 << endl, 0;
    cout << dp[t] << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int map[1005][1005];
int dat[1005][1005];

int n;
int w,h;

int main(void){
	while(1){
		memset(map,0,sizeof(map));
		memset(dat,0,sizeof(dat));
		scanf("%d%d%d",&h,&w,&n);
		if(h==0)break;
		rep(y,h){
			rep(x,w){
				scanf("%d",&map[y][x]);
			}
		}
		dat[0][0]=n-1;
		rep(y,h){
			rep(x,w){
				int no = dat[y][x];
				dat[y+1][x]+=no/2;
				dat[y][x+1]+=no/2;
				if(no%2==1){
					if(map[y][x]==0){
						dat[y+1][x]++;
					}
					else{
						dat[y][x+1]++;
					}
					map[y][x]=1-map[y][x];
				}
			}
		}
		
		int x=0,y=0;
		while(x<w && y<h){
			if(map[y][x]==0)y++;
			else x++;
		}
		printf("%d %d\n",y+1,x+1);
	}
		
	return 0;
}

Measured memory_bytes: 8924
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

const int MOD = 1000000007;
const int MX = 777777 + 5;
int fac[MX+5],inv[MX+5];
 
int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void init(){
  int n=MX+4;
	fac[0] = 1;
  for(int i=0;i<n;++i)fac[i+1]=fac[i]*(i+1)%MOD;
  inv[n]=power(fac[n],MOD-2,MOD);
  for(int i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}
int comb(int n,int r){return (fac[n]*inv[r])%MOD*inv[n-r]%MOD;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    init();

    int S; cin >> S;
    int ans=0;
    for(int i=3;i<=S;i+=3) {
        ans+=comb(i/3+S-i-1,S-i);
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15816
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin >> s;
	printf("%c%c%c\n", s[0], s[1], s[2]);
}

Measured memory_bytes: 3152
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n = sc.nextInt();
long[] a=new long[n+1];
a[0]=0;
HashMap<Long,Integer> m=new HashMap<>();
m.put(a[0],0);
long ans=0;
for(int i=1;i<=n;i++){a[i]=a[i-1]+sc.nextLong();m.put(a[i],0);}
for(int i=0;i<=n;i++){ans+=m.get(a[i]);m.put(a[i],m.get(a[i])+1);}
out.println(ans);
}}

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

int main() {
    long n,m,l;
    cin>>n>>m>>l;
    long a[n][m],b[m][l],c[n][l];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin>>a[i][j];
        }
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < l; ++j) {
            cin>>b[i][j];
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < l; ++i) {
            c[k][i] = 0;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < l; ++i) {
            for (int j = 0; j < m; ++j) {
                c[k][i]+=a[k][j]*b[j][i];
            }
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < l; ++i) {
            if (i==l-1)
                cout<<c[k][i];
            else
                cout<<c[k][i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,l,r;
  cin >> N;
  int a = 0;
  for (int i=0;i<N;i++){
    cin >> l >> r;
    a +=(r-l+1);
  }
  cout << a << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += b[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] + 1 == a[i + 1])
        {
            ans += c[a[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll n,k,t[N],a[N];
int main(){
    cin>>n>>k;
    lol(i,n)cin>>t[i];
    lol(i,n-1)a[i]=t[i+1]-t[i];
    sort(a,a+n-1);
    ll ans=n;
    lol(i,n-k)ans+=a[i]-1;
    cout<<ans<<endl;
    return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

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

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

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


/*FUNCs=================================================*/


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

    ll n, tmp; cin >> n;
    vll a(n);
    rep(i,n) {
        cin >> tmp;
        a[i] = tmp - i;
    }
    // bはaたちの中央値にしたい
    sort(all(a));
    if(n%2) {
        ll b = a[n/2];
        ll t = 0;
        for(auto aa : a) t += abs(aa-b);
        cout << t << '\n';
    }
    else {
        ll b1, b2, t1 = 0, t2 = 0;
        b1 = (a[n/2]+a[n/2-1])/2;
        b2 = (a[n/2]+a[n/2-1]+1)/2;
        for(auto aa : a) t1 += abs(aa-b1);
        for(auto aa : a) t2 += abs(aa-b2);
        cout << min(t1, t2) << '\n';
    }



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


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){

    int siz = 0;
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        int x = n-i;
        for(int q = 0;q<2;q++){
            //cout<<x<<endl;
            if(x<10)siz = 1;
            else if(x<100)siz = 2;
            else if(x<1000)siz = 3;
            else if(x<10000)siz = 4;
            else siz==5;
            if(siz==1){
                cout<<x<<endl;
                goto end;
            }
            if(siz==2){
                if(x/10==x%10){
                    cout<<x<<endl;
                    goto end;
                }
            }
            else if(siz==3){
                if(x/100==x%10){
                    cout<<x<<endl;
                    goto end;
                }
            }
            else if(siz==4){
                if((x%1000)/100==(x%100)/10&&x/1000==x%10){
                    cout<<x<<endl;
                    goto end;
                }
            }
            else if(siz==5){
                if((x%10000)/1000==(x%100)/10&&x/10000==x%10){
                    cout<<x<<endl;
                    goto end;
                }
            }
            x = n+i;
        }
    }
    end:

    return 0;
}

Measured memory_bytes: 1164
package main

import "fmt"

func main() {

	var a, b, ans int
	var op string
	for {
		fmt.Scanln(&a, &op, &b)

		if op == "?" {
			break
		}
		if op == "+" {
			ans = a + b
		} else if op == "-" {
			ans = a - b
		} else if op == "*" {
			ans = a * b
		} else if op == "/" {
			ans = a / b
		}
		fmt.Printf("%d\n", ans)
	}

}



Measured memory_bytes: 1128
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

int a[100010],b[100010];
int main(){
	int n;sc(n);
	up(i,1,n+1)sc(a[i]);
	up(i,1,n)sc(b[i]);
	ll ans=0;
	up(i,1,n)
	if(b[i]>=a[i]){
		ans+=a[i],b[i]-=a[i],a[i]=0;
		if(b[i]>=a[i+1])ans+=a[i+1],b[i]-=a[i+1],a[i+1]=0;
		else ans+=b[i],a[i+1]-=b[i],b[i]=0;
	}else {
		ans+=b[i],a[i]-=b[i],b[i]=0;
	}
	prl(ans,'\n');
}

Measured memory_bytes: 1024