akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include <string>
using namespace std;
/*int main() {
    int n, i, j, k,c,d,e,f;
    c = 0;
    d = 0;
    char a[1000], b[1000];
    cin >> n;
    for (i = 0; i < n; i++) {
        k = 0;
        e = 0;
        f = 0;
        for (j = 0; j < 1000; j++) {
            scanf_s("%c", &a[j]);
            if (a[j] == ' ')break;
            e++;
        }
        for (j = 0; j < 1000; j++) {
            scanf_s("%c", &b[j]);
            if (b[j] == '\n')break;
            f++;
        }
        if (e < f) {
            for (j = 0; j < e; j++) {
                if (a[j] < b[j]) {
                    c += 3;
                    k = 1;
                    break;
                }
                if (a[j] > b[j]) {
                    d += 3;
                    k = 1;
                    break;
                }
            }
            if (k == 0) {
                c += 3;
            }
        }
        if (e >= f) {
            for (j = 0; j < f; j++) {
                if (a[j] < b[j]) {
                    c += 3;
                    k = 1;
                    break;
                }
                if (a[j] > b[j]) {
                    d += 3;
                    k = 1;
                    break;
                }
            }
            if (k == 0) {
                if (e > f) {
                    d += 3;
                }
                else {
                    c++; 
                    d++;
                }
            }
        }
         
    }
    cout << d << " " << c << endl;
    return 0;
}
*/
/*int main() {
    string a, b, c;
    int n, i, j,s,t,p,q;
    p = 0; q = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> c;
        s = c.find(" ");
        a = c.substr(0, s);
        b = c.substr(s + 1);
        if (a > b) {
            p += 3;
        }
        if (a < b) {
            q += 3;
        }
        if (a == b) {
            p += 1;
            q += 1;
        }
    }
    cout << p << ' '<< q << endl;
    return 0;
}
*/
int main() {
    string a, b, c;
    int n, i, j, s, t, p, q;
    p = 0; q = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> a>>b;
        if (a > b) {
            p += 3;
        }
        if (a < b) {
            q += 3;
        }
        if (a == b) {
            p += 1;
            q += 1;
        }
    }
    cout << p << ' ' << q << endl;
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define int long long
typedef long long ll;
using namespace std;
queue<int> q;
int i;
void mutu(int a,int b){
	if(a==0&&b==0){
		q.push(1);
		return ;
	}
	if(a+1==b){
		for(int i=a*b/2+1;i<=b*(b+1)/2;i++){
			q.push(i);
		}
		mutu(i-1,b-1);
		return ;
	}
	else{
		q.push((a+1)*(a+2)/2-b);
		mutu(a-1,b);
	}
}
signed main(){
	int a;
	i=1;
	cin>>a;
	for(;(i+1)*i/2<=a;i++){
		if(i*(i+1)/2==a){
			cout<<"Yes"<<endl<<i+1;
			mutu(i-1,i);
			f(j,a*2){
				if(j%i==0)cout<<endl<<i;
				cout<<" "<<q.front();
				q.pop();
			}
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 7680
X = int(input())
sosu = "Yes"

while True:
  if X == 2:
    break
  for i in range(3, X):
    #print("i is " + str(i))
    if X % i == 0:
      sosu = "No"
      break
  if sosu == "Yes":
    break
  else:
    sosu = "Yes"
    X = X + 1

print(X)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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 int INF = 1<<30;

int main(){
    int n, m, cnt = 0;
    cin >> n >> m;
    int swi[20][20] = {0};
    int P[20];
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int s;
            cin >> s;
            swi[i][--s] = 1;
        }
    }
    for(int i = 0; i < m; i++){
        cin >> P[i];
    }
    for(int bit = 0; bit < 1<<n; bit++){
        int flag = 1;
        int on[20] = {0};
        for(int i = 0; i < n; i++){
            if(bit & 1<<i){
                on[i]++;
            }
        }
        for(int i = 0; i < m; i++){
            int x = 0;
            for(int j = 0; j < n; j++){
                if(on[j] && swi[i][j]) x++;
            }
            if(x % 2 != P[i]){
                flag = 0;
                break;
            }
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
H,W = map(int,input().split())
 
table = [[0]*(W+1) for i in range(H+1)]
 
for row in range(H):
    work = list(map(int,input().split())) 
    for col in range(W):
        table[row][col] = work[col]
 
 
for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]
 
 
for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]
 
 
for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6224
#include<stdio.h>

#define LIM 1000000000000000000

int main(){
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    
    if (k%2==0){
        if(a-b>LIM){
            printf("THIS PATTERN IS NOT COVERED");
        }else{
            printf("%d\n", a-b);
        }
    }else{
        if (b-a>LIM){
            printf("WHAT A SLOPPY TEST!");
        }else{
            printf("%d\n", b-a);
        }
    }
    
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stack>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char slope;
	int i = 0;
	int sum = 0;
	while (cin >> slope){
		if (slope == '\\'){
			S1.push(i);
		}
		else if (slope == '/' &&S1.size() > 0){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
		i++;
	}
	vector<int> ans;
	int t = 0;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++){
		cout << " ";
		t += ans[i];
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
*/
#define ll long long                   
#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 
#define IOS ios_base::sync_with_stdio(0);

using namespace std;                    

const int maxn=4e5+123,inf=1e9,mod=1e9+7;

vector<int> g[maxn];
int n,m,col[maxn];
map<int,int> used[maxn];
string s;
void dfs(int v){
	if(col[v]!=0)
		return;
	col[v]=1;
	for(auto to:g[v]){
		if(col[to]==1){
			cout<<"Yes";
			exit(0);
		}
		dfs(to);
	}
	col[v]=2;
}
int main(){
    cin>>n>>m;
    cin>>s;
    for(int i=0;i<m;i++){
    	int v,u;
    	cin>>v>>u; 
    	--v,--u;   
    	if( used[v][u] )
    		continue;
    	used[v][u]=1;
    	used[u][v]=1;
    	if(s[v]==s[u]){
    		if(s[v]=='B'){      
    			g[v+v+1].pb(u+u);
    			g[u+u+1].pb(v+v);
    		}else{
    			g[v+v].pb(u+u+1);
    			g[u+u].pb(v+v+1);
    		}
    	}else{
    		if(s[v]=='A'){
    			g[v+v+1].pb(u+u+1);
    			g[u+u].pb(v+v);
    		}else{
    			g[v+v].pb(u+u);
    			g[u+u+1].pb(v+v+1);
    		}
    	}
    }
    for(int i=0;i<maxn;i++)
    	if(col[i]==0)
    		dfs(i);
    cout<<"No";
	return 0;
}


Measured memory_bytes: 57860
## coding: UTF-8
N,M = map(int,input().split())
H = list(map(int,input().split()))

'''
path = []
for i in range(M):
    path.append(list(map(int,input().split())))
'''
path = [list(map(int,input().split())) for i in range(M)]  # 二次元配列入力　二次元マップみたいな入力のとき

'''
l = [] 
for i in range(N):
    l.append([0] * N + [H[i]])
'''


highest = [0] + [1] * N
#print(highest)
#print(H)
for i in range(M):
    #print('path[i][0] = {}, path[i][1] = {}'.format(path[i][0], path[i][1]))
    #print('H[path[i][0]-1]:{}, H[path[i][1]-1]:{}'.format(H[path[i][0]-1], H[path[i][1]-1]))
    pa = path[i]
    p = pa[1]-1
    q = pa[0]-1
    x = H[p]
    y = H[q]
    if( x >= y ):
        #print('deny at {}'.format(path[i][0]))
        highest[q+1] = 0
    if(  x <= y  ):
        #print('deny at {}'.format(path[i][1]))
        highest[p+1] = 0
    #print('highest:{}'.format(highest))

print(sum(highest))

'''
for i in range(M):
    print('path[i][0] = Ai = {}, path[i][1] = Bi = {}'.format(path[i][0], path[i][1]))
    l[ path[i][0]-1 ][ path[i][1]-1 ] = H[path[i][1]-1]
    l[ path[i][1]-1 ][ path[i][0]-1 ] = H[path[i][0]-1]
    print(l)
'''



'''
m_neigh = []
for i in range(N):
    print(l[i][:N])
    m_neigh.append(  max(l[i][:N] )  )
    print(m_neigh)
'''
'''
cnt = 0
for i in range(N):
    
'''

Measured memory_bytes: 94100
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, a[1001];
    int ans;

    while (true) {
        cin >> n;
        if (!n) { break; }

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

        ans = 1e8;

        for (int i = 0; i < n-1; i++) {
            for (int j = i+1; j < n; j++) {
                ans = min(ans, abs(a[i] - a[j]));
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

// modulo integer
// M: modulo number
// * M < 2^31
// * M must be prime if you use division
template <int64_t M>
class mint {
public:
        mint() :v(-1) {}
        mint(int n) : v(n % M) {}

        int64_t get() const { return v; }

        mint &operator+=(const mint &r) {
                v = (v + r.v) % M;
                return *this;
        }
        mint &operator-=(const mint &r) {
                v = (v - r.v + M) % M;
                return *this;
        }
        mint &operator*=(const mint &r) {
                v = (v * r.v) % M;
                return *this;
        }
        mint &operator/=(const mint &r) {
                return (*this) *= r.inv();
        }

        mint pow(int r) const {
                mint k = *this, ret = 1;
                while (r > 0) {
                        if (r % 2 != 0) ret *= k;
                        r /= 2;
                        k *= k;
                }
                return ret;
        }

        mint inv() const {
                return pow(M - 2);
        }

private:
        int64_t v;
};

template <int64_t M>
inline mint<M> operator+(mint<M> l, const mint<M> &r) {
        return l += r;
}

template <int64_t M>
inline mint<M> operator-(mint<M> l, const mint<M> &r) {
        return l -= r;
}

template <int64_t M>
inline mint<M> operator*(mint<M> l, const mint<M> &r) {
        return l *= r;
}

template <int64_t M>
inline mint<M> operator/(mint<M> l, const mint<M> &r) {
        return l /= r;
}

template <int64_t M>
inline ostream &operator<<(ostream &os, const mint<M> &r) {
        return os << r.get();
}

typedef mint<1000000007> MINT;

int n, m;
MINT tbl[301][301][301];

MINT solve(int s, int w, int r)
{
    // cout << s << " " << w << " " << r << endl;

    if (r == 0) {
        return s == n ? 1 : 0;
    }

    int u = n - s - w;

    MINT &ret = tbl[s][w][r];
    if (ret.get() >= 0)
        return ret;

    ret = 0;
    ret += solve(s + w, 0, r - 1) * MINT(s);
    if (w > 0) ret += solve(s, w, r - 1) * MINT(w);
    if (u > 0) ret += solve(s, w + 1, r - 1) * MINT(u);

    return ret;
}

int main()
{
    cin.tie(0);

    cin >> n >> m;
    cout << solve(1, 0, m) << endl;

    return 0;
}

Measured memory_bytes: 213376
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int s_size = s.size();

    string a = "000000000000000000000000000";
    for(int i = 0; i < s_size; i++){
        int idx = (int)(s[i] - 'a');
        if (a[idx] == '0') {
            a[idx] = t[i];
        }else{
            if (a[idx] != t[i]){
                puts("No");
                return 0;
            }
        }
    }
    a = "000000000000000000000000000";
    for(int i = 0; i < s_size; i++){
        int idx = (int)(t[i] - 'a');
        if (a[idx] == '0') {
            a[idx] = s[i];
        }else{
            if (a[idx] != s[i]){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;



ll N, M;

int main(){
	cin >> N >> M;
	
	vector<int> s(M);
	for ( int i = 0; i < M; i++ ){
		int k;
		cin >> k;
		
		for ( int j = 0; j < k; j++ ){
			int si;
			cin >> si;
			s[i] |= (1<<(si-1));
		}
	}
	
	vector<int> p(N);
	for ( int i = 0; i < M; i++ )
		cin >> p[i];
	
	int result = 0;
	for ( int i = 0; i < (1<<N); i++ ){
		bool b = true;
		for ( int j = 0; j < M; j++ ){
			if ( __builtin_popcount( s[j] & i ) % 2 != p[j] )
				b = false;
		}
		if ( b ){
			//cout << i << endl;
			result++;
		}
	}
	
	cout << result << endl;
	return 0;
}



Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x = I()
    print(8-((x//200)-2))
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main(void){
    long n,d,ans=0;
    cin >> n >> d;
    long x[n], y[n];
    rep(i,n) cin >> x[i] >> y[i];
    rep(i,n){
        if(x[i]*x[i]+y[i]*y[i]<=d*d) ans++;
    }
    cout << ans << endl;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int n=s.size();
string ans="YES";
map<int,int> cnt;
rep(i,n){
    cnt[s[i]]++;
}

if(n==2){
    if((cnt.count('a')&&cnt.count('b'))||
       (cnt.count('a')&&cnt.count('c'))||
       (cnt.count('c')&&cnt.count('b'))){

       }
    else{
        ans="NO";
    }
}
else if(n>=3){
    int num=floor(n/3);
    if((cnt['a']==num||cnt['a']==num+1)&&
       (cnt['b']==num||cnt['b']==num+1)&&
       (cnt['c']==num||cnt['c']==num+1)){

       }
    else{
        ans="NO";
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000

int main(){
//入力
string s;
int ans=0;

    cin >> s ;
    //部分文字列の開始位置指定
    for(int i=0;i<s.length();i++){
        //ACGT文字列であるような終了文字までループ
        for(int j=i;j<s.length();j++){
            if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T') ans=max(ans,j-i+1);
            else break;
        }
    }

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

Measured memory_bytes: 3556
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

vals = []
for _ in range(M):
    i, j, v = map(int, input().split())
    vals.append( a[i - 1] + b[j - 1] - v)

vals.append(min(a) + min(b))
print(min(vals))

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  rep(i,s.size()){cout<<"x";}
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 1000

int SearchRow(char x[], char y[])
{
    int m, n, i, j;
    int c[N + 1][N + 1];
    m = strlen(x);
    n = strlen(y);
    for (i = 0; i <= m; i++)    c[i][0] = 0;
    for (j = 1; j <= n; j++)    c[0][j] = 0;
    for (i = 1; i <= m; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (x[i - 1] == y[j - 1])
            c[i][j] = c[i - 1][j - 1] + 1;
            else if (c[i - 1][j] >= c[i][j - 1])
            c[i][j] = c[i - 1][j];
            else
            c[i][j] = c[i][j - 1];
        }
    }
    return c[m][n];
}

int main()
{
    int n, i;
    char a[N], b[N];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%s", a);
        scanf("%s", b);
        printf("%d\n", SearchRow(a, b));
    }
    return 0;
}


Measured memory_bytes: 5660
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
const int maxn = 200005;
struct dsu{
	vector<int> fa , sz;
	dsu(int _n){
		fa.resize(_n+1) , sz.resize(_n+1);
		for(int i=0 ; i<=_n ; ++i){
			fa[i] = i;
			sz[i] = 1;
		}
	}
	void resize(int _n){
		fa.resize(_n+1) , sz.resize(_n+1);
		for(int i=0 ; i<=_n ; ++i){
			fa[i] = i;
			sz[i] = 1;
		}
	}
	int Find(int _x){
		if(_x == fa[_x]) return _x;
		return fa[_x] = Find(fa[_x]);
	}
	void Union(int _a, int _b){
		_a = Find(_a) , _b = Find(_b);
		if(_a == _b) return;
		if(sz[_a] < sz[_b]) swap(_a , _b);
		fa[_b] = _a;
		sz[_a] += sz[_b];
	}
	
};
dsu d(maxn);
int ans[maxn] , pos[maxn] , x[maxn] , y[maxn];
int main(){
	int n;  cin >> n ;
	for(int i=0 ; i<n ; ++i){
		cin >> x[i] >> y[x[i]];
		pos[x[i]] = i;
	}
	stack<pii , vector<pii> > stk;
	for(int i=1 ; i<=n ; ++i){
		if(stk.empty() || stk.top().S>y[i]){
			stk.push({i,y[i]});
			continue;
		}
		pii TOP = stk.top();
		while(stk.size() && stk.top().S < y[i]) d.Union(stk.top().F , i) , stk.pop();
		stk.push(TOP);
	}
	for(int i=1 ; i<=n ; ++i){
		int fa = d.Find(i); // father of i
		int sz = d.sz[fa]; // size of x
		ans[pos[i]] = sz;
	}
	for(int i=0 ; i<n ; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 8100
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m,q;
char a[2005][2005];
int s1[2005][2005],s2[2005][2005],s3[2005][2005];
int main()
{
	int i,j;cin>>n>>m>>q;rep(i,n)rep(j,m)cin>>a[i][j];
	rep(i,n)rep(j,m)s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+(a[i][j]=='1');
	rep(i,n)rep(j,m)s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]-(a[i][j]=='1'&&a[i-1][j]=='1');
	rep(i,n)rep(j,m)s3[i][j]=s3[i-1][j]+s3[i][j-1]-s3[i-1][j-1]-(a[i][j]=='1'&&a[i][j-1]=='1');
	while(q--)
	{
		int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
		cout<<s1[x2][y2]-s1[x1-1][y2]-s1[x2][y1-1]+s1[x1-1][y1-1]+s2[x2][y2]-s2[x1][y2]-s2[x2][y1-1]+s2[x1][y1-1]+s3[x2][y2]-s3[x1-1][y2]-s3[x2][y1]+s3[x1-1][y1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 52864
import java.util.*;

public class Main {
    static final long MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        int[] sums = new int[26];
        for (char c : arr) {
            sums[c - 'a']++;
        }
        long total = 1;
        for (int i = 0; i < 26; i++) {
            total *= sums[i] + 1;
            total %= MOD;
        }
        total = (total - 1 + MOD) % MOD;
       System.out.println(total);
    }
}


Measured memory_bytes: 25948
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def solve():
    n = getN()
    if n == 0:
        print(0)
        return
    idx = 0
    pos = True
    ans = []
    while(n != 0):
        if n % 2 == 0:
            ans.append("0")
        else:
            ans.append("1")
            if pos:
                n -= 1
            else:
                n += 1

        n //= 2
        pos = not pos

    ans.reverse()
    print("".join(ans))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int MAX = 10000002;
const int mod = 1e9+7;
const int inf = 2e18;

bool v[MAX];
int len, sp[MAX];
int divcnt[MAX];

void Sieve(){
	for (int i = 2; i < MAX; i += 2)	sp[i] = 2;//even numbers have smallest prime factor 2
	for (int i = 3; i < MAX; i += 2){
		if (!v[i]){
			sp[i] = i;
			for (int j = i; (j*i) < MAX; j += 2){
				if (!v[j*i])	v[j*i] = true, sp[j*i] = i;
			}
		}
	}
}

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	Sieve();		
	// divcnt[1] = 1;
	// divcnt[2] = 2;
	// divcnt[3] = 2;

	int n;
	cin>>n;
	int sum = 0;
	for(int i=1;i<=n;i++)
	{	
		map<int,int> mp;
		int k = i;
		while(k>1)
		{
			mp[sp[k]]++;	
			k/=sp[k];
		}
		int ans = 1;
		for(auto it:mp)
		{
			ans*=(it.ss+1);
		}
		//divcnt[i] = ans;
		sum+=ans*i;	
	}	
	cout<<sum<<'\n';
	return 0;
}	

Measured memory_bytes: 91556
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back



int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n;
		cin>>n;
		double a[n];
		for(auto &x:a)
		{
			cin>>x;
		}
		double dp[n][3000];
		//dp[i][j] pob of getting j number of head at pos i
		memset(dp,0,sizeof(dp));
		dp[0][1]=a[0];
		dp[0][0]=(1-a[0]);
		for(int i=1;i<n;i++)
		{
			for(int j=0;j<=i+1;j++)
			{
				dp[i][j]+=dp[i-1][j]*(1-a[i]);
				if(j-1>=0)
					dp[i][j]+=dp[i-1][j-1]*a[i];
					
					
			}
		}
		double ans=0;
		for(int i=n/2+1;i<=n;i++)
		{
			ans+=dp[n-1][i];
		}
		cout<<setprecision(9)<<ans<<'\n';
	}
		
}


Measured memory_bytes: 74068
from collections import deque

ss = input()
q = int(input())
s = deque()

for i in range(len(ss)) :
  s.append(ss[i])

r = 0
for i in range(q) :
  t = list(map(str,input().split()))
  if t[0] == '1' :
    r += 1
  if t[0] == '2' :
    f = t[1] ; c = t[2]
    if r%2 == 0 :
      if f == '1' :
        s.appendleft(c)
      else :
        s.append(c)
    else :
      if f == '2' :
        s.appendleft(c)
      else :
        s.append(c)
        
if r%2 == 1 :
  s.reverse()
  
print(*s,sep='')

Measured memory_bytes: 82492
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 5010;
const int MOD = 998244353;


int n;
string s;
long long ans = 0;
long long x = 0;
vector<pair<int, int> > v;

void check(int len)
{
    string t = "";
    for (int i = 0; i < len; i++) t += s[i];
    int ok = 1, x = 0;
    for (int i = 0; i < n; i++)
    {
        char c = t[i % len];
        if ((i / len) % 2 == 1) c = '0' + '1' - c;
        if (c > s[i])
        {
            ok = 0;
            break;
        }
        if (c < s[i])
        {
            break;
        }
    }
    for (int i = 0; i < len; i++)
    {
        char c = t[i % len];
        if ((i / len) % 2 == 1) c = '0' + '1' - c;
        x = (2 * x + c - '0') % MOD;
    }
    for (auto e : v) if (len % e.first == 0) x = (x + MOD - e.second) % MOD;
    x = (x + ok) % MOD;
    v.push_back({len, x});
    //cout << t << " " << x << "\n";
    ans = (ans - x * 2 * n % MOD + x * 2 * len % MOD + MOD) % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        x = (2 * x + s[i] - '0') % MOD;
    }
    x++;
    ans = x * 2 * n % MOD;
    //cout << ans << "\n";
    for (int i = 1; i <= n; i++)
    {
        if (n % i == 0 && (n / i) % 2 == 1)
        {
            check(i); cout << "\n";
        }
    }
    cout << ans;
}


Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(max({a+b, a-b, a*b}));
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, A, B int

	fmt.Scan(&N, &A, &B)

	if N*A > B {
		fmt.Print(B)
	} else if N*A < B {
		fmt.Print(N * A)
	} else {
		fmt.Print(B)
	}

}


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

int main()
{
  int n;
  cin>>n;
  string a,b,c;
  cin>>a>>b>>c;
  
  int cnt  = 0;
  for(int i=0;i<n;i++)
  {
    if(a[i] == b[i] && a[i] == c[i])
      continue;
    else if(a[i] == b[i])
      cnt++;
    else if(b[i] == c[i])
      cnt++;
    else if(a[i] == c[i])
      cnt++;
    else
      cnt+=2;
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 36

typedef struct {
  char mark;
  int value;
}Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void disply(Card *, int);
int isStable(Card *, Card *, int);

int main(){
  Card C1[M+1], C2[M+1];
  int i, N;

  scanf("%d",&N);

//文字列と数字をそれぞれ格納
  for(i = 0; i < N; i++){
    scanf(" %c%d", &C1[i].mark, &C1[i].value);
  }

  for(i = 0 ;i < N; i++) C2[i] = C1[i];

  BubbleSort(C1, N);
  disply(C1, N);
  printf("Stable\n");

  SelectionSort(C2, N);
  disply(C2, N);

  if( isStable(C1, C2, N) == 0 ) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

/*1 BubbleSort(C, N)
2   for i = 0 to N-1
3     for j = N-1 downto i+1
4       if C[j].value < C[j-1].value
5         C[j] と C[j-1] を交換*/
void BubbleSort(Card C1[], int N){
  int i, j;
  Card tmp;
  for(i = 0;i < N; i++){
    for(j = N-1; j > i; j--){
      if(C1[j].value < C1[j-1].value){
        tmp = C1[j];
        C1[j] = C1[j-1];
        C1[j-1] = tmp;
      }
    }
  }
}

/*7 SelectionSort(C, N)
8   for i = 0 to N-1
9     minj = i
10    for j = i to N-1
11      if C[j].value < C[minj].value
12        minj = j
13    C[i] と C[minj] を交換*/
void SelectionSort(Card C2[], int N){
  int i, j, minj;
  Card tmp;
  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(C2[j].value < C2[minj].value) minj = j;
    }
    tmp = C2[i];
    C2[i] = C2[minj];
    C2[minj] = tmp;
  }
}

void disply(Card C[], int N)
{
  int i;

  for( i = 0 ; i < N ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", C[i].mark, C[i].value);
  }
  printf("\n");
}

/*1 isStable(in, out)
2   for i = 0 to N-1
3     for j = i+1 to N-1
4       for a = 0 to N-1
5         for b = a+1 to N-1
6           if in[i] と in[j] の数字が等しい && in[i] == out[b] && in[j] == out[a]
7             return false
8 return true*/
int isStable(Card C1[], Card C2[], int N){
  int i;

  for(i = 0; i < N; i++)
  if(C1[i].mark != C2[i].mark ) return 1;
  return 0;
}



Measured memory_bytes: 2048
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

main = do
  [n, l] <- getIntList
  ss <- getNString n
  let ss' = map head ss
  putStrLn $ concat (sort ss')


Measured memory_bytes: 4740
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_VAL_MAX		105										// 最大値

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Val[D_VAL_MAX];									// 値リスト

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化
	memset(sc1Val, D_ON, sizeof(sc1Val));

	// X, 配列数 - 取得
	int liX, liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liX, &liACnt);

	// 値リスト - セット
	for (i = 0; i < liACnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);
		sc1Val[liVal] = D_OFF;
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 最小値 - 取得
	int liMin = INT_MAX;
	int liNum;
	for (i = 0; i < D_VAL_MAX; i++) {
		if (sc1Val[i] == D_ON) {
			int liDF = abs(liX - i);
			if (liMin > liDF) {
				liMin = liDF;
				liNum = i;
			}
		}
	}

	return liNum;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "Yes\n");
	}
	else {
		sprintf(lc1Buf, "No\n");
	}
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1700
import java.util.GregorianCalendar;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = {"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		while(true){
			int m = sc.nextInt();
			int d = sc.nextInt();
			if(m==0)break;
			GregorianCalendar g = new GregorianCalendar(2004, m-1, d);
			System.out.println(s[g.get(GregorianCalendar.DAY_OF_WEEK)]);
		}
	}
}

Measured memory_bytes: 17308
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#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 ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    int cnt[sz(s)] = {};

    rep(i,1,sz(s)){
	cnt[i] = cnt[i-1];
	if(s[i-1] == 'A' && s[i] == 'C')cnt[i]++;
    }

    rep(i,0,q){
	int l,r;
	cin >> l >> r;
	if(l == 1)P(cnt[r-1]);
	else P(cnt[r-1] - cnt[l-1]);
    }
    return  0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int n;
vector<vector<double>>v;
vector<double>w;
vector<int>pre;
double inf=1e7;
void solve(){
	for(int i=0;i<n;i++)w.push_back(inf);
	for(int i=0;i<n;i++)pre.push_back(-1);
	w[0]=0;
	int k=0;
	double res=0;
	while(k++!=n){
		// 选一个最小的 
		double mi=inf;
		int id=-1;
		for(int i=0;i<n;i++)
			if(w[i]!=-1&&w[i]<mi)mi=w[i],id=i;
		w[id]=-1;
		for(int i=0;i<n;i++){
			if(w[i]!=-1&&v[id][i]!=-1&&v[id][i]<w[i]){
				w[i]=v[id][i];
				pre[i]=id;
			}
		}
		res+=mi;
	}
	cout<<res<<endl;
}
int main(){
	int t;
	cin>>n;
	for(int i=0;i<n;i++){
		v.push_back(vector<double>());
		for(int j=0;j<n;j++){
			cin>>t;
			v[i].push_back(t);
		}
	}
	solve();	
	return 0;
}


Measured memory_bytes: 3388
import math

N, M = map(int, input().split())
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N == 0:
  ans = combinations_count(M, 2)
elif M == 0:
  ans = combinations_count(N, 2)
elif N == 1 and M == 1:
  ans = 0
elif N == 1:
  ans = combinations_count(M, 2)
elif M == 1:
  ans = combinations_count(N, 2)
else:
  ans = combinations_count(N, 2) + combinations_count(M, 2)
print(ans)

Measured memory_bytes: 3188
H, W = map(int, input().split())

#H x Wのマスを全て"."の行列で覆う （H+2 x W+2） 
S1 = [list(map(str,input())) for i in range(H)]
for i in range(H):
    S1[i].insert(0,'#')
    S1[i].append('#')
S = S = [['#'] * (W + 2)] + S1 + [['#'] * (W + 2)]

cnt = 0

for i in range(1,H):
    for j in range(1,W):
        if S[i][j] == '#':
            if S[i-1][j] == S[i][j-1] == S[i][j+1] == S[i+1][j] == '.':
                cnt += 1
if cnt == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int dp[N];
int n;


void solve()
{
    cin >> n;

    loop(i,0,n)cin >> A[i];

    loop(i,0,n+1)dp[i] = inf;

    dp[0] = 0;
    dp[1] = abs(A[1] - A[0]); 

    for(int i = 2; i  < n; i++)
    {
        dp[i] = min(dp[i-1] + abs(A[i]-A[i-1]),
                dp[i-2] + abs(A[i] - A[i-2]));
    }

    cout << dp[n-1];
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
     

     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}

Measured memory_bytes: 5120
X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

def comb(n, k):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % MOD        
        ret = ret * pow(i, MOD - 2, MOD) % MOD
        
    return ret

n = (2 * Y - X) / 3
m = (2 * X - Y) / 3

if n >= 0 and m >= 0 and n == int(n) and m == int(m):
    print(comb(int(n + m), int(n)))
else:
    print(0)


Measured memory_bytes: 39536
n, m, k = map(int, input().split())
listA = list(map(int, input().split()))
listB = list(map(int, input().split()))

sumAL = [0]
for i in range(len(listA)):
    sumAL.append(sumAL[-1]+listA[i])
sumBL = [0]
for i in range(len(listB)):
    sumBL.append(sumBL[-1]+listB[i])
ib = len(sumBL)-1
bookMax = 0
for ia in range(len(sumAL)):
    while ib > -1:
        if sumBL[ib] <= k-sumAL[ia]:
            if bookMax < ia+ib:
                bookMax = ia+ib
            break
        ib-=1
print(bookMax)


Measured memory_bytes: 47392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 998244353;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  cout<<(n*n)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    bool ok=false;
    rep(i,n){
        if(a[i]%2!=0) ok=true;
    }
    if(!ok){
        cout << "second" << endl;
        return 0;
    }
    cout << "first" << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	string s, t;
	int cnt[3] = {}, c[3] = {0, 1, 2}, rc[3] = {0, 1, 2}, d[3] = {};
	auto println = [&](string s) {
		for (char &x : s) x = rc[x] + 'A';
		cout << s << endl;
	};
	cin >> s;
	for (char &x : s) {
		x -= 'A';
		if (t.empty() || x != t.back()) ++cnt[x], t.push_back(x);
	}
	sort(c, c + 3, [&](int x, int y) { return cnt[x] < cnt[y]; });
//	for (int i = 0; i < 3; ++i) rc[c[i]] = i;
	sort(cnt, cnt + 3);
	if (cnt[2] != cnt[1] && t.back() == c[2]) --cnt[2], t.pop_back();
	if (cnt[2] != cnt[1] && t.front() == c[2]) --cnt[2], t.erase(t.begin());
//	println(t);
	vector<int> pos = {-1};
	for (int i = 0; i < t.size(); ++i)
		if (t[i] == c[0]) pos.push_back(i);
	pos.push_back(t.size());
	for (int i = 1; i < pos.size(); ++i)
		if (pos[i] - pos[i - 1] == 2) {
			if (t[pos[i] - 1] == c[1]) ++d[1];
			if (i != 1 && i != pos.size() - 1 && t[pos[i] - 1] == c[2]) ++d[2];
		} else if (pos[i] - pos[i - 1] != 1) ++d[0];
	int left = max(d[2] - d[0] - d[1], 0);
//	printf("%d %d %d %d\n", d[0], d[1], d[2], left);
//	println(t);
	s.clear();
	for (char x : t) {
		s.push_back(x);
		while (s.size() >= 3 && s[s.size() - 1] == c[0] && s[s.size() - 2] == c[2] && s[s.size() - 3] == c[0] && left)
			--left, s.pop_back(), s.pop_back();
	}
//	fprintf(stderr, "%d\n", left);
//	println(s);
	pos = {-1};
	cnt[0] = cnt[1] = cnt[2] = 0;
	for (int i = 0; i < s.size(); ++i) {
		++cnt[s[i]];
		if (s[i] == c[0]) pos.push_back(i);
	}
	pos.push_back(s.size());
	t.clear();
	left = cnt[c[2]] - cnt[c[1]];
	for (int i = 0; i < pos.size() - 1; ++i) {
		int bg = pos[i] + 1, ed = pos[i + 1] - 1;
		if (ed - bg + 1 >= 2 && s[bg] == c[2] && left) --left, ++bg;
		if (ed - bg + 1 >= 2 && s[ed] == c[2] && left) --left, --ed;
		if (i) t.push_back(c[0]);
		for (int j = bg; j <= ed; ++j) t.push_back(s[j]);
	}
//	fprintf(stderr, "%d\n", left);
//	println(t);
	pos = {-1};
	for (int i = 0; i < t.size(); ++i)
		if (t[i] == c[0]) pos.push_back(i);
	pos.push_back(t.size());
	s.clear();
	left = cnt[c[1]] - cnt[c[0]];
	for (int i = 0; i < pos.size() - 1; ++i) {
		int len = min(left, max(pos[i + 1] - pos[i] - 1 - (i == 0 || i == pos.size() - 2 ? 0 : 1), 0) / 2) * 2;
		if (i) s.push_back(c[0]);
		for (int j = pos[i] + 1; j <= pos[i + 1] - 1 - len; ++j)
			s.push_back(t[j]);
		left -= len / 2;
	}
//	fprintf(stderr, "%d %d %d\n", c[1], c[2], left);
	println(s);
}


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204