akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

def euclid(a, b):
    m = min(a,b)
    n = max(a,b)
    if (n%m==0):
        return m
    else:
        return euclid(m, n%m)

def lcm(X):
    a = X[0]
    for x in X[1:]:
        a = a* x // euclid(a,x)
    return a

y = lcm(A)-1
s = 0
for a in A:
    s += y%a
print(s)


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 10;
string s[N];
int t[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	FOR(i, 0, n) cin >> s[i] >> t[i];
	
	string x;
	cin >> x;
	
	int ans = 0;
	bool was = 0;
	FOR(i, 0, n) if (s[i] == x) was = 1;
	else
	{
		if (was) ans += t[i];
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int gcd(int a,int b){
    if(b<a){
        int temp = b;
        b = a;
        a = temp;
    }
    while(a != 0){
        int temp = a;
        a = b%a;
        b = temp;
    }
    return b;
}
 
 int main(){
 	int x,y;
 	cin >> x >> y;
    cout << gcd(x,y) << endl; 
    return 0;
}
 


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

const int N = 100000;
vector<ll> a(N), b(N), c(N);

int main() {
  ll n;
  cin >> n;
  a.resize(n), b.resize(n), c.resize(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  rep(i, n) {
    ll a_count = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll c_count = c.end()-upper_bound(c.begin(), c.end(), b[i]);
    ans += a_count * c_count;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n,K;
  cin >> n >> K;
  int x[n],y[n];
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  ll ans = 9000000000000000000;
  rep(i,n){//上辺
    rep(j,n){//左辺
      rep(k,n){//下辺
        rep(l,n){//右辺
          ll top=y[i],lef=x[j],bot=y[k],rig=x[l];
          if(top<=bot || rig<=lef){
            continue;
          }
          int cnt = 0;
          rep(m,n){
            if(bot<=y[m]&&y[m]<=top&&lef<=x[m]&&x[m]<=rig){
              cnt++;
            }
          }
          if(cnt >= K){
            ans = min(ans,(top-bot)*(rig-lef));
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 200001
 
#define ll long long int
 vector<int> wav;
 int m;vector<int> q;
 //int dp[22][11][1002]
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int pos=-1;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='R')
		{
			pos=i;
			break;
		}
	}
	if(pos==-1){
		cout<<0<<endl;
	}
	else{
		int tr=0;
		for(int i=0;i<=pos;i++){
			tr+= (s[i]=='R');
		}
		int r=0;
		for(int i=0;i<tr;i++){
			r+= (s[i]=='R');
		}
		cout<<tr-r<<endl;
	}
 
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){//どこから来たか?
    for(int u : to[v]){ //頂点vから行けるところを全部なめる
        if(u==p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);  
    }
    ans.resize(n);//0埋め
    rep(i,q){
        int p,x;
        cin>>p>>x;
        --p;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 23552
use std::vec::Vec;
use std::cmp::*;

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

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

fn main() {
    let (n, a, b) = {
        let v: Vec<i64> = read_vec();
        (v[0], v[1], v[2])
    };
    let mut h = Vec::new();
    for _ in 0..n {
        let t: i64 = read();
        h.push(t);
    }

    h.sort();

    let m = h[n as usize -1];
    let ans = binary_search_ub(m/b+2, &h, a, b, check);
    print!("{}", ans.unwrap());

    //println!("{:?}", check(&h, 50000000, 2, 1));
}

fn check(h: &Vec<i64>, t: i64, a: i64, b: i64) -> bool {
    let mut count: i64 = t;
    for &e in h {
        if e <= b * t {
           continue
        } else if count > 0 {
           if count < (e - b * t + a - b - 1)  / (a - b) {
               return false;
           } else {
               count -= (e - b * t + a - b - 1)  / (a - b);
           }
        } else {
            return false;
        }
    }
    true
}

// closure f が trueを満たす集合の最小値のインデックスを出力する
// 条件f(&v, m)を満たす集合の下限を出力する
fn binary_search_ub(n: i64, h: &Vec<i64>, a: i64, b: i64, f: fn(&Vec<i64>, i64, i64, i64) -> bool) -> Option<usize>
{
  let mut lb: i64 = -1;
  let mut ub: i64 = n;

  while ub - lb  > 1 {
    let m = lb +  (ub - lb) / 2;
    if f(h, m, a, b) {
      ub = m;
    } else {
      lb = m;
    }
  }
  if ub == n {
      None
  } else {
    Some(ub as usize)
  }
}

Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	int H, W, N;
	cin >> H >> W >> N;

	//
	map<pair<pair<int,int>, pair<int,int>>,int> cnt;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a -= 2; b -= 2;
		for (int j = 0; j < 3; j++)for (int k = 0; k < 3; k++) {
			cnt[{ {a + j, b + k}, { a + j + 2,b + k + 2 }}]++;
		}
	}

	vector < ll > ans(10, 0);
	ans[0] = (ll)(H - 2) * (ll)(W - 2);
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		auto f = (*itr).first.first,s = (*itr).first.second;
		if (1 <= f.first && f.first <= H && 1 <= f.second && f.second <= W &&
			1 <= s.first && s.first <= H && 1 <= s.second && s.second <= W) {
			ans[0]--;
			ans[(*itr).second]++;
		}
	}
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<ll>f(n+1);
  int div=1;
  while (div<=n) {
    int i=1;
    while (div*i<=n) {
      f[div*i]++;
      i++;
    }
    div++;
  }
  ll ans=0;
  for(int i=0 ; i<n+1 ; i++) {
    ans+=i*f[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 81384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<int> abc(3); REP(i, 3) cin >> abc[i];
  sort(ALL(abc), greater<int>());
  if ((abc[0] - abc[1]) & 1) {
    if ((abc[0] - abc[2]) & 1) cout << 1 + (abc[0] - abc[1] - 1) / 2 + (abc[0] - abc[2] - 1) / 2 << '\n';
    else cout << 2 + (abc[0] - abc[1] - 1) / 2 + (abc[0] - abc[2]) / 2 << '\n';
  } else if ((abc[0] - abc[2]) & 1) cout << 2 + (abc[0] - abc[1]) / 2 + (abc[0] - abc[2] - 1) / 2 << '\n';
  else cout << (abc[0] - abc[1]) / 2 + (abc[0] - abc[2]) / 2 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>
 
using namespace std;
 
int main(){
    int n;
    double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
    for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
 
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
    }
    printf("%.6lf\n",p_1);
    printf("%.6lf\n",sqrt(p_2));
    printf("%.6f\n",cbrt(p_3));
    printf("%.6lf\n",p_infinity);
 
}

Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

int n;
vector<ll> a;
vector<ll> imos;

ll sum(ll l, ll r){
    return imos[r] - imos[l];
}

ll get(int l, int r, ll lb){
    ll x = l;
    while(l+1 < r){
        int m = (l+r)/2;
        if(sum(x,m) < lb) l = m;
        else r = m;
    }
    return r;
}

bool check(ll lb){
    rep(i,n){
        ll x = get(i,i+n,lb);
        ll y = get(x,i+n,lb);
        if(sum(i,x) >= lb && sum(x,y) >= lb && sum(y,i+n) >= lb){
            return true;
        }
    }
    return false;
}

ll solve(){
    a.insert(a.end(), a.begin(), a.end());
    imos.assign(a.size()+1,0);
    rep(i,a.size()) imos[i+1] = imos[i] + a[i];
    ll l = 1, r = imos[n]/3;
    while(l+1 < r){
        ll m = (l+r)/2;
        if(check(m)) l = m; else r = m;
    }
    return l;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
    cout << solve() << endl;
}

Measured memory_bytes: 5912
tmp = input().split(" ")
n = int(tmp[0])
k = int(tmp[1])
s = int(tmp[2])

result= []
for i in range(k):
    result.append(str(s))

for i in range(1,10**9):
    if s%i !=0:
        ss = i
        break

for i in range(n-k):
    result.append(str(ss))

print(" ".join(result))

Measured memory_bytes: 13464
import java.util.Scanner;
import java.util.Random;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
import java.io.FileWriter;

public class Main{
    public static Random rand = new Random();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        int D = Integer.parseInt(sc.next());
        int[] C = new int[26];
        int[] L = new int[26];
        for (int i = 0; i < 26; i++){
            C[i] = Integer.parseInt(sc.next());
            L[i] = 0;
        }
        int[][] S = new int[D][26];
        int[] Ans = new int[D];
        for (int i = 0; i < D; i++){
            int maxS = 0;
            for (int j = 0; j < 26; j++){
                S[i][j] = Integer.parseInt(sc.next());
                if (S[i][j] > maxS){
                    maxS = S[i][j];
                    Ans[i] = j + 1;
                }
            }
        }
        int maxPoint = calcPoint(Ans, S, C, L, D);
        

        while (System.currentTimeMillis() - start < 1850){
            maxPoint = change(Ans, S, C, L, D, maxPoint, (1850 - (System.currentTimeMillis() - start)) ^ 2);
        }

        
        
        for (int i = 0; i < D; i++){
            out.print(Ans[i]);
            out.print("\n");
        }

        //template
        sc.close();
        out.flush();
    }

    public static int calcPoint(int[] Ans, int[][] S, int[] C, int[] L, int D){
        int point = 0;
        for (int i = 0; i < 26; i++){
            L[i] = 0;
        }
        for (int i = 0; i < D; i++){
            point += S[i][Ans[i] - 1];
            L[Ans[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++){
                point -= C[j] * (i + 1 - L[j]);
            }
        }
        return point;
    }

    public static int change(int[] Ans, int[][] S, int[] C, int[] L, int D, int maxPoint, long t){
        int ci = rand.nextInt(D);
        int before = Ans[ci];
        Ans[ci] = rand.nextInt(26) + 1;
        int newPoint = calcPoint(Ans, S, C, L, D);
        if (newPoint < maxPoint){
            if (rand.nextInt(1850 ^ 2) < t){
                return newPoint;
            }
            else{
                Ans[ci] = before;
                return maxPoint;
            }    
        }
        else{
            return newPoint;
        }
    }
}

Measured memory_bytes: 41804
N=int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print("hon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print("pon")
elif N%10==3:
    print("bon")

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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    if((a%2==0) ^ (b%2==0))
    {
        ll ans = min(a-1,n-b)+1+(b-a)/2;
        cout<<ans<<endl;
    }
    else
    {
        ll ans = (b-a)/2;
        cout<<ans<<endl;
    }
    return 0;
}


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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& d: a) cin >> d;
	vector<int> mn(n);
	int min = INT_MAX;
	for (int i = n-1; i > -1; --i) {
		if (a[i] < min) min = a[i];
		mn[i] = min;
	}
	for (int i = 0; i < n-1; ++i) {
		if (a[i] - mn[i+1] > 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	vector<string> a;
    vector<int> b;
  int n,y;//yは同じ文字列が既に登場したか否か(1:yes 0:no)
  cin >> n;
  string s;
  for(int i;i < n;i++){
    cin >> s;
    for(int j = 0;j < a.size();j++){
      if(s == a.at(j)){
        b.at(j)++;
        y++;
        break;
      }
    }
    if(y == 0){
      a.push_back(s);
      b.push_back(1);
    }
    y = 0;
  }
  cin >> n;
  for(int i;i < n;i++){
    cin >> s;
    for(int j = 0;j < a.size();j++){
      if(s == a.at(j)){
        b.at(j)--;
        y++;
        break;
      }
    }
    if(y == 0){
      a.push_back(s);
      b.push_back(-1);
    }
    y = 0;
  }
  int m;
  for(int i;i < b.size();i++){
    if(b.at(i) > m) m = b.at(i);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;

    ll N,M;
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    ans=(100*(N-M)+1900*M)*pow(2,M);
    DEB(100*(N-M))
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 999999999
 
using namespace std;
 
typedef pair<int,int>P;
 
const int MAX_N = 100000;
vector<P> G[MAX_N];
int d[MAX_N]; 
bool visited[MAX_N];
 
void dfs(int v)
{
    visited[v] = true;
    for(int i=0; i<G[v].size(); i++){
        if(!visited[G[v][i].first]){
            d[G[v][i].first] = d[v] + G[v][i].second;
            dfs(G[v][i].first);
        }
    }
}
 
int main()
{
    int n,max0=0,maxd,maxx=0;
    scanf("%d",&n);
    fill(d,d+n,INF);
    fill(visited,visited+n,false);
    for(int i=1; i<n; i++){
        int x,y,z;
        scanf("%d %d %d",&x,&y,&z);
        G[x].push_back(make_pair(y,z));
        G[y].push_back(make_pair(x,z));
    }
    d[0] = 0;
    dfs(0);
    for(int i=0; i<n; i++){
        if(max0 < d[i]){
            max0 = d[i];
            maxd = i;
        }
    }
    fill(d,d+n,INF);
    fill(visited,visited+n,false);
    d[maxd] = 0;
    dfs(maxd);
    for(int i=0; i<n; i++){
        maxx = max(maxx,d[i]);
    }
    cout << maxx << "\n";
}


Measured memory_bytes: 13788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    string s;
    
    if(x - r < 0 || x + r > W) s = "No";
    else if(y - r < 0 || y + r > H) s = "No";
    else s = "Yes";
    
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3184
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let hx = a * ((60.0 * h + m) / 360.0 * std::f64::consts::PI).cos();
    let hy = a * ((60.0 * h + m) / 360.0 * std::f64::consts::PI).sin();
    let mx = b * (m / 30.0 * std::f64::consts::PI).cos();
    let my = b * (m / 30.0 * std::f64::consts::PI).sin();
    let dx = hx - mx;
    let dy = hy - my;
    echo!((dx * dx + dy * dy).sqrt());
}


Measured memory_bytes: 2940
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

vector<pair<ll, ll>> prev_5(ll n) {
    vector<pair<ll, ll>> res;
    ll i = 0;
    while (n > 5) {
        i++;
        res.push_back({i, (n / 5) / 2});
        n /= 5;
    }

    return res;
}

int main() {
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<pair<ll, ll>> prev = prev_5(N);
    ll res = 0;
    for (auto p : prev) {
        res += p.second;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long i,n,max = -1000000,min=1000000,sum=0;
    cin >> n;
    long number[n];
    for(i=0;i<n;i++){
        cin >> number[i];
    }
    for(i=0;i<n;i++){
        if(number[i] < min){
            min = number[i];
        }
        if(number[i] > max){
            max = number[i];
        }
        sum += number[i];
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
    
}


Measured memory_bytes: 3168
while gets
    points = $_.split.map(&:to_f).each_slice(2).to_a
    target = points.pop
    points << points[0]
    hoge = points.each_cons(2).map{|u, v|
        x1, y1 = u
        x2, y2 = v
        x3, y3 = target
        ps = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
    }
    if hoge.all?{|x| x >= 0} || hoge.all?{|x| x <= 0}
        puts 'YES'
    else
        puts 'NO'
    end
end

Measured memory_bytes: 6140
#include <iostream>

using namespace std;

int main () 
{
  long int n, k, min, max;
  long int ans = 0;
  const long int MOD = 1000000007;
  cin >> n >> k;
  for (long int i = k; i <= n + 1; i++) {
  min = (i - 1) * i / 2;
  max = (n + 1) * n / 2 - (n - i) * (n - i + 1) / 2;
  ans += (max - min + 1); 
  ans %= MOD; }
  cout << ans;
 }


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 k;
    cin >> k;
    vs64 ans(50);
    s64 n = 50;
    rep (i, n) ans[i] = i;

    rep (i, n)
    {
        ans[i] += k / n;
    }

    rep (i, k % n)
    {
        ans[i] += n;
        rep (j, n)
        {
            if (i == j) continue;
            ans[j] -= 1;
        }
    }

    cout << n << "\n";
    rep (i, n)
    {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6 9
0 1 1
0 2 3
1 2 1
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6

output:
5
"""

import sys
import heapq as hp
from operator import attrgetter


class Edge(object):
    __slots__ = ('source', 'target', 'weight')

    def __init__(self):
        self.weight = float('inf')
        self.source, self.target = None, None


class UnionFind(object):
    __slots__ = ('size', 'tree_height_rank_list', 'ancestor_list')

    def __init__(self, size):
        self.size = int(size)
        self.tree_height_rank_list = [0] * self.size
        self.ancestor_list = [i for i in range(self.size)]

    def _find(self, x):
        if x != self.ancestor_list[x]:
            self.ancestor_list[x] = self._find(self.ancestor_list[x])
        return self.ancestor_list[x]

    def same(self, x, y):
        return self._find(x) == self._find(y)

    def _link(self, x, y):
        if self.tree_height_rank_list[x] > self.tree_height_rank_list[y]:
            self.ancestor_list[y] = x
        else:
            self.ancestor_list[x] = y
            if self.tree_height_rank_list[x] == self.tree_height_rank_list[y]:
                self.tree_height_rank_list[y] += 1

    def union(self, x, y):
        self._link(self._find(x), self._find(y))


def generate_edge_table(v_table):
    for index, each in enumerate(v_table):
        source, target, weight = map(int, each)
        init_edge_table[index].source = source
        init_edge_table[index].target = target
        init_edge_table[index].weight = weight

    return init_edge_table


def graph_Kruskal():
    total_cost = 0
    edge_table.sort(key=attrgetter('weight'))
    # print([i.weight for i in edge_table])
    union_find_case = UnionFind(size=vertices + 1)
    for edge in edge_table:
        if not union_find_case.same(edge.source, edge.target):
            total_cost += edge.weight
            union_find_case.union(edge.source, edge.target)

    return total_cost


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    init_edge_table = [Edge() for _ in range(edges)]
    edge_table = generate_edge_table(v_info)
    print(graph_Kruskal())

Measured memory_bytes: 32784
fn main() {
    let (_n, k) = read_tuple::<i64>();
    let an: Vec<i64> = read_vec();
    let max = *an.iter().max().unwrap();
    let gcd = an.iter().fold(an[0], gcd);

    if k  % gcd == 0 && k <= max{
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


fn gcd(a: i64, b: &i64) -> i64 {
    let b = *b;
    let (mut a, mut b) = (a, b);
    while b != 0 {
        let tmp = a - (a / b) * b;
        a = b;
        b = tmp;
    }
    a
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 6524
#include <bits/stdc++.h>//stayCalmNeverSettle
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;

const ll M = 1e9+7;
const int N = 300010;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    forn(i,n) cin >> a[i];
    int cnt = 0;
    for(int i=0;i<n;i++){
    	if(a[i]%2==1 && (i+1)%2==1){
    		cnt++;
    	}
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3604
///not today

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef pair<long long, long long> pll;

#define SZ(x) (int)(x).size()
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
//#define int long long
#define accept_sho ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define lc (v << 1)
#define rc ((v << 1)| 1)
#define mid ((R + L) >> 1)

int32_t main(){
      int a, v1, b, v2, t;
      cin >>a >>v1 >>b >>v2 >>t;
      if(v2 >= v1 || (abs(a - b) + (v1 - v2) - 1)/ (v1 - v2) > t)
            return cout <<"NO" <<endl, false;
      else
            return cout <<"YES" <<endl, false;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX 100010
int sos[MAX]={1,1,0};
vi sosu;
void init(){
	for(int i=2;i*i<=MAX;i++)if(!sos[i])
	for(int j=i*2;j<MAX;j+=i)sos[j]=true;
	rep(i,MAX)if(sos[i]==0)sosu.pb(i);
}
int main(){
	init();
	int a,b,c;
	while(cin>>a>>b>>c,a+b+c){
		int outa=0,outb=0;
		for(int i=2;i*i<=a;i++)if(!sos[i]){
			for(int j=i;i*j<=a;j++)if(!sos[j]&&b*j<=c*i){
				if(outa*outb<i*j){
					outa=i;
					outb=j;
				}
			}
		}
		cout<<outa<<" "<<outb<<endl;
	}
}

Measured memory_bytes: 3520
import math
while True:
    n,m,p = map(int,input().split())
    if n == m == p == 0:
        break
    m -= 1
    x = [int(input()) for i in range(n)]
    if x[m] == 0:
        print(0)
    else:
        print(math.floor((100-p)*sum(x)/x[m]))


Measured memory_bytes: 5680
# -*- coding: utf-8 -*-
import sys
import numpy as np

sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    a,b,c=map(np.float128,input().split())
    
    if a+b+2*np.sqrt(a*b)<c:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    priority_queue<pair<int,int>, vector<pair<int,int>>,greater<pair<int,int>>> mp;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        mp.push({b,a});
    }
    int dy = 0;
    bool is_ok = true;
    while(mp.size()){
        auto p = mp.top(); mp.pop();
        // cout << p.first << " " << p.second << " " << dy << endl;
        
        dy += p.second;
        if(p.first < dy){
            is_ok = false;
            break;
        }
    }
    if(is_ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

set<int> st;
bool isok(int n){
    stringstream ss;
    ss<<n;
    string s = ss.str();
    
    rep(i,s.size()){
        if(st.count(s[i]-'0')!=0)return false;
    }
    return true;
}

int main(){
    int n,k;
    cin>>n>>k;
    rep(i,k){
        int a;
        cin>>a;
        st.insert(a);
    }
    
    for(int i=n;;i++){
        if(isok(i)){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    if ((N-1)%(K-1) == 0) cout << (N-1)/(K-1) << endl;
    else cout << (N-1)/(K-1) + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,k;
    cin >> a >> b >> k;
    for(int i = 0;i < k;i ++){
        if(i%2){
            a += b/2;
            b /= 2;
        }else{
            b += a/2;
            a /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

constexpr long long MOD = 1e9 + 7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> m(h);
  for (int i=0; i<h; i++)
    cin >> m[i];
  vector<vector<long long>> v(h, vector<long long>(w));
  v[0][0] = 1ll;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (j>0 && m[i][j-1]=='.')
        v[i][j] += v[i][j-1];
      if (i>0 && m[i-1][j]=='.')
        v[i][j] += v[i-1][j];

      v[i][j] %= MOD; 
    }
  }
  cout << v[h-1][w-1] << endl;
  return 0;
}


Measured memory_bytes: 12952
#include<stdio.h>
long int sortk(long long int a[]){
  int i,j,s;
  for (i=0;i<3;i++)
    for (j=i+1;j<4;j++)
      if (a[i]>a[j]) {
        long long int k=a[i];
        a[i]=a[j];
        a[j]=k;
      }
  return a[3];
}
long long int max(long long int a, long long int b, long long int c, long long int d){
  long long int k[4];
  k[0]=a;k[1]=b;k[2]=c;k[3]=d;
  return sortk(k);
}
int main(){
  long long int ans,ac,ad,bc,bd;
  long int a,b,c,d;
  scanf("%li%li%li%li",&a,&b,&c,&d);
  bd=b*d;bc=b*c;ac=a*c;ad=a*d;
  ans=max(ac,ad,bc,bd);
  printf("%lli\n",ans);
  return 0;
}

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

using namespace std;

int lookup[3005][3005];
string str= "";

void LCS(string p,string q,int m,int n)
{
    if(m==0 || n==0) return ;

    if(p[m-1]==q[n-1]) {
        str+=p[m-1];
        return LCS(p,q,m-1,n-1);
    }

    if(lookup[m-1][n]>lookup[m][n-1]) return LCS(p,q,m-1,n);
    else return LCS(p,q,m,n-1);
}

void LCS_length(string p, string q,int m,int n)
{

    for(int i=0;i<=m;i++) lookup[i][0]=0;
    for(int j=0;j<=n;j++) lookup[0][j]=0;

	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (p[i - 1] == q[j - 1])
				lookup[i][j] = lookup[i - 1][j - 1] + 1;

			else
				lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
		}
	}
}

int main()
{
	string X;
	string Y;

	cin>>X>>Y;

	//printf("Longest Common Subsequence is %d\n",LCS_length(X,Y,X.length(),Y.length()));
	LCS_length(X,Y,X.length(),Y.length());
	LCS(X,Y,X.length(),Y.length());

	for(int i=str.length()-1;i>=0;i--)
        cout <<str[i];
    cout <<endl;

	return 0;
}


Measured memory_bytes: 65792
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

using lint = int64_t;
const lint MOD = 1e9 + 7;

lint minv(lint n) {
    lint res = 1, p = MOD - 2;
    while (p > 0) {
        if (p % 2 == 1) {
            res = res * n % MOD;
        }
        n = n * n % MOD;
        p /= 2;
    }
    return res;
}

int main() {
    lint n, k;
    cin >> n >> k;
    lint c = 1, d = n - k + 1;
    cout << n - k + 1 << endl;
    for (int i = 1; i < k; i++) {
        c = c * (k - i) % MOD * minv(i) % MOD;
        d = d * (n - k + 1 - i) % MOD * minv(i + 1) % MOD;
        cout << c * d % MOD << endl;
    }
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	next := 1
	pattern := []int{}
	counter := make([]int, N)
	for i := 0; i < N; i++ {
		counter[i] = 0
	}
	for counter[next-1] == 0 {
		counter[next-1] = len(pattern)
		pattern = append(pattern, next)
		next = A[next-1]
	}
	if K < counter[next-1] {
		fmt.Println(pattern[K])
	} else {
		K -= counter[next-1]
		K %= (len(pattern) - counter[next-1])
		fmt.Println(pattern[counter[next-1]+K])
	}
}


Measured memory_bytes: 14408
#include<stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	long long int a[100005]={0}, b[100005]={0};
	int i;
	for (i=0;i<=n;i++){
		scanf("%lld", &a[i]);
    }
	for (i=0;i<n;i++){
		scanf("%lld", &b[i]);
    }
	long long int ans = 0;
	for (i=0;i<n;i++)
	{
		if (a[i]<=b[i])
		{
			ans += a[i];
			b[i] -= a[i];
			if (a[i + 1] <= b[i])
			{
				ans += a[i+1];
				a[i+1] = 0;
			}
			else
			{
				ans += b[i];
				a[i+1] -= b[i];
			}
		}
		else
			ans += b[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[110];
bool f[110];
int main(){
	ll n;
	vector<ll>ans;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		ll cnt=0;
		bool ok=0;
		for(int j=n-1;j>=0;j--){
			if(f[j]){
				cnt++;
				continue;
			}
			if(a[j]==i-cnt){
				ok=1;
				ans.push_back(a[j]);
				f[j]=1;
				break;
			}
		}
		if(!ok){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(auto x:ans){
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
D, G = map(int,input().split())
MAX = D*100+1
s = 1
g = D*100+1
z = [[0 for i in range(MAX)] for j in range(D+1)]
for i in range(1,D+1):
	p,c = map(int,input().split())
	for j in range(s):
		for k in range(p+1):
			z[i][j+k] = max(z[i][j+k],z[i-1][j]+100*k*i+(c if k == p else 0))
			if z[i][j+k] >= G and g > j+k:
				g = j+k
	s += p
print(g)


Measured memory_bytes: 3188
#include <cstdio>
using namespace std;
int main(){
      int a,b,c,x=0,y=0;
      while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
            if(a*a+b*b==c*c)x++;
            if(a==b)y++;
      }
      printf("%d\n%d\n",x,y);
}

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

using namespace std;
const int maxn = 3e5+10;
const long long mod = 998244353;

int n;
long long a, b, k;
long long fac[maxn];

long long pot(long long a, long long b) {
    if (b == 0) return 1;
    else if (b & 1) return (a * pot(a, b - 1)) % mod;
    else {
        long long out = pot(a, b / 2);
        return (out * out) % mod;
    }
}

long long inv(long long a) {
    return pot(a, mod - 2);
}

long long divi(long long a, long long b) {
    return (a * inv(b)) % mod;
}

long long choose(int n, int k) {
    //printf("choose: %lld %lld %lld\n", fac[n], fac[n - k], fac[k]);
    //if (k > n) return 1;
    return divi(fac[n], (fac[k] * fac[n - k]) % mod);
}

int main() {
    scanf("%d%lld%lld%lld", &n, &a, &b, &k);

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

    long long sol = 0;
    for (int i = 0; i <= n; i++) {
        //printf("%lld\n", i);
        if (k >= a * i && (k - a * i) % b == 0) {
            long long j = (k - a * i) / b;
            if (j > n) continue;
            sol += (choose(n, i) * choose(n, (int)j)) % mod, sol %= mod;
            //printf("%d %d -> %lld\n", i, j, (choose(n, i) * choose(n, j)) % mod);
        }
    }
    printf("%lld", sol);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int cnt[2] = {};
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '1') {
            cnt[i%2]++;
        } else {
            cnt[(i+1)%2]++;
        }
    }

    cout << min(cnt[0], cnt[1]) << endl;

    return 0;
}


Measured memory_bytes: 512
def InsertionSort(A, N):
    for i in range(N):
        v = A[i]       # A[i]は未ソート部分の先頭
        j = i - 1
        while j >= 0 and A[j] > v: 
            A[j+1] = A[j]  # vよりも大きい要素を一つ右に移動させる
            j -= 1     # 比較する位置を移動
        A[j+1] = v     # 空いた部分にvを入れる
        print(*A)

N = int(input())
A = list(map(int, input().split()))

InsertionSort(A, N)


Measured memory_bytes: 5980
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  int num; cin>>num;
  vector<int> v(4);
  rep(i,4) {
    v[3-i] = num%10;
    num/=10;
  }
  int N = 3;      // op1, op2, op3

  string res = to_string(v[0]);
  for(int bit=0; bit<(1<<N); ++bit) {
    int sum = v[0];
    rep(i,N) {
      if(bit & (1<<i))sum += v[i+1]*1;
      else sum += v[i+1]*(-1);
    }

    if(sum==7) {
      rep(i,N) {
        if(bit & (1<<i)) res+='+';
        else res+='-';
        res+=to_string(v[i+1]);
      }
      res+="=7";
      break;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
ans = [0 for _ in range(n)]
for i in range(len(s) - 1):
    if s[i:i+2] == "AC":
        ans[i+1] = ans[i]+1
    else:
        ans[i+1] = ans[i]
    #1indexの累積和

for j in range(q):
    l, r = map(int, input().split())
    print(ans[r-1]-ans[l-1])


Measured memory_bytes: 6180
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

char arr[57][57];
int main(){
	Lancer();
	ll n, m, r;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> arr[i][j];
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			r = 0;
			if (arr[i][j] == '.')
			{
				if (arr[i][j + 1] == '#')
					r++;
				if (arr[i][j - 1] == '#')
					r++;
				if (arr[i + 1][j] == '#')
					r++;
				if (arr[i - 1][j] == '#')
					r++;
				if (arr[i + 1][j + 1] == '#')
					r++;
				if (arr[i - 1][j - 1] == '#')
					r++;
				if (arr[i - 1][j + 1] == '#')
					r++;
				if (arr[i + 1][j - 1] == '#')
					r++;

				arr[i][j] = char(r + '0');
			}
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++)
			cout << arr[i][j];
		cout << endl;
	}
	//cout << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

signed main() {
    capi(n);

    int ans = INT_MAX;
    vector<int> vx;
    rep(i, n) {
        capi(x);
        vx.push_back(x);
    }

    rep(i, 100) {
        int res = 0;
        for (auto x: vx) {
            res += (i + 1 - x) * (i + 1 - x);
        }

        ans = min(ans, res);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int C[N-1], S[N-1], T[N-1], F[N-1];
    rep(i, N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    rep(i, N) {
        int t = 0;
        for(int j = i; j < N-1; j++) {
            if(t < S[j]) {
                t = S[j];
            }
            else if(t%F[j] == 0) {
                ;
            }
            else {
                t = t + F[j] - t%F[j];
            }
            t += C[j];
        }

        cout << t << "\n";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,k = li()
a = list(li())
MOD = 10**9+7

dp = [[0]*(k+1) for _ in range(n+1)]
for i in range(k+1):
    if i <= a[0]:
        dp[1][i] = 1

if n > 1:   
    dp[1] = list(accumulate(dp[1]))
        
for i in range(1,n+1):
    dp[i][0] = 1
    
for i in range(2,n+1):
    for m in range(1,k+1):
        if m-a[i-1] > 0:
            dp[i][m] = dp[i-1][m] - dp[i-1][m-a[i-1]-1]
        else:
            dp[i][m] = dp[i-1][m]
        dp[i][m] %= MOD
    
    if i < n:
        dp[i] = list(accumulate(dp[i]))
        
print(dp[n][k])

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

int main()
{
  int n;cin>>n;
  vector<int> p(n);
  int i;
  for(i=0;i<n;i++)cin>>p.at(i);
  int now=1000000;
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(p.at(i)<now)
    {
      now=p.at(i);
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    map<long long, long long> A;
    for (long long i = 0; i < N; ++i) {
        long long a;
        cin >> a;
        if (A.count(a) == 0) {
            A.insert(make_pair(a, 0));
        }
        A[a] += 1;
    }

    long long ans = 0;
    for (auto e : A) {
        ans += e.first * e.second;
    }

    long long Q;
    cin >> Q;
    for (long long i = 0; i < Q; ++i) {
        long long b, c;
        cin >> b >> c;

        if (A.count(b) > 0) {
            ans -= b * A[b];
            ans += c * A[b];
            if (A.count(c) == 0) {
                A.insert(make_pair(c, 0));
            }
            A[c] += A[b];
            A.erase(b);
        }

        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int d[100009][3], a[3];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++) {
			cin >> a[j];
			d[i][j] = -1;
			for (int k = 0; k < 3; k++) 
				if (j != k)
					d[i][j] = max(d[i][j], d[i - 1][k] + a[j]);
		}
	int mx = -1;
	for (int i = 0; i < 3; i++)
		mx = max(mx, d[n][i]);
	cout << mx << '\n';
	return 0;
}

Measured memory_bytes: 1408
inpl = lambda: list(map(int,input().split()))
N, Z, W = inpl()
a = inpl()[::-1]
a.append(W)
# i = 1
X = Y = Xmin = Ymax = abs(a[0]-a[1])
for i in range(2,N+1):
    X = max(Ymax,abs(a[i]-a[0]))
    Y = min(Xmin,abs(a[i]-a[0]))
    Ymax = max(Ymax, Y)
    Xmin = min(Xmin, X)
print(X)

Measured memory_bytes: 41072
Q = int(input())

S = [False] * (10**5)

S[0] = True
S[1] = True

for i in range(2, 10**5):
    if not S[i]:
        for j in range(2*i, 10**5, i):
            S[j] = True

c = [0] * (10**5)

for i in range(3, 10**5):
    if not S[i] and not S[(i+1)//2]:
        c[i] = c[i-1] + 1
    else:
        c[i] = c[i-1]

for i in range(Q):
    l, r = map(int, input().split())
    print(c[r] - c[l-1])

Measured memory_bytes: 4980
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#include <map> // pair
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  ll mod = 1000000007;
  ll N, M;
  cin >> N >> M;
  ll a[M];
  for(int i = 0; i < M; i++){
    cin >> a[i];
  }
  ll ways[N+1] = {0};
  int j = 0;
  for(int i = 0; i < N+1; i++){
    if((j < M) &&( a[j] == i)){
      while(j < M && a[j] == i){
        j++;
      }
      ways[i] = 0;
      continue;
    }
    if(i == 0){
      ways[i] = 1;
    }else if (i==1){
      ways[i] = 1;
    }else{
      ways[i] = (ways[i-2] + ways[i-1]) % mod;
    }
  }
  cout << ways[N] << endl;
  
  return 0;
}

Measured memory_bytes: 1792