akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main() {
    string S;
    ll N,K;
    cin >>N>>K;
  
    ll ans=0;
    rep2(i,N){
        ans += N/i*(max(ll(0),ll(i)-K))+max(N-N/ll(i) * i+1 -K,ll(0));
    }
    cout << min(ans,N*N) << endl;


    return 0;
    

}

Measured memory_bytes: 3632
x,n = map(int,input().split(" "))

def minusx(f):
    return f-x

if n !=0:
    plist =list(map(int,input().split(" ")))
    for i in range(100):
        if x-i not in plist:
            print(x-i)
            break
        elif x+i not in plist:
            print(x+i)
            break
else:
    print(x)

Measured memory_bytes: 9196
#include <stdio.h>

int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  do{
    e = scanf("%c", &st);

    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }

  }while(e != EOF);

  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);

  return 0;
}



Measured memory_bytes: 2132
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();

        int[] arr = new int[n];
        int count = 0;
        for (int i = 1; i < n; i++) {
            if (s.charAt(i-1) == 'A' && s.charAt(i) == 'C') count++;
            arr[i] = count;
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int start = sc.nextInt() - 1;
            int end = sc.nextInt() - 1;

            sb.append(arr[end] - arr[start]).append('\n');
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 70252
#include <cstdio>
int n, m, d[1005];
int main(){
  scanf("%d%d\n", &n, &m);
  for(int i = 0; i < n; i++) for(int j = 0; j <= m; j++)
      d[j+1] = getchar() == '.' ? (d[j+1] + d[j] + (i+j == 0)) % 1000000007 : 0;
  printf("%d\n", d[m]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> B(N - 1);
	for (int i = 0; i < N - 1; i++) cin >> B[i];

	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (!i) ret += B[i];
		else if (i == N - 1) ret += B[i - 1];
		else ret += min(B[i - 1], B[i]);
	}

	cout << ret << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cmath>


int main(void)
{
	int n, t, a;

	while(scanf("%d%d%d", &n, &t, &a)==3)
	{
		int ans_h=-1, ans_i=-1;

		for(int i=1;i<=n;i++)
		{
			int h;

			scanf("%d", &h);
			if(i==1)
			{
				ans_h=h;
				ans_i=i;
			}
			if(fabs(a-(t-0.006*h))<fabs(a-(t-0.006*ans_h)))
			{
				ans_h=h;
				ans_i=i;
			}
		}
		printf("%d\n", ans_i);
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair

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

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll sum=0;
        for(ll i=1;i<=n;i++)
        {
            if(i%3!=0 && i%5!=0)
            {
                sum+=i;
            }
        }
        cout<<sum<<endl;
    }


    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define ForE(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;
string s,t;

main()
{
        cin>>n;

        set<int> v;
        rep(i,n)
        {
                int it;
                cin>>it;
                v.insert(it);
        }

        if(v.size()==n)
        {
                cout<<"YES"<<endl;
        }else
        {
                cout<<"NO"<<endl;
        }
}

Measured memory_bytes: 9600
def is_right(a0, a1, a2):
    for j in range(H):
        if grids[j][0] - a0 == grids[j][1] - a1 == grids[j][2] - a2:
            continue
        else:
            return False
    return True


H = 3
grids = [list(map(int, input().split())) for _ in range(H)]

for a0 in range(100 + 1):
    for a1 in range(100 + 1):
        for a2 in range(100 + 1):
            if is_right(a0, a1, a2):
                print('Yes')
                exit()
print('No')


Measured memory_bytes: 41836
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll a, b; cin >> a >> b;
    cout << ((b%a == 0) ? a+b : b-a) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Node {
	public int[] adjacentNodes;
	public int id;
	
	public Node(int id, int[] adjNodes) {
		this.id = id;
		this.adjacentNodes = adjNodes;
	}
	
	public boolean hasEdge(int edge) {
		for (int i = 0; i < adjacentNodes.length; i++) {
			if (edge == adjacentNodes[i]) return true;
		}
		
		return false;
	}
}

public class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numNodes = scanner.nextInt();
		Node[] nodes = new Node[numNodes];
		
		for (int i = 0; i < nodes.length; i++) {
			int id = scanner.nextInt();
			int numVerts = scanner.nextInt();
			int[] verts = new int[numVerts];
			
			for (int j = 0; j < numVerts; j++) {
				verts[j] = scanner.nextInt();
			}
			
			nodes[i] = new Node(id, verts);
		}
		scanner.close();
		
		for (int i = 0; i < nodes.length; i++) {
			String adjacencies = "";
			for (int j = 0; j < nodes.length; j++) {
				if (nodes[i].hasEdge(nodes[j].id)) {
					adjacencies += "1";
				}
				else {
					adjacencies += "0";
				}
				if (j+1 < nodes.length) adjacencies += " "; 
			}
			System.out.println(adjacencies);
		}
	}
}



Measured memory_bytes: 48204
import java.io.*;
class Main{
    public static void main(String args[])throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	int i,j,k,h[]=new int[10];
	for(i=0;i<10;i++)
	    h[i]=Integer.parseInt(br.readLine());
	for(i=0;i<3;i++){
	    for(j=i+1;j<10;j++)
		if(h[i]<h[j]){
		    k=h[i];
		    h[i]=h[j];
		    h[j]=k;
		}
	    System.out.println(h[i]);
	}
	return;
    }
}

Measured memory_bytes: 9348
using System;

namespace ConsoleApp8
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] array = new int[int.Parse(Console.ReadLine())];
			var str = Console.ReadLine().Split(' ');
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = int.Parse(str[i]);
			}
			int count = 0;
			double num = 2;
			while (true)
			{
				foreach (var item in array)
				{
					if (item % num != 0)
					{
						Console.WriteLine(count);
						return;
					}
				}
				count++;
				num = Math.Pow(2, count + 1);
			}
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;
string x;
int k;

int main(){
  cin>>x;
  cin>>k;

  vector<string> vs;
  for(int i=1;i<=min(k,(int)x.length());i++){
    for(int j=0;j<(int)x.length()-i+1;j++){
      vs.push_back(x.substr(j,i));
    }
  }

  sort(vs.begin(),vs.end());

  //for(int i=0;i<(int)vs.size();i++){
  //  cout<<vs[i]<<endl;
  //}

  string tmp = "";
  for(int i=0;i<(int)vs.size();i++){
    if(tmp != vs[i]) k--;
    tmp = vs[i];
    if(k==0)break;
  }

  cout<<tmp<<endl;

  return 0;
}

Measured memory_bytes: 1660
import java.util.*;

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

        String ans = "APPROVED";
        int tmp;
        for (int i = 0; i < N; i++) {
             tmp = sc.nextInt();
             if(tmp % 2 == 0){
                 if(tmp % 3 != 0 && tmp % 5 != 0){
                     ans = "DENIED";
                 }
             }
        }

        System.out.println(ans);

    }
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
	string s;
	cin>>s;

	int ans=1,len=1;
	for (int i = 1; i < s.size(); i++){
		if(len==1 && s[i]==s[i-1]){
			len=2;
			i++;
			if(i>=s.size())break;
		}else{
			len=1;
		}
		ans++;
	}

	cout<<ans<<endl;

	return 0;
}
	


Measured memory_bytes: 640
from itertools import groupby

N=int(input())
A=list(map(int,input().split()))
A.sort()
X=groupby(A)
data=[]
for key,group in X:
    g=len(list(group))
    data.append([key,g])
if len(data)==1 and data[0][0]==0:
    print('Yes')
elif N%3!=0:
    print('No')
else:
    if len(data)>3:
        print('No')
    elif len(data)==1:
        if data[0][0]==0:
            print('Yes')
        else:
            print('No')
    elif len(data)==2:
        if data[0][0]==0 and data[0][1]==N//3:
            print('Yes')
        else:
            print('No')
    else:
        if data[0][1]!=N//3 or data[1][1]!=N//3 or data[2][1]!=N//3:
            print('No')
        else:
            if data[0][0]^data[1][0]^data[2][0]!=0:
                print('No')
            else:
                print('Yes')

Measured memory_bytes: 15268
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int[] num = {1, 2, 1, 4, 1, 4, 1, 1, 4, 1, 4, 1};
	
	int x = Integer.parseInt(scan.next());
	int y = Integer.parseInt(scan.next());

	String ans = (num[x-1] == num[y-1] ? "Yes" : "No");
	System.out.println(ans);
	
	scan.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cerr << #x << " " << x << endl;
#define debl(x) std::cerr << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
//const ll LINF = 1001002003004005006ll;
//const int INF = 1001001001;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
// constexpr int MOD = 1e9 + 7;
constexpr int mxN = 3000;
ll dp[2][mxN][mxN];
void solve(){
    int n;
    read(n);
    vl a(n);
    REP(i,n) cin >> a[i];
    for(int d = 0; d < n ; d++){
        for(int i = 0 ; i < n - d; i++){
            int j = i + d;
            if( i == j){
                dp[0][i][j] = a[i];
                dp[1][i][j] = a[i];
                continue;
            }
            // Taro decision
            dp[0][i][j] = max(a[i] - dp[1][i+1][j], a[j] - dp[1][i][j-1]);

            // Jiro decisiont
            dp[1][i][j] = max(a[i] - dp[0][i+1][j], a[j] - dp[1][i][j-1]);
        }
    }
    cout << dp[0][0][n-1] << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 95884
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![];
    for i in 0..n {
        a.push(read::<i64>());
    }
    let a = a.iter().map(|&x| -x).collect::<Vec<_>>();

    let mut dp = vec![std::i64::MAX; n];
    for i in 0..n {
        let pointer = dp.upper_bound(&a[i]);
        dp[pointer] = a[i];
    }
    println!("{:?}", dp.lower_bound(&std::i64::MAX));
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main()
{
    usaco();
    int h, w;
    cin >> h >> w;
    vector <string> a(h);
    for (int i = 0; i < h; ++i) cin >> a[i];
    vector <vector<long long>> dp(h, vector <long long> (w));
    dp[0][0] = 1;
    for (int i = 1; i < h; ++i) dp[i][0] = (a[i][0] == '#' ? 0 : dp[i-1][0]);
    for (int i = 1; i < w; ++i) dp[0][i] = (a[0][i] == '#' ? 0 : dp[0][i-1]);
    for (int i = 1; i < h; ++i)
    {
        for (int j = 1; j < w; ++j)
        {
            if (a[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % 1000000007;
        }
    }
    cout << dp[h-1][w-1] << '\n';
}



Measured memory_bytes: 12136
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
string a,b,c,d,S,n,y;

int main(){
    cin>>S;
    a="maerd";
    b="remaerd";
    c="esare";
    d="resare";
    n="NO";
    y="YES";
    ll N=S.size();
    reverse(all(S));
    rep(i,N){
        if(S[i]=='m'){
            string A;
            A=S.substr(i,5);
            if(A!=a){
                cout<<n<<endl;
                return 0;
            }
            i+=4;
        }
        else if(S[i]=='e'){
            string A;
            A=S.substr(i,5);
            if(A!=c){
                cout<<n<<endl;
                return 0;
            }
            i+=4;
        }
        else if(S[i]=='r'&&S[i+2]=='s'){
            string A;
            A=S.substr(i,6);
            if(A!=d){
                cout<<n<<endl;
                return 0;
            }
            i+=5;
        }
        else if(S[i]=='r'){
            string A;
            A=S.substr(i,7);
            if(A!=b){
                cout<<n<<endl;
                return 0;
            }
            i+=6;
        }
        else{
            cout<<n<<endl;
            return 0;
        }
    }
    cout<<y<<endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n;
    cin >> n;
    cout << 111 * ((n / 111) + (n % 111 > 0)) << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long H = Long.parseLong(s.next());

        // int n = (int) (Math.log(H) / Math.log(2));
        // System.out.println(n);
        // System.out.println("i:"+i+", bits: "+setBits(i));
        // 2分木の要素数を出してしまえば終わり
        System.out.println(2*Long.highestOneBit(H)-1);
        // System.out.println((long) Math.pow(2, n) * 2 - 1);
    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
	bool canWalk = true;
	int N;
	cin >> N;

	int prevX = 0, prevY = 0, prevT = 0;

	for (int i = 0; i < N; ++i) {
		int nextX, nextY, nextT;
		cin >> nextT >> nextX >> nextY;

		int diffT = nextT - prevT;

		int diffX, diffY;
		diffX = abs(nextX - prevX);
		diffY = abs(nextY - prevY);

		if (diffT < diffX + diffY) {
			canWalk =false;
			break;
		}
		else {
			if (diffT % 2 == 0) {
				if (diffX % 2 == 0 && diffY % 2 == 0);
				else if (diffX % 2 != 0 && diffY % 2 != 0);
				else {
					canWalk = false;
					break;
				}
			}
			else {
				if (diffX % 2 == 0 && diffY % 2 != 0);
				else if (diffX % 2 != 0 && diffY % 2 == 0);
				else {
					canWalk = false;
					break;
				}
			}
		}
	}

	if (canWalk) cout << "Yes";
	else cout << "No";


	system("pause");
	return 0;
}

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll n;

  cin>>n;

  vector<ll> v(n);

  set<ll> s = {-1};
  
  ll tmp, cnt=0;
  rep(i, n){
    cin>>tmp;
    if(tmp>=3200) {
      cnt++;
    }
    else {
      s.insert(tmp / 400);
    }
  }

  ll maxi = s.size() - 1 + cnt;
  ll mini = s.size() - 1;
  if(mini==0 && cnt>0) mini++;
  cout << mini << " " << maxi  <<endl;
  
  
}


Measured memory_bytes: 256
n = int(raw_input())
INF = 10000000
queue = []

def bfs(s):
    queue.append(s)
    d = [INF for i in range(n)]
    d[s] = 0
    while len(queue) != 0:
        u = queue.pop(0)
        for v in range(n):
            if M[u][v] == 0:
                continue
            if d[v] != INF:
                continue
            d[v] = d[u] + 1
            queue.append(v)
    for i in range(n):
        if d[i] == INF:
            length = -1
        else:
            length = d[i]
        print "%d %d" %(i + 1, length)
        
M = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    tmp = map(int, raw_input().split())
    u = tmp[0]
    k = tmp[1]
    u -= 1
    for j in range(k):
        v = tmp[j + 2]
        v -= 1
        M[u][v] = 1
bfs(0)

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


long long dp[20][32][2] = {};

int main() {
    string s;
    cin >> s;
    int g[4] = { 5, 1, -1, 3 };
    int n = s.size();
    dp[0][0][1] = 1;
    for (int i = 0; i < n + 1; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 16; ++k) {
                int nex = k & 8;
                if (j == g[0]) {
                    nex |= 1;
                }
                for (int l = 0; l < 3; ++l) {
                    if ((k >> l) & 1) {
                        if (j == g[l + 1] || l + 1 == 2) {
                            nex |= 1 << (l + 1);
                        }
                    }
                }
                dp[i + 1][nex][0] += dp[i][k][0];
            }
        }
        for (int j = 0; j < s[i] - '0'; ++j) {
            for (int k = 0; k < 16; ++k) {
                int nex = k & 8;
                if (j == g[0]) {
                    nex |= 1;
                }
                for (int l = 0; l < 3; ++l) {
                    if ((k >> l) & 1) {
                        if (j == g[l + 1] || l + 1 == 2) {
                            nex |= 1 << (l + 1);
                        }
                    }
                }
                dp[i + 1][nex][0] += dp[i][k][1];
            }
        }
        for (int j = s[i] - '0'; j <= s[i] - '0'; ++j) {
            for (int k = 0; k < 16; ++k) {
                int nex = k & 8;
                if (j == g[0]) {
                    nex |= 1;
                }
                for (int l = 0; l < 3; ++l) {
                    if ((k >> l) & 1) {
                        if (j == g[l + 1] || l + 1 == 2) {
                            nex |= 1 << (l + 1);
                        }
                    }
                }
                dp[i + 1][nex][1] += dp[i][k][1];
            }
        }
    }
    long long ans = 0;
    for (int i = 8; i < 16; ++i) {
        ans += dp[n][i][0] + dp[n][i][1];
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3232
# include <iostream>
using namespace std;
int main() {
	int n,a[2001],q,m[201],d[2001][2001];
	cin>>n;
	for (int i=1; i<=n; i++)
		cin>>a[i];
	cin>>q;
	for (int i=0; i<q; i++)
		cin>>m[i];
    for (int i=0; i<=n; i++) d[i][0]=1;
	for (int k=0; k<q; k++) {
		for (int i=1; i<=n; i++)
			for (int j=0; j<=m[k]; j++) {
				if (j>=a[i])
					d[i][j]=d[i-1][j]||d[i-1][j-a[i]];
				else
					d[i][j]=d[i-1][j];
			}
		if(d[n][m[k]])
		   cout<<"yes"<<endl;
		else 
		   cout<<"no"<<endl;
	}

}


Measured memory_bytes: 3240
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let n: usize = read();
    println!("{}", (0..n).fold(0, |b, i| if read::<u64>() % 2 == 1 && i % 2 == 0 {b + 1} else {b}));
}


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

int find( int* a, int b, int e, int t )
{
	int m = ( b + e ) / 2;
	if( b > e ){
		return 1;
	}
	if( t < a[ m ] && m != b ){
		return 1 + find( a, b, m - 1, t );
	}
	if( t > a[ m ] && m != e ){
		return 1 + find( a, m + 1, e, t );
	}
	return 1;
}


int main()
{
	int n;
	while( cin >> n && n ){
		int a[ 100 ] = {0};
		for( int i = 0; i < n; ++i ){
			cin >> a[ i ];
		}
		int d;
		cin >> d;
		cout << find( a, 0, n - 1, d ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String lower = "abcdefghijklmnopqrstuvwxyz";
		if(s.charAt(0)!='A') {
			System.out.println("WA");
		}else {
			if(!lower.contains(s.charAt(1)+"")) {
				System.out.println("WA");
				return;
			}
			int Ccount = 0;
			for(int i=2;i<s.length()-1;i++) {
				if(s.charAt(i)=='C') {
					Ccount++;
				}else {
					if(!lower.contains(s.charAt(i)+"")) {
						System.out.println("WA");
						return;
					}
				}
			}
			if(!lower.contains(s.charAt(s.length()-1)+"")) {
				System.out.println("WA");
				return;
			}
			if(Ccount==1) {
				System.out.println("AC");
			}else {
				System.out.println("WA");
			}
		}
		
		
	}

}


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

int main(){
    double a,b,x; cin>>a>>b>>x;
    
    //半分より多く入っている
    double ans=0;
    if(pow(a,2)*b <= 2*x){
        ans = atan((2*(a*a*b - x))/(a*a*a));
    }else{
        ans = -(atan((2*x)/(a*b*b)) - M_PI/2);
    }
    cout << fixed << setprecision(15) << ans*(180/M_PI) << endl;
    
}


Measured memory_bytes: 4084
import java.util.Scanner;
//import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {

        //String input = "10 30 20";
        //String[] input_split = input.split(" ",0);
        //double[] input_double = Stream.of(input_split).mapToDouble(Integer::parseInt).toArray();

        Scanner sc = new Scanner(System.in);
        double[] input_double = new double[3];
        input_double[0] = sc.nextInt();
        input_double[1] = sc.nextInt();
        input_double[2] = sc.nextInt();

        double half_of_all_candy = (input_double[0] + input_double[1] + input_double[2]) / 2;
        Boolean result_flag = false;

        for (Double input_element : input_double){
            if(input_element == half_of_all_candy)
            {
                result_flag = true;
                break;
            }
            else
            {
                //なにもしない
            }
        }

        if(result_flag == true) {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

using namespace std;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    string cur = "", p = "";
    for(int i = 0; i < s.size(); i++) {
        cur += s[i];
        if(cur != p) {
            ans++;
            p = cur;
            cur = "";
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}


bool solve(int N, vi& a, vi& b) {
    ll a_to = 0, b_to = 0;
    rep(i,N){
        if (a[i] > b[i]) {
            b_to += a[i] - b[i];
        } else if (a[i] == b[i]) {
            ;
        } else if (a[i] < b[i]) {
            a_to += (b[i] - a[i] + 1)/2;
            b_to += (b[i] - a[i]) % 2;
        }
    }
    // a_to + k == b_to + 2k
    // a_to >= b_to
#ifdef DEBUG
    fprintf(stderr, "a:%lld, b:%lld\n", a_to, b_to);
#endif
    return (a_to >= b_to);
}

int main() {
    int N = loadint();
    vi a(N), b(N);
    loadvec(a,N);
    loadvec(b,N);
    cout << (solve(N,a,b) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
	int a,b;
	cin >> a >> b;

	if(a==1) a+=13;
	if(b==1) b+=13;
	
	if(a>b)
		cout << "Alice" << endl;
	else if(a<b)
		cout << "Bob" << endl;
	else
		cout << "Draw" << endl;
	
	return 0;
}

Measured memory_bytes: 764
is_prime = [True]*55556
ass = []
is_prime[0] = False
is_prime[1] = False
for i in range(2,int(55555**0.5)+1):
  if not is_prime:
    continue
  else:
    if is_prime:
      for j in range(2*i,55556,i):
        is_prime[j] = False
for k in range(55556):
  if is_prime[k]:
    ass.append(k)
L = []
for l in range(len(ass)):
  if ass[l]%5 == 1:
    L.append(ass[l])
N = int(input())
for i in range(N):
  print(L[i],end = ' ')

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

const int INF = 1e9 + 5;

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

	vector<int> h(n);
	for (int& x : h)
		scanf("%d", &x);

	vector<int> dp(n, INF);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j : {i + 1, i + 2}) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp.back());
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys, math


def solve(R: int, G: int, B: int, N: int):
    count = 0
    for r in range(N // R + 1):
        for g in range(N // G + 1):
            nokori = N - r * R - g * G
            if nokori < 0:
                continue
            if nokori % B == 0:
                count += 1
    print(count)
    return


# Generated by 1.1.7.1 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()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

int main()
{
	int n, m;
	std::cin >> n >> m;
	
	int a;
	for (int i = 0; i < m; i++) {
		std::cin >> a;
		n -= a;
	}
	
	std::cout << (n < 0 ? -1 : n) << std::endl;
	
	return 0;
}


Measured memory_bytes: 3192
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

x,y = map(int,input().split())

#最大公約数
import fractions
a = fractions.gcd(x,y)

#最小公倍数
b = x*y//a

print(b)


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

class UnionFindTree {
private:
  int S[10000];
  int h[10000];
public:
  void init(int N) {
    for (int i=0; i<N; i++) {
      S[i]=i;
      h[i]=0;
    }
  }
  int root(int c) {
    if (c==S[c]) {
      return c;
    } else {
      return (S[c]=root(S[c]));
    }
  }
  void unite(int a,int b) {
    a=root(S[a]);
    b=root(S[b]);
    if (a==b) {
      return ;
    }
    if (h[a]<h[b]) {
      S[a]=b;
    } else {
      S[a]=b;
      if (h[a]==h[b]) {
        h[a]++;
      }
    }
  }
  bool same(int a,int b) {
    return (root(a)==root(b));
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  UnionFindTree f;
  f.init(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (!com) {
      f.unite(x,y);
    } else {
      printf("%d\n",f.same(x,y));
    }
  }
  return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
#define ll long long

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    int A, P;
    cin >> A >> P;
    cout << (A*3+P)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
fin=set()
AC=0
WA=0
WAL=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  if not p in fin:
    if s=="AC":
      AC+=1
      fin.add(p)      
    if s=="WA":
      WAL[p-1]+=1
for k in fin:
  WA+=WAL[k-1]
print(AC,WA)

Measured memory_bytes: 12704
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=1005;
int n,m,a,b;
int A[Maxn][Maxn];
int main(){
	scanf("%d %d %d %d",&n,&m,&a,&b);
	for (int i=1;i<=b;i++){
		for (int j=1;j<=a;j++){
			A[i][j]=0;
		}
		for (int j=a+1;j<=m;j++) A[i][j]=1;
	}
	for (int i=b+1;i<=n;i++){
		for (int j=1;j<=a;j++){
			A[i][j]=1;
		}
		for (int j=a+1;j<=m;j++) A[i][j]=0;
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			putchar(A[i][j]+'0');
		}
		puts("");
	}
}

Measured memory_bytes: 5248
// time-limit: 2000
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif
// 3
void _main(int tc) {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return;
    }

    int aux = (b - a) / (a - 1) + ((b - a) % (a - 1) ? 1 : 0);
    if ((a - 1) * aux < b) aux++;
    cout << aux << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}


Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> v(N, 0);
    vector<int> s(N+1, 0);

    for (int i = 0; i + 1 < N; i++) {
        if (S[i] == 'A' && S[i+1] == 'C') v[i]++;
    }

    for (int i = 0; i < N; i++) s[i+1] = v[i] + s[i];

    while(Q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        int ans = s[r] - s[l];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;string s;
	cin>>n>>s;
	ll ans=0;
	for(ll i=0;i<n-2;i++){
		string t;
		for(ll j=i;j<i+3;j++){
			t.push_back(s[j]);
		}
//		cout <<t<<endl;
		if(t=="ABC"){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll N, A, B, C, D, E, ans = 0;

int main()
{

    cin >> N >> A >> B >> C >> D >> E;
    ll X = min({A, B, C, D, E});
    cout << setprecision(30) << ceil((long double)N / (long double)X) + 4;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int N;
    scanf("%d", &N);
    switch (N % 10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;

    case 3:
        printf("bon\n");
        break;

    default:
        break;
    }
    return 0;
}


Measured memory_bytes: 1616
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    long long q;
    cin >> q;
    vector<long long> as;
    for (int i = 0; i < q; i++) {
        long long a, b;
        cin >> a;
        if (a == 0) {
            cin >> b;
            as.push_back(b);
        } else if (a == 1) {
            cin >> b;
            cout << as[b] << endl;
        } else {
            as.pop_back();
        }
    }
}


Measured memory_bytes: 4896
#include <iostream>
#include<math.h>

using namespace std;


int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int counter = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ++ counter;
                }
            }
        }
    }

    cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue> 
using namespace std;
int G[100][100];
int d[100];
int color[100];
int n;
queue<int> qu;
void bfs ()
{
    color[0] = 1;
    d[0] = 0;
    qu.push(0);
    while (!qu.empty())
    { 
        int u = qu.front(); qu.pop();
        for (int i = 0; i < n; i++)
        {
            if (G[u][i] == 1 && color[i] == 0)
            {
                color[i] = 1;
                d[i] = d[u] + 1;
                qu.push(i);
            }
        }
        color[u] = 2;
    } 
    return;
}

int main()
{
    int k, u, v;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            G[i][j] = 0; 
        }  
    } 

    for (int i = 0; i < n; i++)
    {   
        cin>>u>>k;
        for (int j = 0; j < k; j++)
        {
            cin>>v;
            G[u-1][v-1] = 1;
        } 
    }

    for (int i = 0; i < n; i++)
    {
        d[i] = -1; 
        color[i] = 0;
    } 
    bfs();
    for (int i = 0; i < n; i++)
    {
         cout<< i+1<<" "<<d[i]<<endl;
    } 
    return 0;
}

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

using namespace std;


#define MAXN 1000000
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0, n-(n-a)-(n-b)) << endl;
  return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
	if(b==0):
		return a
	else:
		return gcd(b,a%b)

a,b,c,d=map(int,input().split())
n=b-a+1
lcm=(c*d)//gcd(c,d)
a1=(a-1)//c
b1=b//c
a2=(a-1)//d
b2=b//d
a3=(a-1)//lcm
b3=b//lcm
res=n-b1+a1-b2+a2+b3-a3
print(res)


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<std::max({a+b,a-b,a*b})<<endl;

  return 0;
}


Measured memory_bytes: 256