akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    int res = 0;
    int cc=0;
    int slen=s.size()-1;
    do
    {
        cc = 0;
        rep(i, slen)
        {
            if ((s[i] - '0') ^ (s[i + 1] - '0'))
            {
                s.erase(i, 2);
                cc = 2;
                break;
            }
        }
        slen = s.size() - 1;
        res += cc;
    } while (cc != 0);
    cout << res << endl;
    return 0;
}

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

int n, pos;
std::vector<int> pre, in, post;

void rec(int l, int r) {
	if (l >= r) return;
	int root = pre[pos++];
	int m = std::distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve() {
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n; i++) {
		if (i)std::cout << " ";
		std::cout << post[i];
	}
	std::cout << std::endl;
}

int main() {
	int k;
	std::cin >> n;

	for (int  i = 0; i < n; i++) {
		std::cin >> k;
		pre.push_back(k);
	}

	for (int i = 0; i < n; i++) {
		std::cin >> k;
		in.push_back(k);
	}

	solve();

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> foods(m, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      foods.at(a - 1)++;
    }
  }
  int count = 0;
  for (int i = 0; i < foods.size(); i++) {
    if (foods.at(i) == n) { count++; }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++)cout<<"ACL";





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
	}

	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//long n = Long.parseLong(sc.next());
		int n = Integer.parseInt(sc.next());
		//75=5*5*3, 25*3, 15*5, 75, 
		int[] f=new int[101];
		for (int i = 2; i <= n; i++) {
			factor(f, i);
		}
		int t_3=0;
		int t_5=0;
		int t_25=0;
		int t_15=0;
		int t_75=0;
		for (int i = 0; i <= n; i++) {
			if(f[i] >= 2) t_3++;
			if(f[i] >= 4) t_5++;
			if(f[i] >= 14) t_15++;
			if(f[i] >= 24) t_25++;
			if(f[i] >= 74) t_75++;
		}
		out.println(t_75+t_25*(t_3-1)+t_15*(t_5-1)+t_5*(t_5-1)/2*(t_3-2));
		out.flush();
	}
	void factor(int[] a, int c)
	{
		for (int i = 2; i < 100; i++) {
			while(c%i==0)
			{
				a[i] += 1;
				c /= i;
			}
		}
	}
	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public FastScanner(String in) {
			StringReader sr = new StringReader(in);
			reader = new BufferedReader(new BufferedReader(sr));
			tokenizer = null;
		}
		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
	}
}

Measured memory_bytes: 25428
#D
N,K=map(int,input().split())
A=[0]+[int(x) for x in input().split()]

p=1
log=[[0,0] for i in range(N+1)]
log[1]=[1,0]
cnt=0
while True:
    cnt+=1
    p=A[p]
    log[p][0]+=1
    if log[p][0]==2:
        break
    else:
        log[p][1]+=cnt

re=cnt-log[p][1]
if K<cnt+log[p][1]:
    p=1
else:
    K=(K-log[p][1])%re

for i in range(K):
    p=A[p]
print(p)

Measured memory_bytes: 107060
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

template<typename T> struct CumulativeSum
{
   vector<T> s;
   CumulativeSum(const vector<T>& v) {
      int N = v.size();
      s.resize(N+1);
      for (int i = 0; i < N; i++) {
         s[i+1] = s[i] + v[i];
      }
   }
   int sum(int i) {
      return s[i+1];
   }
   int sum(int i, int j) {
      return s[j+1] - s[i];
   }
};

signed main()
{
   int N, T; cin >> N >> T;
   V<int> s(T+1);
   REP(i, N) {
      int l, r; cin >> l >> r;
      s[l]++; s[r]--;
   }
   CumulativeSum<int> S(s);
   int ans = 0;
   FORE(t, 0, T) {
      chmax(ans, S.sum(t));
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 4364
/*B - Digits*/

#include <bits/stdc++.h>

using namespace std;

int cuentaDigitos(int num, int base);

int main(){
	
	int num;
	int base;

	cin >> num >> base;
	cout << cuentaDigitos(num, base);
	
	return 0;
}


int cuentaDigitos(int num, int base){
	int ans = 0;

	while(num > 0){
		num /= base;
		ans++;
	}

	return ans;
}

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

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

    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i <= 9) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long int ll;

class UnionFind{
    public:
        vector<ll> uni;
        UnionFind(ll s) : uni(s, -1) { }
 
       //頂点aが所属するグループを調べる
        ll root(ll a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }
    
        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(ll a, ll b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;
    
            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }
    
            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }
    
        //頂点a,bが同じグループであるかを調べる
        bool isConnect(ll a, ll b)
        {
            return root(a) == root(b);
        }
    
        //頂点aを含むグループの頂点数を調べる
        ll size(ll a)
        {
            return -uni[root(a)];
        }
};

int main(int argc, char const *argv[])
{
    ll n, m, c;
    cin >> n >> m >> c;
    vector<ll> b;
    vector< vector<ll> > a(n + 1);

    for(ll i = 0; i < m; i++)
    {
        ll p;
        cin >> p;
        b.push_back(p);
    }    

    for(ll i = 0; i < n; i++)
    {
        for(ll k = 0; k < m; k++)
        {
            ll p;
            cin >> p;
            a[i].push_back(p);
        }
    }
    

    ll ans = 0;
    for(ll i = 0; i < n; i++)
    {
        ll temp = 0;
        for(ll k = 0; k < m; k++)
        {
            temp += a[i][k] * b[k];
        }
        if (temp + c > 0)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int H, W, D;
	cin >> H >> W >> D;
	vector<pair<int, int>> c(H * W);
	for (auto i = 0; i < H; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			int A;
			cin >> A;
			--A;
			c[A] = { i, j };
		}
	}

	vector<ll> sum(H * W);
	for (auto i = D; i < H * W; ++i)
	{
		sum[i] = sum[i - D];
		auto& current = c[i];
		auto& prev = c[i - D];
		auto diffY = prev.first - current.first;
		auto diffX = prev.second - current.second;
		sum[i] += abs(diffX) + abs(diffY);
	}

	vector<ll> ans;
	int Q;
	cin >> Q;
	for (auto i = 0; i < Q; ++i)
	{
		int L, R;
		cin >> L >> R;
		--L;
		--R;
		ans.push_back(sum[R] - sum[L]);
	}

	for (auto i = 0; i < Q; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3444
n,y=gets.chomp.split.map(&:to_i)
ans10000=-1
ans5000=-1
ans1000=-1
i=0
check=false
while i<=n
  j=0
  while i+j<=n
    k=n-i-j
    if 10000*i+5000*j+1000*k==y
      ans10000=i
      ans5000=j
      ans1000=k
      check=true
      break
    end
    j+=1
  end
  break if check
  i+=1
end
puts [ans10000,ans5000,ans1000].join(" ")


Measured memory_bytes: 1788
class Sort():
	def __init__(self,n,cards):
		self.cards = cards
		self.n = n

	def bubble_sort(self):
		# bubble sort
		flag = 1
		while flag != 0:
			flag = 0
			rev = list(range(1,self.n))
			rev.reverse()
			for j in rev:
				if int(self.cards[j][1]) < int(self.cards[j-1][1]):
					self.cards[j],self.cards[j-1] = self.cards[j-1],self.cards[j]
					flag = 1

	def select_sort(self):
		for i in range(self.n):
			mini = i
			for j in range(i,self.n):
				if int(self.cards[j][1]) < int(self.cards[mini][1]):
					mini = j
			if i != mini:
				self.cards[i],self.cards[mini] = self.cards[mini],self.cards[i]

	def check_stable(self,origin):
		check_org = [["" for i in range(self.n)] for k in range(9)]
		check_sort = [["" for i in range(self.n)] for k in range(9)]
		for i in range(self.n):
			check_org[int(origin[i][1])-1][i] = origin[i][0]
			check_sort[int(self.cards[i][1])-1][i] = self.cards[i][0]
		flag = 0
		for i in range(9):
			if "".join(check_org[i]) != "".join(check_sort[i]):
				flag = 1
				break

		if flag == 0:
			print("Stable")
		else:
			print("Not stable")

	def print_card(self):
		for i in range(self.n):
			if i != self.n-1:
				print("%s" % (self.cards[i]),end=" ")
			else:
				print("%s" % (self.cards[i]))

if __name__ == '__main__':
	n = int(input())
	card = input().split()
	card2 = card.copy()
	card_origin = card.copy()
	
	bubble = Sort(n,card)
	bubble.bubble_sort()
	bubble.print_card()
	bubble.check_stable(card_origin)
	
	select = Sort(n,card2)
	select.select_sort()
	select.print_card()
	select.check_stable(card_origin)


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

string s[100000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    for(int i = 0; i < N; i++){
        sort(s[i].begin(), s[i].end());
    }

    map <string, long long> counts;
    for(int i = 0; i < N; i++){
        if(counts.find(s[i]) != counts.end()){
            counts[s[i]] ++;
        } else {
            counts[s[i]] = 1;
        }
    } 

    long long ans = 0;
    for(auto it = counts.begin(); it != counts.end(); it++){
        ans += it->second * (it->second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18176
def pf(N):
    prime=[]
    for i in range(2,N+1):
        cond=True
        for j in range(2,round(i**0.5)+1):
            if i%j==0:
                cond=False
        if cond:
            prime.append(i)
    return prime

mod=10**9+7
N=int(input())
ans=1
PF=pf(N)
n=len(PF)
Fs=[1 for _ in range(n)]

for i in range(2,N+1):
    nex=i
    j=0
    while nex>1:
        if nex%PF[j]==0:
            nex//=PF[j]
            Fs[j]+=1
            Fs[j]%=mod
        else:
            j+=1

for f in Fs:
    ans*=f
    ans%=mod

#print(PF)
#print(Fs)
print(ans%mod)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while (cin >> n, n){
        int v[10] = {};
        rep(i, n){
            int s = 0;
            rep(j, n){
                int t; cin >> t;
                printf("%5d", t);
                s += t;
                v[j] += t;
            }
            printf("%5d\n", s);
        }
        int s = 0;
        rep(i, n){
            printf("%5d", v[i]);
            s += v[i];
        }
        printf("%5d\n", s);
    }
}

Measured memory_bytes: 1144
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n,a[200005],b[200005],p[600005],dp[600005]; 
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++){
		p[i]=b[i]^b[(i+1)%n];
		p[i+n]=a[i]^a[(i+1)%n];p[i+n*2]=p[i+n];
	}
	int l=0;
	FOR(i,1,n*3-1){
		if(i+dp[i-l]<dp[l]+l){
			dp[i]=dp[i-l];
		}else{
			int t=max(0,l+dp[l]-i);
			while(t+i<3*n&&p[t]==p[t+i])t++;
			dp[i]=t;
			l=i;
		}
	}
	FOR(i,n,2*n-1){
		if(dp[i]>=n){
			cout<<i-n<<' '<<(b[0]^a[i-n])<<'\n';
		}
	}
	RE 0;
}




Measured memory_bytes: 9728
import java.util.Scanner;

//Square Searching
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] a = new int[n][n];
			int[][] sum = new int[n+1][n+1];
			for(int i=0;i<n;i++){
				char[] s = sc.next().toCharArray();
				for(int j=0;j<n;j++)a[i][j]=s[j]=='.'?1:0;
			}
			sum[1][1] = a[0][0];
			for(int i=2;i<=n;i++){
				sum[1][i] = a[0][i-1]+sum[1][i-1];
				sum[i][1] = a[i-1][0]+sum[i-1][1];
			}
			for(int i=2;i<=n;i++){
				for(int j=2;j<=n;j++){
					sum[i][j] = a[i-1][j-1] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
				}
			}
			int max = 0;
			for(int k=1;k<=n;k++){
				boolean f = false;
				for(int i=k;i<=n;i++){
					for(int j=k;j<=n;j++){
						if(sum[i][j]-sum[i-k][j]-sum[i][j-k]+sum[i-k][j-k]==k*k){
							f = true;
							break;
						}
					}
					if(f)break;
				}

				if(f){
					max = k;
				}
				else break;
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <cmath>
using namespace std;

int main()
{
    long long int num;
    cin >> num;

    vector<string> s;
    for (long long int i = 0; i < num; i++) {
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        s.push_back(str);
    }

    sort(s.begin(), s.end());

    long long int count = 0;

    long long int startPoint;
    bool isRenzoku = false;
    long long int tmpCount = 0;
    for (long long int i = 0; i < num - 1; i++) {
        if (isRenzoku) {
            if (s[startPoint] == s[i + 1]) {
                tmpCount++;
            } else {
                isRenzoku = false;
                count += (tmpCount * (tmpCount - 1)) / 2;
                tmpCount = 0;
            }
        } else {
            if (s[i] == s[i + 1]) {
                tmpCount = 2;
                isRenzoku = true;
                startPoint = i;
            }
        }
    }

    if (isRenzoku) {
        count += (tmpCount * (tmpCount - 1)) / 2;
    }

    cout << count << endl;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int Q;
  in >> Q;
  for (int q = 0; q < Q; ++q) {
    int64_t a, b;
    in >> a >> b;
    if (a > b) swap(a,b);
    int64_t prod = a * b;
    if (b - a <= 1) {
      out << 2 * a - 2 << '\n';
      continue;
    }
    int64_t sq = sqrt(prod);
    while (sq * sq < prod) ++sq;
    while (sq * sq >= prod) --sq;
    int64_t count = sq - 1;
    if (sq * (sq + 1) < prod) {
      count += sq;
    } else {
      count += sq - 1;
    }
    out << count << '\n';
  }
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

struct Info{
	int i,j,k,r;
};

int main(){

	int a,b,c,N,checkTable[301];
	Info info[1000];

	while(true){
		scanf("%d %d %d",&a,&b,&c);
		if(a == 0 && b == 0 && c == 0)break;

		for(int i = 1; i <= 300; i++){
			checkTable[i] = 2;
		}

		scanf("%d",&N);

		for(int i = 0; i < N; i++){
			scanf("%d %d %d %d",&info[i].i,&info[i].j,&info[i].k,&info[i].r);
			if(info[i].r == 1){ //??????????????±?????????????¨??????????
				checkTable[info[i].i] = 1;
				checkTable[info[i].j] = 1;
				checkTable[info[i].k] = 1;
			}
		}

		for(int i = 0; i < N; i++){
			if(info[i].r == 0){
				if(checkTable[info[i].i] == 1 && checkTable[info[i].j] == 1 && checkTable[info[i].k] == 2){
					checkTable[info[i].k] = 0;
				}else if(checkTable[info[i].i] == 1 && checkTable[info[i].j] == 2 && checkTable[info[i].k] == 1){
					checkTable[info[i].j] = 0;
				}else if(checkTable[info[i].i] == 2 && checkTable[info[i].j] == 1 && checkTable[info[i].k] == 1){
					checkTable[info[i].i] = 0;
				}
			}
		}
		for(int i = 1; i <= a+b+c; i++)printf("%d\n",checkTable[i]);
	}
	return 0;
}

Measured memory_bytes: 2592
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	int ans = N * (N + 1) / 2;
	co(ans);
	return 0;
}


Measured memory_bytes: 256
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const as = input[1].split(" ").map(n => Number(n));
  const bs = input[2].split(" ").map(n => Number(n));
  let result = 0;
  for(let i = 0; i < n; i++) {
    const a = as[i];
    const nextA = as[i+1];
    const b = bs[i];
    if (b <= a) {
      result += b;
      continue;
    }
    result += a;
    const remainedB = b - a;
    if (remainedB <= nextA) {
      as[i+1] -= remainedB;
      result += remainedB;
      continue;
    }
    result += nextA;
    as[i+1] = 0;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30776
#include<iostream>
#include<stack>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> treeshape(string tree);
string printtree(vector<int> nodes, int root);

int main(){
	string op, first, second;
	while(!cin.eof()){
		cin>>op>>first>>second;
		if(!cin.fail()){
			vector<int> f, s;
			f = treeshape(first);
			s = treeshape(second);
			sort(f.begin(), f.end());
			sort(s.begin(), s.end());
			vector<int> result;
			if(op[0] == 'i'){
				set_intersection(f.begin(), f.end(), s.begin(), s.end(), back_inserter(result));
			}
			if(op[0] == 'u'){
				set_union(f.begin(), f.end(), s.begin(), s.end(), back_inserter(result));
			}
			cout<<printtree(result, result[0])<<endl;
		}
	}
}

vector<int> treeshape(string tree){
	vector<int> vec;
	stack<char> st;
	bool flag = false;
	int node = 1;
	vec.push_back(node);
	for(int i = 1; i < tree.length(); i++){
		if(tree[i] == '('){
			st.push('(');
			node *= 2;
			if(flag){
				node += 1;
				flag = false;
			}
			vec.push_back(node);
		}else if(tree[i] == ',' && tree[i+1] == '('){
			flag = true;
		}else if(tree[i] == ')'){
			st.pop();
			node /= 2;
		}
	}
	return vec;
}

string printtree(vector<int> nodes, int root){
	if(find(nodes.begin(), nodes.end(), root) == nodes.end())
		return "";
	if(find(nodes.begin(), nodes.end(), root * 2) == nodes.end() && find(nodes.begin(), nodes.end(), root * 2 + 1) == nodes.end())
		return "(,)";
	return "(" + printtree(nodes, root * 2) + "," + printtree(nodes, root * 2 + 1) + ")";
}


Measured memory_bytes: 3152
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e4 + 10;

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

	int a;cin >> a;
	int dai = a,syou = a;

	rep(i,n-1)
	{
		int b;cin>>b;
		dai = max(dai,b);
		syou = min(syou,b);
	}

	cout << dai-syou<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N;
  cin >> N;
  vl a(N);
  rep(i,N){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[N-1] << " ";
  ll k=a[N-1]/2;
  ll d=INF;
  ll x=N-1;
  rep(i,N-1){
    if(abs(a[i]-k)<=d){
      d=abs(k-a[i]);
      x=i;
    }
  }
  cout << a[x] << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <cassert>
#define rep(i,n) for (ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
         return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt< MOD >;

int n, s;
int a[3000];
mint dp[3001][3001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    rep(i,n) cin >> a[i];
    mint ans = 0;
    dp[0][0] = 1;
    rep(i,n) {
        rep(j,s+1) dp[i+1][j] = dp[i][j];
        if (a[i] <= s) ans += dp[i][s-a[i]]*(n-i);

        dp[i+1][0] += 1;
        for (int j = a[i]; j <= s; j++) {
            dp[i+1][j] += dp[i][j-a[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35456
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n, k int
  fmt.Scan(&n, &k)
  a := make([]int, n + 1)
  var x int
  for i := 0; i < n; i++ {
    fmt.Scan(&x)
    a[x]++
  }
  sort.Sort(sort.IntSlice(a))
  ans := 0
  for i := 0; i < n - k; i++ {
    ans += a[i + 1]
  }
  fmt.Println(ans)
}


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

int gcd(int a,int b){
    if(a<b){swap(a,b);}
    if(!b){return a;}
    return gcd(b,a%b);
}
int main(){
    int N;
    cin>>N;
    cout<<N*2/gcd(N,2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;
 
int c[10][1005];
 
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = INF;
  rep(div,1<<(h-1)) {
    int g = 0;
    vector<int> id(h);
    rep(i,h) {
      id[i] = g;
      if (div>>i&1) ++g;
    }
    ++g;
    rep(i,g)rep(j,w) c[i][j] = 0;
    rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
 
    int num = g-1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i,g) now[i] += c[i][j];
      rep(i,g) if (now[i] > k) return false;
      return true;
    };
    rep(j,w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

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


int main() {
    string S;
    cin >> S;
    string alp = "abcdefghijklmnopqrstuvwxyz";
    vector<int> num(alp.size());
    for (int i = 0; i < S.size(); ++i) {
        num.at(alp.find(S.at(i)))++;
    }
    for (int i = 0; i < num.size(); ++i) {
        if (num.at(i) == 0) {
            cout << alp.at(i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <limits>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    if ( n == m ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,n; cin>>a>>b>>c>>n;
  
  ll ans=0;
  rep(i,3001){
    rep(j,3001){
      ll x=n-a*i-b*j;
      if(x<0 || x%c!=0) continue;
      // cout<<x<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define N 100010
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],p[N],pn,g,vis[N];
vector<int> ans;
bool ntp[N];
void init(int n){
	ntp[1]=true;
	for(int i=2;i<=n;++i){
		if(!ntp[i])p[++pn]=i;
		for(int j=1;j<=pn&&p[j]*i<=n;++j){
			ntp[p[j]*i]=true;
		}
	}
}
void QAQ(int x){
	for(int i=1;i<=pn;++i){
		if(x%p[i]==0)ans.push_back(p[i]),vis[p[i]]=1;
		while(x%p[i]==0)x/=p[i];
	}
	if(x>1){
		ans.push_back(x);
	}
}
bool check(int x){
	for(int i=0;i<x-1;++i){
		int tot=0;
		for(int j=i;j<=n;j+=x-1){
			tot=(tot+a[j])%x;
		}
		if(tot%x)return false;
	}
	return true;
}
int main(){
	n=read();
	init(40000);
	int sum=0;
	for(int i=n;i>=0;--i){
		a[i]=read();
		sum=(sum+a[i])%2;
		g=__gcd(g,a[i]<0?-a[i]:a[i]);
	}
	QAQ(g);
	for(int i=1;i<=pn&&p[i]<=n;++i){
		if(!vis[p[i]]&&check(p[i])&&a[0]%p[i]==0){
			ans.push_back(p[i]);
		}
	}
	sort(ans.begin(),ans.end());
	for(auto x:ans){
		printf("%d\n",x);
	}
	return 0;
}




Measured memory_bytes: 3864
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

// 切り上げ割り算
template <typename T>
T ceil_div(T a, T b) {
    return a > 0 && b > 0 ? (a + b - 1) / b : a / b;
}

int main() {
    ll h, w; cin >> h >> w;
    if (h > w) swap(h, w);
    if (h != 1) cout << ceil_div(h, 2LL) * ceil_div(w, 2LL) + (h / 2LL) * (w / 2LL) << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int m,t,p,r;
vector<pair<int,pair<int,int> > > vv[55];
typedef struct{
	int num;
	int ans_n;
	int time;
}date_set;

date_set date(int num,int ans_n,int time){
	date_set temp;
	temp.num=num;
	temp.ans_n=ans_n;
	temp.time=time;
	return temp;
}

date_set vre[55];
bool comp(const pair<int,pair<int,int> >& P1,const pair<int,pair<int,int> >& P2){
	return P1.second.second<P2.second.second;
}

bool comp2(const date_set& d1,const date_set& d2){
	if(d1.ans_n!=d2.ans_n){
		return d1.ans_n>d2.ans_n;
	}else if(d1.time!=d2.time){
		return d1.time<d2.time;
	}else{
		return d1.num>d2.num;
	}
}

vector<string> anss;
int main(){
	while(1){
		for(int i=0;i<55;i++){
			vv[i].clear();
			vre[i]={0,0,0};
		}
		cin>>m>>t>>p>>r;
		if(m==0&&t==0&&p==0&&r==0)break;
		for(int i=0;i<r;i++){
			int mm,tt,pp,jj;
			cin>>mm>>tt>>pp>>jj;
			vv[tt].push_back(make_pair(mm,pair<int,int>(pp,jj)));
		}
		vector<int> alr;
		for(int i=1;i<=t;i++){
			alr.clear();
			sort(vv[i].begin(),vv[i].end(),comp);
			int cor=0;
			int time=0;
			for(int j=0;j<vv[i].size();j++){
				if(vv[i][j].second.second==0){
					cor++;
					time+=vv[i][j].first;
					alr.push_back(vv[i][j].second.first);
				}else{
					auto itr=find(alr.begin(),alr.end(),vv[i][j].second.first);
					if(itr!=alr.end()){
						time+=20;
					}
				}
			}
			vre[i-1]=date(i,cor,time);
			
		}
		/*for(int i=0;i<t;i++){
			cout<<vre[i].num<<" "<<vre[i].ans_n<<" "<<vre[i].time<<endl;
		}*/
		sort(vre,vre+t,comp2);
		string st="";
		for(int i=0;i<t-1;i++){
			if(vre[i].ans_n!=vre[i+1].ans_n||vre[i].time!=vre[i+1].time){
				//cout<<vre[i].num<<",";
				st=st+to_string(vre[i].num)+",";
			}else{
				st=st+to_string(vre[i].num)+"=";
				//cout<<vre[i].num<<"=";
			}
		}
		
		st=st+to_string(vre[t-1].num)+"\n";
		//cout<<vre[t-1].num<<endl;
		anss.push_back(st);
	}
	for(int i=0;i<anss.size();i++){
		cout<<anss[i];
	}
	return 0;
}


Measured memory_bytes: 3184
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		String st;
		String longWord;
		String freqWord;
		int maxLength;
		int maxFreq;

		longWord = null;
		freqWord = null;
		maxLength = 0;
		maxFreq = 0;
		while (sc.hasNext()) {
			st = sc.next();
			if (map.get(st) == null) {
				map.put(st, 1);
			} else {
				map.put(st, map.get(st) + 1);
			}
			if (maxLength < st.length()) {
				maxLength = st.length();
				longWord = st;
			}
			if (maxFreq < map.get(st)) {
				maxFreq = map.get(st);
				freqWord = st;
			}
		}
		System.out.println(freqWord + " " + longWord);
	}
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
	int n,a[100001]={0};
	int i,j;
	long long int ans = 1;
	int flag = 0;
	
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i = 0;i < n/2;i++){
		ans *= 2;
		ans %= 1000000007;
	}
	
    qsort(a, n, sizeof(int), compare_int);
	
	if(n%2){
		flag = !(a[0]==0&&a[1]!=0);
		for(i = 1;i < n;i += 2){
			if(!(a[i] == i+1 && a[i] == a[i+1])){
				flag = 1;
			}
		}
	}else{
		for(i = 0;i < n;i += 2){
			if(!(a[i] == i+1 && a[i] == a[i+1])){
				flag = 1;
			}
		}
	}
	if(n==1){
		ans=1;
		flag=a[0];
	}
	
	printf("%d\n",flag?0:ans);
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
    ll N,cnt=0;
    string S;
    cin>>N>>S;
    for(ll i=0;i<1000;i++){
        ll v[3],k=0;
        v[0]=i/100;
        v[1]=i%100/10;
        v[2]=i%10;
        for(ll j=0;j<N;j++){
            if(S[j]=='0'+v[k]) k++;
            if(k==3){
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 384
n, x = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)

if a[0] > x:
  a[0] = x
for i in range(n - 1):
  if a[i] + a[i+1] > x:
    a[i+1] += x - (a[i] + a[i+1])
r = sum_a - sum(a)
    
print(r)

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

int main () {
  int N;
  int A;
  cin >> N >> A;
  if(N % 500 == 0) {
    cout << "Yes" << endl;
  }
  if(N % 500 != 0) {
    if(A >= 500) {
      cout << "Yes" << endl;
    }
    if(A <= 499) {
      if(N % 500 <= A) {
        cout << "Yes" << endl;
      }
      if(N % 500 > A) {
        cout << "No" << endl;
      }
    }
  }
}

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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

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

const int N = 3000 + 5;

/***************************************************************************/

int dp[N][N];

int main() {

	boost;
	string s, t; cin>>s>>t;
	for(int i=1; i<=(int)s.length(); i++) {
		for(int j=1; j<=(int)t.length(); j++) {
			if(s[i-1] == t[j-1]) {
				dp[i][j] = 1 + dp[i-1][j-1];
			}
			else {
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
			}
		}
	}
	string ans;
	int i = s.length(), j = t.length();
	while(dp[i][j]) {
		if(s[i-1] == t[j-1]) {
			ans += s[i-1];
			i--, j--;
		}
		else if(dp[i][j-1] > dp[i-1][j]) j--;
		else i--;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 35456
function Main(input) {
	input = input.split(" ");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
       var sum=0;
       if(a>=b &&a>=c){
        sum=10*a+b+c;
}else if(b>=a && b>=c){
 sum=10*b+a+c;
}else{
 sum=10*c+a+b;
}
	//出力
	console.log('%d',sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}


int atcoder(){
    int n,a,b;
    cin>>n>>a>>b;
    Vi v(3,0);
    REP(i,0,n){
        int tmp;
        cin>>tmp;
        if(tmp<=a) v[0]++;
        else if(tmp<=b) v[1]++;
        else v[2]++;
    }
    
    cout<<*min_element(ALL(v))<<ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanNum = new Scanner(System.in);
	
	int S = scanNum.nextInt(); //??????
	int h,m,s;
	h = S / 3600;
	m = S / 60 % 60;
	s = S % 60;
	System.out.println(h + ":"+ m +":" + s);
	}
}

Measured memory_bytes: 26216
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int d = 0;
		int count = 1;
		for (int i = 0; i < n; i++) {
			d += sc.nextInt();
			if (d > x) {
				break;
			}
			count++;
		}
		System.out.println(count);
	}
}


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

using namespace std;

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

    int ans = 0;
    string str;

    cin >> str;

    for (int i = 0, j = int(str.size()) - 1; i < j;) {
        if (str[i] != str[j])
            ans++;
        i++, j--;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string S,T;
	cin>>S>>T;
	int A,B;
	cin>>A>>B;
	string U;
	cin>>U;
	if(U==S)
	cout<<A-1<<" "<<B;
	else
	cout<<A<<" "<<B-1;
}

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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  long sum = 0; for (int i = 0; i < N; i++) sum += A[i];
  long C[2*N+1]; C[0] = 0;
  for (int i = 0; i < 2*N; i++) C[i+1] = C[i] + A[(2*i+1)%N];
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    int j;
    if (i % 2) j = (N+1)/2 + i/2;
    else j = i/2;
    cout << sum - 2 * (C[j+(N-1)/2] - C[j]);
  }
  cout << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  string w;
  char x;
  int count, flag = 1;

  cin >> w;

  for(int i = 0; i < w.size(); i++){
    x = w[i];
    count = 0;
    for(int j = 0; j < w.size(); j++){
      if(x == w[j]) count++;
    }

    if(count % 2 == 1){
      flag = 0;
      break;
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#define p64 PRId64

#include <cinttypes>
#include <cstdio>
#include <string>
#include <map>

using namespace std;

using ll = int64_t;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    map<char, ll> m;
    for (int i = 0; i < N; i++)
    {
        char tmp[11];
        if (scanf("%s", tmp) < 1) return 0;

        string s = tmp;
        if (s[0] == 'M' || s[0] == 'A'
            || s[0] == 'R' || s[0] == 'C'
            || s[0] == 'H')
        {
            m[s[0]]++;
        }
    }

    ll ans = 0;
    if (m.size() == 3)
    {
        ans++;
        for (pair<char, ll> p : m)
        {
            ans *= p.second;
        }
    }
    else if (m.size() == 4)
    {
        ll val[4];
        int i = 0;
        for (pair<char, ll> p : m)
        {
            val[i] = p.second;
            i++;
        }

        ans = val[0] * val[1] * val[2];
        ans += val[0] * val[1] * val[3];
        ans += val[0] * val[2] * val[3];
        ans += val[1] * val[2] * val[3];
    }
    else if (m.size() == 5)
    {
        ll val[5];
        int i = 0;
        for (pair<char, ll> p : m)
        {
            val[i] = p.second;
            i++;
        }

        ans = val[0] * val[1] * val[2];
        ans += val[0] * val[1] * val[3];
        ans += val[0] * val[2] * val[3];
        ans += val[1] * val[2] * val[3];

        ans += val[0] * val[1] * val[4];
        ans += val[0] * val[2] * val[4];
        ans += val[1] * val[2] * val[4];

        ans += val[0] * val[3] * val[4];
        ans += val[1] * val[3] * val[4];

        ans += val[2] * val[3] * val[4];
    }

    printf("%" p64 "\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int a = 0;
  scanf("%d",&a);
  int b = a%100;
  int c = b%10;
  if(c == 3){
    printf("bon");
  }else if(c == 0 || c==1 || c==6 || c==8){
    printf("pon");
  }else{
    printf("hon");
  }
  return 0;
}


Measured memory_bytes: 2144