akhauriyash/Code-Regression huggingface dataset:
#include<iostream> 
using namespace std;

const int maxn = 3e5 + 50;
int N, p[maxn];

bool check(int l, int r) {
	for (int i = l; i <= r; ++i) {
		if (p[i]<l || p[i]>r) {
			return false;
		}
	}
	int L = -1, R = -1;
	for (int i = l; i <= r; i += 2) {
		if (p[i] < i) {
			if (L > p[i]) return false;
			L = p[i];
		}
		else {
			if (R > p[i]) return false;
			R = p[i];
		}
	}
	return true;
}

bool sol() {
	for (int i = 2; i < N; ++i) {
		if (p[i - 1] != i - 1 && p[i] != i && p[i + 1] != i + 1) {
			return false;
		}
	}
	int l = 1;
	while (l <= N) {
		while (l <= N && p[l] == l) ++l;
		if (l > N) break;
		int r = l;
		while (r + 2 <= N && p[r + 1] == r + 1 && p[r + 2] != r + 2) r += 2;
		if (!check(l, r)) return false;
		l = r + 1;
	}
	return true;
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &p[i]);
	}
	puts(sol() ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int N = sc.nextInt();
            if (N == 0) break;
            
            Die d = new Die();
            
            while (N-- > 0) {
                String str = sc.next();
                switch (str.charAt(0)) {
                    case 'n': d.north(); break;
                    case 'e': d.east(); break;
                    case 'w': d.west(); break;
                    case 's': d.south(); break;
                    default: break;
                }
            }
            
            System.out.println(d.top);
        }
    }
    
    public static class Die {
        int top;
        int bottom;
        int north;
        int south;
        int east;
        int west;
        
        public Die() {
            top = 1;
            north = 2;
            west = 3;
            bottom = 6;
            south = 5;
            east = 4;
        }
        
        public void north() {
            int tmp = north;
            north = top;
            top = south;
            south = bottom;
            bottom = tmp;
        }
        
        public void south() {
            int tmp = south;
            south = top;
            top = north;
            north = bottom;
            bottom = tmp;
        }
        
        public void east() {
            int tmp = east;
            east = top;
            top = west;
            west = bottom;
            bottom = tmp;
        }
        
        public void west() {
            int tmp = west;
            west = top;
            top = east;
            east = bottom;
            bottom = tmp;
        }
    }
}




Measured memory_bytes: 29552
# coding: utf-8
# Your code here!

W, H, x, y = map(int, input().rstrip().split(' '))

if abs(W / 2 - float(x)) < 1e-9 and abs(H / 2 - float(y)) < 1e-9:
    print((W * H) / 2, 1)
else:
    print((W * H) / 2, 0)

Measured memory_bytes: 38384
import sys
input = sys.stdin.readline
from collections import Counter
from itertools import chain

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())

def main():
    h, w = map(int, input().split())

    C = list(map(list, readlines(10)))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    counter = Counter(chain(*readlines(h)))

    for i in range(10):
        yield C[i][1] * counter[i]


print(sum(main()))


main()

Measured memory_bytes: 5868
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int Amax = *max_element(all(A));
    vector<int> buckets(Amax + 1), buckets2(Amax + 1);
    rep(i, N) buckets[A[i]]++;
    for (int i = 1; i <= Amax; ++i) buckets2[i] = (ll)buckets[i] * (buckets[i] - 1) / 2 % MOD;

    vv<int> divs(Amax + 1);
    for (int i = 1; i <= Amax; ++i) {
        for (int n = i; n <= Amax; n += i) {
            divs[n].push_back(i);
        }
    }

    vector<ll> w(Amax + 1);
    w[1] = 1;
    for (int i = 2; i <= Amax; ++i) {
        ll v = mpow(i, MOD - 2);
        for (int d : divs[i]) {
            if (d != i) v = (v + MOD - w[d]) % MOD;
        }

        w[i] = v;
    }

    ll ans = 0;
    for (int i = 1; i <= Amax; ++i) {
        ll S = 0;
        ll C = 0;
        for (ll n = i; n <= Amax; n += i) {
            C = (C + n * buckets[n] % MOD * S) % MOD;
            C = (C + n * n % MOD * buckets2[n] % MOD) % MOD;
            S = (S + n * buckets[n]) % MOD;
        }
        C %= MOD;

        ans = (ans + w[i] * C) % MOD;
    }

    write(ans);
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n, k; cin >> n >> k;
  k += n;
  vi a(n);
  int r = 0;
  REP(i, n) {
    cin >> a[i];
    r = max(r, a[i]);
  }

  int l = 0;
  REP(i, 300) {
    int mid = (l + r) / 2;
    if(mid == 0) break;
    int cnt = 0;
    REP(j, n) {
      int div = (a[j] - 1) / mid + 1;
      cnt += div;
    }
    if(cnt <= k) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
}








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

main(){
    int L, M, N;
    while( cin >> L && L ){
	int t = 0, S = 0;
	for ( int i = 1; i <= 12; i++ ){
	    cin >> M >> N; 
	    S += M - N;
	    if ( S >= L && t == 0 ) t = i;
	}
	if ( S < L ) cout << "NA" << endl;
	else cout << t << endl;
    }
}

Measured memory_bytes: 0
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 300;

int N;

ll A[MAX_N + 1][MAX_N + 1];
bool need[MAX_N + 1][MAX_N + 1];

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

    cin >> N;

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            cin >> A[i][j];
        }
    }

    bool exist = true;
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            ll lmin = INF;
            for (int k = 1; k <= N; k++) {
                lmin = min(A[i][k] + A[k][j], lmin);
            }
            if (A[i][j] != lmin) {
                exist = false;
            }
        }
    }

    ll ans = 0;
    if (exist) {
        fill(need[0], need[N + 1], true);
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                for (int k = 1; k <= N; k++) {
                    if (k != i && k != j && A[i][j] == A[i][k] + A[k][j]) {
                        need[i][j] = false;
                        need[j][i] = false;
                    }
                }
            }
        }
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (need[i][j]) {
                    ans += A[i][j];
                }
            }
        }
    } else {
        ans = -1;
    }

    cout << ans << "\n";

    return 0;
}


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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i=0;i<n;i++){
		int in;
		cin >> in;
		int limit = sqrt(in);
		for(int j=2;j<=limit;j++){
			if(in%j == 0){
				ans++;
				break;
			}
		}
	}
	cout << n - ans << endl;
	
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	ll mi=1LL<<60;
	for(i=-100;i<=100;i++) {
		ll tot=0;
		FOR(x,N) tot+=(A[x]-i)*(A[x]-i);
		mi=min(mi,tot);
	}
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;

static const int INF = 1LL << 61;
//static const int MAX_N = 100005;

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

    string s;
    cin >> s;
    int ans = 0;
    bool flg = 0;
    for (auto c : s) {
        if (flg) {
            if (c == 'g') ans++;
        } else {
            if (c == 'p') ans--;
        }
        flg = !flg;
    }

    cout << ans << endl;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<int>v;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(i>=1 and i<=9)
            cnt++;
        else if(i>=100 and i<=999)
            cnt++;
        else if(i>=10000 and i<=99999)
            cnt++;
    }
    cout<<cnt;

}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if(N == 1){
                Console.WriteLine("Hello World");
            }else{
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                Console.WriteLine(A+B);
            }
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13140
import collections
n = int(input())
v = list(map(int,input().split()))
a1 = []
a2 = []
for i in range(0,n,1):#スライスで絶対もっときれいにかけるなりねー
    if i%2==0:
        a1.append(v[i])
    if i%2==1:
        a2.append(v[i])

c1 = collections.Counter(a1)#配列を渡す
c2 = collections.Counter(a2)#配列を渡す
if c1.most_common()[0][0]!=c2.most_common()[0][0]:
    print(len(a1) - c1.most_common()[0][1] + len(a2) - c2.most_common()[0][1])#最も出現回数が多いものの出現回数
else:
    c12bannte = c1.most_common()[1][1] if len(c1)>1 else 0
    c22bannte = c2.most_common()[1][1] if len(c2)>1 else 0
    ans = min(len(a1) - c1.most_common()[0][1] + len(a2) - c22bannte,len(a1) - c12bannte + len(a2) - c2.most_common()[0][1])
    print(ans)

Measured memory_bytes: 99252
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n;cin >> n;vector<int> l(2 * n);
	rep(i, 2 * n) cin >> l[i];
	sort(l.begin(), l.end());
	int sum = 0;
	rep(i, n) sum += l[2 * i];
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define repn(i,x) for(int i=1;i<=x;i++)
ll f[405],r[405],rui[405][405][135];
int n,a[405],b[405],pos[405],pos2[405],t[405][405];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n;
	repn(i,n)cin>>a[i],pos[a[i]]=i;
	repn(i,n)cin>>b[i],pos2[b[i]]=i;
	f[0]=r[0]=1;
	repn(i,400)f[i]=f[i-1]*1LL*i%mod,r[i]=modpow(f[i],mod-2);
	repn(i,n)repn(j,n)repn(k,n)if(pos[k]<=i||pos2[k]<=j)t[i][j]++;
	repn(k,n/3)repn(x,n)repn(y,n){
		rui[x][y][k]=rui[x-1][y][k]+rui[x][y-1][k]-rui[x-1][y-1][k];
		if(x<pos[b[y]]&&y<pos2[a[x]]&&2*k<=t[x][y]&&t[x][y]<=3*k-1){
			rui[x][y][k]+=(rui[x-1][y-1][k-1]+(k==1))*r[3*k-3-t[x-1][y-1]]%mod*f[3*k-t[x][y]]%mod;
		}
		rui[x][y][k]%=mod;
	}
	ll ans=rui[n][n][n/3];
	repn(i,n)if(i%3!=0)ans=ans*1LL*i%mod;
	cout<<(ans%mod+mod)%mod<<endl;
}


Measured memory_bytes: 171904
n,l = gets.split(" ").map(&:to_i)
apples = (0...n).map{ |a| a + l }
taste = apples.inject(:+)
bite = if apples.include?(0)
        0
       elsif taste > 0
        apples[0]
       else
        apples[n-1]
       end
print taste - bite

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	if(N==1) {
		if(A==B) cout<<1<<endl;
		else cout<<0<<endl;
	}
	else {
		if(A>B) {
			cout<<0<<endl;
		}
		else {
			ll X=A*(N-1)+B;
			ll Y=B*(N-1)+A;
			
			cout<<abs(X-Y)+1<<endl;
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string S;
        cin >> S;
        bool all9 = true;
        for (int i = 1; i < S.size(); ++i) {
            if (S[i] != '9') all9 = false;
        }
        if (all9) {
            cout << (S.size() - 1) * 9 + (S[0] - '0') << endl;
            return;
        }
        if (S.size() == 1) {
            cout << S << endl;
            return;
        }

        Int ans = (S[0] - '0' - 1) + (S.size() - 1) * 9;
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int p;
    int q;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}
//構造体の.pを降順
int comp( const void *c1, const void *c2 )
{ data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.p;   /* b を基準とする */
  int tmp2 = test2.p;
    return tmp2 - tmp1;}




int main(){
    ll x,y;
    scanf("%lld%lld",&x,&y);
    ll sum=x;
    ll cnt=1;
    while(1){
        if(sum*2>y){
            printf("%lld",cnt);
            return 0;
        }else{
            sum*=2;
            cnt++;
        }
    }
}


Measured memory_bytes: 1728
#include <algorithm>
#include <iostream>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    string S;
    cin >> S;
    int res = 0;
    for (char ch : S) {
        res += int(ch - '0');
        res %= 9;
    }
    if (res == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
int N;
vector<int> g[maxn];
LL qpow(LL a, LL b)
{
    LL res = 1;
    a %= MOD;
    while(b)
    {
        if(b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
LL fact[maxn], fact_inv[maxn];
void preprocess()
{
    fact[0] = 1;
    for(int i = 1; i < maxn; i++)
        fact[i] = fact[i-1] * i % MOD;
    fact_inv[maxn-1] = qpow(fact[maxn-1], MOD - 2);
    for(int i = maxn - 2; i >= 0; i--)
        fact_inv[i] = fact_inv[i+1] * (i + 1) % MOD;
}
LL dp[maxn];
int sz[maxn];
void DFS1(int u, int fa)
{
    dp[u] = 1;
    sz[u] = 1;
    for(auto v : g[u])
    {
        if(v == fa)
            continue;
        DFS1(v, u);
        dp[u] = dp[u] * dp[v] % MOD * fact_inv[sz[v]] % MOD;
        sz[u] += sz[v];
    }
    dp[u] = dp[u] * fact[sz[u]-1] % MOD;
}
void DFS2(int u, int fa)
{
    for(auto v : g[u])
    {
        if(v == fa)
            continue;
        LL t = dp[u];
        dp[u] = dp[u] * fact_inv[N-1] % MOD * fact[N-sz[v]-1] % MOD * fact[sz[v]] % MOD;
        dp[u] = dp[u] * qpow(dp[v], MOD - 2) % MOD;
        dp[v] = dp[v] * fact_inv[sz[v]-1] % MOD * fact[N-1] % MOD * fact_inv[N-sz[v]] % MOD;
        dp[v] = dp[v] * dp[u] % MOD;
        dp[u] = t;
        DFS2(v, u);
    }
}
int main()
{
    preprocess();
    scanf("%d", &N);
    for(int i = 1; i <= N - 1; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    DFS1(1, -1);
    DFS2(1, -1);
    for(int i = 1; i <= N; i++)
        printf("%lld\n", dp[i]);
    return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
string s;
void solve() {
    cin >> n >> s;

    int ans = 0;
    rep(i, n) if (s.substr(i, 3) == "ABC") ++ans;

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
public class Main{
	static HashMap<Integer,Integer>[] map;
	static boolean[] r;
	static int[] t;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		map=new HashMap[n+1];
		r=new boolean[n+1];
		t=new int[n+1];
		for(int i = 0; i<=n; i++){
			map[i]=new HashMap<>();
		}
		for(int i = 0; i<m; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			int d = sc.nextInt();
			map[l].put(r,d);
			map[r].put(l,-d);
		}
		for(int i = 1; i<=n; i++){
			if(!r[i]){
				if(!dfs(i,0)){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
	static boolean dfs(int i,int j){
		if(r[i]){
			return t[i]==j;
		}
		r[i]=true;
		t[i]=j;
		for(int k:map[i].keySet()){
			if(!dfs(k,j+map[i].get(k))){
					return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 201696
#include <cstdio>

using namespace std;

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

int main( void )
{

	while( 1 )
	{

		int point_a = 0;
		int point_b = 0;

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

		if( n == 0 )
			break;

		FOR( i, n )
		{
			int a, b;
			scanf( "%d %d", &a, &b );

			if( a > b )
			{
				// AÌ¿
				point_a += a+b;
			}
			else
			{
				if( a == b )
				{
					// ø«ª¯
					point_a += a;
					point_b += b;
				}
				else
				{
					// BÌ¿
					point_b += a+b;
				}
			}

		}

		// Ê
		printf( "%d %d\n", point_a, point_b );

	}

	return 0;
}

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


int main() {
 string a;
 cin >> a;
 int b=0;
 int c=a.size();
 for(int i = 0;i<c;i++){
   int ss = a.at(i) - '0';
   b+=ss;
 }
  if(b%9==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3656
/*package whatever //do not write package name here */

import java.util.*;

class Main {
	public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n%1000==0)
System.out.println("0");
else
System.out.println(1000-(n%1000));
	}
}

Measured memory_bytes: 35580
n = int(input())
a = list(map(int, input().split()))
flug = True
for i in range(len(a)):
    if a[i] % 2 == 0:
        if not (a[i] % 5 == 0 or a[i] % 3 == 0):
            flug = False
            break
if flug:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import sys
H, W = map(int, input().split())

lst = [['.'] * (W+2)]
lst += [['.'] + list(input()) + ['.'] for _ in range(H)]
lst += [['.'] * (W+2)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if lst[i][j] == '#':
            if lst[i+1][j] == '#' or lst[i-1][j] == '#' or lst[i][j+1] == '#' or lst[i][j-1] == '#':
                pass
            else:
                print ('No')
                sys.exit()

print ('Yes')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  LL n,l;
  cin >> n >> l;
  vector<LL> a(n);
  REP(i,n) cin >> a[i];
  LL mlen=-1,mind=-1;
  REP(i,n-1) if(mlen < a[i]+a[i+1]){
    mlen=a[i]+a[i+1];
    mind=i+1;
  }
  if(mlen<l) cout << "Impossible" << endl;
  else{
    cout << "Possible" << endl;
    for(LL i=1;i<mind;++i) cout << i << endl;
    for(LL i=n-1;i>=mind;--i) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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 main(){
ll n,cnt=0,m;
cin>>n>>m;
vector<ll> h(n);
vector<vector<ll>> g(n);

rep(i,n)cin>>h[i];
rep(i,m){
  ll a,b;
  cin>>a>>b;a--;b--;
  g[a].push_back(b);
  g[b].push_back(a);
}
vector<int> ans(n);
rep(i,n){
  int ok=1;
  if(g[i].size()==0){
    cnt++;
    //cout<<"e"<<i<<endl;
    continue;
  }
  for(auto u:g[i]){
    if(h[u]>=h[i]){
      ok=0;break;
    }
  }
  if(ok){cnt++;}
}

cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 10356
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

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

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

const int MOD = 1e9 + 7;

int Comb(int n, int k) {
    int p = 1, q = 1;
    k = min(k, n - k);
    for (int i = 1; i <= k; i++) {
        p = 1LL * p * (n--) % MOD, q = 1LL * q * i % MOD;
    }
    return 1LL * p * powmod(q, MOD - 2, MOD) % MOD;
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    int res = 1;
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) m /= i, cnt++;
            res = 1LL * res * Comb(n + cnt - 1, n - 1) % MOD;
        }
    }
    if (m > 1) res = 1LL * res * n % MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N;
string S;
vector<int> R, G, B;

int main(){
	cin >> N;
	cin >> S;
//--------------------------------------------------------
	ll cnt = 0;
	vector<int> B2(N);
	rep(i,N){
		if(S[i]=='R') R.pb(i);
		else if(S[i]=='G') G.pb(i);
		else{
			B.pb(i);
			cnt++;
		}
		B2[i] = cnt;
	}
	//cout << endl;

	/*
	rep(i,N){
		cout << B2[i] << " ";
	}cout << endl;
	*/
	/*
	rep(i,G.size()){
		cout << G[i] << " ";
	}
	cout << endl;
	cout << G.size() << endl;
	*/

	ll total = 0;
	rep(i,R.size()){
		rep(j,G.size()){
			if(R[i] < G[j]){
				//cout << "R:" << R[i] << " G:" << G[j] << endl;
				int d = G[j] - R[i];

				int aim = R[i] - d;
				if(aim >= 0){
					total += B2[R[i]]-B2[aim];
					if(aim>0) total += B2[aim-1];
				}else{
					total += B2[R[i]];
				}
				//cout << "1:" << total << endl;

				int aim2 = G[j] + d;
				//cout << "aim2:" << aim2 << endl;
				if(aim2<N){
					total += B2[aim2-1]-B2[G[j]];
					total += B2[N-1]-B2[aim2];
				}else{
					total += B2[N-1]-B2[G[j]];
				}
				//cout << "2:" << total << endl;

				if((R[i]+G[j])%2==0){
					int aim3 = (R[i]+G[j])/2;
					total += B2[aim3-1]-B2[R[i]];
					total += B2[G[j]]-B2[aim3];
				}else{
					total += B2[G[j]]-B2[R[i]];
				}
				//cout << "3:" << total << endl;
		
			}else{
				//cout << "R:" << R[i] << " G:" << G[j] << endl;
				int d = R[i] - G[j];

				int aim = G[j] - d;
				if(aim >= 0){
					total += B2[G[j]]-B2[aim];
					if(aim>0) total += B2[aim-1];
				}else{
					total += B2[G[j]];
				}
				//cout << "1:" << total << endl;

				int aim2 = R[i] + d;
				if(aim2<N){
					total += B2[aim2-1]-B2[R[i]];
					total += B2[N-1]-B2[aim2];
				}else{
					total += B2[N-1]-B2[R[i]];
				}
				//cout << "2:" << total << endl;

				if((R[i]+G[j])%2==0){
					int aim3 = (R[i]+G[j])/2;
					total += B2[aim3-1]-B2[G[j]];
					total += B2[R[i]]-B2[aim3];
				}else{
					total += B2[R[i]]-B2[G[j]];
				}
				//cout << "3:" << total << endl;
			
			}
		}
	}	
//--------------------------------------------------------
	cout << total << endl;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int, int > S; 


bool comp(S lhs, S rhs) {
	return lhs.first > rhs.first;
}

int main()
{
	int n,m;cin >> n >> m;
	vector<int> A(n);
	rep(i, n)cin>>A[i];
	vector<pair<int , int>> BC(m);
	rep(i, m)
	{
		int b, c; cin >> b >> c;
		BC[i] = make_pair(c, b);
	}

	sort(A.begin(),A.end());
	sort(BC.begin(),BC.end(),comp);

	//rep(i,BC.size())cout<<BC[i].first;
	
	
	rep(i,A.size())
	{
		if(A[i]<BC[0].first)
		{
			A[i]=BC[0].first;
			BC[0].second--;
		}
		else break;

		//cout<<BC[0].second<<endl;
		if(BC[0].second==0)
		{
			BC.erase(BC.begin());
		}
		if(BC.size()==0)break;
	}

	ll sum=0;
	rep(i,A.size())sum+=A[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>

using namespace std;
typedef pair<char, int> P;
typedef long long ll;

int marked_ancestor[100000];
int n, q;
int ancestor[100000] = {}, ismarked[100000] = {}, is_doubleused[100000] = {};
vector<P> outlog;

//Union_Find??¨???
struct UnionFind {

	int size;
	std::vector<int> root, high;

	UnionFind() = default;

	//??????????????????????????????
	UnionFind(int vsize) {

		root.resize(vsize), high.resize(vsize);
		for (auto i = 0; i < root.size(); i++) {
			root[i] = i, high[i] = 0;
		}

	}

	UnionFind& operator= (UnionFind &ru) {

		root.resize(ru.root.size()), high.resize(ru.high.size());
		for (auto i = 0; i < root.size(); i++) {
			root[i] = i, high[i] = 0;
		}

	}

	int getroot(int vx) {

		if (vx == root[vx])return vx;
		return root[vx] = getroot(root[vx]);

	}

	void unite(int vx, int vy) {

		int x = getroot(vx), y = getroot(vy);
		if (x == y)return;
		root[y] = x;

	}

	bool issame(int vx, int vy) {

		return getroot(vx) == getroot(vy);

	}

};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> n >> q, n + q) {
		UnionFind uf(n);
		ancestor[0] = 0;
		for (int i = 1; i < n; i++) {
			cin >> ancestor[i], ancestor[i]--;
		}
		ismarked[0] = true;
		for (int i = 0; i < q; i++) {
			char c;
			int a;
			cin >> c >> a;
			a--;
			if (c == 'M' && !is_doubleused[a]) {
				ismarked[a] = true;
				is_doubleused[a] = true;
				outlog.push_back(make_pair(c, a));
			}
			else if(c == 'Q') {
				outlog.push_back(make_pair(c, a));
			}
		}
		for (int i = 0; i < n; i++) {
			if (!ismarked[i]) {
				uf.unite(ancestor[i], i);
			}
		}
		ll ans = 0;
		for (int i = outlog.size() - 1; i >= 0; i--) {
			int tmp = outlog[i].second;
			if (outlog[i].first == 'M')uf.unite(ancestor[tmp], tmp);
			else {
				ans += (uf.getroot(tmp) + 1);
			}
		}
		cout << ans << "\n";
		for (int i = 0; i < n; i++)ancestor[i] = 0, marked_ancestor[i] = 0, ismarked[i] = false,is_doubleused[i] = false;
		outlog.clear();
	}
	return 0;
}

Measured memory_bytes: 6152
#include<algorithm>
#include<iostream>
#include<cstring>
#include<climits>
#include<cstdio>
using namespace std;
int f[15][10005];
int r,c,ans=0;
void dfs(int row)
{
    if(row==r+1)
    {
        int cont1=0;  
        for(int i=1;i<=c;i++)
        {  
            int cont2=0;
            for(int j=1;j<=r;j++)if(f[j][i]==1)cont2++;  
            cont1+=max(cont2,r-cont2);  
        }  
        ans=max(ans,cont1);  
        return ;
    }
    dfs(row+1);
    for(int i=1;i<=c;i++)
    if(f[row][i])f[row][i]=0;
    else f[row][i]=1;
    dfs(row+1);
}
int main()
{   
    while(1)
    {
        ans=0;
        scanf("%d%d",&r,&c);
        if(r==0&&c==0)break;
        for(int i=1;i<=r;i++)
            for(int j=1;j<=c;j++)
                scanf("%d",&f[i][j]);
        dfs(1);
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
  int N;
  cin>>N;
  map<int,int> m;
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    int t = i;
    for(int j = 2; j<=t; j++) {
      while(t%j==0){
        m[j]++;
        if(m[j]==2){
          int k = 0;
          for(auto x:m){
            if(x.first==j)continue;
            if(x.second>=24)ans++;
            if(x.second>=4)k++;
          }
          ans += (k*(k-1))/2;
        }
        if(m[j]==4) {
          int k=0,s=0;
          for(auto x:m){
            if(x.first==j)continue;
            if(x.second>=14)ans++;
            if(x.second>=4) k++;
            if(x.second>=2)s++;
          }
          ans += k*(s-1);
        }
        if(m[j]==14){
          for(auto x:m){
            if(x.first==j)continue;
            if(x.second>=4)ans++;
          }
        }
        if(m[j]==24){
          for(auto x:m){
            if(x.first==j)continue;
            if(x.second>=2)ans++;
          }
        }
        if(m[j]==74)ans++;
        t/=j;
      }
    }
  }
  cout<<ans <<endl;
}
    
    

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
 
    int N, Q;
    scanf("%d %d", &N, &Q);
 
    int i, j, cnt=0, flag, l, r, acnum[N], accnt[N];
    char S[N];
 
    scanf("%s", S);
 
    cnt = 0;
    for (i=0; i<N; i++){
        accnt[i] = cnt;
        if (S[i] == 'A' && S[i+1] == 'C'){
            cnt++;
        }
    }
 
    for(i=0; i<Q; i++){
        scanf("%d %d", &l, &r);
        printf("%d\n",accnt[r-1]-accnt[l-1]);
    }
 
    return 0;
}

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

using namespace std;

const int MAX = 1000;
int H,W,h,w;
int mass[501][501];

int main() {
  cin >> H >> W >> h >> w;

  if(H % h == 0 && W % w == 0) {
    cout << "No" <<endl;
    return 0;
  }

  cout <<"Yes"<<endl;
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      if(i % h == 0 && j % w == 0) {
	mass[i][j] = -MAX * (w*h-1) - 1;
      }
      else mass[i][j] = MAX;
    }
  }
  
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      cout << mass[i][j] <<" ";
    }
    cout <<endl;
  }
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
  ll ans=1;
  rep(i,n){
    ans*=2;
  }
  return ans;
}

int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  //##########################################################CODE_START
  int n;cin>>n;
  vector<int> A(n+1);
  rep(i,n){
    cin>>A[i+1];
  }
  ll ans=0;
  rep(i,n){
    if(A[A[i+1]]==i+1)ans++;
  }
  cout<<ans/2<<endl;
  
  
  
  
  //##########################################################CODE_END
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(){
  vector<int> p(3);
  cin >> p[0] >> p[1] >> p[2];
  sort(p.begin(), p.end());
  cout << p[0] + p[1] << endl;
  return 0;
}

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

using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int total = 0;
  for (int i = 0; i < n; i++) {
    int cm;
    cin >> cm;
    if (cm >= k) total++;
  }
  cout << total << endl;

  return 0;
}

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

const int maxn(1e5 + 5);

int n, a[maxn];
ll sum, cur, x, v[maxn];

int main() {
	int i;
	scanf("%d", &n);
	if (n == 1) return puts("YES"), 0;
	for (i = 1; i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
	cur = (ll)n * (n + 1) / 2;
	if (sum % cur) return puts("NO"), 0;
	sum /= cur, a[0] = a[n], cur = 0;
	for (i = 1; i <= n; ++i) {
		if ((a[i - 1] + sum - a[i]) % n) return puts("NO"), 0;
		x = (a[i - 1] + sum - a[i]) / n;
		if (x < 0) return puts("NO"), 0;
		cur += x;
	}
	if (cur != sum) return puts("NO"), 0;
    return puts("YES"), 0;
}

Measured memory_bytes: 640
h,w = map(int, input().split())
g = []
for _ in range(h):
  g.append(input())
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
u = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if g[i][j] == '.':
      if j == 0:
        l[i][j] = 1
      else:
        l[i][j] = l[i][j-1]+1
      if i == 0:
        u[i][j] = 1
      else:
        u[i][j] = u[i-1][j]+1
for i in reversed(range(h)):
  for j in reversed(range(w)):
    if g[i][j] == '.':
      if j == w-1:
        r[i][j] = 1
      else:
        r[i][j] = r[i][j+1]+1
      if i == h-1:
        d[i][j] = 1
      else:
        d[i][j] = d[i+1][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    ans = max(l[i][j]+r[i][j]+u[i][j]+d[i][j]-3,ans)
print(ans)

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

int main() {
    long long int n, m;
    cin >> n >> m;
    long long int res = n * m;
    if(n != 1) res -= 2 * m;
    if(m != 1) res -= 2 * n;
    res += 4 * (n != 1) * (m != 1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256