akhauriyash/Code-Regression huggingface dataset:
#                       _oo0oo_
#                      o8888888o
#                      88" . "88
#                      (| -_- |)
#                      0\  =  /0
#                    ___/`---'\___
#                  .' \\|     |// '.
#                 / \\|||  :  |||// \
#                / _||||| -:- |||||- \
#               |   | \\\  -  /// |   |
#               | \_|  ''\---/''  |_/ |
#               \  .-\__  '-'  ___/-. /
#             ___'. .'  /--.--\  `. .'___
#          ."" '<  `.___\_<|>_/___.' >' "".
#         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
#         \  \ `_.   \_ __\ /__ _/   .-` /  /
#     =====`-.____`.___ \_____/___.-`___.-'=====
#                       `=---='
#
#
#     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#               佛祖保佑         永无BUG

l = ["Sunny", "Cloudy", "Rainy"]
print(l[(l.index(input())+1) % 3])

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

using namespace std;
#define ll long long
const int MAXN=1e5+1;
const ll inf = 1e15;
vector<vector<pair<int, ll>>> vert(MAXN, vector<pair<int, ll>>(0));
vector<ll> dp(MAXN, inf);
vector<ll> t(4*MAXN+1, inf);
vector<pair<ll,ll>> ff(0);


void build(int v, int tl, int tr){ //По массиву arr строим
    if(tl==tr){
        t[v]=dp[tl];
        return;
    }
    int tmp=(tl+tr)>>1;
    build( 2*v, tl, tmp);
    build( 2*v+1, tmp+1, tr);
    t[v]=min(t[2*v],t[2*v+1]); //К примеру это построили сумму на отрехке l,r  - можно кучу всего другого
}//o(n)

ll sum(int v, int tl, int tr, int l, int r){
    if(l>r) return inf;
    if(l==tl && r==tr) return t[v];
    int tmp=(tl+tr)/2;
    return min(sum(2*v, tl,tmp, l, min(r,tmp)), sum(2*v+1, tmp+1, tr, max(l,tmp+1),r));
}//o(logn)

void update(int v, int tl, int tr, int pos, ll new_el){//Хотим пересчитать дерево, если arr[pos]=new_el;
    if(tl==tr) {
        t[v]=new_el;
        return;
    }
    int tmp=(tl+tr)>>1;
    if(pos<=tmp) update(2*v, tl,tmp,pos,new_el);
    else update(2*v+1,tmp+1,tr, pos,new_el);
    t[v]=min(t[2*v],t[2*v+1]);
}//o(logn)



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        ll w;
        cin>>a>>b>>w;
        vert[a].push_back({b,w});
    }
    dp[n-1]=0;
    build(1,0,n-1);
    dp[n-1]=inf;
    dp[n]=0;
    for(int i=n-1;i>=1;i--){
        ll ans=inf;
        for(auto &son:vert[i]){
            ll mm=sum(1, 0, n-1,i,son.first-1);
           // cout<<mm<<" "<<son.second<<endl;
            ans=min(ans,mm+son.second);
        }
        dp[i]=ans;
        update(1,0,n-1,i-1, ans);
    }
    if(dp[1]==inf) {
        cout<<"-1"<<endl;
    }
    else cout<<dp[1];
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b;

int main(){
	cin>>a>>b;
	cout<<max(a-2*b,0)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner itr = new Scanner(System.in);
        String s = itr.next();

        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
function Main(input){
    let money = 100;
    const targetMoney =  input;

    for (let i = 0; i < targetMoney; i++) {
        if (money >= targetMoney) {
            console.log(i);
            i = targetMoney;
        }
        money = Math.floor(money * 1.01);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29748
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> pl;
const int INF=100000001;

int main(){
  int n; cin>>n;
  vector<int> a(n);
  multiset<int> s;
  rep(i,n){
    cin>>a[i];
  }
  int ans=0;
  rep(i,n){
    auto it=s.upper_bound(-a[i]);
    if(it==s.end()){
      ans++;
    }else{
      s.erase(it);
    }
    s.insert(-a[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
    int A, B, C, D, E, F;
    double mx = -1;
    int max_ws = 0,max_su = 0;
    cin >> A >> B >> C >> D >> E >> F;
    //a,b,c,dは操作1,2,3,4の回数
    for (int a = 0; 100*A*a<=F; ++a) {
        for (int b = 0; 100*B*b<=F; ++b) {
            int s = (A*a + B * b)*E;//水に溶ける砂糖の最大値
            for (int c = 0; C*c<=s; ++c) {
                for (int d = 0; D*d<=s; ++d) {
                    int su = C * c + D * d;//砂糖の量
                    int ws = 100 * A*a + 100 * B*b + su;//全体量
                    if (su > s)continue;
                    if (ws > F)continue;
                    if (mx < 100 * su / (double)ws) {
                        mx = 100 * su / (double)ws;
                        max_ws = ws;
                        max_su = su;
                    }
                }
            }
        }
    }
    cout << max_ws << " " << max_su << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  
  vector<int>d(N);
  
  for(int i=0;i<N;i++)
    cin>>d.at(i);
  
  sort(d.begin(),d.end());
  
  int res=1;
  
  for(int i=0;i<N-1;i++){
    if(d.at(i)!=d.at(i+1))
      res++;
  }
  
  cout<<res;
}

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;

void solve1()
{
	string s;
	cin >> s;
	int a = 0, b = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R')
			a++;
		else
			b = max(a, b), a = 0;
	}
	cout << max(a, b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	cout << s[0] << s[1] << s[2];
	
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
using namespace std;

int main(void){
    int a;
    int b;

    scanf("%d",&a);
    scanf("%d",&b);

if(a<b){
    printf("a < b\n");
}
else if(a==b){
    printf("a == b\n");
}
else{
    printf("a > b\n");
}

    return 0;
}


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

using namespace std;

bool is_even_all(vector<int> a){
    int count = 0;
    for (int i=0;i<a.size();i++){
        if (a[i]%2==0) count++;
    }
    return (count == a.size());
}

void divide_two_all(vector<int> &a){
    for (int i=0;i<a.size();i++){
        a[i]/=2;
    }
}

int main(void){
    int n,count;
    vector<int> a;

    cin >> n;
    for (int i=0;i<n;i++){
        int v;
        cin >> v;
        a.push_back(v);
    }

    while ( is_even_all(a) ){
        count++;
        divide_two_all(a);
    }

    cout << count;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 0, N;
	int dp[4][4] = {};
	
	cin>>N;
	
	for(int i = 0; i < 4; i++) dp[i][0] = 1;
	
	for(int i = 0; i < N; i++){
		for(int k = 0; k < 4; k++){
			dp[k][(i+1)%4] = 0;
			for(int j = 0; j < 4; j++)dp[k][(i+1)%4] = (dp[k][(i+1)%4]+dp[j][i%4])%MOD;
		}
		
		dp[1][(i+1)%4] = (MOD+dp[1][(i+1)%4]-dp[0][(i+3)%4]-dp[2][(i+3)%4]-dp[0][(i+2)%4]*3%MOD)%MOD;
		dp[2][(i+1)%4] = (MOD+dp[2][(i+1)%4]-dp[0][(i+3)%4]+dp[2][(i+2)%4])%MOD;
		
	}
	
	for(int i = 0; i < 4; i++) ans += dp[i][(N+3)%4];
	
	cout<<ans%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

bool ch(string s, char c) {
    for(auto hoge : s) {
        if(hoge == c) {
            return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    if(n < 26) {
        for(char c = 'a'; c <= 'z'; c++) {
            if(ch(s, c)) {
                cout << s + c << endl;
                return 0;
            }
        }
    }
    int id = -1;
    for(int i = n - 2; i >= 0; i--) {
        if(s[i] < s[i + 1]) {
            id = i;
            break;
        }
    }
    if(id == -1) {
        cout << -1 << endl;
        return 0;
    }
    string t = s.substr(0, id);
    int idd = id + 1;
    for(int i = id + 1; i < n; i++) {
        if(s[i] < s[idd] && s[i] > s[id]) {
            idd = i;
        }
    }
    t += s[idd];
    cout << t << endl;
}


Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer(16) :: n,q,i,j,count_s=0,l,r
character(len=10**5) :: s,b
integer,allocatable :: c(:)

read(*,*) n,q,s

allocate(c(n))

do i = 1, n-1
  if ( s(i:i) == 'A' .and. s(i+1:i+1) == 'C') then
    s(i:i) = 'a'
  end if
end do

c = 0
do i = 2,n
  if ( s(i-1:i-1) == 'a' ) then
    c(i) = c(i-1) + 1
  else
    c(i) = c(i-1)
  end if
end do

do i = 1, q, 1
  read(*,*) l, r
  write(*,'(i0)') c(r)-c(l)
end do

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER


Measured memory_bytes: 1572
m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        x, y = j % 10, j // 10
        if x >= 2 and y >= 2 and x * y == i:
            ans += 1
print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

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

int main() {
  int H,W;
  cin >> H >> W;
  char array[60][60] = {{0}};
  for(int i=0;i<H;i++) {
    cin >> array[i];
    //cout << array[i] << endl;
  }
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++) {
      if(array[i][j] == '.') {
	int sum=0;
	for(int l=-1;l<=1;l++) {
	  for(int m=-1;m<=1;m++) {
	    if((l==0 && m==0) || i+l<0 || j+m<0) continue;
	    else if(array[i+l][j+m] == '#') sum++;
	  }
	}
	//cout << sum << endl;
	array[i][j] = sum + '0';
      }
    }
    cout << array[i] << endl;
  }
}
      

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    ll N;
    cin >> N;
    string s = to_string(N);
    if (s[0] == s[2]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


k = inp()
s = str_inp()
if len(s) <= k:
    print("".join(s))
else:
    print("".join(s[:k]) + "...")


Measured memory_bytes: 68484
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

    int n,x;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        int cnt = 0;
        for(int a = 1;a <= n;a++){
            for(int b = a+1;b <= n;b++){
                int c = x-a-b;
                if(c > b  && c <= n)cnt++;
            }
        }
        cout << cnt << endl;
    }
    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc154.contest.atcoder.jp/tasks/abc154_b


Measured memory_bytes: 3088
function main()
  
  N = parse(Int,readline())
  A = map(x -> parse(Int,x), split(readline()))
  
  count = zeros(Int,N)
  num = 1
  
  for i in 1:N-1
    
    if A[i] >= A[i+1]
      count[num] += 1
    else
      num += 1
    end
    
  end
  
  println(maximum(count))
  
end

main()

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int N, k; cin >> N >> k;
   vector<LL> V(N);
   for (int i = 0; i < N; ++i) {
      cin >> V[i];
   }

   LL ans = -LINF;
   for (int K = 0; K <= k; ++K) {
      for (int m = 0; 2*m <= K; ++m) {
         if (K-m > N) {
            continue;
         }
         for (int i = 0; i <= K-m; ++i) {
            vector<LL> vec;
            for (int j = 0; j < i; ++j) {
               vec.push_back(V[j]);
            }
            for (int j = 0; j < (K-m)-i; ++j) {
               vec.push_back(V[N-1-j]);
            }
            sort(vec.begin(), vec.end());

            LL sum = accumulate(vec.begin(), vec.end(), 0LL);
            for (int j = 0; j < m; ++j) {
               sum -= vec[j];
            }
            chmax(ans, sum);
         }
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)
x = n.times.map{ gets.split.map(&:to_i) } 

count = 0
for hoge in (0...n).to_a.combination(2).to_a
    fuga = 0
    d.times{ |i| fuga += (x[hoge[0]][i] - x[hoge[1]][i]) ** 2 }
    count += 1 if (fuga ** (1/2.0))%1 == 0
end

puts count

Measured memory_bytes: 1916
N, Q = map(int, input().split())
S = input()
l, r = [0]*Q, [0]*Q
for i in range(Q):
    l[i], r[i] = map(int,input().split())
    l[i] -= 1
    r[i] -= 1
lr = zip(l,r)

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

for i,j in lr:
    print(R[j] - R[i])

Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,q;cin>>n>>q;
    map<ll,ll> mp[2];
    mp[0][n]=n;
    mp[1][n]=n;
    ll ans=(n-2)*(n-2);
    rep(i,0,q-1){
        ll a,x;cin>>a>>x;
        if(a==1){
            auto it=mp[0].lower_bound(x);
            if(it==mp[0].begin()){
                auto itr=mp[1].begin();
                mp[0][x]=(itr->first);
                ll k=(itr->first);
                mp[1][k]=x;
                ans-=(k-2);
            }else{
                ans-=((it->second)-2);
            }
        }else{
            auto it=mp[1].lower_bound(x);
            if(it==mp[1].begin()){
                auto itr=mp[0].begin();
                mp[1][x]=(itr->first);
                ll k=(itr->first);
                mp[0][k]=x;
                ans-=(k-2);
            }else{
                ans-=((it->second)-2);
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 16128
n,m=map(int,input().split())
X=[]
M=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    X.append([a-1,b-1])
    M[a-1].append(b-1)
    M[b-1].append(a-1)
ans=0

def dfs(x,se):
    visited[x]=1
    for m in M[x]:
        if se!={x,m} and visited[m]==0:
            dfs(m,se)


for i in range(m):
    visited=[0]*n
    dfs(0,set(X[i]))
    if 0 in visited:
        ans+=1
print(ans)

Measured memory_bytes: 3064
import sys
readline = sys.stdin.buffer.readline
a,b,c = map(int,readline().split())

if a == 5 and (b==5 or c==5):
    if b==7 or c==7:
        print("YES")
    else:
        print("NO")
elif a == 7 and (b==5 and c==5):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, deque
from bisect import bisect
from random import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

INF = 1 << 60
def bfs(K):
  result = [INF] * K
  result[1] = 1
  que = deque([(1, 1)])
  while len(que) > 0:
    (d, u) = que.popleft()
    if result[u] < d:
      continue
    v0 = (10 * u) % K
    if d < result[v0]:
      result[v0] = d
      que.appendleft((d, v0))
    v1 = (u + 1) % K
    if d + 1 < result[v1]:
      result[v1] = d+1
      que.append((d+1, v1))
  return result

def solve(k):
  return bfs(k)[0]

K = read()
print(solve(K))

Measured memory_bytes: 43504
n, a, b = map(int, input().split())

ans = 0
for i in range(1, n + 1):
  t = 0
  k = i
  while(True):
    t += k % 10
    k = int(k / 10)
    if k == 0:
      break
  if a <= t <= b:
    ans += i

print(ans)

Measured memory_bytes: 9128
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [i32; n],
    }
    let mut b = a.clone();
    b.sort();
    for x in &a {
        let y = if *x == b[n - 1] {
            b[n - 2]
        } else {
            b[n - 1]
        };
        println! ("{}", y);
    }
}

fn main() {
    run();
}


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

using namespace std;

const int MAX_N = 100;
int pts[MAX_N];
int n;

int main() {
	while (true) {
		cin >> n; if (n <= 0) break;
		for (int i = 0; i < n; ++i) 
			cin >> pts[i];
		sort(pts, pts + n);

		long pt = 0;
		for (int i = 1; i < n-1; ++i)
			pt += pts[i];

		cout << pt / (n-2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

ll dp[1100][1100][8];

int main(){
    int N,M;
    cin>>N>>M;
    ll x[1100],y[1100],z[1100];
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i]>>z[i];
    }
    dp[0][0][0]=0;
    for(int i=1;i<1100;i++){
        for(int j=0;j<1100;j++){
            for(int k=0;k<8;k++) dp[i][j][k]=-1000000000000000;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            for(int S=0;S<8;S++){
                ll temp=0;
                dp[i+1][j][S]=max(dp[i+1][j][S],dp[i][j][S]);
                if(bit(S,0)) temp+=x[i];
                else temp-=x[i];

                if(bit(S,1)) temp+=y[i];
                else temp-=y[i];

                if(bit(S,2)) temp+=z[i];
                else temp-=z[i];
                dp[i+1][j+1][S]=max(dp[i+1][j+1][S],dp[i][j][S]+temp);
            }
        }
    }
    ll ans=-1000000000000000;
    for(int i=0;i<8;i++){
        ans=max(ans,dp[N][M][i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 75904
while 1:
    n, m = [int(i) for i in raw_input().split(" ")]
    if not n and not m:
        break
    dic = []
    now_pos = 0
    for i in range(n):
        dic.append(int(raw_input()))
    
    for i in range(m):
        now_pos += int(raw_input())
        if now_pos >= n-1:
            for j in range(m-i-1):
                raw_input()
            print i+1
            break
        now_pos += dic[now_pos]
        if now_pos >= n-1:
             for j in range(m-i-1):
                 raw_input()
             print i+1
             break

Measured memory_bytes: 4284
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int n, e, p, q;
    while(cin >> n, n != 0) {
        ll m[4001] = {};
        int a[1000] = {};
        REP(i, n){
            cin >> e >> p >> q;
            m[e] += p * q;
            a[i] = e;
        }
        bool f = true;
        REP(i, n){
            if(m[a[i]] >= 1000000){
                cout << a[i] << '\n';
                m[a[i]] = 0;
                f = false;
            }
        }
        if(f) cout << "NA\n";
    }
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans = 0, j, count;
    for(int i=1; i<=n; i++){
        j = i;
        count = 0;
        while(j){
            count += j%10;
            j /= 10;
        }
        if(a<=count && count<=b)ans+=i;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	string a[] = {"Sunny", "Cloudy", "Rainy"};
	string s;
	cin >> s;

	int p = 0;

	while (a[p] != s) p++;
	p++;
	p %= 3;
	cout << a[p] << "\n";
 	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=1e5+100;
int x[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>x[i];
    int ans=0x3f3f3f3f;
    for(int i=1;i<=n-k+1;i++)
    {
        int left=i;int right=i+k-1;
        if(x[right]<=0)
        {
            ans=min(ans,-x[left]);
        }
        else if(x[left]<0&&x[right]>0)
        {
            ans=min(ans,2*x[left]*(-1)+x[right]);
            ans=min(ans,2*x[right]+x[left]*(-1));
        }
        else ans=min(ans,x[right]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	int c[n-1];
	int s[n-1];
	int f[n-1];
	for(int i=0;i<n-1;i++)
		cin>>c[i]>>s[i]>>f[i];
	
		int res[n];
	for(int i=0;i<n-1;i++)
	{
		int t=0;
		for(int j=i;j<n-1;j++)
		if(t<=s[j])
		{
			t=s[j]+c[j];
		}
		else
		{
			int r = (f[j] - t%f[j])%f[j];
			t += r + c[j];
			
			
		}
		res[i]=t;
	}
	res[n-1]=0;
	for(int i=0;i<n;i++)
	{
		cout<<res[i]<<"\n";
	}

}

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

int dp[101][11];
ll MOD=1000000007;

int f(int x){
  if(x<=0){
    return 1;
  }else if(x==1){
    return 2;
  }else if(x==2){
    return 3;
  }else{ 
    return f(x-1)+f(x-2);
  }
}

int main(void) {
  int h,w,k;
  cin >> h >> w >> k;

  if(w==1){
    cout << 1 << endl;
    return 0;
  }
  
  dp[0][1]=1;
  for (int i = 2; i <= w; i++) {
    dp[0][i]=0;
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if(1==j){
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j+1]*f(w-3)) % MOD;
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j]*f(w-2)) % MOD;
      } else if(j==w){
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j-1]*f(w-3)) % MOD;
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j]*f(w-2)) % MOD;
      } else {
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j-1]*f(j-3)*f(w-j-1)) % MOD;
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j+1]*f(j-2)*f(w-j-2)) % MOD;
	dp[i][j]= (dp[i][j]+(ll)dp[i-1][j]*f(j-2)*f(w-j-1)) % MOD;
      }
    }
  }

  cout << dp[h][k] << endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from math import gcd

MOD = 10 ** 9 + 7
N = int(input())
AB = []
NUMS = defaultdict(int)
zeros = 0
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

    if a == b == 0:
        zeros += 1
        continue

    d = gcd(a, b)
    x, y = a // d, b // d
    if y < 0:
        x, y = -x, -y
    NUMS[x, y] += 1

todo = set(NUMS.keys())
ans = 1
while todo:
    x, y = todo.pop()
    if (-y, x) in todo or (y, -x) in todo:
        assert not ((-y, x) in todo and (y, -x) in todo)
        if (-y, x) in todo:
            v = NUMS[-y, x]
        else:
            v = NUMS[y, -x]
        ans = ans * (2 ** NUMS[x, y] + 2 ** v - 1) % MOD
        todo -= {(-y, x), (y, -x)}
    else:
        ans = ans * (2 ** NUMS[x, y]) % MOD
ans += zeros - 1
print(ans % MOD)

Measured memory_bytes: 87144
#include <bits/stdc++.h>
using namespace std;
#define MIN(a,b) ((a)<(b)?(a):(b))

int count(vector <int> array, int left, int right) {
   if (left > right) {
      return 0;
   }
   if (left == right) {
      return array[left];
   }
   for (int i = left; i <= right; i++) {
      if (array[i] == 0) {
         return count(array, left, i - 1) + count(array, i + 1, right);
      }
   }
   int minimum = 10000000;
   for (int i = left; i <= right ; i++) {
      minimum = MIN(minimum, array[i]);
   }
   for (int i = left; i <= right; i++) {
      array[i] -= minimum;
   }
   return count(array, left, right) + minimum;
}
int main(void) {
   int N;
   cin >> N;
   vector <int> v(N);
   for (int i = 0; i < N; i++) {
     int a; 
     cin >> a;
     v[i] = a;
   }
   int ans = count(v, 0, N - 1);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int mod = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll calc(ll n, ll m, ll k) {
    ll sigma_comb;
    ll a = 1, b = 1, c = 1;
    rrep(i, 1, m * n - 2 + 1) {a *= i; a %= mod;}
    rrep(i, 1, m * n - k + 1) {b *= i; b %= mod;}
    rrep(i, 1, k - 2 + 1) {c *= i; c %= mod;}
    sigma_comb = a * power(b * c % mod, mod - 2) % mod;
    ll sigma_ij = 0;
    rep(d, n) {sigma_ij += d * (n - d) * (m * m); sigma_ij %= mod;}
    return sigma_comb * sigma_ij % mod;
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, m, k; cin >> n >> m >> k;
    ll ansx = calc(n, m, k), ansy = calc(m, n, k);
    cout << (ansx + ansy) % mod << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
int main()
{
    int a,b;

    scanf("%d %d",&a,&b);

    if(a<b)
        printf("a < b\n");

    else if(a>b)
        printf("a > b\n");

    else if(a==b)
        printf("a == b\n");

    return 0;
}

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

using namespace std;

typedef long long int ll;
const int maxn = 100100;

const int p = 1e9 + 7;
inline int add(const int a, const int b)
{
  return (0ll + a + b) % p;
}
inline int mul(const int a, const int b)
{
  return (1ll * a * b) % p;
}

struct jsum
{
  int s[maxn];
  int qow(int a, int x)
  {
    int ret = 1;
    while (x)
    {
      if (1 & x) ret = mul(ret, a);
      a = mul(a, a);
      x >>= 1;
    }
    return ret;
  }
  jsum(void)
  {
    s[0] = 0;
    for (int i = 1; i < maxn; i++)
    {
      int d = qow(i, p - 2);
      s[i] = add(s[i - 1], d);
    }
  }
  int operator[](const unsigned pos) const { return s[pos]; }
}S;
struct fact
{
  int f[maxn];
  fact(void)
  {
    f[0] = 1;
    for (int i = 1; i < maxn; i++)
    {
      f[i] = mul(f[i - 1], i);
    }
  }
  int operator[](const unsigned pos) const { return f[pos]; }
}f;

int main(void)
{
  int N;
  int ans = 0;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
  {
    int Ai;
    scanf("%d", &Ai);
    int d = add(add(S[i], S[N - i + 1]), p - 1);
    ans = add(ans, mul(Ai, d));
  }
  printf("%d\n", mul(ans, f[N]));
  return 0;
}


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

using namespace std;
#define ll long long int


int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    unordered_set<string> s;
    for(auto& w:a) {cin >> w;s.insert(w);}
    cout << s.size() << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  OUT(N*N*N);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long x,y,z;
    int count;
    while(cin >> x >> y){
        z = x + y;
        count=1;
        while(z/=10){
            count++;
        }
        cout<<count<<"\n";
    }
}

Measured memory_bytes: 3188
N ,K =map(int,input().split())
S ="R" +input() +"L"
coun = 0
foo = 0
for i in range(N+1):
    if S[i:i+2] =="RL":
        coun += 1
        if i==0 or i==N:
            foo  +=1
if K >= coun:
    print(N-1)
elif coun -K <= foo:
    print(N-(coun-K))
else:
    print(N-2*(coun-K) +foo)

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


int main(){
    string S;
    std::cin >> S;
    if(S[S.size()-1]=='s'){
        S.push_back('e');
        S.push_back('s');
    }else{
        S.push_back('s');
    }

    std::cout << S;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;

int a[100];

int main(){
	int N,K;
	cin>>N>>K;
	
	rep1(i,N){
		int x=0;
		int now=i;
		while(now<K){
			x++;
			now*=2;
		}
		a[x]++;
	}
	long double ans=0;
//  	rep(i,5)cout<<a[i]<<" ";
//  	cout<<endl;
	rep(i,100)if(a[i]!=0){
      	long double p=1;
		rep(j,i)p/=2;
		ans=ans+(long double)a[i]*p;
	}
  	ans=ans/(long double)N;
  	cout<<fixed;
	cout<<setprecision(12)<<ans;
}

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

int PNtest(int n) {
	int i=0,d[10];
	while (n>0) { // n が 0 になるまで
		d[i]= n % 10;
		n /= 10;
		i++;
	}
	if(d[4]==d[0]&&d[3]==d[1]){
		return 1;
	}else{
		return 0;
	}
}

int main() {
	int a,b,ct=0,i;
	cin>>a>>b;
	for(i=a;i<=b;i++){
		ct+=PNtest(i);
	}
	cout<<ct<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  
  int *a = new int[m];
  
  for(int i=0;i<m;i++){
    cin>>a[i];
    sum += a[i];
  }
  if(sum > n){
    cout<<-1;
  }else{
    cout<<(n-sum);
  }
}

Measured memory_bytes: 3676
import math as ma

n, p = map(int, raw_input().split())
a = map(int, raw_input().split())

e = 0
for ai in a:
  if ai % 2 == 0:
    e += 1

o = len(a) - e
ans = 0


nck = {(o,0): 1}
for k in range(0, o+1):
  nck[(o,k+1)] = nck[(o,k)] * (o-k) / (k+1)

if p % 2 == 0:
  ans = 2 ** e
  if o >= 2:
    t = 0
    for k in range(0, o+1, 2):
      t += nck[(o,k)]
    ans *= t
  print ans

else:
  if o >= 1:
    t = 0
    for k in range(1, o+1, 2):
      t += nck[(o,k)]
    print t * (2 ** e)
  else:
    print 0

Measured memory_bytes: 2696
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    l=list(map(int,input().split()))
    l.sort()
    if n==1 and m>=2:
        print(l[-1]-l[0])
    elif n>=m:
        print(0)
    else:
        aida=[]
        for i in range(m-1):
            aida.append(l[i+1]-l[i])
        aida.sort()
        print(sum(aida[:m-n]))
resolve()

Measured memory_bytes: 56744
c=[]
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
c.append(list(map(int,input().split())))
ans='Yes'
if c[0][0]-c[1][0]!=c[0][1]-c[1][1] or c[0][1]-c[1][1]!=c[0][2]-c[1][2]:
    ans='No'
if c[1][0]-c[2][0]!=c[1][1]-c[2][1] or c[1][1]-c[2][1]!=c[1][2]-c[2][2]:
    ans='No'
if c[0][0]-c[0][1]!=c[1][0]-c[1][1] or c[1][0]-c[1][1]!=c[2][0]-c[2][1]:
    ans='No'
if c[0][1]-c[0][2]!=c[1][1]-c[1][2] or c[1][1]-c[1][2]!=c[2][1]-c[2][2]:
    ans='No'
print(ans)



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

long long a[1000009]={10,23};

int cnt=7058;
void Add(int i,int j,int k){
	printf("+ %d %d %d\n",i,j,k);
	a[k]=a[i]+a[j];
}
void Small(int i,int j,int k){
	printf("< %d %d %d\n",i,j,k);
	a[k]=a[i]<a[j];
}

void calcA(){
	Small(4,4,4);
	for(int i=80;i>=50;--i){
		Add(4,4,4);
		Add(4,i,4);
	}
}
void calcB(){
	Small(4,4,4);
	for(int i=120;i>=90;--i){
		Add(4,4,4);
		Add(4,i,4);
	}
}
//10~40 2^x

//50~80

//90~120

int main(){
	printf("%d\n",cnt);
	
	Add(0,1,11);
	Small(12,11,10);
	for(int i=11;i<=40;++i)Add(i-1,i-1,i);
	
	for(int i=30;i>=0;--i){
		calcA();
		Add(4,10+i,4);
		Add(0,10,5);
		Small(4,5,50+i);
	}
	for(int i=30;i>=0;--i){
		calcB();
		Add(4,10+i,4);
		Add(1,10,5);
		Small(4,5,90+i);
	}
	
	Small(3,3,3);
	for(int k=58;k>=0;--k){
		Add(2,2,2);
		for(int i=0;i<=k;++i){
			int j=k-i;
			if(i>30||j>30)continue;
			Add(50+i,90+j,3);
			Small(10,3,3);
			Add(2,3,2);
		}
	}
	return 0;
}

Measured memory_bytes: 3740
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x: i64 = sc.input();

    for i in -1000..1000i64 {
        for j in -1000..1000i64 {
            let i5 = i * i * i * i * i;
            let j5 = j * j * j * j * j;
            if i5 - j5 == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


Measured memory_bytes: 2080
#include <iostream>
using namespace std;
int main(){
    while(true){
        int m,f,r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1){
            break;
        }
        int kid;
        if (m == -1){
            cout << "F";
        } else if (f == -1){
            cout << "F";
        } else{
            kid = m+f;
                    if (kid >= 80){
            cout << "A";
        } else if (65 <= kid && kid < 80){
            cout << "B";
        } else if (50 <= kid && kid < 65){
          cout << "C";
        } else if (30 <= kid && kid < 50){
          if (r > 49){
            cout << "C";
          }else {
            cout << "D";
          }
        }else{
          cout << "F";
        }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=2*b)cout<<a-2*b<<endl;
    else cout<<0<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    vector<bool>flg(n,false);
    ll pena=0;
    vector<ll>wa(n,0);
    for (int i = 0; i < m; ++i) {
        ll p;string s;
        cin >>p>>s;
        p--;
        if(!flg[p]){
            if(s=="WA")wa[p]++;
            else flg[p]=true;
        }
    }
    ll ac=0;
    for (int i = 0; i < n; ++i) {
        if(flg[i]){
            ac++;
            pena+=wa[i];
        }
    }
    cout <<ac<< " "<<pena<<endl;
    return 0;
}



Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string Swords = Console.ReadLine();
            string Twords = Console.ReadLine();

            for (int i = 0; i < Swords.Length; i++)
            {
                if (Swords[i] != Twords[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            if (Twords[Twords.Length - 1] != null)
            {
                Console.WriteLine("Yes");
                return;
            }
            
            Console.WriteLine("No");
        }
    }
}

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

int max(int a,int b){return a > b ? a:b;} 
int sortmax(int h[],int n);
int hantei(int Cx,int Cy,int H,int N,int x[],int y[],int h[]);

int main(){
    /*入力*/
    int N;
    int m =scanf("%d",&N);
    int x[N],y[N],h[N];
    for(int i = 0;i < N;i++){
        int l = scanf("%d%d%d",&x[i],&y[i],&h[i]);
    }

    /*hのうち一番高いところはどこか調べる*/
    int hh[N];
    for(int i =0;i < N;i++)hh[i]=h[i];
    int maxh = sortmax(hh,N);
    maxh = max(maxh,1);

/*各Cx,Cy,Hについて全ての観測値に整合するかどうかを調べる。もしそうなるのが合ったらそれを出力する*/
    int Cx,Cy,H;
    for(H = maxh;;H++){
        for(int Cx = 0;Cx <= 100;Cx++){
            for(int Cy = 0;Cy <=100;Cy++){
                int mark = hantei(Cx,Cy,H,N,x,y,h);//ここで判定。一致したら１を返す。
                if(mark == 1){
                    printf("%d %d %d\n",Cx,Cy,H);
                    return 0;
                }
            }
        }
    }
    return 0;
}

int sortmax(int h[],int n){
    for(int i = 0;i < n;i++){
            h[0] = max(h[0],h[i]);
        }
    return h[0];
}

int hantei(int Cx,int Cy,int H,int N,int x[],int y[],int h[]){
    for(int i = 0;i < N;i++){
        int cal = H - abs(x[i] - Cx) - abs(y[i] - Cy);
        if(h[i] != max(cal,0))return 0;
    }
    return 1;
}

Measured memory_bytes: 128
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200500;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll r;
     cin >> r;
     ld ans = 2*acos(-1)*r;
     cout<<fixed<<setprecision(12)<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 3804