akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
    }
    else if(n==1&&a!=b){
        cout<<0<<endl;
    }
    else{
        cout<<((n-1)*b+a) - ((n-1)*a+b)+1<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#define M 1000000007
using namespace std;

unsigned long long power(unsigned long long x, unsigned long long n) {
  if (n == 0) {
    return 1;
  }
  unsigned long long res = power(x, n/2);
  if (n % 2 == 0) {
    return res * res % M;
  } else {
    return res * res % M * x % M ;
  }
}

int main() {
  unsigned long long m, n;
  cin >> m >> n;
  cout << power(m, n) << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using vi = vector<int>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
#define forn(i,n) for (int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()

int main() {
    cxxio();
    int n;
    cin>>n;
    vi xs(n);
    forn(i, n) cin>>xs[i];
    ost<int> s(all(xs));
    int ans=0;
    forn(i, n) ans+=(int)s.order_of_key(xs[i])%2!=i%2;
    cout<<ans/2<<'\n';
}


Measured memory_bytes: 5376
N,M = map(int, input().split())
list_A = input().split()
list_A_int = [int(s) for s in list_A]
list_A_int_sort = sorted(list_A_int, reverse=True)

compare_num = sum(list_A_int)/(4*M)

if list_A_int_sort[M-1] < compare_num:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int G[500][500], n, m;

int main(){
  while(scanf("%d%d", &n, &m) && n+m){
    memset(G, 0, sizeof(G));
    int a, b;
    rep(i, m){
      scanf("%d%d", &a, &b); --a; --b;
      G[a][b] = G[b][a] = 1;
    }

    map<int, int>m;
    vi v;
    m[0] = 1;
    rep(i, n) if(G[0][i]){ v.PB(i); m[i] = 1; }

    int vsize = (int)v.size();
    rep(i, vsize){
      rep(j, n){
	if(!G[v[i]][j] || m.count(j)) continue;
	v.PB(j);
	m[j] = 1;
      }
    }
	
    printf("%d\n", (int)v.size());
  }
  return 0;
}

Measured memory_bytes: 2216
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),count=0,res=0;
    Map<Integer,Integer> m=new TreeMap<>();
    for(int i=0;i<n;i++)m.put(sc.nextInt(),sc.nextInt());
    for(int key:m.keySet()){
        count++;
        if(count==n) {
        	res=key+m.get(key);
        }
      }
    System.out.println(res);
  }
}


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

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4) {
        if ( s[i] == '+' ) ans++;
        else               ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],b[N],d,cnt[N];
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		++cnt[a[i]];
	}
	for(int i=1;i<=n;++i){
		b[i]=read();
		++cnt[b[i]];
	}
	int pa=1,pb=1;
	for(int i=1;i<=n;++i){
		while(a[pa]==i)++pa;
		d=max(d,pa-pb);
		while(b[pb]==i)++pb;
	}
	rotate(b+1,b+n+1-d,b+n+1);
	for(int i=1;i<=n;++i){
		if(a[i]==b[i])return !printf("No\n");
	}
	printf("Yes\n");
	for(int i=1;i<=n;++i){
		printf("%d ",b[i]);
	}
	return 0;
}



Measured memory_bytes: 6072
#!/usr/bin/env python3
import sys
import numpy as np
 
YES = "Yes"  # type: str
NO = "No"  # type: str
 
 
def solve(N: int, M: int, A: "List[int]"):
    A = np.array(A)
    n_sum = np.sum(A)/4/M
    if len(set(A)) != N:
        print("??")
    if (A >= n_sum).sum() >= M:
        print(YES)
    else:
        print(NO)
 
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 12424
#include<iostream>
#include<cstring>
#include<map>
#include<vector>
#define ll long long
#define pb push_back
using namespace std;
map<int, int>visited;
map<int, vector<int> >G;

void dfs(int u)
{
	visited[u]=1;
	for(int i=0; i<G[u].size(); i++)
	{
		
	  	int v=G[u][i];
	 	if(!visited[v])
	 	{
	 		
	 		dfs(v);
	 	}
	}
}

int main()
{
	visited.clear();
	G.clear();
	int n,m;
	cin>>n>>m;
	int a,b;
	while(m--)
	{
		cin>>a>>b;
		G[a].pb(b);
		G[b].pb(a);
		
	}
	int cnt=0;
	for(int i=1; i<=n; i++)
	{
		if(visited[i]==0)
		{
			dfs(i);
			cnt++;
		}
	
	}
	cout<<cnt-1<<endl;
}

Measured memory_bytes: 21728
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
		// 出力
		if(s.indexOf("RRR") != -1){
		    System.out.println(3);
		}
		else if(s.indexOf("RR") != -1){
		    System.out.println(2);
		}
		else if(s.indexOf("R") != -1){
		    System.out.println(1);
		}
		else{
		    System.out.println(0);
		}
	}
}

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

using namespace std;

typedef long long int ll;

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

vector < ll > fact (N);

ll pwr (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv (ll a) {
  return pwr (a, mod - 2);
}

ll nCr (int n, int r) {
  return ((((fact[n] * inv(fact[r])) % mod) * inv (fact[n - r])) % mod);
}

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

  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int n, m;
  cin >> n >> m;

  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ll a = (((nCr (n, i) * nCr (m - i, n - i)) % mod) * fact[n - i]) % mod;
    if (i & 1) ans = (ans - a + mod) % mod;
    else ans = (ans + a) % mod;
  }

  ans = (((ans * nCr (m, n)) % mod) * fact[n]) % mod;

  cout << ans << '\n';
}


Measured memory_bytes: 7008
b = input().split()
c = [int(b[i]) for i in range(len(b))]

d = input().split()
e = [int(d[i]) for i in range(c[0])]

r = input().split()
f = [int(r[i]) for i in range(c[1])]

ansx = 0
for i in range(c[0]):
  tmp = i*e[i] - (c[0]-i-1)*e[i]
  ansx += tmp

ansy = 0
for j in range(c[1]):
  tmp = j*f[j] - (c[1]-j-1)*f[j]
  ansy += tmp

print((ansx * ansy) % (10**9 + 7))

Measured memory_bytes: 26640
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		String s = sc.next();
		sc.close();
		out.println(a>=3200?s:"red");
	}
}


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

namespace AtCoder.Contest.C
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			long n = cin.NextLong();
			long ans = long.MaxValue;
            for (long i = 1; i <= Math.Sqrt(n); i++)
            {
				if(n % i == 0)
                {
					ans = Math.Min(ans, i + n / i);
                }
            }
            Console.WriteLine(ans - 2);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = gets.split.map(&:to_i)
if (a.include?(x) && a.include?(y)) || (b.include?(x) && b.include?(y))
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1788
A,B,C=map(int,input().split())
i = 0
if A==B==C:
	print(-1+(A%2))
else:
	i = 0
	while A%2==B%2==C%2==0:
		A,B,C = B//2+C//2, C//2+A//2, A//2+B//2
		i += 1
	print(i)


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
  int n,i,total=100000;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    total=total*1.05;
    if(total%1000!=0){
      total=total+1000-total%1000;
    }
  }
  printf("%d\n",total);
  return(0);
}

Measured memory_bytes: 592
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

in_str = sys.stdin.readline().strip()
q = int(sys.stdin.readline())

for i in range(q):
    command = sys.stdin.readline().split()
    pos_a = int(command[1])
    pos_b = int(command[2])

    if command[0] == 'print':
        print(in_str[pos_a:pos_b+1])
    elif command[0] == 'reverse':
        if pos_a == 0: to_pos = None
        else: to_pos = pos_a - 1
        in_str = in_str[:pos_a] + in_str[pos_b:to_pos:-1] + in_str[pos_b+1:]
    elif command[0] == 'replace':
        in_str = in_str[:pos_a] + command[3] + in_str[pos_b+1:]
    else:
        raise ValueError



Measured memory_bytes: 5616
#include<iostream>

using namespace std;

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

	if (n < 105) {
		cout << 0 << endl;
	}
	else if (n < 135) {
		cout << 1 << endl;
	}
	else if (n < 165) {
		cout << 2 << endl;
	}
	else if (n < 189) {
		cout << 3 << endl;
	}
	else if (n < 195) {
		cout << 4 << endl;
	}
	else {
		cout << 5 << endl;
	}

	return 0;
}

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

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

  vector<int> A(N);
  for(int i=0; i<N; ++i){
    cin >> A[i];
    --A[i];
  }

  vector<int> B(N);
  for(int j=0; j<N; ++j){
    cin >> B[j];
  }

  vector<int> C(N-1);
  for(int l=0; l<N; ++l){
    cin >> C[l];
  }

  int sum = 0;
  for(int i=0; i<N; ++i){
    sum += B[A[i]];
    if(i > 0 && (A[i]-1) == A[i-1]){
      sum += C[A[i-1]];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
#define F first
#define S second
#define MP make_pair
const int N=5e5+10;
const ll INF=1LL<<60;
ll dis(pi a,pi b){
    ll x=a.F-b.F,y=a.S-b.S;
    return x*x+y*y;
}
int main(){
    int n,lim;
    ll ans=INF;
    pi a[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i].F,&a[i].S);
    sort(a,a+n);
    lim=min(100,n);
    for(int i=0;i<lim;i++)for(int j=i+1;j<lim;j++)ans=min(ans,dis(a[i],a[j]));
    for(int i=lim;i<n;i++)for(int j=1;j<lim;j++)ans=min(ans,dis(a[i],a[i-j]));
    printf("%lld\n",ans);
}


Measured memory_bytes: 6636
#include<stdio.h>

#include<string.h>

int a[13],vis[13],flag;

void dfs(int x,int l,int r)

{

    int i;

    if(x==11)return; 

    if(flag)return ;

    if(a[x]>l)dfs(x+1,a[x],r);

    else  if(a[x]>r)dfs(x+1,l,a[x]);

    else  {flag=1;return;}

  

}

int main()

{

int T,i,j,k;

scanf("%d",&T);

while(T--)

{

flag=0;

for(i=1;i<=10;i++)

scanf("%d",&a[i]);

memset(vis,0,sizeof(vis));

dfs(1,0,0);

if(flag)printf("NO\n");

else printf("YES\n");

}

return 0;

}

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

#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> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)3e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        ll ans=0;
           cin>>k>>m;
           for(i=0;i<=k;i++){
                   for(j=0;j<=k;j++){
                           ll tt=m-i-j;
                           if(tt>=0 && tt<=k)ans++;
                   }
           }
           cout<<ans<<endl;
              
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3632
fn main() {
    let n = read::<i32>();
    let x = ((n as f64) / 1.08).floor() as i32;

    if (x as f64 * 1.08) as i32 == n {
        println!("{}", x);
    } else if ((x + 1) as f64 * 1.08) as i32 == n {
        println!("{}", x + 1);
    } else {
        println!(":(");
    }
}

#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import math

a, b, x = map(int, input().split())

sita = 0

if x > (a * a * b) / 2:
    sita = math.atan(((b / a) - (x / a ** 3))*2)
else:
    sita = math.atan((b * b*a)/ (2*x))

print(sita * (180.0 / math.pi))

Measured memory_bytes: 38468
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector< ll > z_algorithm(const string &s) {
  vector< ll > prefix(s.size());
  for(ll i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      ll k = max(0LL, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (ll) s.size();
  return prefix;
}

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	s += s;
	ll ans = 0;
	rep(i,n){
		string t = s.substr(i,n);
		auto z = z_algorithm(t);
		REP(j,1,n-i) chmax(ans,min({z[j],n-i-j,j}));
	}
	cout << ans << endl;
}

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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    if(n % 2 == 0)
    {
        cout << n;
        return 0;
    }
    cout << n * 2;
}


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

int calc(int x) {
	int cnt = 0;
	for (int i = 1; i <= x; i++) {
		if (x % i == 0)cnt++;
	}
	return cnt;
}

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

	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		int cnt = calc(i);
		if (cnt == 8)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>

using namespace std;

int main()
{
	string s;
	int a, b;
	cin >> s;
	a = s.find('A');
	b = s.find_last_of('Z');
	cout << b - a+1;
	return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    l :
    for(int i = N;true; i++){
        for(int j = 2; j <= Math.sqrt(N); j++){
            if(i%j == 0){
                continue l;
            }
        }
        System.out.println(i);
        return;
    }
  }
}

Measured memory_bytes: 25300
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double a, b; double p, q, r; cin >> a >> b >> p >> q >> r;
	double tmp = p * b - (b-a) * q;
	cout << fixed << setprecision(15) << b + tmp / (r + q) << endl;
	return 0;
}



Measured memory_bytes: 3308
val = input()
zero = '0'
one = '1'
c = 0
l = list(val)
for i in range(len(l)):
  if i == 0:
    continue
  if l[i - 1] == l[i]:
    if l[i - 1] == zero:
      l[i] = one
    else:
      l[i] = zero
    c = c + 1
print(c)

Measured memory_bytes: 3956
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    int lt=0;
    int an=0;
    REP(i,n){
        int x;
        R(x);
        an+=max(0,x-lt);
        lt=x;
    }
    W(an);
    return 0;
}


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

vector<pair<int, int> > v;
vector<int> a, b;
int main()
{
loop:
  int tmp;
  int as = 0, bs = 0, d, n, m;
  a.clear(); b.clear(); v.clear();
  cin >> n >> m;
  if(!(n || m))
    return 0;
  for(int i = 0; i < n; i++)
  {
    cin >> tmp;
    a.push_back(tmp);
    as += tmp;
  }
  for(int i = 0; i < m; i++)
  {
    cin >> tmp;
    b.push_back(tmp);
    bs += tmp;
  }
  d = as - bs;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++)
      if((a[i] - b[j]) * 2 == d)
        v.push_back(make_pair(a[i], b[j]));
  sort(v.begin(), v.end());
  if(v.size() == 0)
    cout << -1 << endl;
  else
    cout << v[0].first << " " << v[0].second << endl;
  goto loop;
}

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

int main() {
  int n;
  cin >> n;
  for(int i=1; i<=9; i++) {
    for(int j=1; j<=9; j++) {
      if(n == i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    if(a < c && c < b)cout << "Yes" << endl;
    else if(b < c && c < a)cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))

    big = 10**18
    count = 1

    ju = True


    if 0 in A:
        count = 0
    else:
        for i in range(len(A)):
            count = count * A[i]

            if count > big:
                ju = False
                break


    if ju:
        print(count)
    else:
        print("-1")




if __name__ == '__main__':
    main()



Measured memory_bytes: 21788
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int n;
    string str;
    cin>>n>>str;
    for(int i=0;i<str.size();i++)
    {
        int temp=str[i]+n;
        if(temp>90)
            str[i]=char('A'+temp-91);
        else
            str[i]=char(temp);
    }
    cout<<str;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  ll N,M;
  cin>>N>>M;
  ll high[N];
  vector<vector<ll>> G(N,vector<ll>(0));
  for(int i=0;i<N;i++){
    cin>>high[i];
  }
  for(int i=0;i<M;i++){
    ll a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    int c=1;
    for(int j=0;j<G[i].size();j++){
      if(high[i]<=high[G[i][j]]){
        c=0;
        break;
      }
    }
    if(c){
      ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 9808
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var q=sc.I;
		var h=new long[100001];
		long ans=0;
		for(int i = 0;i<n;i++) {
			h[a[i]]++;
			ans+=a[i];
		}
		for(int i = 0;i<q;i++) {
			var e=sc.Ia;
			ans-=h[e[0]]*e[0];
			ans+=h[e[0]]*e[1];
			h[e[1]]+=h[e[0]];
			h[e[0]]=0;
			Console.WriteLine(ans);
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 44476
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        long[] a = new long[N+1];
        long[] b = new long[N];
        for (int i = 0; i < N + 1; i++) {
            a[i] = Long.parseLong(sc.next());
        }
        for (int i = 0; i < N; i++) {
            b[i] = Long.parseLong(sc.next());
        }
        long ans = 0;
        
        for (int i = 0; i < N; i++) {
            if (a[i] >= b[i]) {
                ans += b[i];
            } else if (a[i] < b[i] && a[i+1] >= b[i] - a[i]) {
                ans += b[i];
                a[i+1] -= (b[i] - a[i]);
            } else if (a[i] < b[i] && a[i+1] < b[i] - a[i]) {
                ans += (a[i] + a[i+1]);
                a[i+1] = 0;
            }
        }
        
        out.println(ans);
        
        out.flush();
    }
}

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

using namespace std;
int W, H;
string s[20];
int num;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

void dfs(int x, int y){
  num++;
  s[y][x] = '#';
  for(int i=0; i<4; i++){
    if(0<=x+dx[i] && x+dx[i]<W && 0<=y+dy[i] && y+dy[i]<H && s[y+dy[i]][x+dx[i]]=='.'){
      dfs(x+dx[i], y+dy[i]);
    }
  }
}

int main(){
  while(cin >> W >> H, W || H){
    for(int i=0; i<H; i++){
      cin >> s[i];
    }
    int x, y;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
	if(s[i][j] == '@'){
	  x = j;
	  y = i;
	}
      }
    }
    num = 0;
    dfs(x, y);
    cout << num << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    string head, tail;
    REP(i, q){
        int query;
        cin >> query;
        if(query == 1){
            rev = !rev;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(rev)
                f = f%2+1;
            if(f == 1){
                head.push_back(c);
            }
            else{
                tail.push_back(c);
            }
        }
    }
    reverse(head.begin(), head.end());
    string ans = head + s + tail;
    if(rev)
        reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1348
x,n = map(int, input().split())
p = input().split()
for i in range(len(p)):
    p[i] = int(p[i])
index = 0
while True:
    if p == []:
        print(x)
        break
    try:
        a = p.index(x-index)
    except ValueError:
        print(x-index)
        break

    try:
        b = p.index(x+index)
    except ValueError:
        print(x+index)
        break

    index += 1

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define int ll
#define double ld
#define openfiles ifstream in("input.txt");ofstream out("output.txt");
#define faster ios_base::sync_with_stdio(false);
typedef pair<int,int> pii;
const int inf=1e18;
const int mod=1e9+7;
const double eps=0.00000001;
///----------------------------------------------------------------------
int n;
string s;
vector<vector<int> > dp;
void init()
{
    cin>>n;
    cin>>s;
    dp.resize(n+1,vector<int>(n+1));
}

int solve()
{
    dp[1][1]=1;
    vector<int> pref(n+1);
    pref[1]=dp[1][1];
    for(int i=2;i<=n;i++)
        pref[i]=pref[i-1]+dp[1][i];
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(s[i-2]=='>')
                dp[i][j]=(pref[i]+mod-pref[j-1])%mod;
            else
                dp[i][j]=pref[j-1]%mod;
        }
        pref.assign(n+1,0);
        pref[1]=dp[i][1]%mod;
        for(int j=2;j<=n;j++)
        {
            pref[j]=(pref[j-1]+dp[i][j])%mod;
        }
    }
    return pref[n];
}
signed main()
{
    init();
    cout<<solve();
    return 0;
}
///   1





Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000];
  int odcnt=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]%2==1) odcnt++;
  }
  if(odcnt%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  

  return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X):
    ans = INF
    for i in range(1, 100):
        t = 0
        for x in X:
            t += (x-i)**2
        ans = min(ans, t)
    return ans


def main():
    N = read_int()
    X = read_int_n()
    print(slv(N, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7620
using System;

namespace Volume0_0000_QQ
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 1; i <= 9; i++)
            {
                for(int j = 1; j <= 9; j++)
                {
                    Console.WriteLine(i+"x"+j+"="+ (i*j));
                }
            }
        }
    }
}

Measured memory_bytes: 5528
#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>

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 long long ll;
//typedef unsigned long long ull;
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;
//typedef unsigned int uint;

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;

int T[100010];

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

	int N, Q;
	string S;

	cin >> N >> Q >> S;

	rep(i, 1, N)
	{
		if (S[i - 1] == 'A'&&S[i] == 'C')
		{
			T[i] = 1;
		}
		T[i] += T[i - 1];
	}

	int l, r;
	rep(i, 0, Q)
	{
		cin >> l >> r;
		r--;
		l--;
		cout << T[r] - T[l] << endl;
	}

	return 0;
}



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

int sumofDigits(int N)
{
    int sum = 0; 
    while (N)
    {
        sum += N%10;
	N /= 10;
    }	
    return sum;
}

int main()
{
    int N;
    cin >> N;
    if (N%10 == 0)
	cout << 10;
    else
	cout << sumofDigits(N);
    return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int pwi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = pwi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long pwl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = pwl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

map<long, long> factorization(long N) {
    map<long, long> res;
    long SQRT_N = ceil(sqrt(N));
    for (long i = 2; i < SQRT_N; i++) {
        while (N % i == 0) {
            if (res.find(i) == res.end()) {
                res[i] = 1;
            } else {
                res[i] += 1;
            }
            N /= i;
        }
    }
    if (N > SQRT_N) res[N] = 1;
    return res;
}

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

    // a+b= x
    // 2a + 4b = y
    // 2a + 2b = 2x
    // 2b = y - 2x
    // 2a = 2x - y + 2x = 4x -y

    int a2 = 4 * x - y;
    int b2 = y - 2 * x;

    if (a2 >= 0 && a2 % 2 == 0 && b2 >= 0 && b2 % 2 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int b=0;
  rep(i,0,k) b+=a[i];
  cout<<b<<endl;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) b[i] = sc.nextInt();
		for(int i = 0; i < n; i++) c[i] = sc.nextInt();
		Arrays.sort(a);
		Arrays.sort(c);
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += lowerBound(a, b[i]) * (n - upperBound(c, b[i]));
		}
		System.out.println(ans);
	}

	static long lowerBound(int[] a, int x) {
		int l = -1, r = a.length;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(a[mid] >= x) r = mid;
			else l = mid;
		}
		return r;
	}

	static long upperBound(int[] a, int x) {
		int l = -1, r = a.length;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			if(a[mid] <= x) l = mid;
			else r = mid;
		}
		return r;
	}

}


Measured memory_bytes: 93344
import numpy as np
A = np.zeros((3,3))

# ビンゴシートを作成する
A[0][0], A[0][1], A[0][2] = map(int, input().split())
A[1][0], A[1][1], A[1][2] = map(int, input().split())
A[2][0], A[2][1], A[2][2] = map(int, input().split())

# 結果を取得する
N = int(input())
N_list = []
for _ in range(N):
    N_list.append(int(input()))

# 結果をビンゴシートにあてこむ
for n in N_list:
    A = np.where(A==n, 0, A)

# 判定処理
result = 'No'
for i in np.all(A==0, axis=0):
    if i == True:
        result = 'Yes'
for i in np.all(A==0, axis=1):
    if i == True:
        result = 'Yes'
if np.all(np.diag(A)==0) == True or np.all(np.array([A[0,2], A[1,1], A[2,0]]) == 0) == True:
    result = 'Yes'
print(result)

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

int main() {
	int n;
	vector<int> abc(26);
	cin >> n;
	vector<string> s(n);
	for (string& in : s)
		cin >> in;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 26; j++) {
			if (i)
				abc.at(j) = min((int)count(s.at(i).begin(), s.at(i).end(), 'a' + j), abc.at(j));
			else
				abc.at(j) = (int)count(s.at(i).begin(), s.at(i).end(), 'a' + j);
		}
	}
	for (int i = 0; i < 26; i++)
		for (int j = 0; j < abc.at(i); j++)
			cout << (char)('a' + i);
	cout << endl;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	
	ll n;
	cin>>n;
	ll p=n;
	p+=(n*n);
	p+=(n*n*n);
	cout<<p;
	
	return 0;
}

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

int main(){
    int h,w;
    cin>>h>>w;
    int c[10][10]={};
    for(int i=0;i<10;i++)for(int j=0;j<10;j++) cin>>c[i][j];
    int dp[10][10]={};
    for(int i=0;i<10;i++)for(int j=0;j<10;j++){
        dp[i][j]=c[i][j];
    }

    for(int k=0;k<10;k++)for(int i=0;i<10;i++)for(int j=0;j<10;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    int a;
    int ans=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        cin>>a;
        if(a!=-1){
            ans+=dp[a][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define x first
#define y second


int main() {
    fast;
    int n;
    cin>>n;
    vector<ll> arr(n+1), h(n);
    for (int i = 0; i <=n; ++i) {
        cin>>arr[i];
    }
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < i+2; ++j) {
            if(arr[j] >= h[i])
            {
                sum += h[i];
                arr[j] -= h[i];
                h[i] = 0;
            } else
            {
                sum += arr[j];
                h[i] -= arr[j];
                arr[j] = 0;
            }
        }
    }
    cout<<sum;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = a.back() - a.front();
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool win = false;
	while (a > 0 && c > 0) {
		c -= b;
		if (c <= 0) {
			win = true;
			break;
		}

		a -= d;
	}

	cout << (win ? "Yes": "No") << endl;
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int maximum = 0;
	int smaximum = 0;
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	vector<int> S = A;
	sort(S.begin(), S.end());
	reverse(S.begin(), S.end());
	for(int i = 0; i < N; i++){
		if(A.at(i) != S.at(0)){
			cout << S.at(0) << endl;
		}
		else{
			cout << S.at(1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200