akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=200005;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



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


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

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}





signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int m,n;
		cin>>n>>m;
		int a[n];
		int sum=0;
		rep(i,n){
			cin>>a[i];
			sum+=a[i];
		}
		
		//int x = (sum)/(4*m));
		// cout<<sum<<" "<<x<<endl;
		int cnt=0;
		rep(i,n){
			if(4*m*a[i]>=sum)
				cnt++;
		}
		if(cnt>=m)
			cout<<"Yes\n";
		else cout<<"No\n";
	}

	return 0;
}

Measured memory_bytes: 256
# Tenka1 Programmer Beginner Contest 2019
# https://atcoder.jp/contests/tenka1-2019-beginner
# 
# 

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def grouping(N, S):
    g = []
    s = S[0]
    c = 1
    for i in range(1, N):
        if S[i] == s:
            c += 1
        else:
            g.append((s, c))
            c = 1
            s = S[i]
    g.append((s, c))
    return g

def main(N, S):
    g = grouping(N, S)
    gl = len(g)
    l = 0
    r = gl - 1
    if g[l][0] == '.':
        l += 1
    if g[r][0] == '#':
        r -= 1
    if r - l < 1:
        print(0)
        return
    ll = [0]
    lr = [0]
    lc = 0
    for i in range(l, r, 2):
        ll.append(g[i][1] + ll[-1])
        lr.append(g[i+1][1] + lr[-1])
        lc += 1
    ans = N
    for i in range(lc+1):
        tl = ll[i]
        tr = lr[lc] - lr[i]
        ans = min(ans, tl + tr)
    print(ans)

N = i2n()
S = i2s()
main(N, S)


Measured memory_bytes: 25956
n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)



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

int main(){
  int a;
  int b;
  int c;
  int shahen;
  int hoge;
  int san_ei=0;
  int san_do=0;
  int san_ty=0;
  int san=0;
  
  for(;;){
    cin >> a >> b >> c;
    
    if(a<b){hoge=a; a=b; b=hoge;}
    if(a<c){hoge=a; a=c; c=hoge;}

    if(a+b>c && b+c>a && c+a>b){
      shahen=a*a;
      if(shahen==b*b+c*c){
	san_ty++;
      }else if(shahen>b*b+c*c){
	san_do++;
      }else if(shahen<b*b+c*c){
	san_ei++;
      }
      san++;
    }else{
      cout << san << " " << san_ty << " " << san_ei << " "  << san_do << "" << endl;
    break;
    }


  }
    
  return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int odd_memo[100001], even_memo[100001];

void solve(long long n, std::vector<long long> v){
    REP(i, 100001) {
        odd_memo[i] = 0;
        even_memo[i] = 0;
    }
    REP(i, n) {
        if(i % 2 == 0) odd_memo[v[i]]++;
        else even_memo[v[i]]++;
    }

    vector<pair<int, int>> odd_pair_vec, even_pair_vec;
    REP(i, 100001) {
        if(odd_memo[i] != 0) odd_pair_vec.PB(MP(odd_memo[i], i));
        if(even_memo[i] != 0) even_pair_vec.PB(MP(even_memo[i], i));
    }

    sort(ALL(odd_pair_vec), greater<PII>());
    sort(ALL(even_pair_vec), greater<PII>());

    int ans = INF;
    int max_odd_cnt = n / 2 + n % 2;
    int max_even_cnt = n / 2;
    if(odd_pair_vec[0].second != even_pair_vec[0].second) ans = min(ans, max_odd_cnt - odd_pair_vec[0].first + max_even_cnt - even_pair_vec[0].first);
    if(odd_pair_vec.size() >= 2 && odd_pair_vec[1].second != even_pair_vec[0].second) ans = min(ans, max_odd_cnt - odd_pair_vec[1].first + max_even_cnt - even_pair_vec[0].first);
    if(even_pair_vec.size() >= 2 && odd_pair_vec[0].second != even_pair_vec[1].second) ans = min(ans, max_odd_cnt - odd_pair_vec[0].first + max_even_cnt - even_pair_vec[1].first);
    if(odd_pair_vec.size() == 1 && even_pair_vec.size() == 1 && odd_pair_vec[0].second == even_pair_vec[0].second) ans = n / 2;

    cout << ans << endl;

}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> v(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&v[i]);
    }
    solve(n, std::move(v));
    return 0;
}


Measured memory_bytes: 2812
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e3+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
   string str;cin>>str;
   if(str[1]=='R')cout<<"ABC"<<endl;
   else cout<<"ARC"<<endl;
return 0;
}


Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
#define repM1(i, n) for(ll i = (ll)(n - 1); i > 0; 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 (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);
	string s, t;
	cin >> s >> t;
	
	ll count = 0;
	rep(i, s.size()) {
		if (s[i] != t[i])
			count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3872
main = getContents >>= putOut.formatOut.map calc.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> [[Int]]
formatIn =  map ((map (read :: String -> Int)).words).takeWhile (/= "-1 -1 -1").lines

formatOut :: [String] -> String
formatOut = unlines

calc :: [Int] -> String
calc (m:f:r:_)
    | m == -1 || f == -1 || p < 30 = "F"
    | p >= 80                      = "A" 
    | p >= 65 && p < 80            = "B"
    | p >= 50 && p < 65 || r >= 50 = "C"
    | otherwise                    = "D"
  where p = m + f

Measured memory_bytes: 4068
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int> > vvi;
#define rep(i,n) for (int i=0;i<n;i++)

ll mod = 1e9+7;

int main(){
    int n ;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    int ans = 0;
    rep(i,n-2){
        for (int j=i+1;j<n-1;j++){
            int x = l[i]+l[j];
            int right = lower_bound(l.begin(),l.end(),x)-l.begin();
            int left= j+1;
            ans += max(0,right-left);
        }
    }
    cout << ans << endl;
}

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

void solve(long long A, long long B) {
  int MAXN = 100;
  vector<vector<int>> field(MAXN, vector<int>(MAXN, 0));

  for (int i = 0; i < MAXN / 2; i++) {
    for (int j = 0; j < MAXN; j++) {
      field[i][j] = 1;
    }
  }

  for (int i = 0; i < MAXN / 2; i += 2) {
    for (int j = 0; j < MAXN; j += 2) {
      if (A > 1) {
        A--;
        field[i][j] = 0;
      }
    }
  }

  for (int i = MAXN / 2 + 1; i < MAXN; i += 2) {
    for (int j = 0; j < MAXN; j += 2) {
      if (B > 1) {
        B--;
        field[i][j] = 1;
      }
    }
  }
  cout << "100 100" << endl;
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      cout << (field[i][j] ? "#" : ".");
    }
    cout << endl;
  }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#include <numeric>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls x<<1
#define rs x<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double pi=acos(-1.0); 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	double r;cin>>r;cout<<2*pi*r<<endl;
	return 0;
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

vector<int> eratosthenes(int n){
  vector<bool> isPrime(n+1,true);
  isPrime[0] = false;
  isPrime[1] = false;
  for(int i = 2; i<sqrt(n); i++){
    for(int j = i+1; j<=n; j++){
      if(j%i == 0) isPrime[j] = false;
    }
  }
  int i;
  vector<int> v;
  REP(i,n+1) if(isPrime[i])v.push_back(i);
  return v;
}

int main(void){
  int n = 55555;
  int N;cin >> N;
  vector<int> v = eratosthenes(n);
  int i,count = 0;
  REP(i,v.size()){
    if(v[i]%5==1){
      cout << v[i] << " ";
      count++;
    }
    if(count >= N) break;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int a, z;
  for (int i = 0; i < s.size(); i++) {
	if (s[i] == 'A') {
	  a = i;
	  break;
	}
  }
  for (int i = s.size() - 1; i >= 0; i--) {
	if (s[i] == 'Z') {
	  z = i;
	  break;
	}
  }
  cout << z - a + 1 << endl;
  return 0;
}



Measured memory_bytes: 640
def dfs(inParam, digits, lunlunCount, lunlun):
    if len(inParam) != digits:
        if int(inParam[len(inParam)-1]) == 0:
            nextNumList = [0, 1]
        elif int(inParam[len(inParam)-1]) == 9:
            nextNumList = [8, 9]
        else:
            nextNum = int(inParam[len(inParam)-1])
            nextNumList = [nextNum-1, nextNum, nextNum+1]
        
        for item in nextNumList:
            myTupp = dfs(inParam+str(item), digits, lunlunCount, lunlun)
            lunlunCount = myTupp[0]
            if myTupp[2] == 'e':
                return myTupp
        
        return myTupp
    
    else:
        lunlunCount += 1
        state = 'c'

        if lunlunCount == lunlun:
            state = 'e'
            print(inParam)

        return (lunlunCount, inParam, state)

K = int(input())

mylunlun = 0
mydigits = 1
while mylunlun != K:
    for indx in range(1, 10):
        mylunlun, lunlunNumber, _ = dfs(str(indx), mydigits, mylunlun, K)
        # if mylunlun == K:
        #     break
    
    if mylunlun >= K:
        break

    mydigits += 1


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
#define PI 3.14159265359


int main() {
    int n;
    cin >> n;
    string mo[n];
    int sum[] ={0,0,0,0};
    for(int i = 0 ; i < n ; ++i){
        cin >> mo[i];
    }
    for(int i = 0 ; i < n ; ++i){
        if(mo[i] == "AC"){
            sum[0] += 1;
        }
        else if(mo[i] == "WA"){
            sum[1] += 1;
        }
        else if(mo[i] == "TLE"){
            sum[2] += 1;
        }
        else if(mo[i] == "RE"){
            sum[3] += 1;
        }
    }
        printf("AC x %d\n" , sum[0]);
        printf("WA x %d\n" , sum[1]);
        printf("TLE x %d\n" , sum[2]);
        printf("RE x %d\n" , sum[3]);
    return 0;
}

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

namespace AtCoder_Beginner_Contest_126
{
    class Program
    {
        struct tdst
        {
            public int top;
            public int dst;            
            public tdst(int top, int dst) { this.top = top; this.dst = dst; }
        }
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var num = N[0];//ノード数
            var node = new List<tdst>[num + 1];
            var clr = new int[num + 1];
            for (int i=0;i<=num;++i)
            {
                node[i] = new List<tdst>();
                clr[i] = -1;
            }
            for (int i = 0; i < num-1; ++i)
            {
                var uvw = Console.ReadLine().Split().Select(int.Parse).ToArray();
                node[uvw[0]].Add(new tdst(uvw[1], uvw[2]));
                node[uvw[1]].Add(new tdst(uvw[0], uvw[2]));
            }

            clr[1] = 0;
            recv(1, node, clr);

            for (int i = 1; i <= num; ++i)
            {
                Console.WriteLine(clr[i]);
            }
        }
        static void recv(int next, List<tdst>[] node, int[] clr)
        {
            foreach (var nd in node[next])
            {
                if (-1 != clr[nd.top]) continue;
                if (nd.dst % 2 == 0)
                { clr[nd.top] = clr[next]; }
                else
                { clr[nd.top] = clr[next] == 1 ? 0 : 1; }
                recv(nd.top, node, clr);
            }
        }
    }
}


Measured memory_bytes: 33384
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(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 INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int main(void){

    int n;
    cin >> n;
    string c[n];
    REP(i,n){
      cin >> c[i];
    }
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    REP(i,n){
      if( c[i] == "AC"){
        ac++;
      } else if( c[i] == "WA"){
        wa++;
      } else if( c[i] == "TLE"){
        tle++;
      } else {
        re++;
      }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

ll n;

void func(ll cur, int use, ll &res)
{
    if (cur > n) return ;
    if (use == 0b111) res++;

    func(cur * 10 + 7, use | 0b001, res);
    func(cur * 10 + 5, use | 0b010, res);
    func(cur * 10 + 3, use | 0b100, res);
}



int main()
{
    cin >> n;
    ll res = 0;
    func(0, 0, res);
    cout << res << endl;;
}

Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]

for j in range(n):
    if j<n-1:
      print(a[j],end=" ")
    else:
      print(a[j])
      
for i in range(1,n):
  v=a[i]
  j=i-1
  while j>=0 and a[j]>v:
    a[j+1]=a[j]
    j-=1
  a[j+1]=v
  for j in range(n):
    if j<n-1:
      print(a[j],end=" ")
    else:
      print(a[j])


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

int main() {
  int K, X;
  cin >> K >> X;
  
  int left = max(-1000000, X-K+1);
  int right = min(X+K-1, 1000000);

  for (int i = left; i <= right; i++) {
    cout << i << " ";
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#define maxn 200005
#define lson (now<<1)
#define rson ((now<<1)|1)
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
int a[maxn];
int cnt[maxn];
int main()
{
	int x,n;
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		int y;
		cin>>y;
		cnt[y]++;
	}
	for(int i=0;i<=100;i++)
	{
		if(!cnt[x-i])
		{
			printf("%d\n",x-i);
			return 0;
		}
		if(!cnt[x+i])
		{
			printf("%d\n",x+i);
			return 0;
		}
	}
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 250
#define MAX_R 1050
#define INF 1e8
 
int G1[MAX][MAX], G2[MAX][MAX];
int dp[MAX_R][MAX];
 
int main(){
  int N, M;
 
  while(cin >> N >> M ,(N | M)){
    fill(G1[0], G1[MAX], INF);
    fill(G2[0], G2[MAX], INF);
 
    int x, y, t;
    char ch;
    for(int i = 0 ; i < M ; i++){
      cin >> x >> y >> t >> ch;
      x--, y--;
      if(ch == 'L'){
        G1[x][y] = G1[y][x] = t;
      }else{
        G2[x][y] = G2[y][x] = t;
      }
    }
     
    for(int i = 0 ; i < N ; i++){
      G1[i][i] = G2[i][i] = 0;
    }
     
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          G1[i][j] = min(G1[i][j], G1[i][k]+G1[k][j]);
          G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j]);
        }
      }
    }
 
    int R, z[MAX_R];
    for(int i = 0 ; i < MAX_R ; i++){
      for(int j = 0 ; j < MAX ; j++){
        dp[i][j] = INF;
      }
    }
 
    cin >> R;
    for(int i = 0 ; i < R ; i++){
      cin >> z[i]; z[i]--;
    }
 
    int now = z[0];
    dp[0][now] = 0;
    for(int r = 1 ; r < R ; r++){
      int next = z[r];
      for(int j = 0 ; j < N ; j++){
        for(int i = 0 ; i < N ; i++){
          dp[r][j] = min(dp[r][j], dp[r-1][i] + G1[now][i] + G2[i][j] + G1[j][next]);
        }
        dp[r][j]=min(dp[r][j], dp[r-1][j] + G1[now][next]);
      }
      now = next;
    }
 
    int ans = INF;
    for(int i = 0 ; i < N ; i++){
      ans = min(ans, dp[R-1][i]);
    }
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
const int mxn(1e1 + 10), mxm(4e5 + 10);
const long long modl(1e9 + 7);
long long nm, n, m, p, t, k, ans, l, r;
int a[mxn], b[mxn], h[mxn];
int main() {
  ios_base::sync_with_stdio(false);
//  freopen("in.txt", "r", stdin);///////////////////////////
//  cin >> nm;
//  string s;
  while (cin >> n) {
    while (++k <= n) {
      ans += n/k;
      if (!(n%k)) --ans;
    }
    cout << ans;
    cout << endl;
  }
  return 0;
}
////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   2005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int dp[N][N]={{0}} , a[N] , b[N];
signed main(){
  fast;
  int n , m;
  cin>>n>>m;
  a[0] = 0;
  b[0] = 0;
  for(int i = 1 ; i<= n ; i++)  cin>>a[i];
  for(int i = 1 ; i<=m ; i++) cin>>b[i];

  dp[0][0] = 1;
  for(int i = 0;i<=n;i++)
  	for(int j = 0;j<= m ; j++){
  		if(i==0 && j==0) continue;
  		if(i>0)dp[i][j]+=dp[i-1][j];
        if(j>0)dp[i][j]+=dp[i][j-1];
        if(i>0&&j>0) dp[i][j] = (dp[i][j]-dp[i-1][j-1] + mod)%mod;
        dp[i][j]%=mod;
  		if(a[i]==b[j])
  			dp[i][j]+= dp[i-1][j-1];
  		dp[i][j]%= mod;
  	}

  cout<<dp[n][m]<<endl;
  


}
  


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

int main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==1 && i%2==0)ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3588
max_num = None
min_num = None
sum_num = 0
n = input()
num_list = list(map(int,input().split()))
for i in num_list:
        if max_num is None or max_num < i:
            max_num = i
        if min_num is None or min_num > i:
            min_num = i
        sum_num += i
print("{} {} {}".format(min_num,max_num,sum_num))


Measured memory_bytes: 6556
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! print_vec {
    ($vec:expr) => {
        for (i, &v) in $vec.iter().enumerate() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", v);
        }
        println!();
    };
}

fn main() {
    let (m, k) = scan!(usize, usize);

    if m == 0 {
        if k == 0 {
            println!("0 0")
        } else {
            println!("-1")
        }
        return;
    }

    if m == 1 {
        if k == 0 {
            println!("0 0 1 1")
        } else {
            println!("-1")
        }
        return;
    }

    if k >= 2usize.pow(m as u32) {
        println!("-1");
        return;
    }

    let vec = (0..2usize.pow(m as u32))
        .filter(|&v| v != k)
        .collect::<Vec<_>>();
    let mut ans = vec.to_vec();
    ans.push(k);
    ans.append(&mut vec.into_iter().rev().collect());
    ans.push(k);
    print_vec!(ans);
}


Measured memory_bytes: 11512
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n,k,mx=0;
		cin>>n>>k;
		vll A(n);
		forn(i,n)
		{
			cin>>A[i];
			mx=max(mx,A[i]);
		}
		ll l=0,r=mx;
		//dbg(mx)
		if(k==0)
		{
			cout<<mx<<endl;
			return;
		}
		while(r-l>1)
		{
			ll mid=(l+r)/2;
			ll er=0;
			forn(i,n)
			{
				ll res=A[i];
				er+=(A[i]-1)/mid;
			}
			//dbg(er);
			if(er>k)
			{
				l=mid;
			}
			else
			{
				r=mid;
			}
		}	
		cout<<r<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 4784
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2000010; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

int main(){
  cominit();
  ll ans=0;
  ll r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  for(int i=r1+1;i<=r2+1;i++){
    ans+=com(i+c2,c2);
    ans-=com(i+c1-1,c1-1);
    if(ans<0) ans+=mod;
    else ans%=mod;
  }
  cout << ans << endl;
}

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

typedef long long LL;

LL lcm(LL a, LL b) {
    LL ret = a * b;

    if (a < b) swap(a, b);
    while (b > 0) {
        LL t = b;
        b = a%b;
        a = t;
    }

    return ret / a;
}

int main() {
    int a1, a2, a3, m1, m2, m3;
    int a[3], m[3];

    while (cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2]) {
        if ((a[0]|a[1]|a[2]|m[0]|m[1]|m[2]) == 0) {
            break;
        }

        LL ret = 1;

        for (int j = 0; j < 3; ++j) {
            int x = a[j]%m[j], cycle = 1;
            while (x > 1) {
                ++cycle;
                x = (a[j]*x)%m[j];
            }

            ret = lcm(ret, cycle);
        }

        cout << ret << endl;
    } 
    return 0;
}

Measured memory_bytes: 1156
S = list(input())

n = len(S) + 1

a = [0] * n

for i, x in enumerate(S):
    if x == '<':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = 0

for i, x in enumerate(reversed(S)):
    j = n - i - 1
    if x == '>':
        a[j - 1] = max(a[j] + 1, a[j-1])

print(sum(a))

Measured memory_bytes: 26808
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] stones = new int[n];
        for (int i = 0; i < n; i++) {
            stones[i] = scanner.nextInt();
        }

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            for (int j = i - k; j <= i - 1; j++) {
                if (j >= 0) {
                    dp[i] = Math.min(dp[i], dp[j] + Math.abs(stones[j] - stones[i]));
                }
            }
        }

        writer.println(dp[n - 1]);
    }
}


Measured memory_bytes: 48884
# ABC 110
def db(x): 
    global debug
    if debug: print(x)
debug = False
def swap(fromStr, toStr, nth):
    db((fromStr,toStr,nth))
    fromChar = fromStr[nth]
    toChar = toStr[nth]
    toStr = toStr.replace(fromChar,'#')
    db(toStr)
    toStr = toStr.replace(toChar,fromChar)
    db(toStr)
    toStr =  toStr.replace('#', toChar)
    db(toStr)
    return toStr
S = input()
T = input()
db((S,T))
used = []
for i in range(len(S)):
    if S[i] in used: 
        continue
    else:
        used.append(S[i])
        if S[i]==T[i]: continue
        T = swap(S, T, i)
if S==T: print('Yes')
else: print('No')
db((S,T,used))
        

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

int main() {
    ll N;
    cin >> N;
    ll ans = 1e18;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0)
            continue;

        ll j = N / i;
        ans = min(i + j - 2, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, H: "List[int]"):
    for i in range(1, N):
        if H[i] > H[i - 1]:
            H[i] -= 1
        elif H[i] < H[i - 1]:
            print(NO)
            return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15288
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long cnt = 0;
        long ans = 0;
        
        while(N!=0){
            N/=2;
            ans = ans + (long)Math.pow(2,cnt);
            cnt++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    char A, B;
    cin>>A>>B;
    if(A>B) cout<<">"<<endl;
    else if(A<B) cout<<"<"<<endl;
    else cout<<"="<<endl;
    
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
using namespace std;
int main()
{
    char ym[4];
    cin >> ym;
    for(int i = 0; i < 4; i++){
        ym[i] -= '0';
    }
    int bef = ym[0]* 10 + ym[1], aft = ym[2] * 10 + ym[3];
    if(1 <= bef && bef <= 12){
        if(1 <= aft && aft <= 12){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if(1 <= aft && aft <= 12){
            cout << "YYMM" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	string s;
	cin>>s;
	int n=s.size();
	if(n&1) over("No");
	for(int i=0;i<n;i+=2)
	{
		if(!(s[i]=='h' && s[i+1]=='i')) over("No");
	}
	over("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
#define mp make_pair
#define MAXN 200005
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int64 A[MAXN];
int N;

void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(A[i]);
	A[i] -= i;
    }
    sort(A + 1,A + N + 1);
    int64 t = A[N / 2 + 1],ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
	ans += abs(A[i] - t);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

using namespace std;

int gcd(int x, int y) {
  int a, b;

  if(x < y) {
    a = x;
    b = y;
  } else {
    a = y;
    b = x;
  }

  int r = a % b;
  while(r) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main(void)
{
  int x, y;
  cin >> x >> y;

  cout << gcd(x, y) << endl;

  return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	
	bool AC[100000] = {};
	rep(i, N - 1) {
		if (S[i] == 'A' && S[i + 1] == 'C') AC[i] = true;
	}
	int ACN[100000];
	ACN[0] = 0;
	rep(i, N - 1) {
		ACN[i + 1] = ACN[i] + AC[i];
	}

	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		co(ACN[r - 1] - ACN[l - 1]);
	}



	Would you please return 0;
}

Measured memory_bytes: 1616
import java.lang.*;
import java.util.*;

public class Main
{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[])
    {
	int[] m = new int[31];

	m[1]=1;
	m[2]=2;
	m[3]=4;
	
	for(int i=4; i<=30;i++){
	    m[i] = m[i-1]+m[i-2]+m[i-3];
	    
	}
	
	while(true){
	int N = sc.nextInt();
	if(N==0)break;
	    System.out.println( m[N]/3650 + 1 );
	}	
    }
}

Measured memory_bytes: 17184
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    map<int, int> cnt;
    rep(i, N) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        if (itr->first > itr->second) {
            ans += itr->second;
        }
        else {
            ans += (itr->second - itr->first);
        }
    }

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

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0, M;
ll ret = 0;

vl table(100005, -1);
queue<pair<ll, ll>> q;
vvl adj(100005);

void bfs(ll init) {
  q.push(mp(1, 1)); // from, now
  while(!q.empty()) {
    auto p = q.front();
    q.pop();
    if (table[p.second] != -1) {
      continue;
    }
    table[p.second] = p.first;
    for (ll n : adj[p.second]) {
      q.push(mp(p.second, n));
    }
  }
}

int main(void){
  
  I(N);
  I(M);
  REP(i, M) {
    ll A, B;
    I(A);
    I(B);
    adj[A].pb(B);
    adj[B].pb(A);
  }
  bfs(1);
  bool ok = true;
  FOR(i, 2, N+1) {
    if (table[i] == -1) ok = false;
    // D(table[i]);
  }
  if (!ok) {
    P("No");
  } else {
    P("Yes");
    FOR(i, 2, N+1) {
      P(table[i]);
    }
  }

}


Measured memory_bytes: 17888
program ABC136B
    implicit none
    integer::N,i,digits,j,ans=0
    read*,N
    do i=1,N
        j=i
        digits=1
        do
            if(j/10==0)exit
            j=j/10
            digits=digits+1
        end do
        if(mod(digits,2)==1)ans=ans+1
    end do
    print'(i0)',ans
end program ABC136B

Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    int ind = 0;
    ll ans = 1;
    bool pre;
    if(s[ind] == t[ind]){
        ans = 3;
        ind++;
        pre = true;
    }
    else{
        ans = 6;
        ind += 2;
        pre = false;
    }


    while(ind < N){
        if(s[ind] == t[ind]){
            if(pre){
                ans = ans * 2 % MOD;
                pre = true;
            }
            else{
                pre = true;
                ans = ans * 1 % MOD;
            }
            ind++;
        }
        else{
            if(pre){
                pre = false;
                ans = ans * 2 % MOD;
            }
            else{
                pre = false;
                ans = ans * 3 % MOD;
            }
            ind += 2;
        }


    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3692
#include<stdio.h>

int main(){
    int x,h,m,s;
    
    scanf("%d",&x);
    h = x / 3600;
    m = (x - 3600*h) / 60;
    s = x % 3600 % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2048
n, m, d = map(int, input().split())

# (n - 1) spots for beauty
# if enabled, m^(n - 2) sequences that have that spot

# (n - 1) * (pairs) * (n - 2)^m / 
# E(1) = 0
# E(2) = E(1) + P(i - 1, i)
# E(3) = E(2)

# (m - 1) * pairs / (n choose 2) 
pairs = n if d == 0 else 2 * (n - d)
num = (m - 1) * pairs
den = n * n
print('{:.15f}'.format(num / den))


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int nmax = 50;
  ll n, m; cin >> n >> m;
  ll a[nmax], b[nmax], c[nmax], d[nmax];
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int j = 0; j < m; j++) {
    cin >> c[j] >> d[j];
  }

  for(int i = 0; i < n; i++) {
    int min_dist = abs(a[i] - c[0]) + abs(b[i] - d[0]), checkpoint = 1;
    for(int j = 1; j < m; j++) {
      int cur_dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(min_dist > cur_dist) {
        min_dist = cur_dist;
        checkpoint = j+1;
      }
    }
    cout << checkpoint << endl;
  }

  return 0;
}


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

int main(){
    int n;
    cin >>n;
    int m = n/10;
    n = n - m*10;
    if(n == 2||n == 4||n==5||n==7||n==9){
        cout << "hon" << endl;
    }
    else if (n == 3){
        cout << "bon" << endl;
    }
    else{
        cout<<"pon"<<endl;
    }
    
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (100010)
int n,k;
ll ans;
vector<int>G[N];

ll calc(int k){
	ll res=1;
	for (int i=1;i<=k;i++) res=res*i%M;
	return res;
}

ll dfs(int x,int fa,int i){
	ll res=1,cnt=2;
	if (fa==0) --cnt;
	for (int i=0;i<G[x].size();i++){
		int y=G[x][i];
		if (y==fa){--cnt; continue;}
		res=res*dfs(y,x,i+cnt)%M;
	}
	return res*(k-i)%M;
}

int main(){
	scanf("%d%d",&n,&k);
	int x,y;
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	ans=dfs(1,0,0);
	printf("%lld",ans);
}


Measured memory_bytes: 11520