akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    int h, w;   cin >> h >> w;
    vector<vector<char>> g(h, vector<char>(w));
    ll cnt=0;
    REP(i, h)   
        REP(j, w){
            cin >> g[i][j];
            if(g[i][j]=='.') cnt += 1;
        }
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    vector<vector<ll>> path(h, vector<ll>(w, LINF));
    path[0][0]=1;
    while(!que.empty()){
        pair<int, int> p =que.front();  que.pop();
        REP(i, 4){
            int nx=p.second+dx[i], ny=p.first+dy[i];
            if(nx<0 || ny<0 || h<=ny || w<=nx) continue;
            if(g[ny][nx]=='#') continue;
            if(LINF!=path[ny][nx]) continue;
            que.emplace(ny, nx);
            path[ny][nx] = path[p.first][p.second]+1;
        }
    }
    ll res = cnt - path.back().back();
    if(res<0) res = -1;
    cout << res << endl;
}

Measured memory_bytes: 256
//void _(){
//    int n,m;
//    cin >> n >> m;
//    vl dist(n);
//    rep(i,1,n-1){
//        cin >> dist[i];
//        dist[i] += dist[i-1];
//    }
//    vvl arr(n,vl(m));
//    cin >> arr;
//    vector<vpll> changes(m);
//    vl sums(n),adds(n);
//    ll ans = 0;
//    rep(i,0,n-1){
//        rep(j,0,m-1){
//            ll w = arr[i][j];
//            adds[i] += w;
//            while(!changes[j].empty() && changes[j].back().X < w){
//                ll val,pos;
//                tie(val,pos) = changes[j].back();
//                changes[j].pop_back();
//                ll from = changes[j].empty() ? 0 : changes[j].back().Y+1;
//                adds[from] += w-val;
//                adds[pos+1] -= w-val;
//            }
//            changes[j].pb({w,i});
//        }
//        rep(j,1,i) adds[j] += adds[j-1];
//        rep(j,0,i){
//            sums[j] += adds[j];
//            adds[j] = 0;
//            ans = max(ans,sums[j]-dist[i]+dist[j]);
//        }
//    }
//    print(ans);
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n,m;
    cin >> n >> m;
    vl dist(n);
    rep(i,1,n-1){
        cin >> dist[i];
        dist[i] += dist[i-1];
    }
    vvl arr(n,vl(m));
    cin >> arr;
    vector<vpll> changes(m);
    vl sums(n),adds(n);
    ll ans = 0;
    rep(i,0,n-1){
        rep(j,0,m-1){
            ll w = arr[i][j];
            adds[i] += w;
            while(!changes[j].empty() && changes[j].back().X < w){
                ll val,pos;
                tie(val,pos) = changes[j].back();
                changes[j].pop_back();
                ll from = changes[j].empty() ? 0 : changes[j].back().Y+1;
                adds[from] += w-val;
                adds[pos+1] -= w-val;
            }
            changes[j].pb({w,i});
        }
        rep(j,1,i) adds[j] += adds[j-1];
        rep(j,0,i){
            sums[j] += adds[j];
            adds[j] = 0;
            ans = max(ans,sums[j]-dist[i]+dist[j]);
        }
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

typedef pair <int, int>P;

int main() {
	int N;
	cin >> N;
	vector<P>a(N);
	rep(i, N) {
		int x, l;
		cin >> x >> l;
		a[i].first = x + l;
		a[i].second = x - l;
	}
	sort(a.begin(), a.end());
	int last = -10e9;
	int ans = 0;
	rep(i,N){
		if (a[i].second >= last) {
			ans++;
			last = a[i].first;
		}
	}
	print(ans);
}

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

int main()
{
	int a, b;
	while (cin >> a >> b, a | b) {
		int c = a;
		bool flag[1000]{};
		int now = 0;
		for (; a != 1;a--) {
			int k = 0;
			for(;;now++) {
				if (!flag[now%c]) {
					k++; 
					if (k == b) {
						flag[now%c] = true;
						break;
					}
				}
			 }
		}
		for (int i = 0; i < c; i++) {
			if (!flag[i]) {
				cout << i + 1 << endl;
			}
		}
	}
}

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

#define vi vector<int>
#define vvi vector<vi>

const int INF = 1e9 + 5;

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

    int k;
    string s;
    cin >> k >> s;

    if(s.length() <= k){
        cout << s;
    }else{
        cout << s.substr(0,k) << "...";
    }


    return 0;
}

Measured memory_bytes: 3616
d = int(input())
c_l = list(map(int,input().split()))
s_l = [list(map(int,input().split())) for i in range(d)]


def calc_score(contest_num, last_l):
  contest_val = s_l[day][contest_num]
  point = contest_val

  temp_last_l = last_l[:]
  temp_last_l[contest_num] = day

  for i in range(26):
    point -= c_l[i] * (day - temp_last_l[i])

  return point


last_l = [-1 for i in range(26)]
ans = []

point = 0
for day in range(d):
  each_point = 0
  each_contest_num = 0

  for temp_contest_num in range(26):
    temp_point = calc_score(temp_contest_num, last_l)

    if temp_point > each_point:
      each_point = temp_point
      each_contest_num = temp_contest_num

  last_l[each_contest_num] = day
  ans.append(each_contest_num + 1)
  point += each_point
#  print(last_l)

for i in ans:
  print(i)

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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> b(N+1, 1);
	b[0] = 0;
	vector<int> r(N+1);
	r[1] = 1;
	rep(i,M) {
		int x, y;
		cin >> x >> y;
		if (r[x] == 1 ) r[y] = 1;
		if (r[x] == 1 && b[x] == 1) r[x] = 0;
		b[x]--; b[y]++;
	}

	int ans = 0;
	rep(i,N) ans += r[i+1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4060
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
int a,b,c,x,y;

int main()
{	
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	
	ll ans=0;
	int tmp=min(x,y);
	x-=tmp;y-=tmp;
	ans+=min(2*c,a+b)*tmp;

	if(y)
		swap(x,y),swap(a,b);

	ans+=x*min(a,2*c);

	printf("%d\n",ans);
	return 0;
}


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

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

fn main() {
    let kazu1: usize = read();
    let mut vec1= Vec::new();
    let mut vec2= Vec::new();
    let mut lights = HashMap::new();
    //in
    for x1 in 0..kazu1 {
        let ans2: usize = read();
        vec1.push(ans2);
        if (lights.get(&ans2).is_some()){
            let mut count:i32 =*lights.get(&ans2).unwrap();
            lights.remove(&ans2);
            count=count+1;
            lights.insert(ans2, count);
        }else{
            lights.insert(ans2, 1);
        }
    }
    let kazu2: usize = read();
    for x1 in 0..kazu2 {
        let ans2: usize = read();
        vec2.push(ans2);
        if (lights.get(&ans2).is_some()){
            let mut count:i32=*lights.get(&ans2).unwrap();
            lights.remove(&ans2);
            count=count-1;
            if (count <0){
                print!("NO");
                return;
            }
            lights.insert(ans2, count);
        }else{
            print!("NO");
            return;
        }
    }
    print!("YES");
}

Measured memory_bytes: 17720
#include <iostream>
#include <vector>
#include <algorithm>
#include<queue>
#include<map>
using namespace std;
vector<int> a[100005];
int d[100005];
int t=0;
int n,m;
queue<int> q;

void bfs(){
    d[1]=1;
    q.push(1);

    while(!q.empty()){
        int node=q.front();
        q.pop();
        t++;
        for(int i=0;i<a[node].size();i++){
            if(d[a[node][i]]!=0){
                continue;
            }
            d[a[node][i]]=node;
            q.push(a[node][i]);
        }
    }
    if(t==n){
        cout << "Yes\n";
        for(int i=2;i<=n;i++){
            cout << d[i] << '\n';
        }
        return;
    }else{
        cout << "No\n";
    }
}

int main(){
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    bfs();
    return 0;
}


Measured memory_bytes: 9944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	}

}


Measured memory_bytes: 35684
#include <stdio.h>
#define MOD 1000000007
#define MAX 1001

int main() {
  int primes[MAX];
  int primeNum = 0;
  int factor[MAX][MAX];
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      factor[i][j] = 0;
    }
  }
  int N;
  scanf("%d", &N);

  for (int i = 2; i <= N; i++) {
    int isPrime = 1;
    int minPrimeIndex = primeNum;
    for (int j = 0; j < primeNum; j++) {
      if (i % primes[j] == 0) {
        isPrime = 0;
        minPrimeIndex = j;
        break;
      }
    }
    if (isPrime) {
      primes[primeNum] = i;
      factor[i][primeNum] = 1;
      primeNum++;
    } else {
      for (int j = 0; j < primeNum; j++) {
        factor[i][j] = factor[i / primes[minPrimeIndex]][j];
      }
      factor[i][minPrimeIndex]++;
    }
  }

  long result = 1;
  for (int i = 0; i < primeNum; i++) {
    int numOfI = 0;
    for (int j = 2; j <= N; j++) {
      numOfI += factor[j][i];
    }
    result *= (numOfI + 1);
    result %= MOD;
  }

  printf("%ld\n", result);
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
char s[N][N];
int a[N][N], b[N][N], c[N][N];
int sum(int a[N][N], int x1, int y1, int x2, int y2) {
	x1 --, y1 --;
	return a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1];
}
int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; ++ i) scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
			a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + (s[i][j] == '1');
			b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1] + (s[i][j] == '1' && s[i][j - 1] == '1');
			c[i][j] = c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1] + (s[i][j] == '1' && s[i - 1][j] == '1');
		}
	}
	while (q --) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", sum(a, x1, y1, x2, y2) - sum(b, x1, y1 + 1, x2, y2) - sum(c, x1 + 1, y1, x2, y2));
	}
}



Measured memory_bytes: 52864
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int readint()
{
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}

ll A,S;
vector<ll>p;
vector<pair<ll,int> >prime;

ll solve_small(ll base){
	ll cur=A,sum=0LL;
	while(cur){
		sum+=cur%base;
		cur/=base;
//		if(base==2)cout<<sum<<" "<<cur<<endl;
	}
	return sum;
}

void get_prime(ll x){
	for(ll i=2LL;i*i<=x;i++){
		if(x%i)continue;
		prime.push_back(mk(i,0));
		while(x%i==0){
			prime[prime.size()-1].se++;
			x/=i;
		}
	} 
	if(x>1)prime.push_back(mk(x,1));
} 

void go(ll cur,int pos){
	if(pos==prime.size()){
		p.push_back(cur);
		return;
	}
	go(cur,pos+1);
	rep(i,prime[pos].se){
		cur*=prime[pos].fi;
		go(cur,pos+1);
	}
}

ll solve_big(ll lim){
	if(A==S)return A+1;
	ll cur=A-S;
	if(cur<0)return -1;
	get_prime(cur);
	go(1LL,0);
	sort(p.begin(),p.end());
	rep(i,p.size()){
		ll now=p[i]+1LL;
		if(now<lim)continue;
		if(A/now+A%now==S)return now; 
	} 
	return -1;
}

int main(){
	scanf("%lld%lld",&A,&S);
	ll i=2LL;
	for(i=2LL;i*i<=A;i++){
		if(solve_small(i)==S){
			printf("%lld\n",i);
			return 0;
		}
	}
	printf("%lld\n",solve_big(i));
	return 0;
}
/*
100000000000
50000000000
*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String StringA = String.valueOf(a);
		String StringB = String.valueOf(b);
		String StringC = String.valueOf(c);
		
		if (a >= b && a >= c) {
			if (b  >= c) {
				System.out.println(Integer.parseInt(StringA + StringB)+ c);
			} else  {
				System.out.println(Integer.parseInt(StringA + StringC)+ b);
			}
		} else if (b>=a && b >= c){
			if (a>=c) {
				System.out.println(Integer.parseInt(StringB + StringA) + c);
			} else {
				System.out.println(Integer.parseInt(StringB + StringC)+a);	
			}
		} else {
			if(a>= b) {
				System.out.println(Integer.parseInt(StringC + StringA)+b);
			} else {
				System.out.println(Integer.parseInt(StringC + StringB)+a);
			}
		}

	}
}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		char[] P = sc.next().toCharArray();
		int n = S.length;
		int m = P.length;

		int[] T = new int[m + 1];
		T[0] = -1;
		T[1] = 0;
		int i = 2;
		int j = 0;
		while(i <= m) {
			if(P[i-1] == P[j]) {
				T[i] = j + 1;
				i++;
				j++;
			} else if(j > 0) {
				j = T[j];
			} else {
				T[i] = 0;
				i++;
			}
		}

		i = 0;
		j = 0;
		while(i + j < n) {
//			System.out.println("i = " + i);
			if(P[j] ==S[i + j]) {
				j++;
				if(j == m) {
					System.out.println(i);
				} else {
					continue;
				}
			}
			i = i + j - T[j];
			if(j > 0) {
				j = T[j];
			}
		}
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

const int mod = 1e9+7;

string L;
int dp[100010][2];

int rec(int digit, int smaller) {
	if (digit >= L.size()) {
		return dp[digit][smaller] = 1;
	}

	if (dp[digit][smaller] != -1) {
		return dp[digit][smaller];
	}

	int ret = 0;
	int d = L[digit] - '0';
	
	if (smaller == 0) {
		if (d == 1) {
			Add(ret, rec(digit+1, 0)*2);
			Add(ret, rec(digit+1, 1));
		} else {
			Add(ret, rec(digit+1, 0));
		}
	} else {
		Add(ret, rec(digit+1, 1)*3);
	}

	return dp[digit][smaller] = ret;
}

signed main() {
	cin >> L;
// int dp[100010][2];
	rep (i, 100010) rep (j, 2) dp[i][j] = -1;
	int ans = rec(0, 0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

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

	vector <int>l(Q);
	vector <int>r(Q);
	for (int i = 0; i < Q; i++) {
		cin >> l.at(i) >> r.at(i);
		l.at(i)--;
		r.at(i)--;
	}

	vector <int>t(S.size(), 0);
	for (int i = 0; i < S.size() - 1; i++) {
		if (S.at(i) == 'A' && S.at(i + 1) == 'C') {
			t.at(i + 1) = t.at(i) + 1;
		}
		else {
			t.at(i + 1) = t.at(i);
		}
	}

	for (int i = 0; i < Q; i++) {
		cout << t.at(r.at(i)) - t.at(l.at(i)) << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		String answer="";
		//int t[]=new int[(int)Math.pow(10,5)];
		int max=Integer.MIN_VALUE;
		int min=Integer.MAX_VALUE;
		
		//入力
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		//List<Integer> A=new ArrayList<Integer>();
		//Arrays.sort(a,(x,y) -> Long.compare(x[0], y[0]));
		//処理
		if(A==B && B==C && C==A)
		{
			answer="Yes";
		}else
		{
			answer="No";
		}
		// 出力
		//System.out.println(Arrays.toString(X));
		//System.out.println(Arrays.deepToString(a));
		//System.out.println(Arrays.toString(A.toArray()));
		System.out.println(answer);
	}
}

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

typedef long long ll;

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

  ll a;
  string b;
  cin >> a >> b;
  int n = b.size();
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] == '.') continue;
    sum = sum * 10 + (b[i] - '0');
  }
  a = a * sum / 100;
  cout << a << endl;
  return 0;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#define N 300100
int min(long long a,long long b)
{
    return a<b?a:b;
}
int main()
{
    long long m,n,s;
    scanf("%lld%lld",&m,&n);
    if(2*m<=n)
        s=m+(n-2*m)/4;
    else
        s=n/2;
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
#define inf 0x3f3f3f3f
#define ll long long
int a[N],b[10];
int main() 
{
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],sum+=a[i];
	sort(a+1,a+1+n);
	int i=1;
	if(sum%10==0)
	{	
		while(i<=n&&a[i]%10==0)
		{
			i++;
		}
		sum-=a[i];
		if(i==n+1)
			sum=0;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())
kai = 0
xy = abs(X)
if xy >= K*D:
    kotae = abs(xy-(K*D))
if xy < K*D:
    kai, mod = divmod(xy, D)
    ds = kai*D
    if (K-kai)%2==0:
        kotae = abs(xy-ds)
    if (K-kai)%2!=0:
        kotae = abs(xy-ds-D)
print(kotae)

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

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

    int blue = 0, red = 0;
    rep(i, s.size()) {
        if (s[i] == '1')
            blue++;
        else
            red++;
    }

    int ans;
    if (blue > red)
        ans = red * 2;
    else if (red > blue)
        ans = blue * 2;
    else
        ans = blue * 2;

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
//ll k;
ll n;
string c;
/******* define variable end *******/
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= m;
	if (u < 0)
		u += m;
	return u;
}
int solve() {
	/*
	cin >> k;
	REP(i, 1000000){
		if((7 * (modpow(10, i+1, k)-1) * modinv(9, k)) % k == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	*/
	cin >> n;
	cin >> c;
	vl cl(n);
	REP(i, n){
		if(c.substr(i, 1) == "R"){
			cl[i] = 0;
		}else{
			cl[i] = 1;
		}
	}
	ll front_ite = 0;
	ll back_ite = n-1;
	ll ans = 0;
	while(true){
		if(front_ite >= back_ite) break;
		if(cl[front_ite] == 1){
			if(cl[back_ite] == 0){
				swap(cl[front_ite], cl[back_ite]);
				front_ite++;
				back_ite--;
				ans++;
			}else{
				back_ite--;
			}
		}else{
			if(cl[back_ite] == 0){
				front_ite++;
			}else{
				front_ite++;
				back_ite--;
			}
		}
	}
	bool flag = false;
	REP(i, n){
		if(cl[i] == 1 && !flag) flag = true;
		if(flag && cl[i] == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, q, a[2019] = {}, z = mod;
    cin >> n >> k >> q;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        vector<vector<int>> b;
        vector<int> c;
        b.push_back({});
        for (int j = 0; j < n; j++) {
            if (a[j] >= a[i]) b.back().push_back(a[j]);
            else b.push_back({});
        }
        for (vector<int> j : b) {
            sort(j.begin(), j.end());
            if (j.size() >= k) {
                for (int l = 0; l + k <= j.size(); l++) c.push_back(j[l]);
            }
        }
        sort(c.begin(), c.end());
        if (c.size() >= q) z = min(z, c[q - 1] - c[0]);
    }
    cout << z;
}


Measured memory_bytes: 384
n = map(int, input())
alist = list(map(int, input().split(" ")))

def two_factor(n) :
    cnt = 0

    while n % 2 == 0:
        n /= 2
        cnt += 1

    return cnt 
    
fact_cnt = 0
for a in alist :
    fact_cnt += two_factor(a)
    
print(fact_cnt)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    string s,p;
  p="ABC";
  int n;
    cin>>n;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {  //cout<<i<<endl;
        if(s[i]==p[0])
        {   //cout<<i<<endl;
            string temp=s.substr(i,p.length());
            if(temp==p)
            { // cout<<s<<endl<<temp<<endl;
              // cout<<"Hello"<<endl;
                ans++;
                i=i+p.length()-1;
               // cout<<i<<endl;
                
            temp.clear();
            }
            else continue;
        }
    }
    cout<<ans;
    

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b&&b < c) {
		cout << "Yes" << endl;
	}
	if (a > b&&b > c) {
		cout << "No" << endl;
	}
	if (a < b&&b > c) {
		cout << "No" << endl;
	}
	if (a > b&&b < c) {
		cout << "No" << endl;
	}
	if (a == b&&b > c) {
		cout << "No" << endl;
	}
	if (a == b&&b < c) {
		cout << "No" << endl;
	}
	if (a < b&&b == c) {
		cout << "No" << endl;
	}
	if (a > b&&b == c) {
		cout << "No" << endl;
	}
	if (a == b&&b == c) {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, m;   cin >> n >> m;
    int *x = new int[m];
    for (int i = 0; i < m; i++)
        cin >> x[i];

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    sort(x, x+m);
   
    int *y = new int [m-1];
    for (int i = 0; i < m-1; i++)
        y[i] = x[i+1]-x[i];

    sort(y, y+(m-1), greater<int>());
    
    int ans = 0;
    for (int i = 0; i < n-1; i++)
        ans += y[i];
    cout << x[m-1]-x[0]-ans << endl;
    return 0;
}

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

int main()
{
	char S[200001], T[200001];
	scanf("%s", S);
	scanf("%s", T);
	
	int i, j, flag[26][26] = {}, sum[2][26] = {}, ans = 1;
	for (i = 0; S[i] != 0; i++) flag[S[i] - 'a'][T[i] - 'a'] = 1;
	for (i = 0; i < 26; i++) {
		for (j = 0; j < 26; j++) {
			sum[0][i] += flag[i][j];
			sum[1][i] += flag[j][i];
		}
	}
	for (i = 0; i < 26; i++) if (sum[0][i] > 1 || sum[1][i] > 1) ans = 0;
	
	if (ans == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 512
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a[4];
    rep(i,0,4) cin >> a[i];
    sort(a, a+4);
    ll diff = abs((a[0]+a[3]) - (a[1] + a[2]));
    print(diff);


    

}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){
 
    int N,D,X,a[110],e;

    cin >> N>>D>>X;

    int tmp=D-1;

    for(int i=1;i<=N;i++){
        cin >> a[i];
    }

    for(int i=1;i<=N;i++){
        
        e = e + (tmp/a[i]) + 1;
    }

    cout << e+X <<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
        public static void main(String[] args){
                Scanner scanner = new Scanner(System.in);
                int N = scanner.nextInt();
                int M = scanner.nextInt();
                int C = scanner.nextInt();
                int B[] = new int[M];
                int A[][] = new int[N][M];
                int cnt = 0;

                for (int i = 0; i < M ; i++) {
                        B[i] = scanner.nextInt();
                }

                for (int i = 0; i < N ; i++) {
                        for (int j = 0; j < M ; j++) {
                                A[i][j] = scanner.nextInt();
                        }
                }

                for (int i = 0; i < N ; i++) {
                        int sum = 0;
                        for (int j = 0; j < M ; j++) {
                                sum += A[i][j]*B[j];
                        }
                        if(sum + C > 0){
                                cnt++;
                        }
                }
                System.out.println(cnt);
        }
}

Measured memory_bytes: 24148
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var X = Console.ReadLine().Split().ToArray();
        var Ps = Enumerable.Range(1, 100).ToArray();
        var answer = 100 * 100 * 100;
        foreach (var P in Ps)
        {
            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                var consume = int.Parse(X[i]) - P;
                sum += consume * consume;
            }
            if (sum < answer) answer = sum;
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 28064
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, m;
  std::vector<std::array<long, 2>> xs;
  std::vector<std::array<long, 2>> ys;
  Solver() {
    S002 reader;
    reader >= n >= m >n>= xs >m>= ys;
  }
  void solve() {
    for(long i = 0; i < n; ++i) {
      long len = (1 << 30);
      long resj = -1;
      for(long j = 0; j < m; ++j) {
        long temp = std::abs(xs[i][0] - ys[j][0]) + std::abs(xs[i][1] - ys[j][1]);
        if( len > temp ) {
          len = temp;
          resj = j;
        }
      }
      printf("%ld\n", resj + 1);
    }
  }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

using namespace std;

#define int long long

const int N = 51;
const int LIM = N * N;
const int INF = 1e18 + 239;

struct State {
	int v;
	int mon;

	State() {}

	State(int v_, int mon_) {
		v = v_;
		mon = mon_;
	}

	bool operator<(const State &other) const {
		return make_pair(v, mon) < make_pair(other.v, other.mon);
	}
};


int g_a[N][N];
int g_b[N][N];

int C[N];
int D[N];

void init(){
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			g_a[i][j] = 2 * LIM;
		}
	}
}

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

	init();

	int n, m, S;
	cin >> n >> m >> S;
	while (m--) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		g_a[u][v] = a;
		g_a[v][u] = a;
		g_b[u][v] = b;
		g_b[v][u] = b;
	}
	for (int i = 0; i < n; i++) {
		cin >> C[i] >> D[i];
	}
	S = min(S, LIM);
	map<State, int> d;
	set<pair<int, State>> q;
	q.insert({0, State(0, S)});
	d[State(0, S)] = 0;
	vector<int> ans(n, INF);
	while (!q.empty()) {
		State cur = q.begin()->second;
		q.erase(q.begin());
		ans[cur.v] = min(ans[cur.v], d[cur]);
		for (int i = 0; i < n; i++) {
			if (cur.mon >= g_a[cur.v][i]) {
				State nw = State(i, cur.mon - g_a[cur.v][i]);
				int add = g_b[cur.v][i];
				if (!d.count(nw) || d[nw] > d[cur] + add) {
					q.erase({d[nw], nw});
					d[nw] = d[cur] + add;
					q.insert({d[nw], nw});
				}
			}
		}
		{
			if (cur.mon + C[cur.v] <= LIM) {
				State nw = State(cur.v, cur.mon + C[cur.v]);
				int add = D[cur.v];
				if (!d.count(nw) || d[nw] > d[cur] + add) {
					q.erase({d[nw], nw});
					d[nw] = d[cur] + add;
					q.insert({d[nw], nw});
				}
			}
		}
	}
	// cerr << -1 << endl;
	for (int i = 1; i < n; i++) {
		cout << ans[i] << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 13444
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define A 100
void push(int);
int pop(void);

int main(){
  int x[A],top=0;
  char s[N];

  while(scanf("%s",&s) != EOF){
    if(s[0] == '+'){
      x[top-2]=x[top-2]+x[top-1];
      top--;
    }
    
    else if(s[0] == '-'){
      x[top-2]=x[top-2]-x[top-1];
      top--;
    }
    else if(s[0] == '*'){
      x[top-2]=x[top-2]*x[top-1];
      top--;
    }
    
    else{
      x[top]=atoi(s);
      top++;
    }
  
  }
  printf("%d\n",x[0]);
                     
  return 0;
}




Measured memory_bytes: 2108
n,x =map(int,input().split())
L = list(map(int,input().split()))

D=[0]*(n+1)
D[0]=0
ans = 1

for ii in range(1,n+1):
    D[ii] = D[ii-1] + L[ii-1]
    if D[ii] <= x:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

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



int main() {
    int n; cin >> n;
    vector<string> s(n);
    vector<int> v(n);
    rep(i, n) cin >> s[i] >> v[i];
    int count;
    vector<pair<string, int> > rank_s(n);
    rep(i,n){
        rank_s[i] = make_pair(s[i], i);
    }
    sort(rank_s.begin(), rank_s.end());
    vector<pair<int, int> > vv;
    string before = "";
    rep(k, n){
        if (before == rank_s[k].first){
            continue;
        }
        before = rank_s[k].first;
        rep(i, n){
            if (before == rank_s[i].first){
                vv.push_back(make_pair(v[rank_s[i].second],rank_s[i].second));
            }
        }
        sort(vv.rbegin(), vv.rend());
        rep(i, vv.size()){
            cout << vv[i].second + 1 << endl;
        }
        vv.clear();
    }

    return 0;
}

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

int main(){
  string str;
  cin >> str;
  
  string::iterator pb, pe;
  pb = str.begin();
  pe = str.end();
	pe--;
    int count = 0;
  while(pb < pe){
      if(*pb != *pe)count++;
      pb++;
      pe--;
  }

  cout << count;

    return 0;
}

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

int main()
{
	int n; cin >> n;
	
	int maximum = 0;
	vector<int> p(n); for (int i = 0; i < n; i++) {
		cin >> p[i];
		maximum = max(maximum, p[i]);
	}
	
	int maxIndex = 0;
	for (int i = 0; i < n; i++) {	
		if (p[i] == maximum) maxIndex = i;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i == maxIndex) {
			ans += p[i] / 2;
		}
		else {
			ans += p[i];
		}
	}

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

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int func(int N)
{
        if (N < 10)
                return N;
        return func(N / 10) + N % 10;
}

int main()
{
        int N;
        cin >> N;
        vector<int> a(N);
        rep(i, N) cin >> a[i];
        sort(all(a));
        reverse(all(a));
        int Ali = 0, Bob = 0;
        for (int i = 0; i < N; i += 2)
        {
                Ali += a[i];
        }
        for (int i = 1; i < N; i += 2)
        {
                Bob += a[i];
        }

        cout << Ali - Bob << endl;

        return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

#define int long long
#define MAX 1e18

signed main() {
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        n -= a;
    }

    cout << (n < 0 ? -1 : n) << endl;
    return 0;
}

Measured memory_bytes: 3588
s=input()
n=len(s)
if s.count('N')!=0 and s.count('S')!=0 and s.count('E')!=0 and s.count('W')!=0:
  print('Yes')
elif s.count('N')!=0 and s.count('S')!=0 and s.count('E')==0 and s.count('W')==0:
  print('Yes')
elif s.count('N')==0 and s.count('S')==0 and s.count('E')!=0 and s.count('W')!=0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  ll A, P;
  cin >> A;
  cin >> P;

  cout << ((A * 3) + P) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
struct node
{
    int ai, bi;
}ss[MAX];
bool cmp(node a,node b)
{
    return a.ai < b.ai;
}
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
    {
        scanf("%d%d",&ss[i].ai,&ss[i].bi);
    }
    sort(ss, ss+n, cmp);
    int i;
    for(i = 0; i < n; ++i)
    {
        k -= ss[i].bi;
        if(k <= 0) break;
    }
    cout << ss[i].ai << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

long long n, s, a, sum;
int main()
{
	sum = 1;
	cin >> n >> s;
	a = s;
	while (s <= n) {
		++sum;
		s *= a;
	}
	cout << sum;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	for(llong i = 1;; i++){
		if(i*(i+1)/2 >= x){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;                      
                                               
 class Main {                                  
    public static void main(String[] args) {   
     Scanner scanner = new Scanner(System.in);      
     int s = scanner.nextInt();
     int a = s/3600;
     int b = s%3600/60;
     int c = s%3600%60;	 
     System.out.println( a+":"+ b +":"+c);
     scanner.close();
    }                                          
 }        


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

int n, k, cnt[101], ans=0;

int main(){
	memset(cnt,0,sizeof cnt);
	cin >> n >> k;
	for (int i=0;i<k;i++){
		int a;
		cin >> a;
		for (int j=0;j<a;j++){
			int b;
			cin >> b;
			cnt[b]++;
		}
	}
	for (int i=1;i<=n;i++){
		if (cnt[i]==0) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
typedef long long ll;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;

ll gcd(ll,ll);
ll lcm(ll,ll);
ll notbai(ll,ll,ll);
ll max(ll,ll);
ll min(ll,ll);

ll max(ll x,ll y){
  if(x>y)return x;
  else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

ll gcd(ll x,ll y){
  if(x<y)swap(x,y);//xが大きい
  if(x%y==0)return y;
  return gcd(x%y,y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y) *y;
}

  ll notbai(ll x,ll y,ll z){
  ll xx=z/x;
  ll yy=z/y;
  ll xy=z/lcm(x,y);
  return z-(xx+yy-xy);
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << notbai(c,d,b)-notbai(c,d,a-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;

int main(){
	ll a,b;
	cin >> a >> b;
	cout << a*b/__gcd(a,b) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int L = GetInt();
		int[] a = Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();

		for(int i = 0; i < N - 1; i++)
		{
			if(a[i] + a[i + 1] < L)
				continue;

			var list = new List<int>(N);
			list.Add(i + 1);

			for(int j = i; j > 0; j--)
				list.Add(j);

			for(int j = i + 2; j < N; j++)
				list.Add(j);

			list.Reverse();

			var ans = new StringBuilder();
			for(int j = 0; j < N - 1; j++)
				ans.AppendFormat($"{list[j]}\n");

			Console.WriteLine("Possible");
			Console.Write(ans);
			return;
		}

		Console.WriteLine("Impossible");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 32596
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD2;



int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
           map<string,string> m;
           m["ABC"]="ARC";
           m["ARC"]="ABC";
           string s;
           cin>>s;
           cout<<m[s]<<endl; 
      }

      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 3656