akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int H,W; cin >> W >> H;
        if(H == 0 && W == 0) break;

        int visited[30][30] = {};
        int masu[30][30] = {};
        queue<PII> que;
        int ans = 0;
        int dx[] = {0,0,-1,1};
        int dy[] = {-1,1,0,0};
        REP(i,H){
            string S; cin >> S;
            REP(j,W){
                if(S[j] == '.') masu[i][j] = 1;
                else if(S[j] == '#') masu[i][j] = 2;
                else{
                    que.push(PII(i,j));
                    visited[i][j] = 1;
                    ans++;
                }
            }
        }
        while(!que.empty()){
            auto p = que.front(); que.pop();
            int nx = p.first;
            int ny = p.second;
            REP(i,4){
                int x = nx + dx[i];
                int y = ny + dy[i];
                if(0 <= x && x < H && 0 <= y && y <= W && masu[x][y] == 1 && visited[x][y] == 0){
                    que.push(PII(x,y));
                    visited[x][y] = 1;
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 3236
def main():
    import bisect
    a, b, c, d, e, f = map(int, input().split())
    a = a * 100
    b = b * 100
    g = f * e // 100
    wtr = [0] * f
    sgr = [0] * g
    wtr[0] = 1
    sgr[0] = 1
    wtr_l = []
    sgr_l = []


    def comb(lmt, tgt, lis):
        for i in range(lmt - tgt):
            if lis[i] != 0:
                lis[i + tgt] = 1


    comb(f, a, wtr)
    comb(f, b, wtr)
    comb(g, c, sgr)
    comb(g, d, sgr)

    for i, w in enumerate(wtr):
        if i == 0:
            continue
        elif w == 1:
            wtr_l.append(i)

    for j, s in enumerate(sgr):
        if s == 1:
            sgr_l.append(j)

    res = -1
    ans = []
    for wt in wtr_l:
        pct = min(f - wt, wt * e // 100)
        sid = bisect.bisect_left(sgr_l, pct)
        if pct in sgr_l:
            sgr_max = sgr_l[sid]
        else:
            sgr_max = sgr_l[sid - 1]
        pct_max = 100 * sgr_max / (wt + sgr_max)
        if pct_max > res:
            res = pct_max
            ans.append((wt + sgr_max, sgr_max))
    print(*ans[-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t[100005] = {};
  int n, q;
  int l, r;
  string s;

  cin >> n >> q;
  cin >> s;

  for(int i = 0;i < n - 1;i++){
    if(s[i] == 'A' && s[i + 1] == 'C'){
      s[i] = 'a';
    }
  }

  if(s[0] == 'a') t[1] = 1;
  
  for(int i = 1;i < n;i++){
    t[i + 1] = t[i];
    if(s[i] == 'a'){
      t[i + 1]++;
    }
  }

  for(int i = 0;i < q;i++){
    cin >> l >> r;
    cout << t[r - 1] - t[l - 1] << endl;
  }
  return 0;
}



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

int main()
{
	int n,s=0,m=10000;
	cin>>n;
	int a[n+1];
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i]; 
	} 
	
	int s1=s/n;
	int a1=0;
	for(int i=1;i<=n;i++)
	{
		a1+=fabs(s1-a[i])*fabs(s1-a[i]);
	}
	
	int s2=s/n+1;
	int a2=0;
	for(int i=1;i<=n;i++)
	{
		a2+=fabs(s2-a[i])*fabs(s2-a[i]);
	}
	if(a1<a2)
		cout<<a1;
	else
		cout<<a2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

bool sRotate(string S, string T) {
    string res = "";
    rep(i, len(S)) {
        res = S.at(len(S) - 1);
        S.pop_back(); res += S;

        if (res == T) return true;
        S = res; res = "";
    }
    return false;
}

int main() {
    string S, T; cin >> S >> T;
    if (sRotate(S, T)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>


const double PI = 4.0 * atan(1.0);
double ToRadian(double degree)
{
	return degree * PI/180;
}

using namespace std;


int main()
{
	int d, t;
	double x, y;
	x = y = 0;
	int totalAngle = 90;
	while (true)
	{
		scanf("%d,%d", &d, &t);
		if (d == 0 && t ==0)
			break;

		double ang = ToRadian(totalAngle);
		x += d * cos(ang);
		y += d * sin(ang);
		totalAngle -= t;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n];
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long ans=0,t=0;
    for(long long i=0;i<n;i++)
    {
        t=max(t,a[i]);
        ans+=(t-a[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 5188
s=input()
s_r = s[::-1]
n = len(s)
s1 = s[:(n-1)//2]
s1_r = s1[::-1]
s2 = s[(n+3)//2 - 1:]
s2_r =s2[::-1]

if s == s_r and s1 == s1_r and s2 == s2_r:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  std::vector<int> s(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>s[i];
  }
  sort(s.begin(), s.end());
  int sum=accumulate(s.begin(), s.end(),0);
  if(sum%10!=0){
    cout<<sum;
    return 0;
  }
  for(auto&& e: s) {
    if(e%10==0) continue;
    sum-=e;
    cout<<sum;
    return 0;
  }
  cout<<0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long n = read.to!long;
	long k = read.to!long;
	
	long[] as = readln.chomp.split.to!(long[]);
	
	long ans = ((n - 1) + (k - 1 - 1)) / (k - 1);
	
	ans.writeln;
	}

Measured memory_bytes: 4160
N, Q = [int(_) for _ in input().split()]

S = input()

a = [0] * N
for i in range(N - 1):
    a[i] = 1 if S[i] == 'A' and S[i + 1] == 'C' else 0
s = [0] * (N + 1)
for i in range(N):
    s[i + 1] = a[i] + s[i]

for _ in range(Q):
    l, r = [int(_) - 1 for _ in input().split()]
    print(s[r] - s[l])


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

int main() {
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++) {
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s << "\n";
}


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

int main() {
	string s;
	vector<long long> count;
	long long c = 1;
	cin >> s;
	if (s.length() > 1) {
		for (int i = 1; i < s.length(); i++) {
			if (s[i - 1] != s[i]) {
				count.push_back(c);
				c = 1;
			}
			else {
				c++;
			}
			if (i == s.length() - 1) {
				count.push_back(c);
			}
		}
		cout << count.size() - 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> vec(n,vector<int>(0));
  for(int i=0; i<n-1; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  vector<int> cn(n);
  int cum = 0;
  for(int i=0; i<n; ++i){
    cin >> cn[i];
    cum += cn[i];
  }
  sort(cn.begin(),cn.end());
  reverse(cn.begin(),cn.end());
  vector<int> ans(n,-1);
  cout << cum-cn[0] << endl;
  
  queue<int> que;
  que.push(0);
  ans[0] = cn[0];
  int point = 1;
  while(!que.empty()){
    int x = que.front();
    que.pop();
    for(int a:vec[x]){
      if(ans[a] != -1) continue;
      ans[a] = cn[point];
      ++point;
      que.push(a);
    }
  }
  for(int i=0; i<n; ++i){
    if(i != n-1) cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4016
#include <stdio.h>

int main(void)
{
	int n,a[100],i,j,t,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(a[j-1]>a[j]){
				t=a[j-1];
				a[j-1]=a[j];
				a[j]=t;
				s++;
			}
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)printf(" %d",a[i]);
	printf("\n%d\n",s);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  char S;
  char c;
  int count =0;

  for(int i=0;i<N;i++){
    cin >> S;
    if(c == S){
        count++;
    }else{
    }
    c= S;
  }
  cout << N-count;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){

  int a,d,n;
  int count;
  
  while(1){
    count = 0;
    cin>>a>>d>>n;

    if(a == 0 && d == 0 && n == 0){
      break;
    }

    if(a == 1){
      a = a+d;
    }
    
    while(1){
      int judge = 1;
      
      if(a%2 != 0){
	for(int i = 3; i*i<=a; i += 2){
	  if(a%i == 0){
	    judge = 0;
	  }
	}
      }
      else{
	if(a == 2){
	  judge = 1;
	}
	else{
	  judge = 0;
	}
      }
      if(judge == 1){
	++count;
      }
      if(count == n){
	break;
      }
      a = a+d;
    }

    cout<<a<<endl;
  }
  return 0;

}

Measured memory_bytes: 3072
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#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 readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#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 print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#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 endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
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

    readc(n, h, w);
    cout << (n-h+1) * (n-w+1);

    return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n - 1],
    }

    let mut rs = vec!(0; n);

    for i in a {
        rs[i - 1] += 1;
    }

    for r in rs {
        println!("{}", r);
    }
}


Measured memory_bytes: 5476
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

class UnionFind
{
    private int[] p;
    private int[] r;
    this(int n){ p = iota(n).array(); r = new int[n]; }
    int find(int x)
    {
        if(x==p[x]) return x;
        return p[x]=find(p[x]);
    }
    void unite(int x, int y)
    {
        x=find(x);
        y=find(y);
        if(r[x]>r[y]) swap(x,y);
        p[y]=x;
        if(r[x]==r[y]) ++r[y]; 
    }
    bool same(int x, int y){ return find(x)==find(y); }
}

void main()
{
    for(int n; 0!=(n=readln().chomp().to!int()); )
    {
        immutable m = readln().chomp().to!int();
        auto g = iota(m).map!(_=>readln().chomp().split(",").map!(to!int).array()).array()
            .map!(a=>[a[2]/100-1,a[0],a[1]]).array().sort();
        auto uf = new UnionFind(n);
        int c=0;
        foreach(e;g)
        {
            if(uf.same(e[1],e[2])) continue;
            uf.unite(e[1],e[2]);
            c+=e[0];
        }
        writeln(c);
    }
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int main() {
  int K;
  scanf("%d", &K);

  rep(i, K) {
    printf("ACL");
  }

  return 0;
}


Measured memory_bytes: 1728
a, b, c, money = [int(input()) for i in range(4)]
counter = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500 * i + 100 * j + 50 * k == money:
        counter += 1
        
print(counter)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	ll P;
	cin >> N >> P;
	string S;
	cin >> S;
	vl U(N + 1);
	U[N] = 0;
	if (P == 2 || P == 5) {
		for (i = 0; i < N; i++) {
			if (ctoi(S[i]) % P == 0) {
				ans += i + 1;
			}
		}
		cout << ans;
	}
	else {
		map<ll, ll> M;
		//0文字選ぶとあまりは0
		M[0] = 1;
		ll sum = 0;
		ll keta = 1;
		for (i = N-1; i >= 0; i--) {
			(sum += ctoi(S[i]) * keta) %= P;
			(keta *= 10) %= P;
			M[sum]++;
		}
		for (auto x : M) {
			//MODが同じもの同士を選ぶ
			ans += x.second * (x.second - 1) / 2;
		}
		cout << ans;
	}
}

Measured memory_bytes: 2564
def solve():
    names = {}
    for si in s:
        if si in names:
            names[si]+=1
        else:
            names[si] = 1
    maxi = 0
    winners = []
    for n in names:
        maxi = max(maxi, names[n])
    for n in names:
        if names[n] == maxi:
            winners.append(n)
    winners.sort()
    for winner in winners:
        print(winner)
    return



n = int(input())
s = []
for i in range(n):
    s.append(input())

# n, m = [int(s) for s in input().split(" ")]
solve()


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double n;
	cin>>n;
	cout<<fixed << setprecision(15)<<n*2*3.141592653589793<<endl;
	return 0;
}


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

int main(){

  int a,b,n,ans;

  while(cin >> a >> b >> n){

    ans = 0;

    for(int i=0;i<n;i++){
      a %= b;
      a *= 10;
      ans += a/b;
    }

    cout << ans << endl;
  }

}

Measured memory_bytes: 1160
if __name__ == "__main__":
    n = int(input())
    s = {}
    o = []
    for i in range(n):
        tmp = input()
        if tmp not in s.keys():
            s[tmp] = 1
        else:
            s[tmp] += 1
    s_sorted = sorted(s.items(), key=lambda x:x[1], reverse = True)
    
    l = s_sorted[0][1]
    for i in s_sorted:
        if i[1] == l:
            o.append(i[0])
        else:
            break
    
    for i in sorted(o):
        print(i)

Measured memory_bytes: 47324
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	cout << (x-a)%b << endl;

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
bool a[8][8];
int N;

int dfs(int u,bool check[]){
    bool all=true;
    for(int i=0;i<N;i++){
        if(check[i]==false) all=false;
    }
    if(all==true) return 1;
    int sum=0;
    for(int i=0;i<N;i++){
        if(a[u][i]==false) continue;
        if(check[i]==true) continue;
        check[i]=true;
        sum+=dfs(i,check);
        check[i]=false;
    }
    return sum;
}

int main(){
    int M;
    cin >> N >> M;
    memset(a,false,sizeof(a));
    for(int i=0;i<M;i++){
        int u,v;
        cin >> u >> v;
        a[u-1][v-1]=true;
        a[v-1][u-1]=true;
    }
    bool check[N];
    memset(check,false,sizeof(check));
    check[0]=true;
    cout << dfs(0,check) << endl;
    return 0;
}

Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)
S = gets.chomp.chars
lr_list = Q.times.map { gets.split.map(&:to_i) }
ac_count_list = Array.new(N)
count = 0
prev_ch = nil
S.each.with_index do |ch, i|
  count += prev_ch == 'A' && ch == 'C' ? 1 : 0
  prev_ch = ch
  ac_count_list[i] = count
end
lr_list.each do |(l, r)|
  l -= 1
  r -= 1
  ans = ac_count_list[r] - ac_count_list[l]
  puts ans
end


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

int main() {
  int N;
  cin >> N;
  string P,W,G,Y;
  for(int i = 0;i < N;i++){
    string x;
    cin >> x;
    if (x == "Y"){
      cout << "Four" <<endl;
      break;
    }
    else{
      if(i == N - 1){
        cout << "Three" <<endl;
      }
      else{
        continue;
      }
    }
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<int>a(N);
    for (int i=0; i<N; i++)cin >> a[i]; 
    int sm=0;
    for (int i=0; i<N; i++)sm += a[i];

    int mean = ceil((double)sm/N);
    int ans1, ans2;
    ans1 = ans2 = 0;
    for (int i=0; i<N; i++){
        ans1 += (mean-a[i])*(mean-a[i]);
    }
    mean--;
    for (int i=0; i<N; i++){
        ans2 += (mean-a[i]) * (mean-a[i]);
    }
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 3792
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        for(int i = 0; ; i++)
        {
            if ((1 << i) > n)
            {
                Console.WriteLine(1 << (i - 1)); break;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S;
  cin >> S;
  if (S == "SUN") {
    cout << 7 << endl;
  }
  if (S == "MON") {
    cout << 6 << endl;
  }
  if (S == "TUE") {
    cout << 5 << endl;
  }
  if (S == "WED") {
    cout << 4 << endl;
  }
  if (S == "THU") {
    cout << 3 << endl;
  }
  if (S == "FRI") {
    cout << 2 << endl;
  }
  if (S == "SAT") {
    cout << 1 << endl;
  }
}
  

Measured memory_bytes: 3552
def prod(list):
    prod = 1
    for k in list:
        prod = (prod * k) % (10**9+7)
    return prod
    
    


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

plus = []
minus = []

for k in a:
    if k >= 0:
        plus.append(k)
    if k <= 0:
        minus.append(k)

if len(plus) == 0:
    if kk % 2 == 0:
        mi = sorted(minus)
        ans = prod(mi[:kk])
    else:
        mi = sorted(minus, reverse=True)
        ans = prod(mi[:kk])

    print(int(ans) % (10**9+7))

elif n == kk:
    ans = prod(a)
    print(int(ans) % (10**9+7))

else:
    mi = sorted(minus)
    pl = sorted(plus, reverse=True)
    mi.append(0)
    mi.append(0)
    pl.append(0)
    pl.append(0)
    miind = 0
    plind = 0
    ans = 1
    while kk > miind + plind:
        if mi[miind]*mi[miind+1] > pl[plind]*pl[plind+1] and kk != miind + plind + 1:
            ans = (ans*mi[miind]*mi[miind+1]) % (10**9+7)
            miind += 2
        else:
            ans = (ans*pl[plind]) % (10**9+7)
            plind += 1

    print(ans)

Measured memory_bytes: 31864
import Control.Monad
import Data.List

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
  a <- getLine
  putStrLn $ f a

f [] = []
f (',':xs) = ' ' : f xs
f (x:xs) = x : f xs

Measured memory_bytes: 380
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		long n=nextLong();
		long a=nextLong();
		long b=nextLong();
		long ans=(n/(a+b))*a+Math.min(a,n%(a+b));
		out.println(ans);

	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/


int main() {
	lint N;
	cin >> N;
	lint dp[100];
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 2; i <= N; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[N] << endl;
}

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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++){
        int start,end;
        cin >> start >> end;
        ans += end - start + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
 
void solve()
{
    ll n,k;cin>>n>>k;
    ll a[maxn+3]={0};ll cnt = 0;
    for(ll i=k;i>=1;i--)
    {
        ll till = k/i;ll ans =0;
        (ans+=power(till,n,MOD))%=MOD;
        for(ll j=(i<<1);j<=k;j+=i)
        {
            (ans-=a[j]+MOD)%=MOD;
        }
        a[i] = (ans+MOD)%MOD;
        (cnt+= a[i]*i)%=MOD;
    }
    cout<<cnt<<endl;
}

signed main()
{
   Need_for_speed(activated);
//
//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


Measured memory_bytes: 7524
#include<bits/stdc++.h>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 3604
import sys
class alphabet: #Trueなら大文字
    def __init__(self, capitalize):
        self.num = dict()
        self.index = dict()
        self.abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"\
            ,"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
        if capitalize: 
            for i in range(26): self.abc[i] = self.abc[i].upper()
        for i, a in enumerate(self.abc):
            self.num[a] = i
            self.index[i] = a

def solve():
    input = sys.stdin.readline
    N = int(input())
    S = input().strip("\n")
    AB = alphabet(True)
    Ans = [None] * len(S)
    for i in range(len(S)):
        Ans[i] = AB.index[(AB.num[S[i]] + N) % 26]
    print("".join(map(str, Ans)))
    

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3188
from bisect import bisect_right
a, b, c, d, e, f = map(int, input().split())
waters = set(i*a+j*b if (i*a+j*b)*100<=f else 0 for i in range(31) for j in range(31))
sugers = list(set(i*c+j*d if i*c+j*d<=f else 0 for i in range(1501) for j in range(1501)))
sugers.sort()
ans_water = 0
ans_suger = 0
ans_conc = -1
for water in waters:
    if water==0:
        continue
    tmp = bisect_right(sugers, e*water)-1
    while tmp>=0:
        suger = sugers[tmp]
        if water*100+suger<=f:
            break
        tmp -= 1
    if ans_conc < suger/(water*100+suger):
        ans_conc = suger/(water*100+suger)
        ans_suger = suger
        ans_water = water*100
print(ans_water+ans_suger, ans_suger)

Measured memory_bytes: 3188
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        k: usize
    }
    let mut s = vec![0usize; k];
    s[0] = 7 % k;
    for i in 1..k {
        s[i] = (s[i - 1] * 10 + 7) % k;
    }
    for i in 0..k {
        if s[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
    println!("-1");
}


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

#define out cout 
#define in cin
#define el endl
#define rep(i, N) for (int i = 0; i < N; i++)
#define ol(N) cout << N << endl

int main()
{
	int x, y;
	while (in >> x >> y, x || y){
		int n, dp[17][17] = {0};
		bool f[17][17] = {false};

		in >> n;
		rep(i, n){
			int a, b;
			in >> a >> b;
			f[--b][--a] = true;
		}
		dp[0][0] = 1;
		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				if (!f[i + 1][j]) dp[i + 1][j] += dp[i][j];
				if (!f[i][j + 1]) dp[i][j + 1] += dp[i][j];
			}
		}
		ol(dp[--y][--x]);
	}
	return (0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    string s;
    cin >> s;
    repi(i,s.size(),0){
    int a = 0;
        repi(j,s.size(),0){
            if(s[i] == s[j])a++;
        }
        if(a != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    long double n;
    long double m;
    cin >> n >> m;
    ll M = m;
    vector<long double> vec(n);

    long double sum = 0;
    rep(i, n){
        cin >> vec[i];
        sum += vec[i];
    } 

    sort(all(vec),greater<long double>());

    long double tmp = sum / (4 * m);


    string ans = "Yes";
    rep(i,M){
        if(vec[i] < tmp){
            ans = "No";
        }
    }
    cout << ans << endl;



}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, K = map(int, input().split())
# 横
A = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
tmp = 0

for i, a in enumerate(A) :
    for aa in range(i + 1, N) :
        if a > A[aa] :
            ans += 1

for a in A :
    for aa in A :
        if a > aa :
            tmp += 1

ans = (ans * K)
ans += (tmp * ((K * (K - 1)) // 2) % MOD)
ans %= MOD

print(ans)


Measured memory_bytes: 41708
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>

using namespace std;

int main(){
  vector< vector<int> > c(3, vector<int>(3,0));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      int temp;
      cin >> temp;
      c[i][j] = temp;
    }
  }

  bool ans = false;
  for(int a=0; a<=100; a++){
    int b1 = c[0][0] - a;
    int b2 = c[0][1] - a;
    int b3 = c[0][2] - a;
    if( c[1][0] - b1 == c[1][1] - b2 && c[1][1] - b2 == c[1][2] ){
      if( c[2][0] - b1 == c[2][1] - b2 && c[2][1] - b2 == c[2][2] ){
        ans = true;
        break;
      }
    }
  }

  if(ans){
    cout << "Yes";
  }else{
    cout << "No";
  }
}



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

int count(vector<int> s, vector<int> t)
{
  int cnt=0;
  for(int j=0;j<t.size();j++){
    for(int i=0;i<s.size();i++){
      if(s[i]==t[j]){
	//cout<<s[i]<<','<<t[j]<<endl;
	cnt++;
	break;
      }
    }
  }
  return cnt;
}
int main()
{
  int n,q;
  cin>>n;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }

  cin>>q;
  vector<int> t(q);
  for(int i=0;i<q;i++){
    cin>>t[i];
  }
  cout<<count(s,t)<<endl;
  return 0;
}


Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const long mod = 1000000007;
        

        static void Main(string[] args)
        {
            var n = Input();
            long ans = 0;

            long ten = 1;
            long nine = 1;
            long eight = 1;

            for(long i = 1; i <= n; i++)
            {
                ten *= 10;
                nine *= 9;
                eight *= 8;
                ten = ten % mod;
                nine = nine % mod;
                eight = eight % mod;
            }



            ans = (ten - nine * 2 + eight) % mod;
            if (ans < 0) ans += mod;


            Console.WriteLine(ans);

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        /*static public void DFS(int h, int w, bool[][] _visited)
        {
            
            if (w < 0 || h < 0 || h > _visited.Length - 1 || w > _visited[h].Length-1 || map[h][w]=='x')
                return;
            if (_visited[h][w])
                return;
            //Console.WriteLine(h + " " + w+" "+ _visited[h].Length + " " + _visited.Length);
            _visited[h][w] = true;

            DFS(h + 1, w,_visited);
            DFS(h - 1, w,_visited);
            DFS(h, w + 1,_visited);
            DFS(h, w - 1,_visited);

        }*/
        
        
        
    }
}


Measured memory_bytes: 27480
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    vector<ll> s;
    s.push_back(2);
    for(ll i = 3; i <= 55555; i++){
        bool ok = true;
        for(ll j = 2; j <= sqrt(i); j++){
            if(i%j==0){
                ok = false;
                break;
            }
        }
        if(ok==true && i%5==1){
            s.push_back(i);
        }
    }
    for(ll i = 0; i < n; i++)
        cout << s[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node
{
  int p, l, r;
};

struct Node T[MAX];
int n;

int main()
{
  int i, j, k, a, b, c, d, p, dep = 0;

  scanf("%d",&n);

   for(i = 0; i < n; i++)
    {
      T[i].p = NIL;
      T[i].l = NIL;
      T[i].r = NIL;
    }


  for(i = 0; i < n; i++)
    {
      scanf("%d%d",&a,&b);

      for(j = 0; j < b; j++)
	{
	  scanf("%d",&c);
	  if(j == 0)T[a].l = c;
	  else T[d].r = c;
	  d = c;
	  T[c].p = a;
	}
    }

  for(i = 0; i < n; i++)
    {
      printf("node %d: ",i);
      
      printf("parent = %d, ",T[i].p);

      k = i;
      dep = 0;
      while(T[k].p != NIL)
	{
	  k = T[k].p;
	  dep++;
	}
      printf("depth = %d, ",dep);
      
      if(T[i].p == NIL)
	{
	  printf("root, [");
	  if(T[i].l != -1)
	    {
	      printf("%d",T[i].l);
	      k = T[i].l;
	      while(T[k].r != NIL)
		{
		  printf(", %d",T[k].r);
		  k = T[k].r;
		}
	    }
	  printf("]\n");
	}
      else if(T[i].l == NIL)printf("leaf, []\n");
      else
	{
	  printf("internal node, [");
	      printf("%d",T[i].l);
	      k = T[i].l;
	      while(T[k].r != NIL)
		{
		  printf(", %d",T[k].r);
		  k = T[k].r;
		}
	  printf("]\n");
	}
    }
  
  return 0;
}



Measured memory_bytes: 2976
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
#include <atcoder/all>
using namespace std; using namespace atcoder;
using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;
int main() {
	int N;
	cin >> N >> Q;
	fenwick_tree<ll> FT(N);
	for (i = 0; i < N; i++) {
		ll a;
		cin >> a;
		FT.add(i, a);
	}
	for (i = 0; i < Q; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		if (a == 0) FT.add(b, c);
		else cout << FT.sum(b, c) << endl;
	}
}

Measured memory_bytes: 8220
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
	Scanner scanner = new Scanner(System.in);
	// "abc"という文字列
	String a=scanner.next();
	String b=scanner.next();
	// 変数strの長さ分回す
	for (int i = 0; i < a.length(); i++) {
	    // strの先頭から1文字ずつString型にして取り出す
	    String str1 = String.valueOf(a.charAt(i));
	    String str2 = String.valueOf(b.charAt(i));
	    if(str1.equals(str2)){
	    	if(i==a.length()-1) {
	    		System.out.println("Yes");
	    		break;
	    	}
        }
	    else {
	    	System.out.println("No");
	    	break;
	    }

	}}
}


Measured memory_bytes: 35636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int 
#define ll long long int 
#define lol std::ios::sync_with_stdio(false);std::cin.tie(NULL);cout.tie(NULL);
template<typename T>
T gcdr(const T& a, const T& b){
    if(b==0) return a;
    return gcdr(b,a%b);
}
int main() {
    ull a,b,i=0,k=0,ans=1;
    cin>>a>>b;
    ull d=__gcd(a,b);
    ull aa=sqrt(d)+1;
    for(i=2;i<=aa;i++){
        if(d%i==0){
            ++ans;
            while(d%i==0){
                d/=i;
            }
        }
    }
    if(d!=1) ++ans;
    cout<<ans<<endl;
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a;
    int sum = 0;
    rep(0, 3) {
        cin >> a;
        sum += a;
    }

    cout << (22 <= sum ? "bust" : "win") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	
	s[5]=' ';
	s[13]=' ';
	cout << s << endl;
	return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int ss = s.size();
    if(ss%2 == 1)
        ss--;
    else
        ss-=2;
    int i=ss;
    for(; i>0; i-=2){
        bool a = true;
        for(int j=0; j<i/2; ++j){
            if(s[j] != s[i/2+j]){
                a = false;
                break;
            }
        }
        if(a)
            break;
    }
    cout<<i<<"\n";
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i,0,N){
        cin >> vec[i];
    }
    int mini=MOD,tmp;
    REP(i,-100,101){
        int sum=0;
        REP(j,0,N){
            tmp=abs(vec[j]-i);
            sum+=tmp*tmp;
        }
        mini=min(mini,sum);
    }
    P(mini);
}

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

int main() {
  ll N;
  cin >> N;
  ll x = 0;
  ll y = 0;
  for (ll i = sqrt(N); i >= 1; i--) {
    if (N % i == 0) {
      x = i;
      y = N / i;
      break;
    }
  }
  cout << (x - 1) + (y - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll dp[2][1<<12];
void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[m],b[m],c[m];
  mem(c);
  rep(i,m) {
    cin >> a[i] >> b[i];
    rep(j,b[i]) {
      ll x;
      R x;
      x--;
      c[i]|=1<<x;
    }
  }
  rep(i,2)rep(j,1<<n) dp[i][j]=MAXL;
  dp[0][0]=0;
  ll t=0;
  rep(i,m) {
    rep(r,1<<n) {
      dp[t^1][r]=min(dp[t^1][r],dp[t][r]);
      dp[t^1][r|c[i]]=min(dp[t^1][r|c[i]],dp[t][r]+a[i]);
    }
    t^=1;
  }
  ll ans=dp[t][(1<<n)-1];
  if(ans==MAXL) ans=-1;
  pr(ans);
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
	string s; cin>>s;
	int a=0,b=0;
	if(s[0]=='A'){
		a=1;
	}else{
		b=1;
	}
	if(s[1]=='A'){
		a=1;
	}else{
		b=1;
	}
	if(s[2]=='A'){
		a=1;
	}else{
		b=1;
	}
	if(a*b==0){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Main.run();
    }

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        // カードリスト
        ArrayList<Integer> cardlist = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            cardlist.add(Integer.parseInt(sc.next()));
        }
        // カードリストを降順ソート
        Collections.sort(cardlist);
        Collections.reverse(cardlist);
        // アリスとボブの得点
        int alice = 0;
        int bob = 0;
        // アリス→ボブの順で交互に高いカード引く
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alice += cardlist.get(i);
            } else {
                bob += cardlist.get(i);
            }
        }
        out.println(alice - bob);
        out.close();
        sc.close();
    }

}


Measured memory_bytes: 35744