akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans[n];
    ans[0]=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            ans[0]+=a[i];
        }
        else{
            ans[0]-=a[i];
        }
    }
    for(int i=1;i<n;i++){
        ans[i]=2*(a[i-1]-ans[i-1]/2);
    }
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a;
    cin >> a;
    if (a % 10 == 7) cout << "Yes";
    else if (a % 100 / 10 == 7) cout << "Yes";
    else if (a / 100 == 7 ) cout << "Yes";
    else cout << "No";
}

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

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

	vector<int> a(n);
	int x = 0;
	for (int& ai : a) {
		cin >> ai;
		x ^= ai;
	}

	for (int ai : a) {
		cout << (x ^ ai) << " ";
	}
	
	return 0;
}


Measured memory_bytes: 4048
import java.sql.SQLOutput;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long X = scanner.nextInt();
        long[] pos = new long[N];

        for (int i = 0; i < N; i++) {
            pos[i] = scanner.nextLong();
        }
        if (N == 1) {
            System.out.println(Math.abs(X - pos[0]));
            return;
        }
        long tmpGcd = gcd(dist(X, pos[0]), dist(X, pos[1]));
        for (int i = 2; i < N; i++) {
            tmpGcd = gcd(tmpGcd, dist(X, pos[i]));
        }
        System.out.println(tmpGcd);
    }

    public static long dist(long X, long pos) {
        if (X > pos) {
            return X - pos;
        }
        return pos - X;
    }

    public static long gcd(long x, long y) {
        if (x < y) {
            long tmp = x;
            x = y;
            y = tmp;
        }
        if ((x % y) == 0) return y;
        else return gcd(y, x % y);
    }
}

Measured memory_bytes: 47708
#include<iostream>
using namespace std;
int main(){
	int i,k=0,tmp,a[10];
	

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

	while(1){//無限ループ
		for(i=0;i<9;i++){
			if(a[i]<a[i+1]){//もし昇順でない場合
				tmp=a[i];//隣接しあう値を昇順に入れ替える
				a[i]=a[i+1];
				a[i+1]=tmp;
				k++;//カウント
			}
		}
		if(k==0) break;//入れ替える必要がなくなったら終了
		k=0;//カウントの初期化
	}
	cout<<a[0]<<endl;
	cout<<a[1]<<endl;
	cout<<a[2]<<endl;
}

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

using namespace std;

const int maxn = 1e5 + 5;
char s[maxn];
int n;

bool judge() {
	for (int i = 1; i < n; ++i)
		if (s[i] != s[n-i]) return true;
	return false;
}

int main() {
	cin >> (s+1);
	for (n = 1; s[n] != '\0'; ++n);
	--n;
	if (s[n] != '0' || s[1] != '1' || judge()) puts("-1");
	else {
		int root = 1;
		printf("1 2\n");
		for (int i = 2; i < n; ++i) {
			printf("%d %d\n", root, i+1);
			if (s[i] == '1') root = i+1;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

const ll mod = 1e9+7;

int main()
{
    int S;
    cin >> S;
    vll dp(S+1,0);
    dp[0] = 1;
    REP(i,S+1){
        for(int j=3; j<=i; j++){
            dp[i] += dp[i-j];
            dp[i] %= mod;
        }
    }
    cout << dp[S] << endl;
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	data := strings.Split(s, "")
	tmp := len(data)
	number := tmp - 2

	ans := data[0] + strconv.Itoa(number) + data[tmp-1]

	fmt.Println(ans)
}


Measured memory_bytes: 1844
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    // ll A, B;
    // cin >> A >> B;

    // ll ans = 0;

    // if(true){
    //     cout << "Yes" << endl;
    // }else{
    //     cout << "No" << endl;
    // }

    ll A, B;
    char op;
    cin >> A >> op >> B;

    if(op == '-'){
        cout << A - B << endl;
    }else{
        cout << A + B << endl;
    }

}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

struct maximum_bipartite_matching {
  int nl, nr, mbm = 0;
  vector<bool> v;
  vector<int> ml, mr;
  vector<vector<int>>& e;
  maximum_bipartite_matching(int nl, int nr, vector<vector<int>> & e) : nl(nl), nr(nr), ml(nl, -1), mr(nr, -1), e(e) {
    int prv = 0;
    do {
      prv = mbm;
      v.assign(nr, false);
      for (int i = 0; i < nl; i++)
        if (ml[i] == -1)
          mbm += findPath(i);
    } while (mbm > prv);
  }
  bool findPath(int i) {
    for (int j : e[i])
      if (!v[j]) {
        v[j] = true;
        if (mr[j] == -1 || findPath(mr[j])) {
          ml[i] = j; mr[j] = i;
          return true;
        }
      }
    return false;
  }
};

int n, m, a[200][200], b[200][200], c[200][200];
bool u[200][200];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> a[i][j], a[i][j]--;
  for (int k = 0; k < m; k++) {
    vector<vector<int>> e(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (!u[i][j])
          e[i].push_back(a[i][j] / m);
    maximum_bipartite_matching mbm(n, n, e);
    assert(mbm.mbm == n);
    for (int i = 0; i < n; i++) {
      int j = 0;
      while (u[i][j] || a[i][j] / m != mbm.ml[i])
        j++;
      u[i][j] = true;
      b[i][k] = a[i][j];
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      c[b[i][j] / m][j] = b[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cout << b[i][j] + 1 << (j < m - 1 ? " " : "\n");
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cout << c[i][j] + 1 << (j < m - 1 ? " " : "\n");
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;
const ll d=5e15;
int main()
{
string s;
ll k;
cin>>s>>k;
for(int i=0; i<s.size(); ++i)
{
if(s[i]=='1')k--;
if(s[i]!='1' || !k)return cout<<s[i], 0;
}
}

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

int main() {
    ll N;
    cin >> N;

    vector<ll> bits(101, 0);

    if(N>=0) {
        ll t = 0;
        for(ll i=1; i<(1<<30); i*=2) {
            if(N&i) {
                if(t%2 == 0) bits[t]++;
                else {bits[t]++; bits[t+1]++;}
            }
            t++; 
        }
    } else {
        N *= -1;
        ll t= 0;
        for(ll i=1; i<(1<<30); i*=2) {
            //cout << i << endl;
            if(N&i) {
                if(t%2 == 0) {bits[t]++; bits[t+1]++;}
                else bits[t]++;
            }
            t++;
        }
    }

    for(ll i=0; i<101; i++) {
        if(bits[i] > 1) {
            bits[i+1] += bits[i]/2;
            bits[i+2] += bits[i]/2;
            bits[i] -= int(bits[i]/2) * 2;
        }
    }
    
    ll seq = 100;
    for(ll i=100; i>=1; i--) {
        if(bits[i] > 0) break;
        seq--;
    }

    for(ll i=seq; i>=0; i--) {
        cout << bits[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
data =input()
s1 =[]
ans =[]
memo=-1
for i in range(len(data)):
	if data[i]=='\\':
		s1.append(i)
	if data[i]=='/':
		if len(s1)==0:pass
		# elif len(s1)==1:
		# 	ans.append(i-s1.pop())
		else:
			a = i-s1[-1]
			while len(ans)!=0:
				if ans[-1][1]<=s1[-1]:break
				a+=ans.pop()[0]
			ans.append([a,s1.pop()])

	# print(ans)
ans2=[int(ans[i][0]) for i in range(len(ans))]
print(sum(ans2))
print(len(ans),end='')
if len(ans):
	print('',end=' ')
print(' '.join(list(map(str,ans2))))





Measured memory_bytes: 6204
def pd(A):
    print(" ".join(map(str,A)))

def insertionSort(A, N):
    pd(A)
    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
        pd(A)

    return A

n = int(input())
a = list(map(int, input().split()))
insertionSort(a, n)

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

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n+1),b(m+1);
  for(int i=1;i<n+1;i++){cin>>a[i];a[i]+=a[i-1];}
  for(int i=1;i<m+1;i++){cin>>b[i];b[i]+=b[i-1];}
  int ans=0,now;
  for(int i=m;i>=0;i--){if(b[i]<=k){now=i;ans=i;break;}}
  
  for(int i=0;i<=n;i++){
    for(int j=now;j>=0;j--){
      if(a[i]+b[j]<=k){
        ans=max(ans,i+j);
        now=j;
        break;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 6428
#include <stdio.h>

int main() {
	int M1, M2, D1, D2;
	scanf("%d %d", &M1, &D1);
	scanf("%d %d", &M2, &D2);
	if (M1 != M2 && D2 == 1) printf("1\n");
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

ll N, X, M;
vector<ll> repeat;
ll ans = 0;

void fun(ll total, ll idx) {
	if (find(all(repeat), total) != repeat.end()) {
		int i = 0;
		for (;;++i) {
			if (total == repeat[i]) break;
			ans += repeat[i];
		}

		int pre_cycle_terms = i;
		ll cycle_sum = accumulate (all(repeat), -ans);
		ll cycle_terms = repeat.size() - i;
		ll x = (N - i) / cycle_terms;
		ans += cycle_sum * x;
		ll y = (N - i) % cycle_terms;

		ans = accumulate (repeat.begin() + i, repeat.begin() + i + y, ans);
		return;
	}

	if (idx == N) {
		repeat.pb(total);
		ans = accumulate(all(repeat), 0);
		return;
	}

	repeat.pb(total);
	fun((total * total) % M, idx + 1);
}

int main() {
	cin>>N>>X>>M;
	fun(X, 1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6068
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut v = Vec::new();
    let mut map = HashMap::new();
    for _ in 0..n {
        let x:i64 = read();
        v.push(x);
        *map.entry(x).or_insert(0) += 1;
    }
    let ans = map.values().map(|v| v * (v - 1) / 2).sum::<i64>();
    for i in v.iter() {
        let val = map[i];
        let before = val * (val - 1) / 2;
        let after = (val - 1) * (val - 2) / 2;
        println!("{}", ans - before + after);
    }
}


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

using ll = long long;

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

  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b <= 0) {
    cout << "No\n";
    return 0;
  }
  if (4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

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

signed main() {
  string s;
  cin >> s;
  string t;
  vector<int> v;
  int tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'x')
      tmp++;
    else {
      t.push_back(s[i]);
      v.push_back(tmp);
      tmp = 0;
    }
  }
  v.push_back(tmp);
  string u = t;
  reverse(begin(u), end(u));
  if (t != u) cout << -1 << endl, exit(0);
  int m = (t.size() + 1) / 2;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    ans += abs(v[i] - v[v.size() - 1 - i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int X, Y; cin >> X >> Y;
    
    int res = 0;
    switch (X) {
    case 1:
        res += 300000;
        break;
    case 2:
        res += 200000;
        break;
    case 3:
        res += 100000;
    default:
        break;
    }
    switch (Y) {
    case 1:
        res += 300000;
        break;
    case 2:
        res += 200000;
        break;
    case 3:
        res += 100000;
    default:
        break;
    }
    if (X == 1 && Y == 1) res += 400000;

    cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

pair<ll, int> solve(int a, int b, ll c) {
  ll res = 0;
  vector<ll> mem_c(10, -1), mem_res(10, -1);
  while (c > 0) {
    if (mem_c[a] != -1) {
      ll use_c = mem_c[a] - c;
      ll cost = res - mem_res[a];
      ll cnt = c / use_c;
      res += cnt * cost;
      c -= cnt * use_c;
      auto v = solve(a, b, c);
      res += v.fst;
      a = v.snd;
      break;
    }
    mem_c[a] = c;
    mem_res[a] = res;
    int s = a + b;
    ++res;
    --c;
    while (s > 9) {
      int ns = (s / 10) + (s % 10);
      ++res;
      s = ns;
    }
    a = s;
  }
  return {res, a};
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int M;
  while (cin >> M) {
    ll res = 0;
    int a = 0;
    for (int i = 0; i < M; i++) {
      int d;
      ll c;
      cin >> d >> c;
      auto r = solve(a, d, c);
      res += r.fst;
      a = r.snd;
    }
    cout << res - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int Prime(int);

int main(){
  int n,i,x;
  int cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(Prime(x)) cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}

int Prime(int x){
  int i=3;

  if(x==2) return 1;
  if(x%2==0) return 0;
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
    i=i+2;
  }
  return 1;
}

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

#define SIZE 50

int n, k, res;
int l[SIZE];

int main() {
    std::cin >> n >> k;
    for (int i=0; i<n; ++i) std::cin >> l[i];
    std::sort(l, l+n, std::greater<int>());
    for (int i=0; i<k; ++i) res += l[i];
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map> 
#include<set> 
using namespace std;
#define mid 1000000007
typedef long long  ll;
int main(){
	int a;
	ll i,j;
	cin>>a;
	for(i=-200;i<=200;i++){
		for(j=-200;j<=200;j++){
			if(pow(i,5)-pow(j,5)==a){
			cout<<i<<" "<<j;
			return 0;
			}
		}
	} 
	return 0;
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


signed main(){
    FAST;

    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy";
    else if(s=="Cloudy") cout<<"Rainy";
    else if(s=="Rainy") cout<<"Sunny";
}


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

#define ul unsigned long 
#define ull unsigned long long
#define li long long int

int main()
{
  ul a,b,k;
  cin >> a>>b>>k;

  ul m=min(a,b),ct1=0,ans=-1;
  for (ul i=m;i>=1;i--) {
    if ((a%i|b%i)==0) {
      ct1++;
      if (ct1== k)
      {
        ans=i;
        break;
      }
    }
  }

  cout << ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

ll bit[200010];
ll n;

void update(ll idx, ll val) {
	ll i;
    for(i=idx;i<=n;){
    	bit[i]=max(bit[i],val);
    	i += i&(-i);
    }
}

ll query(ll idx) 
{
	ll i,val=-1;
	for(i=idx;i>0;){
		val=max(val,bit[i]);
		i -= i&(-i);
	}
	return val;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i;
    cin>>n;
    vector<pair<ll,ll>>v;
    ll h[n],val[n];
    for(i=0;i<n;i++){
    	cin>>h[i];
    	v.push_back({h[i],i});
    }
    for(i=0;i<n;i++){
    	cin>>val[i];
    }
    sort(v.begin(),v.end());
    mem(bit,0);
    ll ans=0;
    for(i=0;i<n;i++){
    	ll temp = val[v[i].second]+query(v[i].second+1);
    	ans=max(ans,temp);
    	update(v[i].second+1,temp);
    }
    cout<<ans;
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int h[n];
	int mx=0;
	rep(i,n){
		cin>>h[i];
		if(mx-1>h[i]){
			puts("No");
			return 0;
		}
		mx=max(mx,h[i]);
	}
	puts("Yes");
			return 0;
}

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

int main() {
	int n;
	cin >> n;
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 0; i < n; i++) {
		string s, t;
		cin >> s >> t;
		if (s > t)
			sum1 += 3;
		if (s < t)
			sum2 += 3;
		if (s == t) {
			sum1++;
			sum2++;
		}
	}
	cout << sum1 << " " << sum2 << endl;
}



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

int N, Q;
string S;
vector<int> vl(100000);
vector<int> vr(100000);
vector<int> ac(100000);

int main() {
  cin >> N >> Q;
  cin >> S;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    vl.at(i) = (l - 1);
    vr.at(i) = (r - 1);
  }

  int num = 0;
  for (int i = 0; i < N - 1; i++) {
    ac.at(i) = num;
    if (S.at(i) == 'A' && S.at(i+1) == 'C') { ++num; ac.at(i+1) = num; }
  }
  ac.at(N - 1) = num;

  for (int k = 0; k < Q; k++) {
    if (vl.at(k) == 0) cout << ac.at(vr.at(k)) << endl;
    else cout << ac.at(vr.at(k)) - ac.at(vl.at(k)) << endl;
  }
}
/*
8 3
ACACTACG
3 7
2 3
1 8

 */


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MOD = 1e9 + 7;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)

ll dp[1<<21];
int a[23][23];
int bitcnt[1<<21];

int main() {
    int n;
    cin  >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0;j < n; j++){
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for(int s = 1; s < (1<<n);s++){
        bitcnt[s] = bitcnt[s/2] + s%2;
        for(int l = 0;l< n;l++){
            if((s >> l) % 2 == 0)continue;
            dp[s] += dp[s - (1 << l)] * a[bitcnt[s]-1][l];
            dp[s] %= MOD;
            }
        }
    cout << dp[(1<<n) - 1] << endl;
}

Measured memory_bytes: 24832
#!/usr/bin/env python3

a, b, k = map(int, input().split())
# print(a, b, k)

if k >= a + b:
    a = 0
    b = 0
else:
    if k >= a:
        b = b - (k - a)
        a = 0
        # print("k >= a")
        # print(a, b)
    else:
        # print("k < a")
        a = a - k
        b = b
        # print(a, b)

print(a, b)


Measured memory_bytes: 2940
def insert_sort(L,n,g):
    cnt =0
    for i in range(g,n):
        v = L[i]
        j = i-g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j = j-g
            cnt +=1
        L[j+g] = v
    return cnt


if __name__ == '__main__':
    n = int(input())
    L = []
    G = []
    h = 1
    cnt = 0
    for _ in range(n):
        L.append(int(input()))
    while 1:
        if h > n: break
        G.append(h)
        h = 3*h + 1
    G = G[::-1]
    for gap in G:
        cnt += insert_sort(L,n,gap)
    print(len(G))
    print(*G)
    print(cnt)
    for i  in range(n): 
        print(L[i])


Measured memory_bytes: 45508
#include<stdio.h>

int main(void)
{
	int i, j, x, y;

	while (1)
	{
		scanf("%d %d", &i, &j);
		if (i == 0 && j == 0)break;
		for (x = 0; x < i; x++)
		{
			for (y = 0; y < j; y++)
			{
				if (x == 0 ||x==(i-1)|| y == 0 || y == (j-1))
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
				}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}
int main() {
    int N,X;
    vi L;
    cin >> N >> X;
    L = vi(N);
    rep(i,N){
        cin >> L[i];
    }

    vi D = vi(N+1);

    D[0] = 0;
    rep(i,N){
        D[i+1] = D[i] + L[i];
    }

    Int ans = 0;
    rep(i,N+1){
        if(D[i]<=X){
            ans++;
        }
    }

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


Measured memory_bytes: 256
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 1000* 100 + 5;
int cn[maxn];

int32_t main(){
    int n, m;
    cin >>n >>m;
    while(m --){
        int u, v;
        cin >>u >>v;
        u --;
        v --;
        cn[u] ++;
        cn[v] ++;
    }
    for(int i = 0; i < n; i ++){
        if(cn[i]% 2){
            cout <<"NO" <<'\n';
            return false;
        }
    }
    cout <<"YES" <<'\n';
    return false;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a[5];
  int i,j;
  scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
  for(i=0; i<5; i++){
    for(j=0; j<4; j++){
      if(a[j]<a[j+1]){
	int temp =a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
  return(0);
}

Measured memory_bytes: 596
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

var allstr = "abcdefghijklmnopqrstuvwxyz"

func main() {
        line := nextLine()

        maps := map[string]bool{}

        for _, v := range line {
                if _, ok := maps[string(v)]; !ok {
                        maps[string(v)] = true
                }
        }

        count := 0
        for {
                strs := line[:len(line)-count]
                for _, v := range allstr {
                        if v, _ := maps[string(v)]; v {
                                continue
                        }

                        added := strs + string(v)
                        if line < added {
                                fmt.Println(added)
                                return
                        }
                }
                count++
                if count > 26 {
                        break
                }
                maps[string(line[len(line)-count])] = false
        }

        fmt.Println("-1")

}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a;
	cin >> a;
	int s=0,heru=0;
	int n = a.size();
	REP(i,n){
		if(a[i] == 'S'){
			s++;
		}
		else if(s != 0){
			heru += 2;
			s--;
		}
	}
	cout << n-heru << endl;
    return 0;
}

Measured memory_bytes: 640
N=int(input())
A=[]
node=[]
for i in range(N):
  x,y=map(int,input().split())
  A.append((x,i,"left"))
  A.append((y,i,"right"))
  node.append((x,y))
  
A.sort()
Used=[[False,False] for i in range(N)]
Used_node=0
for i in range(N):
  if A[i][2]=="left":
    Used[A[i][1]][0]=True
    if not Used[A[i][1]][1]:
      Used_node+=1
  if A[i][2]=="right":
    Used[A[i][1]][1]=True
    if not Used[A[i][1]][0]:
      Used_node+=1
if Used_node!=N:
  ans=0
  for i in range(N):
    ans+=A[i][0]
  print(ans)
else:
  if Used[0][0]:
    f=0
  else:
    f=1
  NO=0
  for i in range(N):
    if not Used[i][f]:
      NO=1
      break
  ans=0
  for i in range(N):
    ans+=A[i][0]
  ans2=float("inf")
  if NO==1:
    for w in range(N):
      if A[N][1]==w:
        ans2=min(ans2,ans-min(node[w])+A[N+1][0])
      else:
        ans2=min(ans2,ans-min(node[w])+A[N][0])
    print(ans2)
    exit()
  print(ans)
    

Measured memory_bytes: 96728
import sys
import numpy as np
# from numba import njit

# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

# @njit(cache=False)
def main(N,K,P,C): #,ans):


	# XeXは、Float?
	# numbaの場合、intでないとまずいのかもしれないので、そのまま1e9はヤバそう
	# ans = -1e9
	ans = int(-1e9)		
	# ans = -10 ** 9		# これはOK

	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = np.full( N, -1, dtype=np.int64 )
	cycleInfs = []


	# print(P)

	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			currentCycleItemCnt, currentCycleTotal = cycleInfs[ cycleIDs[v] ]
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleInfs.append( (currentCycleItemCnt, currentCycleTotal) )
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = int(( K - procCnt ) // currentCycleItemCnt)

			# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, procCnt)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( int(ans), int(tmp) )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(int(ans))

if sys.argv[-1]=='ONLINE_JUDGE':
	# from numba import njit
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('main','void(i8,i8,i8[:],i8[:])')(main)
	# main=njit(main, cache=True)
	cc.compile()
	exit(0)
from my_module import main



if __name__ == "__main__":
	N,K = map(int,input().split())
	P = np.array( input().split(), np.int64 )
	P -= 1
	C = np.array( input().split(), np.int64 )

	main(N,K,P,C) #,ans)
	#print(ans)




Measured memory_bytes: 28020
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    //start from here

    int n, m; cin >> n >> m;
    cout << (n*(n-1))/2 + (m*(m-1))/2;

    return 0;
}


Measured memory_bytes: 256
//     THE ONLY WAY IS UP

#include<bits/stdc++.h>

#define ll              long long int
#define ld              long double
#define f1(i, a, b)     for(ll i = a; i < b; i++)
#define f2(a, b)        for(auto a : b)
#define ar(v, i)        v[i]
#define in_(x)          ll x; cin >> x;
#define ino_(type, x)   type x; cin >> x;
#define pb              push_back
#define nl              "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    in_(n)
    ll res=0;
    f1(i, 1, n+1){
        f1(j, 1, n+1){
            f1(k, 1, n+1){
                res+=gcd(i, gcd(j, k));
            }
        }
    }
    cout << res << nl;
}

Measured memory_bytes: 3652
/**
 *      ABC 52 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-06 01:37:58
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    string S; cin >> S;
    int count = 0; int max = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'I'){
            ++count;
        }
        else if (S[i] == 'D'){
            --count;
        }

        if (count > max){
            max = count;
        }        
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
//Create Time: 2018-04-27 16:48:28
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <functional>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#include <complex>
#include <cassert>
#include <climits>
#include <iterator>
#include <tuple>
using namespace std;
#define snuke(i,x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
// #define OUT(x) std::cout<<(#x)<<":"<<(x)<<std::endl
// #define TST(x) std::cout<<(#x)<<":"<<(x)<<" "
#define OUT(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("\n",_it,args);}
#define TST(args...) {string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);OUT_TST("",_it,args);}
#define SZ(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define unq(x) sort(all(x)),(x).erase(unique(all(x)),(x).end())
#define mem(f,x) memset((f), (x), sizeof(f))
#define clr(f) mem(f,0)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define DEBUG
void OUT_TST(string s,istream_iterator<string> it) {cerr<<s;}
template<typename T, typename... Args> void OUT_TST(string s,istream_iterator<string> it,T a,Args... args){cerr<<*it<<"="<<a<<" ";OUT_TST(s,++it,args...);}
template<class T> void rd(T&ret){ret=0;bool ok=0,u=0;for(;;){int c=getchar();if(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',ok=1;else if(c=='-')u=1;else if(ok){if(u)ret*=-1;return;}}}
long long powmod(long long p,long long n,long long mod){long long ret=1;for(;n;n>>=1){if(n&1)ret=ret*p%mod;p=p*p%mod;}return ret;}
template <class T> bool chmin(T& a, const T &b) {return b < a? a = b, 1: 0;}
template <class T> bool chmax(T& a, const T &b) {return b > a? a = b, 1: 0;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef tuple<int,int,int> tp;
/****head****/
char bd[111][111];
void gao(int a,char c){
    if(!a)return;
    for(int i=0;i<100;i+=2){
        for(int j=0;j<100;j+=2){
            bd[i][j]=c;
            if(--a==0)return;
        }
    }
}
int main(){
    int a,b;cin>>a>>b;--a;--b;
    rep(i,0,50)rep(j,0,100)bd[i][j]='#';
    rep(i,50,100)rep(j,0,100)bd[i][j]='.';
    gao(a,'.');
    rep(i,0,50)rep(j,0,100)swap(bd[i][j],bd[99-i][99-j]);
    gao(b,'#');
    puts("100 100");
    rep(i,0,100){
        bd[i][100]=0;
        puts(bd[i]);
    }
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int k, n;
  cin >> k >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> b(n);
  rep(i, n-1) b[i] = a[i+1]-a[i];
  b[n-1] = a[0]+k-a[n-1];

  cout << k - *max_element(ALL(b)) << endl;
}


Measured memory_bytes: 6392
#include<iostream>
#include<vector>
#define INT_MAX 999999999
#define ll long long int
using namespace std;
int main()
{
  ll n, w;
  cin>>n>>w;
  vector<ll> a(n), v(n);
  for(int i =0; i< n; i++)
    cin>>a[i]>>v[i];
  ll dp[w+1][n+1];
  for(int i = 0 ; i<= n; i++)
    dp[0][i] = 0;
for(int i = 0 ; i<= w; i++)
    dp[i][0] = 0;
  for(int i =1; i<=w; i++)
  {
    for(int j = 1; j<=n; j++)
    {
        if(i-a[j-1]>=0)
        {
            dp[i][j] = max(dp[i][j-1],v[j-1]+dp[i-a[j-1]][j-1]); 
        }
        else
        {
            dp[i][j] = dp[i][j-1];
        }
    }
  }
  cout<<dp[w][n]<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, K;
  cin >> N >> K;
  int a = (N+1)/2;
  cout << (K <= a ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
#define reprev(i, N) for(int i=N-1; i>=0; --i)
using namespace std;
//using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));
const int MLG = 105;
string S; int K;
int lg;
vec c(MLG);

//関数：
int countcells(int ini) {
	c[0] = ini;
	int ct = 0;
	rep(i, lg-1) {
		if(S[i] == S[i+1]) c[i+1] = c[i] + 1;
		else c[i+1] = 0;
	}
	rep(i, lg) {
		int re = c[i] % 2;
		ct += re;
	}
	return ct;
}

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

	cin >> S; cin >> K;
	lg = S.size();

	int ini = 0;
	if(S[0] == S[lg-1]) {
		ini = 1;
		for(int i=lg-1; i>=0; --i) {
			if(S[i] != S[i-1]) break;
			ini += 1;
		}
	}

	if(ini == lg) {
		int ct = (lg * K) / 2;
		cout << ct << endl;
		return 0;
	} else {

	int ct = 0;
	ct += countcells(0);
	ct += countcells(ini) * (K-1);

	cout << ct << endl; 
	return 0;

	}
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);


Measured memory_bytes: 256
import java.util.Scanner;

class Command {

	private String method;
	private int a;
	private int b;
	private String p;

	public Command(String input) {
		super();

		String[] parts = input.split(" ");

		this.method = parts[0];
		this.a = Integer.parseInt(parts[1]);
		this.b = Integer.parseInt(parts[2]);

		if(parts.length == 4) this.p = parts[3];
	}

	public String doMethod(String str) {

		switch (this.method) {
		case "print":

			System.out.println(str.substring(a, b+1));
			break;

		case "reverse":

			char[] reverse = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				if(a <= i && i <= b) {
					reverse[i] = str.charAt(b-(i-a));
				} else {
					reverse[i] = str.charAt(i);
				}
			}
			str = new String(reverse);
			break;

		case "replace":

			char[] replace = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				if(a <= i && i <= b) {
					replace[i] = p.charAt(i-a);
				} else {
					replace[i] = str.charAt(i);
				}
			}
			str = new String(replace);
			break;

		default:
			break;
		}

		return str;
	}
}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		int num = sc.nextInt();
		sc.nextLine();

		Command[] commands = new Command[num];
		for (int i = 0; i < num; i++) {

			String input = sc.nextLine();
			commands[i] = new Command(input);

		}
		sc.close();

		for(Command command : commands) {
			str = command.doMethod(str);
		}

	}
}

Measured memory_bytes: 28272
N = int(input())
h = [0]
h += list(map(int, input().split()))

count = 0
while True:
    ### 草むらの端から端まで調べる
    ### 0 で区切られている1以上の箇所がn個 を調べる
    num_block = 0
    for i in range(len(h)):
        if h[i] > 0:
            if i == 0 or h[i - 1] == 0:
                num_block += 1
    ### n が0なら終了
    if num_block == 0:
        break
    ### count に n を足す
    count += num_block

    ### 1以上のh の要素 -1 する
    ### 0 の要素はmax(0 - 1, 0) = 0 となる
    h = list(map(lambda x: max(x - 1, 0), h))

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll n;
    ll sum=0;
    cin >> n;
    vector<ll> a(n);
    map<int, ll> m;
    rep(i,n){
        cin >> a.at(i);
        m[a.at(i)]++;
    }
    for(auto e: m){
        sum+=e.second*(e.second-1)/2;
    }
    rep(i,n){
        ll k = a.at(i);
        ll sb=-m[k]*(m[k]-1)/2;
        sb+=(m[k]-1)*(m[k]-2)/2;
        cout << sum+sb << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
	int n, p, digit, fx;
	fx = 0;
	scanf("%d", &n);
	p = n;
	while(p>0){
		digit = p % 10;
		fx+=digit;
		p/=10;
	}
	if(n % fx == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
require 'prime'
N, M = gets.split.map(&:to_i)

primes = Prime.prime_division(M)

num = 1
primes.each do |pr, n|
    num *= n+1
end
divs = []
num.times do |i|
    prod = 1
    primes.each do |pr, n|
        prod *= pr ** (i % (n+1))
        i /= n+1
    end
    divs.push(prod)
end

puts divs.select{|d| d*N <= M}.max

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  string S;
  cin >> S;
  bool ans = true;
  REP(i,a+b+1){
      if (i==a){
          //dump(i);
          //dump(S[i]);
          if (S[i]!='-')ans=false;
      }else{
          if (S[i]=='-')ans=false;
      }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n - 1; i++) std::cin >> c[i] >> s[i] >> f[i];
    for (int start = 0; start < n; start++) {
        int ans = 0;
        for (int pos = start; pos < n - 1; pos++) {
            int t = std::max(s[pos], (ans + f[pos] - 1) / f[pos] * f[pos]);
            ans = t + c[pos];
        }
        std::cout << ans << std::endl;
    }
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int max= 0;
    int preans = 0;
    for(int i=0; S[i] != '\0'; i++) {
        if(S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
            preans++;
        }
        else{
            if(preans > max) {
                max = preans;
                preans = 0;
            }
        }
    }
    if(preans > max) {
        max = preans;
    }
    cout << max;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		if (s == "A") {
			M++;
		}
		else {
			M--;
		}
		if (M < 0) {
			cout << "NO\n";
			return 0;
		}
	}
	if (M != 0) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
	return 0;
}

Measured memory_bytes: 3208