akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 5;
const int mod = (int) 1e9 + 7;

vector<int> g[N];
int n, m, Q, ans[N], ds[N], u[N];
int q[N * 100], qd[N * 100], qb, qe, t = 1, f[N];

void paint (int c) {
        while (qb < qe) {
                int v = q[qb], d = qd[qb++];
                if (ans[v] != 0 && ds[v] >= d) {
                        continue;
                }
                if (!ans[v]) {
                        ans[v] = c; ds[v] = d;
                }else

                {
                        ds[v] = d;
                }
                if (d) {
                        for (int to : g[v]) {
                                if (u[to] != t) {
                                        u[to] = t;
                                        q[qe] = to;
                                        qd[qe++] = d - 1;
                                }
                        }
                }
        }
        qb = qe = 0; ++t;
}

int v[N], d[N], c[N];

inline void solve () {
        scanf ("%d%d", &n, &m);
        for (int i = 1; i <= m; i++) {
                int x, y;
                scanf ("%d%d", &x, &y);
                g[x].emplace_back (y);
                g[y].emplace_back (x);
        }
        scanf ("%d", &Q);
        for (int i = 1; i <= Q; i++) {
                scanf ("%d%d%d", &v[i], &d[i], &c[i]);
        }
        for (int i = Q; i >= 1; i--) {
                q[qe] = v[i]; qd[qe++] = d[i];
                u[v[i]] = t;
                if (c[i] != c[i - 1]) {
                        paint (c[i]);
                }
        }
        for (int i = 1; i <= n; i++) {
                printf ("%d\n", ans[i]);
        }
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 15224
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")



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


Measured memory_bytes: 38256
#include<iostream>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<vector>
#include<iterator>

int main() {
  using namespace std;

  auto n = 0;
  cin >> n;

  vector<int> balls;
  multimap<int, int> mballs;
  for(int i = 0; i < n; i++)
  {
    int num = 0;
    cin >> num;
    balls.push_back(num);
    mballs.emplace(num, i);
  }

  const unordered_set<int> uniqueBalls(balls.begin(),balls.end());
  unordered_map<int, int> countBalls;
  long long cxcm1A = 0;
  for (const auto &b : uniqueBalls)
  {
    const auto c = mballs.count(b);
    countBalls.emplace(b, c);
    cxcm1A += c * (c - 1);
    mballs.erase(b);
  }

  for(int i = 0; i < n; i++)
  {
    const int kCount = countBalls.at(balls[i]);
    const long long && count = -(2 * kCount - cxcm1A - 2) / 2;
    cout << count << endl;
  }
}

Measured memory_bytes: 21912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<ll,ll>;
#define ALL(x) (x).begin(),(x).end()

int main(){
	ll N; cin >> N;
	ll ans =0;
	for(ll n=1;n<=N;n++) {
		if(n % 3 == 0 or n % 5 == 0) {

		} else {
			ans += n;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
<?php
fscanf(STDIN, "%d", $N);

$tmpMax = 0;

for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    if ($tmpMax < $A) {
        $tmpMax = $A;
        $tmpB = $B;
    }
}

echo $tmpMax + $tmpB . "\n";


Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  vector<int> n(4);
  for(int i=0;i<4;i++)cin>>n[i];
  ndifix::sort(n);
  if(n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(void){
    int n, i, x[100]={}, y[100]={};
    long double  D1=0, D2=0, D3=0,D4=0, proD4;
    cin >> n;
    
    for(i=0; i<n; i++){
        cin >> x[i];
    }
    for(i=0; i<n; i++){
        cin >> y[i];
    }
    
    for(i=0; i<n; i++){
        D1 += abs(x[i] - y[i]);
        D2 += pow((x[i] - y[i]), 2);
        D3 += pow(fabs(x[i] - y[i]), 3); 
        proD4 = abs(x[i] - y[i]);
        if(D4 < proD4) D4 = proD4;
    }
    
    D2 = sqrt(D2);
    D3 = pow(D3, pow(3, -1));
    
    cout << fixed << setprecision(8) << D1 << endl << D2 << endl << D3 << endl << D4 << endl;
    return 0;
    
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const 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 true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	int c = min(A, B / 2);
	cout << c+(B-2*c)/4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#define maxn 100009
#define maxm
#define PS system("pause");
using namespace std;
char s[maxn];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
fn main() {
    let n: i32 = read();
    let mut ac: i32 = 0;
    let mut wa: i32 = 0;
    let mut tle: i32 = 0;
    let mut re: i32 = 0;

    for _ in 0..n {
        let result: String = read();

        if result == "AC" {
            ac += 1;
        } else if result == "WA" {
            wa += 1;
        } else if result == "TLE" {
            tle += 1;
        } else if result == "RE" {
            re += 1;
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];

	vector<ll> sum_l(N+1, 0), sum_r(N+1, 0);

	for (ll i = 0; i < N; ++i) sum_l[i+1] = sum_l[i] + A[i];
	for (ll i = N-1; i >= 0; --i) sum_r[i] = sum_r[i+1] + A[i];

	ll res{INF};
	for (ll i = 1; i < N; ++i)
	{
		res = min(res, abs(sum_l[i]- sum_r[i]));
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
using ll =int;
int main() {
	
		string g;
		cin >> g;
		
		ll count=0;
      	ll m=0;
		for(ll i=0;i<g.size();i++)
		{
			if(g[i]=='R')
			count++;
			else
			{
				m=max(count,m);
				count=0;
			}
        }
  		m=max(count,m);
		cout<<m<<endl;
	//}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 3592
from collections import deque
from bisect import bisect_left
import sys

sys.setrecursionlimit(10**9)

def dfs(v, p=-1):
    a = A[v]
    idx = bisect_left(LIS, a)
    old_val = LIS[idx]
    LIS[idx] = a

    ans[v] = bisect_left(LIS, INF)

    for u in G[v]:
        if u == p:
            continue
        dfs(u, v)
    
    LIS[idx] = old_val

INF = 10**9 + 1
N = int(input())
A = list(map(int, input().split()))
G = [[] for i in range(N)]
for i in range(N-1):
    u, v = list(map(int, input().split()))
    G[u-1].append(v-1)
    G[v-1].append(u-1)

LIS = [INF] * N
ans = [0] * N

dfs(0)

print(*ans, sep='\n')

Measured memory_bytes: 349796
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }


template<typename T> T GCD(T a, T b)
{
    if(b == 0) return a;
    return GCD(b, a % b);
}

void solve()
{
    ll n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                ans += GCD(GCD(i, j), k);
            }
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int selectionSort(int A[], int N) {
    int min_j=0,sw=0;
    for(int i=0; i<N; i++) {
        min_j = i;
        for(int j=i+1; j<N; j++) {
            if(A[j]<A[min_j])min_j = j;
        }
        if(min_j!=i) {
            swap(A[i],A[min_j]);
            sw++;
        }
    }
    return sw;
}

int main() {
    int N,A[110],sw;
    while(cin>>N) {
        for(int i=0; i<N; i++)cin>>A[i];

        sw = selectionSort(A,N);

        for(int i=0; i<N-1; i++)cout<<A[i]<<' ';
        cout<<A[N-1]<<endl;
        cout<<sw<<endl;
    }
    return 0;
}



Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var WHN = Sarray();
            var W = WHN[0];
            var H = WHN[1];
            var N = WHN[2];
            var xl = 0L;
            var xr = W;
            var yd = 0L;
            var yu = H;
            for (var i = 0; i < N; ++i)
            {
                var xya = Sarray();
                var x = xya[0];
                var y = xya[1];
                var a = xya[2];
                if (1 == a)
                    xl = Max(xl, x);
                else if (2 == a)
                    xr = Min(xr, x);
                else if (3 == a)
                    yd = Max(yd, y);
                else if (4 == a)
                    yu = Min(yu, y);
            }
            if (xr < xl || yu < yd)
                WriteLine(0);
            else
                WriteLine((xr - xl) * (yu - yd));
            //Out.Flush();
        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);
    }
}

Measured memory_bytes: 13396
#include<iostream>

int main(int argc, char** argv){
  int N;
  int a;
  int i,count4=0, count1=0, count2 = 0;
  std::cin >> N;
  for(i = 0; i < N; ++i){
    std::cin >> a;
    if(a%4==0) ++count4;
    else if(a%2 == 0) ++count2;
    else ++count1;
  }
  if(count2 > 0) ++count1;
  if(count4+2 > count1) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String nn = sc.next();
    long n = Long.parseLong(nn);
    String aa = sc.next();
    String bb = sc.next();
    long a = Long.parseLong(aa);
    long b = Long.parseLong(bb);
    long set = 0;
    long amari = 0;
    if(!(a+b == 0)){
      set = n / (a+b);
      amari = n % (a+b);
    }
    long ama = a;
    if(amari < a){
      ama = amari;
    }
    System.out.println(set * a + ama);

  }
}


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

int grp(int x) {
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) return 1;
	if (x == 4 || x == 6 || x == 9 || x == 11) return 2;
	return 3;
}

int main() {
	int x, y;
	scanf("%d %d", &x, &y);
	if (grp(x) == grp(y)) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 764
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  A = input.shift().split(" ");
  B = input.shift().split(" ");
  C = input.shift().split(" ");
  N = input.shift();
  BB = input.map(v=>parseInt(v));

  const check = (a, b, c, BB) => {
    return BB.find(v=>v == a) && BB.find(v=>v == b) &&BB.find(v=>v == c)
  };
  console.log(
    [
      check(A[0], A[1], A[2], BB),
      check(B[0], B[1], B[2], BB),
      check(C[0], C[1], C[2], BB),
      check(A[0], B[0], C[0], BB),
      check(A[1], B[1], C[1], BB),
      check(A[2], B[2], C[2], BB),
      check(A[0], B[1], C[2], BB),
      check(A[2], B[1], C[0], BB)
    ].some(v => v) ? 'Yes' : 'No'
  );
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		String result = "No";
		
		if ((a < b) && (b < c)) {
			result = "Yes";
		}
		
		System.out.println(result);
	}
}

Measured memory_bytes: 26216
import math
x = input().split()
n = int(x[0])
a = int(x[1])
b = int(x[2])
z = 0
z = math.floor(n / (a+b)) * a
amari = math.floor(n % (a+b))
if amari == 0:
  pass
elif amari <= a:
  z += amari
else:
  z += a
print(z)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        long w = sc.NextLong();

        string answer = string.Join("", s.Where((c, index) => index % w == 0));

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27972
import java.util.Scanner;
import java.util.HashMap;

public class Main{

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

        // input
        String input1 = scan.next();
        String input2 = scan.next();
        char[] before = input1.toCharArray();
        char[] after = input2.toCharArray();
        HashMap<Character, Character> judge = new HashMap<>();

        // search
        String answer = "Yes";
        for(int i = 0; i < before.length; i++){
            if(!judge.containsKey(before[i])){
                judge.put(before[i], after[i]);
            } else if(judge.get(before[i]) != after[i]) {
                answer = "No";
                break;
            }
        }
        if(answer.equals("Yes")){
            judge.clear();
            for(int i = 0; i < after.length; i++){
                if(!judge.containsKey(after[i])){
                    judge.put(after[i], before[i]);
                } else if(judge.get(after[i]) != before[i]) {
                    answer = "No";
                    break;
                }
            }

        }
        
        //answer 
        System.out.println(answer);

    }
}

Measured memory_bytes: 28720
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

map<char,ll> next_alphabet;
map<char,vector<ll>> indexs;

int main(){
      string s,t;
      cin>>s>>t;
      int N=s.size();
      rep0(i,N){
            indexs[s[i]].push_back(i);
      }
      for(char c='a';c<='z';c++){
            if(indexs[c].size()){
                  indexs[c].push_back(N);
            }
      }
      int M=t.size();
      ll pos=0;
      rep0(j,M){
            ll ind=pos%N;
            //cout<<ind<<endl;
            if(indexs[t[j]].size()==0){
                  cout<<-1<<endl;
                  return 0;
            }
            ll next_ind=N;
            /*for(auto a:indexs[t[j]]){cout<<a<<" ";}
            cout<<endl;*/
            next_ind=*(lower_bound(indexs[t[j]].begin(),indexs[t[j]].end(),ind));
            //cout<<next_ind<<endl;
            if(next_ind>=N){
                  next_ind=*(lower_bound(indexs[t[j]].begin(),indexs[t[j]].end(),0));
                  pos+=N;
            }
            //cout<<next_ind<<endl;
            pos=(pos/N)*N+next_ind+1;
      }
      cout<<pos<<endl;
      return 0;
}

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

int main(){
    ll n,m,a[10001],sum=0;
    cin >> n >> m ;
    rep(i,m){
        cin >> a[i];
        sum+=a[i];
    }
    if(n<sum){
        sum=-1;
    }else{
        sum=n-sum;
    }
    cout << sum;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
main(){
  int N;
  vector<int> A(N);
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[i];
  int mx=A[0];
  int mn=A[0];
  for(int i=0;i<N;i++){
    if(mx<A[i]) mx=A[i];
    if(mn>A[i]) mn=A[i];
  }

  cout << mx-mn <<endl;
}

Measured memory_bytes: 3728
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
mi=2*(10**5)
for i in range(m):
    x,y,c=map(int,input().split())
    mi=min(a[x-1]+b[y-1]-c,mi)
mi=min(mi,min(a)+min(b))
print(mi)


Measured memory_bytes: 18736
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let t: usize = iter.next().unwrap().parse().unwrap();

    let mut v: Vec<(usize, u32)> = Vec::with_capacity(n);
    for _ in 0..n {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: u32 = iter.next().unwrap().parse().unwrap();
        v.push((a, b));
    }
    v.sort();

    let mut dp: Vec<u32> = vec![0; t + 1];
    for i in 0..n {
        for j in (0..t).rev() {
            let nj: usize = cmp::min(j + v[i].0, t);
            dp[nj] = cmp::max(dp[nj], dp[j] + v[i].1);
        }
    }

    let mut ans: u32 = 0;
    for i in 0..(t + 1) {
        ans = cmp::max(ans, dp[i]);
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p));
#define mp make_pair;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);}

int main() {
	ll n,ans=0,temp,curr;
	cin>>n;
	if (n==2) {
		cout<<0<<endl;
		return 0;
	}
	ans+=(n-1);
	for (ll i = 2; i*i <= n; ++i)
	{
		temp = n%(n/i);
		curr = n/i - (i-temp)/i;
		if (curr>n/(i+1) && n/curr==n%curr) ans+=curr;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7

if M == 1:
    print(1)
    exit()

while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        if M_ != 1:
            d[M_] += 1
        break

maxi = max(d.values())
fact = [0] * (maxi + N + 1)
p = 1

def nCr(n, r):
    if r > n - r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    ret = 1
    for i in range(1, r+1):
        ret *= (n-(i-1))
        ret //= i

    return ret

ans = 1
nCr_d = {}
for key, val in d.items():
    if (val+N-1, N-1) not in nCr_d:
        nCr_d[(val+N-1, N-1)] = nCr(val+N-1, N-1)
    ans = (ans * nCr_d[(val+N-1, N-1)]) % MOD

print(ans)

Measured memory_bytes: 4084
from collections import deque

N = int( input() ) + 1 # empty counts

hi = 0
while 1 << hi + 1 <= N:
  hi += 1
hi -= 1

ans_A = deque()
ans_B = deque()
ptr = 1
for i in range( hi, -1, -1 ):
  ans_A.append( ptr )
  ans_B.append( ptr )
  ptr += 1
  if N >> i & 1:
    ans_A.append( ptr )
    ans_B.appendleft( ptr )
    ptr += 1

print( len( ans_A ) * 2 )
for i in range( len( ans_A ) ):
  print( ans_A[ i ], end = ' ' )
for i in range( len( ans_B ) ):
  print( ans_B[ i ], end = ' \n'[ i + 1 == len( ans_B ) ] )


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
const int N=1e5+100;
ll a[N];
main()
{
int n;
scanf("%d",&n);
map<ll,ll> mp;
ll sum=0;
for(int i=0;i<n;i++){
    int x;
    scanf("%lld",&x);
    mp[x]++;
    sum+=x;
}
int q;
scanf("%d",&q);
while(q--){

        int x,y;
scanf("%d",&x);
scanf("%d",&y);
sum-=x*mp[x];
sum+=y*mp[x];
mp[y]+=mp[x];
mp[x]=0;
printf("%lld\n",sum);
}

}


Measured memory_bytes: 9572
#include <stdio.h>
#include <math.h>

int main(void){
    double N,A,C;
    int B;

    scanf("%lf",&N);

    A = (N+1.0)/1.08;

    B = floor(A);

    C = floor((double)B*1.08);

    if(N == C){
        printf("%d",B);
    }

    else{
        printf(":(");
    }
    
    return 0;

}

Measured memory_bytes: 128
use proconio::input;

macro_rules! chmin {
    ($min_v: expr, $v: expr) => {
        if $v < $min_v {
            $min_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    };
    let max_w = 1_000_000_000 * n;
    let max_v = 1_000 * n;
    let mut dp = vec![vec![max_w + 1; max_v + 1]; n + 1];
    dp[0][0] = 0;
    for (i, &(w_i, v_i)) in wv.iter().enumerate() {
        for j in 0..max_v {
            chmin!(dp[i + 1][j], dp[i][j]);
            if j + v_i <= max_v {
                chmin!(dp[i + 1][j + v_i], dp[i][j] + w_i);
            }
        }
    }
    let ans = dp[n]
        .iter()
        .enumerate()
        .filter(|&(_, &w_i)| w_i <= w)
        .map(|(i, _)| i)
        .max()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 81204
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

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


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

	string s;
	cin >> s;
	while (s.size() != 1 || s[0] != '0') {
		int ans = 0;
		vector<vector<int>>dp(2, vector<int>(11));
		for (int i = 0; i < s.size(); i++) {
			vector<vector<int>>ndp(2, vector<int>(11));
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 11; k++) {
					ndp[j ^ 1][(k + 11 + (j * 2 - 1)*(s[i] - '0')) % 11] += dp[j][k];
				}
			}
			dp = ndp;
			ans += dp[0][0];
			ans += dp[1][0];
			if(s[i]-'0'>0)dp[0][s[i] - '0']++;
		}
		cout << ans << endl;
		cin >> s;
	}
}


Measured memory_bytes: 3148
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A, B, C, X, Y = list(map(int, sys.stdin.buffer.readline().split()))

# Cぴざの数を全探索
ans = INF
for c in range(0, max(X, Y) * 2 + 1, 2):
    a = max(0, X - c // 2)
    b = max(0, Y - c // 2)
    cost = a * A + b * B + c * C
    ans = min(cost, ans)
print(ans)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    a_list = input_to_int_tuple()

    a_sorted = list(sorted(a_list))

    max_val = a_sorted[-1]
    cands = [0] * max_val

    for num in a_sorted:
        # if cands[num - 1] >= 2:
        #     continue
        for i in range(num, max_val + 1, num):
            cands[i - 1] += 1

    ans = 0
    for num in a_sorted:
        if cands[num - 1] == 1:
            ans += 1

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 32488
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  int n;
  cin >> n;
 
  for(int q=0;q<n;q++) {
    string str;
    cin >> str;
    if(str[0] != '>') {
      cout <<"NA"<<endl; 
      continue;
    }  else if(str[1] != '\''&& str[1] != '^') {
      cout << "NA" << endl;
      continue;
    }
    int flg = 0,sum;
    if(str[1] == '\'') {
      int t = 0;
      sum=0;
      for(int i=2;i<str.size();i++) {
    if(str[i] == '=') t++;
    else if(str[i] == '#' && sum==0 && i!=2) sum = t , t = 0;
    else break;
    if(str[str.size()-1] == '~' && i == str.size() -2 && sum==t ) flg = 1;
     
      }
    }
 
      if(str[1] == '^' && flg == 0) {
    flg = 0;
    for(int i=2;i<str.size() ;i++) {
      if(i%2 == 0 && str[i] != 'Q') break;
      if(i%2 == 1 && str[i] !='=')  break;
 
      if(str[str.size()-2] == '~' && str[str.size()-1] =='~' && i == str.size()-3&& i%2==1 ){
        flg = 2;
        break;
      }
    }
      }
 
      if(flg == 0) cout << "NA" << endl;
      else if(flg == 1)cout <<"A" << endl;
      else if(flg == 2) cout << "B"<<endl;
  }     
 
 
  return 0;
}

Measured memory_bytes: 1208
s = input()
p = s.replace('x', '')
k = [p[i] for i in range(len(p)-1,-1,-1)]
k = "".join(k)
if k == p:
    left = 0
    right = len(s)-1
    ans = 0
    while True:
        if s[left] != s[right]:
            if s[left] == 'x':
                left += 1
                ans += 1
            else:
                right -= 1 
                ans += 1
        else:
            right -= 1
            left += 1
        if right <= left:
            break
    print(ans)
else:
    print(-1)


Measured memory_bytes: 3956
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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)

typedef long long ll;

int main(void) {
    int n,q;
    cin >> n >> q;
    queue<pair<string,int> > qu;
    pair<string,int> p;
    REP(i,n){
        cin >> p.first >> p.second;
        qu.push(p);
    }
    int time = 0;
    while(!qu.empty()){
        p = qu.front();
        qu.pop();
        if (p.second<=q){
            time += p.second;
            cout << p.first << " " << time << endl;
        }else{
            time += q;
            p.second -= q;
            qu.push(p);
        }
    }

    return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);






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

	int color[9] = {};

	int N; cin >> N;
	rep(i, N) {
		int a;
		cin >> a;
		if (a < 3200)color[a / 400]++;
		else color[8]++;
	}
	int ansmin = 0;
	rep(i, 8)if (color[i] > 0)ansmin++;
	cout << (ansmin == 0 ? 1 : ansmin) << " " << ansmin + color[8] << endl;



	return 0;
}



Measured memory_bytes: 256
n = int(input())
s = input()

"""
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
"""
# gagsg
r = s.count('R')
g = s.count('G')
b = s.count('B')

"""
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1
"""
ans = r*g*b

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2 * j - i
        if k < n:
            if s[i] == s[j]:
                continue
            if s[j] == s[k]:
                continue
            if s[k] == s[i]:
                continue
            ans -= 1
print(ans)


Measured memory_bytes: 67992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String read = br.readLine().replace(" ", "");
		read = read.replaceFirst("5", "");
		read = read.replaceFirst("7", "");
		read = read.replaceFirst("5", "");

		if(read.equals("")) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

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

namespace ABC103B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var sum = 0;

            for(var i=0; i<N.Length; i++)
            {
                var num = int.Parse(N[i].ToString());
                sum += num;
            }

            if (int.Parse(N) % sum == 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

class Combination{
public:
  typedef long long ll;
  ll N;
  ll mod;
  vector<ll> fac;
  vector<ll> finv;
  vector<ll> inv;
  
  
  Combination(ll N = 1e6,ll mod = 1e9 + 7): N(N), mod(mod), fac(N+1), finv(N+1), inv(N+1){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i <= N; i++){
      fac[i] = fac[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod / i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }

  function<ll(ll,ll)> get = [&](ll n,ll r){
    if( n < r ) return 0LL;
    if( n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod;
  };
  //auto nCr = (new Combination())->get;
};

signed main(){
  
  int X, Y;
  cin>>X>>Y;
  
  if( ( X + Y ) % 3 != 0 ){
    cout << 0 << endl;
    return 0;
  }
  
  int minus = ( X + Y ) / 3;
  
  X -= minus;
  Y -= minus;
  
  if( X < 0 || Y < 0 )   cout << 0 << endl;
  else if( X == 0 || Y == 0 ) cout << 1 << endl;
  else{
    
    Combination nCr;
    
    cout << nCr.get( X + Y, X ) << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 23680
require 'pp'
require 'set'

a, b, c, d, e, f = gets.chomp!.split(" ").map(&:to_i)

# 作れる水のパターン
water_patterns = Set.new
30.times do |y|
    30.times do |x|
        z = 100 * b * y + 100 * a * x
        if z <= f && z > 0
            water_patterns << z
        end
    end
end

# とかえる砂糖のパターン
suger_patterns = Set.new
30.times do |y|
    30.times do |x|
        z = y * c + d * x
        if z <= e && z > 0
            suger_patterns << z
        end
    end
end

#pp water_patterns
t = water_patterns.max / 100 * e
#pp t
tokaseru = {}
tokaseru[0] = 1

0.step(t, d) do |i|
    0.step(t, c) do |j|
        x = i + j
        break if x > t

        tokaseru[x] = 1
    end
end

# pp tokaseru

y = water_patterns.flat_map {|x|
    tokaseru.map {|k, y|
        if x + k > f
            [0, 0, 0]
        elsif x / 100 * e < k
            [0, 0, 0]
        else
            [k.to_f / (x + k).to_f, x + k, k, x]
        end
    }
}.sort

puts "#{y[-1][1]} #{y[-1][2]}"



Measured memory_bytes: 7968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int ctoi(char a) {
    switch (a) {
    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;
    }
}

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

    string s;
    cin >> s;

    ll ans = 0, cnt = 0, ten = 1;
    vector<vector<ll>> a(s.length(), vector<ll>(13, 0));
    bool ever = 1, o = 0;
    FOR(i, 0, s.length()) {
        if(i)ten = ten * 10 % 13;
        if (s[s.length() - i - 1] != '?') {
            cnt = (cnt + ten * ctoi(s[s.length() - i - 1])) % 13;
        }
        else o = 1;
    }
    if (!o) {
        cout << (cnt == 5) << "\n";
        return 0;
    }

    ten = 1;
    FOR(i, 0, s.length()) {
        if(i)ten = ten * 10 % 13;
        if (s[s.length() - i - 1] != '?') {
            if (!ever)FOR(k, 0, 13)a[i][k] = a[i - 1][k];
        }
        else if (ever) {
            ever = 0;
            FOR(j, 0, 10)a[i][(ten * j + cnt) % 13]++;
        }
        else {
             FOR(j, 0, 10) {
                ll b = ten * j;
                FOR(k, 0, 13) {
                    ll c = (k + b) % 13;
                    a[i][c] += a[i - 1][k];
                    a[i][c] %= mod;
                }
             }
        }
    }
    cout << a[s.length() - 1][5] << "\n";
}

Measured memory_bytes: 13648
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 
const int N=505;
int grid[N][N],vis[N][N],dis[N][N],n;

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


 void dfs(int d,int x,int y){
 	int i,a,b,c,xx;
 	//cout<<"("<<x<<","<<y<<") ";
 	fo(i,0,4){
 		a=x+dx[i];
 		b=y+dy[i];
 		
 		if((a<1)||(a>n)||(b<1)||(b>n))continue;
 		
 		c=dis[a][b];
 		xx=d+grid[x][y];
 		//cout<<a<<","<<b<<","<<c<<"< ";
 		if(c>xx){
 			//cout<<"["<<dis[a][b]<<","<<xx<<"] ";
 			dis[a][b]=xx;
 			
 			dfs(xx,a,b);
 		}
 	}

 }
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x;
   cin>>n;
   fo(i,1,n+1){
   	fo(j,1,n+1){
   		grid[i][j]=1;
   		vis[i][j]=-1;
   		dis[i][j]=min({i-1,n-i,j-1,n-j});
   		//cout<<dis[i][j]<<" ";
   	}
   //	cout<<endl;
   }

   vi v;
   fo(i,0,n*n){
   	cin>>x;
   	v.pb(x);
   }
   int ans=0;
   fo(i,0,n*n){
   	int a,b,c,d;
   	x=v[i];
   	a=((x-1)/n)+1;
   	b=((x-1)%n)+1;
   	//cout<<x<<" ";
   	//cout<<"("<<a<<","<<b<<")"<<" ";
   	ans+=dis[a][b];
   	grid[a][b]=0;
   	x=dis[a][b];
   	fo(j,0,4){
   		c=a+dx[j];
   		d=b+dy[j];
   		if((c<1)||(c>n)||(d<1)||(d>n))continue;
   		x=min(dis[c][d]+grid[c][d],x);
   	}
   	dis[a][b]=x;
   	//cout<<dis[a][b]<<" ";
   	dfs(dis[a][b],a,b);
   	//cout<<endl;
   }
   cout<<ans<<endl;
   
   
   
   
    return 0;
}

Measured memory_bytes: 30144
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

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

// 約数を求める
vi divisor(int n){
	vi res;
	for(int i=1; i*i<=n; ++i){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i){
				res.push_back(n/i);
			}
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	if(n==1){
		cout<<m<<'\n';
		return 0;
	}
	int ans=0;
	vi a=divisor(m);
	REP(i, a.size()){
		if(a[i]<=m/n){
			ans=max(ans, a[i]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  int l[q],r[q];
  rep(i,q){
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }
  int sum[n+2]={};
  for(int i=0;i<n;i++){
    sum[i+1]=sum[i];
    if(s[i]=='A' && s[i+1]=='C'){
      sum[i+1]++;
    }
  }
  rep(i,q){
    cout << sum[r[i]]-sum[l[i]] << endl;
  }
return 0;}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int
main(void)
{
    int i, j;
    char str[202];
    char p[101];

    bool flag;

    scanf("%s", str);
    scanf("%s", p);
    
    int len = strlen(str);
    for (i = 0; i < len; i++)
        str[len + i] = str[i];

    for (i = 0; i < strlen(str); i++)
        if (str[i] == p[0]) {
            flag = true;
            for (j = 0; j < strlen(p); j++)
                if (p[j] != str[i + j])
                    flag = false;
            if (flag) {
                printf("Yes\n");
                break;
            }
        }

    if (!flag)
        printf("No\n");

    return 0;
}



Measured memory_bytes: 2112
#include<cmath>
#include<iostream>
using namespace std;
int main(){
	long long N;
	cin>>N;
	long long sum=0;
	for(long long i=1;i<=(long long)sqrt(N);i++){
		if(N%i==0){
			long long m=N/i-1;
			if(m>i)sum+=m;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const double EPS = 1e-3;
const double PI = 3.1415926535897932384626433832795028841971;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, int>> x(n), y(n);
    rep(i, n)
    {
        x[i].second = i;
        cin >> x[i].first;
        y[i].second = i;
        cin >> y[i].first;
    }
    sort(ALL(x));
    sort(ALL(y));
    vector<int> xpos(n), ypos(n);
    rep(i, n)
    {
        xpos[x[i].second] = i;
        ypos[y[i].second] = i;
    }
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pque;
    pque.push({0, 0});
    ll ans = 0;
    vector<bool> used(n, false);
    while (!pque.empty())
    {
        //       cerr << pque.size() << endl;
        ll cost = pque.top().first;
        int idx = pque.top().second;
        pque.pop();
        if (used[idx])
        {
            continue;
        }
        //cerr << idx << " " << cost << endl;
        used[idx] = true;
        //cerr << xpos[idx] << endl;
        ans += cost;
        if (xpos[idx] > 0 && !used[x[xpos[idx] - 1].second])
        {
            pque.push({llabs(x[xpos[idx]].first - x[xpos[idx] - 1].first), x[xpos[idx] - 1].second});
        }
        if (ypos[idx] > 0 && !used[y[ypos[idx] - 1].second])
        {
            pque.push({llabs(y[ypos[idx]].first - y[ypos[idx] - 1].first), y[ypos[idx] - 1].second});
        }

        if (xpos[idx] + 1 < n && !used[x[xpos[idx] + 1].second])
        {
            pque.push({llabs(x[xpos[idx]].first - x[xpos[idx] + 1].first), x[xpos[idx] + 1].second});
        }
        if (ypos[idx] + 1 < n && !used[y[ypos[idx] + 1].second])
        {
            pque.push({llabs(y[ypos[idx]].first - y[ypos[idx] + 1].first), y[ypos[idx] + 1].second});
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool complete(int satisfied[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		if (satisfied[i] != 1)
			return false;
	}
	return true;
}
void swap(int *x, int *y)
{
	int t = *x;
	*x = *y;
	*y = t;
}

bool f(int x, int y)
{
	return x > y;
}
int Lucky(int n)
{
	int c = 0;
	while (n != 0)
	{
		int r = n % 10;
		if (r == 4 || r == 7)
			c++;
		n /= 10;
	}
	return c;
}
bool isPrime(int x)
{
	int i;
	for (i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}
int32_t main()
{
	
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int k, a, b, c;
	cin >> k;
	int sum = 0;
	for (a = 1; a <= k; a++)
	{
		for (b = 1; b <= k; b++)
		{
			for (c = 1; c <= k; c++)
			{
				sum += (__gcd(c, __gcd(a, b)));
			}
		}
	}
	cout << sum;
}



Measured memory_bytes: 3628