akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a < b ? a : b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1; tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}



Measured memory_bytes: 11892
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9+7;

long long pwr( long long a , long long b , long long m = M ){
	
	long long ret = 1;
	a %= m , b %= m;

	while( b>0 ){
		if(b&1)	ret = ret*a % m;
		a = a*a % m;
		b >>= 1;
	}

	return ret;
}

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	int n;
	cin>>n;

	long long fac=1;	
	vector<int> pre(n+5,0);
	for(int i=1 ; i<n ; ++i){
		pre[i] = ( pre[i-1] + pwr(i,M-2) ) % M;
		fac = fac * i % M;
	}

	long long ans=0;
	vector<int> a(n);

	for(int i=0 ; i<n ; ++i){
		cin>>a[i];
		if(i)	ans = ( ans + 1l*(a[i]-a[i-1])*pre[i] % M ) % M;
	}

	ans = ans * fac % M;
	cout<< ans ;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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





int main(){
    int N; std::cin >> N;
    long long K; std::cin >> K;
    //doubling[i][j] := 町i(0o)から2^j個先の町(0o)
    // log2(10^18) < 60
    std::vector<std::vector<int>> doubling(N, std::vector<int>(64));
    for(int i(0); i < N; ++i){
        std::cin >> doubling[i][0];
        --doubling[i][0];
    }
    for(int j(0); j < 63; ++j){
        for(int i(0); i < N; ++i){
            doubling[i][j+1] = doubling[doubling[i][j]][j];
        }
    }
    int cur(0);
    for(int j(0); K > 0; ++j){
        if(K & 1) cur = doubling[cur][j];
        K >>= 1;
    }
    std::cout << cur + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 61084
S = input()

for i in range(len(S)):
  if i % 2 == 0:
    if S[i] in {'R','U','D'}:
      continue
    else:
      print('No')
      exit()
  else:
    if S[i] in {'L','U','D'}:
      continue
    else:
      print('No')
      exit()

print('Yes')

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

using namespace std;

int main()
{
    double N;
    while(cin>>N)
    {
        int n;
        n=(int)N;
        if(n==1)
            printf("1.0000000000\n");
        else if(n%2==0)
            printf("0.5000000000\n");
        else
        {
            double k;
            k=((N-1)/2+1)/N;
            printf("%.10f\n",k);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int dir[4][2] = {1, -1, -1, 1, -1, -1, 1, 1};
const int kN = 10010, kInf = 1e18, kNode = 1e5;
const int inf = kInf;
int node_cnt, n;
int id1[4], id2[4];
int x[kN], y[kN], w[kN];

namespace mcmf {
  typedef int FlowType, CostType;
  const int maxn = 1e5, maxm = 2e5;
  const FlowType inff = 1e18;
  const CostType infc = 1e18;

  int n, m, s, t;
  vector<int> g[maxn];

  struct Edge {
    int v;
    FlowType cap, flow;
    CostType cost;
  } edge[maxm << 1];

  CostType dist[maxn], h[maxn];
  void AddEdge(int u, int v, FlowType cap, CostType cost) {
	  g[u].push_back(m);
	  edge[m++] = (Edge){v, cap, 0, cost};
	  g[v].push_back(m);
	  edge[m++] = (Edge){u, 0, 0, -cost};
  }

  struct Node {
    int u;
    CostType d;
    bool operator < (const Node &rhs) const {
      return d > rhs.d;
    }
  };

  bool Dijkstra(void) {
    priority_queue<Node> q;
    q.push((Node){s, 0});
    fill(dist, dist + n, infc);
    dist[s] = 0;
    while (!q.empty()) {
      int u = q.top().u;
      CostType d = q.top().d;
      q.pop();
      if (d != dist[u]) continue;
      for (int i = 0; i < g[u].size(); ++i) {
        Edge &e = edge[g[u][i]];
        if (e.flow < e.cap) {
          CostType t = dist[u] + h[u] - h[e.v] + e.cost;
          if (dist[e.v] > t) {
            dist[e.v] = t;
            q.push((Node){e.v, t});
          }
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      h[i] = min(h[i] + dist[i], infc);
    }
    return h[t] != infc;
  }

  bool ins[maxn];
  int cur[maxn];

  FlowType Dfs(int u, FlowType f) {
    if (u == t) return f;
    ins[u] = true;
    FlowType sum = 0;
    for (int &i = cur[u]; i < g[u].size(); ++i) {
      Edge &e = edge[g[u][i]], &r = edge[g[u][i] ^ 1];
      if (e.flow < e.cap && e.cost + h[u] - h[e.v] == 0 && !ins[e.v]) {
        FlowType t = Dfs(e.v, min(f - sum, e.cap - e.flow));
        e.flow += t;
        r.flow -= t;
        sum += t;
        if (sum == f) break;
      }
    }
    ins[u] = false;
    return sum;
  }

  pair<FlowType, CostType> Solve(void) {
    pair<FlowType, CostType> ans(0, 0);
    fill(h, h + n, 0);
    fill(ins, ins + n, false);
    while (Dijkstra()) {
      fill(cur, cur + n, 0);
      FlowType f = Dfs(s, inff);
      ans.first += f;
      ans.second += f * h[t];
    }
    return ans;
  }
}

using mcmf::AddEdge;

signed main() {
	mcmf::s = ++mcmf::n;
	mcmf::t = ++mcmf::n;
	scanf("%lld", &n);
	for (int i = 0; i < 4; ++i) {
		id1[i] = ++mcmf::n;
		id2[i] = ++mcmf::n;
	}
	for (int i = 1; i <= n * 2; ++i) {
		scanf("%lld%lld%lld", &x[i], &y[i], &w[i]);
		int p = ++mcmf::n;
		if (i <= n) AddEdge(1, p, w[i], 0);
		else AddEdge(p, 2, w[i], 0);
		for (int j = 0; j < 4; ++j) {
			int w = x[i] * dir[j][0] + y[i] * dir[j][1];
			if (i <= n) AddEdge(p, id1[j], inf, -w);
			else AddEdge(id2[j], p, inf, -w);
		}
	}
	for (int i = 0; i < 4; ++i)
		AddEdge(id1[i], id2[i ^ 1], inf, 0);
	++mcmf::n;
	printf("%lld", -mcmf::Solve().second);
}


Measured memory_bytes: 6016
s = input()

flag = True

if s[0] != 'A' or s.count('C') != 1 or s[2:-1].count('C') != 1:
    flag = False
else:
    for i in range(1, len(s)):
        if s[i] != 'C' and s[i].isupper():
            flag = False

print('AC') if flag else print('WA')


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll M = 7368791;
ll solve(const ll m, const ll n) {
    vector<bool> used(M+1, false);
    ll k = 0;
    rep(i, m, M+1) {
        if (!used[i]) {
            if (++k > n) return i;
            for (ll j = i; j <= M; j += i) used[j] = true;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll m, n;
    while (cin >> m >> n, m || n) {
        cout << solve(m, n) << endl;
    }
}

Measured memory_bytes: 4040
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──████AJ████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long

int N;
vector<ll> a;
ll dp[3001][3001];

ll getMaxVal(int start, int end) {
	if (start == end) {
		return a[start];
	}
	if (dp[start][end] != -1) return dp[start][end];
	return dp[start][end] = max(a[start] - getMaxVal(start + 1, end),
	                            a[end] - getMaxVal(start, end - 1));
}

int main() {
	cin >> N;
	a = vector<ll> (N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			dp[i][j] = -1;
		}
	}
	cout << (getMaxVal(0, N - 1)) << endl;
	return 0;
}

Measured memory_bytes: 74036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define MOD 998244353 //1000000007


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

    // solution comes here
    ll N, ans=0;
    string S;
    cin >> N >> S;
    for(char c1='0'; c1<='9'; c1++) for(char c2='0'; c2<='9'; c2++) for(char c3='0'; c3<='9'; c3++){
        ll i=0;
        while(i<N) if(c1 == S[i++]) break;
        while(i<N) if(c2 == S[i++]) break;
        while(i<N) if(c3 == S[i++]) {
            ans++;
            break;
        }
    }

    cout << ans << nl;
}

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

m,n=map(int,input().split())
k=int(input())

joi=dict()
joi["J"]=0
joi["O"]=1
joi["I"]=2


mnj=[[0]*(n+1) for i in range(m+1)]
mno=[[0]*(n+1) for i in range(m+1)]
mni=[[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
    mns=input()
    mnii=[0]*3
    for ii in range(1,n+1):
        mnii[joi[mns[ii-1]]]+=1
        mnj[i][ii]=mnj[i-1][ii]+mnii[0]
        mno[i][ii]=mno[i-1][ii]+mnii[1]
        mni[i][ii]=mni[i-1][ii]+mnii[2]
    
s=[0]*3
for j in range(k):
    aj,bj,cj,dj=map(int,input().split())
    aj-=1
    bj-=1
    sj=mnj[cj][dj]-mnj[aj][dj]-mnj[cj][bj]+mnj[aj][bj]
    so=mno[cj][dj]-mno[aj][dj]-mno[cj][bj]+mno[aj][bj]
    si=mni[cj][dj]-mni[aj][dj]-mni[cj][bj]+mni[aj][bj]
    print(sj,so,si)


Measured memory_bytes: 122988
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: Vec<char> = util::line().chars().collect();
    let (mut x, mut y) = get!(i64, i64);

    let mut op = Vec::new();
    let mut f = 0;
    for &c in &s {
        if c == 'F' {
            f += 1;
        } else {
            op.push(f);
            f = 0;
        }
    }
    op.push(f);

    x -= op[0];
    op.remove(0);

    let mut v = Vec::new();
    let mut h = Vec::new();

    for (i, &p) in op.iter().enumerate() {
        if i % 2 == 0 {
            v.push(p);
        } else {
            h.push(p);
        }
    }

    x = x.abs();
    y = y.abs();

    v.sort();
    h.sort();

    if v.iter().rev().fold(y, |a, &b| (a - b).abs()) == 0
        && h.iter().rev().fold(x, |a, &b| (a - b).abs()) == 0
    {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int &x : v){
        cin >> x ;
    }
    vector<int> sum(n+1,0);
    for(int i=1;i<=n;i++){
        sum[i] = max(sum[i-1],v[i-1]);
    }
    int cnt = 0 ;
    for(int i=1;i<=n;i++){
        if ( v[i-1] == sum[i] ){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void){
	double r, s, c;

	while(scanf("%lf", &r) > 0.0)
	{
		s = r * r * M_PI;
		c = r * 2.0 * M_PI;
		printf("%.6lf %.6lf\n", s, c);
	}

	return 0;
}

Measured memory_bytes: 1792
#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>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

const int maxn = 2005;
int dp[maxn][maxn];
int a[maxn], b[maxn];

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  for(int i = 1; i <= m; i++){
    cin >> b[i];
  }
  dp[0][0] = 1;
  vector <vi> pfsm(n + 1, vi(m + 1));
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(a[i] == b[j]){
        dp[i][j] = add(dp[i][j], pfsm[i - 1][j - 1]);
        dp[i][j] = add(dp[i][j], 1);
      }
      pfsm[i][j] = dp[i][j];
      pfsm[i][j] = add(pfsm[i][j], add(pfsm[i][j - 1], pfsm[i - 1][j]));
      pfsm[i][j] = sub(pfsm[i][j], pfsm[i - 1][j - 1]);
    }
  }
  int res = 0;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      res = add(res, dp[i][j]);
    }
  }
  cout << res; 
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
long long a[500005];
int main()
{
    string s;
    cin >> s;
    memset(a, 0, sizeof(a));
    a[0] = 0;
    long long sum = 0;
    int slen = s.size();
    for (int i = 0; i < slen; i++)
    {
        if (i == 0&&s[i] == '>')
        {
            long long tt = 0;
            for (int j = i; j < slen; j++)
            {
                if (s[j + 1] == '<' || j == slen - 1)
                {
                    tt = j - i+1;
                    break;
                }
            }
            //cout << tt << endl;
            a[i] = tt;
            for (int j = 1; j <= tt; j++)
            {
                a[i + j] = tt - j;
            }
            i = i + tt-1;
        }
        else if (s[i] == '<')
        {
            if (s[i + 1] == '<')
            {
                a[i + 1] = a[i] + 1;
            }
            else
            {
                long long tt = 0;
                for (int j = i + 1; j < slen; j++)
                {
                    if (s[j + 1] == '<' || j == slen - 1)
                    {
                        tt = j - i;
                        break;
                    }
                }
                //cout << tt << endl;
                a[i + 1] = max(a[i] + 1, tt);
                for (int j = 2; j <= tt; j++)
                {
                    a[i + j] = tt - j + 1;
                }
                i = i + tt;
            }
        }
    }
    for (int i = 0; i <= slen; i++)
    {
    //    printf("%d ",a[i]);
        sum += 1ll * a[i];
    }
    //puts("");
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4740
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		int n=1000;
		int[] a=new int[n];
		int[] c={1, 5, 10, 50, 100, 500};
		fill(a, INF);
		a[0]=0;
		for(int j=0; j<c.length; j++){
			for(int i=c[j]; i<n; i++){
				a[i]=min(a[i], a[i-c[j]]+1);
			}
		}
		for(;;){
			int m=sc.nextInt();
			if(m==0){
				break;
			}
			println(a[1000-m]+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    int cnt[3] = {0, 0, 0};
    map<char, int> next_turn = {{'a', 0}, {'b', 1}, {'c', 2}};
    map<int, char> winner = {{0, 'A'}, {1, 'B'}, {2, 'C'}};
    int turn = 0;
    while (true)
    {
        if (cnt[turn] == S[turn].length())
        {
            break;
        }
        char c = S[turn][cnt[turn]];
        cnt[turn]++;
        turn = next_turn[c];

    }
    cout << winner[turn] << endl;
 //   system("pause");
    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m = 0;
  unsigned long int f = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    f += a[i]-1;
  }
  cout << f;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
# N=O(10^5)なので、O(N)で解く
# ABC-155-C-Poll の類題
# 方針：各数字の出現回数を数える
 
# Counter(リスト) は辞書型のサブクラスであり、キーに要素・値に出現回数という形式
# Counter(リスト).most_common() は(要素, 出現回数)というタプルを出現回数順に並べたリスト
A = Counter(A).most_common()
 
# 出現回数の大きい方からK種類はそのままにしておく。これによって、変えない個数が求まる。
# 変える個数は、N-(変えない個数)
s = 0
for i in range(min(K, len(A))):
  s += A[i][1]
  
print(N-s)

Measured memory_bytes: 44364
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, P> S;

llint w, h;
char c[55][55], c2[55][55];
llint sx, sy, gx, gy;
llint sx2, sy2, gx2, gy2;
bool used[55][55][55][55];
llint dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void get(char c[55][55], llint &sx, llint &sy, llint &gx, llint &gy)
{
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '%'){
				c[x][y] = '.';
				gx = x, gy = y;
			}
			else if(c[x][y] != '.' && c[x][y] != '#'){
				c[x][y] = '.';
				sx = x, sy = y;
			}
		}
	}
}

P calc(char c[55][55], llint x, llint y, llint dir)
{
	llint nx = x + dx[dir], ny = y + dy[dir];
	if(nx <= 0 || nx > w || ny <= 0 || ny > h) return P(x, y);
	if(c[nx][ny] == '#') return P(x, y);
	return P(nx, ny);
}

void bfs()
{
	queue<S> Q;
	Q.push(S(P(sx, sy), P(sx2, sy2)));
	
	for(int x = 1; x <= w; x++){
		for(int y = 1; y <= h; y++){
			for(int x2 = 1; x2 <= w; x2++){
				for(int y2 = 1; y2 <= h; y2++){
					used[x][y][x2][y2] = false;
				}
			}
		}
	}
	used[sx][sy][sx2][sy2] = true;
	
	while(Q.size()){
		llint x = Q.front().first.first, y = Q.front().first.second;
		llint x2 = Q.front().second.first, y2 = Q.front().second.second;
		Q.pop();
		for(int i = 0; i < 4; i++){
			llint mi = i;
			if(mi % 2 == 0) mi = (mi+2)%4;
			P res = calc(c, x, y, i), res2 = calc(c2, x2, y2, mi);
			if(res.first == -1 || res2.first == -1) continue;
			if(used[res.first][res.second][res2.first][res2.second]) continue;
			bool r = (res.first == gx && res.second == gy);
			bool r2 = (res2.first == gx2 && res2.second == gy2);
			if((r&&!r2) || (!r&&r2)) continue;
			used[res.first][res.second][res2.first][res2.second] = true;
			Q.push(S(res, res2));
		}
	}
}

int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		string s;
		for(int y = 1; y <= h; y++){
			cin >> s;
			for(int x = 1; x <= w; x++) c[x][y] = s[x-1];
			cin >> s;
			for(int x = 1; x <= w; x++) c2[x][y] = s[x-1];
		}
		get(c, sx, sy, gx, gy);
		get(c2, sx2, sy2, gx2, gy2);
		
		bfs();
		
		if(used[gx][gy][gx2][gy2]) cout << "Yes" << endl;
		else cout << "No" << endl;
		
	}
	return 0;
}


Measured memory_bytes: 12424
a, b, c = map(int, input().split())

# 偶数が入っている場合 = 0 (高さにする)
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)

# 小さい2つを選ぶ
else:
    lv = sorted([a, b, c])
    aa, bb = lv[0], lv[1]
    area = aa * bb
    print(area)

Measured memory_bytes: 38384
#include <iostream>
#include <cmath>

using namespace std;

//ifstream cin("/home/mihai/Documents/C++/ATCoder/Beginer_097/A/A.in");
//ofstream cout("/home/mihai/Documents/C++/ATCoder/Beginer_097/A/A.out");

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

ll mod=1e9+7;

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<bool> inc(n+1,true);
    vector<int> dp(n+1);
    for(int i=0;i<m;i++){
        int temp;
        scanf("%d",&temp);
        inc[temp]=false;
    }
    dp[0]=1;
    dp[1]=inc[1];
    for(int i=2;i<=n;i++){
        if(inc[i]){
            dp[i]=dp[i-1]+dp[i-2];
        }
        dp[i]%=mod;
    }
    cout<<dp[n]<<"\n";
    return 0;
}


Measured memory_bytes: 3796
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)


Measured memory_bytes: 143420
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=1005;
int sum[MAX_N];
int main()
{
	rep(i,1,1000)
	{
		sum[i]=sum[i-1]+i;
	}
	int a=read(),b=read();
	rep(i,1,1000)
	{
		if(abs(a-b)==abs(sum[i]-sum[i-1]))cout<<abs(sum[i]-b)<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;
    ll a = 0, ans = 0;

    rep(i, (int)s.size() - 2) {
        if (s[i] == 'A') {
            a++;
            if (s[i + 1] == 'B' && s[i + 2] == 'C') {
                ans += a;
                a--;
                s[i + 2] = 'A';
                i++;
            }
        }
        else {
            a = 0;
        }
    }

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

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

long long mod_pow(int a, int b){
	long long res = 1;
	for(int i=0; i<b; i++){
		res *= a;
		res = res%998244353;
	}
	return res;
}

int main(){
	int n;
	bool zero_flag=false;
	long long res = 0;
	cin >> n;
	vector<int> d(n);
	vector<int> dp(n);

	for(int i=0; i<n; i++){
		cin >> d[i];
	}	
	if(d[0] != 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i=1; i<n; i++){
		if(d[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}	

	for(int i=0; i<n; i++){
		dp[d[i]]++;
	}
	//for(int i=0; i<n; i++){
	//	cout << dp[i] << " ";
	//}
	//cout << endl;
	for(int i=0; i<n; i++){
		if(dp[i]==0 && !zero_flag){
			zero_flag = true;
		}else if(dp[i]!=0 && zero_flag){
			cout << 0 << endl;
			return 0;
		}
	}

	res = 1;
	int cnt, prev_cnt;
	prev_cnt = 1;
	for(int i=1; i<n; i++){
		cnt = dp[i];
		res *= mod_pow(prev_cnt,cnt)%998244353;
		res = res%998244353;
		prev_cnt = cnt;
	}

	cout << res << endl;
	return 0;
	
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int N,i,ans=INF;
  scanf("%d",&N);
  int W[N],a[N],b[N];
  FOR(i,0,N)scanf("%d",&W[i]);
  a[0]=W[0];b[N-1]=W[N-1];
  FOR(i,0,N-1)a[i+1]=a[i]+W[i+1];
  FOR(i,0,N-1)b[N-i-2]=b[N-i-1]+W[N-i-2];
  FOR(i,0,N-1)if(ans>abs(b[i+1]-a[i]))ans=abs(b[i+1]-a[i]);

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 500000;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long inverse[MAX+1];
long long factorial[MAX+1];
long long factorial_inverse[MAX+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	return factorial[n] * (factorial_inverse[k] * factorial_inverse[n-k] % MOD) % MOD;
}

int main() {
	long long n, m;
	cin >> n >> m;
	calc(m);
	long long a = comb(m, n) * factorial[n] % MOD;
	long long b_ = 0;
	for (int i = 1, sign = 1; i <= n; i++, sign *= -1) {
		b_ = mod(b_ + mod(sign) * comb(n, i) % MOD * comb(m-i, n-i) % MOD * factorial[n-i] % MOD);
	}
	long long b = mod(a - b_);
	long long ans = a * b % MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15196
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);

  deque< int > d;
	REP(i, n) {
		if (i % 2 == 0) d.push_back(a[i]);
		else d.push_front(a[i]);
	}

	if (n % 2 == 0) {
		REP(i, n) {
			OUT(d[i]);
			if (i < n - 1) SP
				else BR
							 }
	} else {
		RREP(i, n) {
			OUT(d[i]);
			if (i > 0) SP
				else BR
							 }
	}
	
  return 0;
}


Measured memory_bytes: 5376
#include <functional>
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(int argc, char *argv[])
{
  ll n;

  cin >> n;

  ll d[n];

  for (ll i = 0; i < n; i++) {
    cin >> d[i];
  }

  sort(d, d+n, greater<int>());

  ll current_size = d[0];
  ll current_num = 1;
  for (ll i = 1; i < n; i++) {
    if (current_size > d[i]) {
      current_size = d[i];
      current_num += 1;
    }
  }

  cout << current_num << endl;
}

Measured memory_bytes: 256
n=int(input())
a= list(map(int,input().split()))
from collections import defaultdict as dd
dp=dd(int)

dp[1]=0
dp[2]=abs(a[0]-a[1])

for i in range(3,n+1):
    dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2])
print(dp[n])


Measured memory_bytes: 23588
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define maxnn 2000
ll n;
ll ry[maxnn][maxnn];
ll ru[maxnn];
ll d=0;
ll mark[maxnn];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)
	{
		scanf("%lld",&ry[i][j]);
		ru[i]=1;
	}
	}
	while(1)
	{
		d++;
		for(int i=1;i<=n;i++)
{
		mark[i]=0;
}
		int tt=0;
		int tr=0;
		for(int i=1;i<=n;i++)
{
		if(ru[i]==n)	{continue;}
		if(mark[i]) {continue;}
		if(ry[ry[i][ru[i]]][ru[ry[i][ru[i]]]]!=i) 
	{
		tt++;
	} 
	else
	if(!mark[i]&&!mark[ry[i][ru[i]]])
	{
			ru[ry[i][ru[i]]]++;
			mark[i]=1;
			mark[ry[i][ru[i]]]=1;
			ru[i]++;
	}
}
	for(int i=1;i<=n;i++)
	if(ru[i]==n) tr++;
	if(tr==n) {cout<<d;return 0;}
	if(n-tr==tt) {cout<<-1;return 0;}
	}
} 

Measured memory_bytes: 16256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = []
point = 0
for t in T[:K]:
    if t == 'r':
        ans.append(('p', True))
        point += P
    elif t == 's':
        ans.append(('r', True))
        point += R
    else:
        ans.append(('s', True))
        point += S

for i, t in enumerate(T[K:]):
    if t == 'r':
        if ans[i][0] == 'p' and ans[i][1]:
            ans.append(('-', False))
        else:
            ans.append(('p', True))
            point += P
    elif t == 's':
        if ans[i][0] == 'r' and ans[i][1]:
            ans.append(('-', False))
        else:
            ans.append(('r', True))
            point += R
    else:
        if ans[i][0] == 's' and ans[i][1]:
            ans.append(('-', False))
        else:
            ans.append(('s', True))
            point += S

print(point)

Measured memory_bytes: 4340
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int A[200005];
int cc=0;
vector<int> V;
int B[200005];

int main(){
    int n;
    ll ans=0;
    cin >> n;
    rep(i,n){
        cin >> A[i];
        B[i]=A[i]-i;
        if(-200005<B[i]&&B[i]<0){
            V.push_back(-B[i]);
        }
    }
    sort(V.begin(),V.end());
    rep(i,n){
        int k=A[i]+i;
        if(200005>k){
            int temp=upper_bound(V.begin(),V.end(),k)-lower_bound(V.begin(),V.end(),k);
            ans+=temp;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

template <class T>
class SegTree {
	size_t n;                       // 葉の数
	vector<T> data;              // データを格納するvector
	T def;                       // 初期値かつ単位元
	function<T(T, T)> operation; // 区間クエリで使う処理
	function<T(T, T)> update;    // 点更新で使う処理

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def; // 交差しない
		if (a <= l && r <= b)
			return data[k]; // a,l,r,bの順で完全に含まれる
		else {
			T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
			T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
			return operation(c1, c2);
		}
	}

public:
	// _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
	// _update:更新関数
	SegTree(size_t _n, T _def, function<T(T, T)> _operation,
		function<T(T, T)> _update)
		: def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	// 場所i(0-indexed)の値をxで更新
	void change(int i, T x) {
		i += n - 1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	// [a, b)の区間クエリを実行
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	// 添字でアクセス
	T operator[](int i) {
		return data[i + n - 1];
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	auto add = [](int rhs, int lhs) { return rhs + lhs;  };
	auto and2 = [](int rhs, int lhs) { return lhs;  };
	vector<SegTree<int>> segs(26, SegTree<int>(n, 0, add, and2));

	string s; cin >> s;
	FOR_LT(i, 0, n) {
		segs[s[i] - 'a'].change(i, 1);
	}

	int m; cin >> m;
	FOR_LT(i, 0, m) {
		int q; cin >> q;
		if (q == 1) {
			int p; cin >> p;
			p--;
			char c; cin >> c;
			segs[s[p] - 'a'].change(p, 0);
			s[p] = c;
			segs[s[p] - 'a'].change(p, 1);
		}
		else {
			int l, r; cin >> l >> r;
			l--;

			int ans = 0;
			FOR_LT(j, 0, 26) {
				if (segs[j].query(l, r) != 0) ans++;
			}
			cout << ans << endl;
		}
	}



	return 0;
}

Measured memory_bytes: 110976
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ll unsigned long long
using namespace std;;
//const ll mod=1e9+7;

int main()
{
    int n,m;
    cin>>n>>m;
    double s1=0;
    for(int i=1;i<=n;i++)
    {   /*int z=log2(m/i);
   if(i>=m){
        s+=1.0/n;
        continue;
    }
    int q;
     if((1<<z)==m)q=z;
     else q=z+1;//cout<<q<<endl;
        s+=(1.0/n);*pow(0.5,q);*/
        ll s,ss;     s=i;ss=1;
        int sum=0;
        while(s<m)
        {
            s<<=1;//cout<<s<<endl;
            ss<<=1;
            sum++;
        }
      //  cout<<sum<<endl;
        s1+=1.0/n/ss;
    }
    printf("%.14f\n",s1);
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s; cin >> s;
	pair<int,int> dest, cur;
	cin >> dest.first >> dest.second;
	bool ans = false, turn = 0;	
//	int fcnt = count(s.begin(),s.end(),'F'), tcnt = count(t.begin(),t.end(),'T');
	queue <pair<char,int>> q;
	pair<char,int> tmp;
	tmp = make_pair(s[0], 1);
	for (int i = 1; i < (int) s.length(); ++i){
		if (s[i] == tmp.first){
			++tmp.second;
		}else{
			if (tmp.first == 'T') tmp.second %= 2;
			q.push(tmp);
			tmp = make_pair(s[i],1);
		}
	}
	q.push(tmp);
	cur = make_pair(1,0);
	if (q.front().first == 'F'){
		dest.first -= q.front().second;
		q.pop();
	}
	vector <int> dx, dy;
	while(!q.empty()){
		auto p = q.front();
		if (p.first == 'F'){
			if (turn) dy.push_back(p.second);
			else dx.push_back(p.second);
		}else{
			if (p.second == 1) turn ^= 1;
		}
		q.pop();
	}
	sort(dx.rbegin(),dx.rend());
	sort(dy.rbegin(),dy.rend());
	for (auto i : dx){
		dest.first -= i * (dest.first > 0 ? 1 : -1);
	}
	for (auto i : dy){
		dest.second -= i * (dest.second > 0 ? 1 : -1);
	}
	if (dest.first == 0 && dest.second == 0) ans = true;	
	cout << ((ans)?  "Yes" : "No") << "\n";
	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
    int x;
    cin>>x;
    bool ok=false;
    while(!ok){
        ok=IsPrime(x);
        x++;
    }
  x--;
    cout << x<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    int win = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'o') {
        win++;
      }
    }
    
    int remain = 15 - s.length();
    
    //System.out.println("remain:" + remain);
    //System.out.println("win:" + win);
    //System.out.println("s.length:" + s.length());
    
    if (remain >= (8 - win)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if (s[i]==t[i]) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;
int prime(int x) {
	int a = x - 1;
	while (a >= pow(x, 0.5)) {
		if (x % a == 0) {
			return 1;
			break;
		}
		a--;
	}
	return 0;
}

int main() {
	ll x;
	cin >> x;
	while (prime(x) == 1) {
		x++;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        int A = int.Parse(str[0]);
        int B = int.Parse(str[1]);
        int C = int.Parse(str[2]);
        Console.WriteLine((A+B == C || B+C == A || A+C == B) ? "Yes\n" : "No\n");
    }    
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=5001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound

ll k1=0;
void solve(string s,string r)
{
   int z[maxn]={};
   string t=r;
   t+'#';
   t+=s;
   //for(i=0;i)
   z[0]=0;
   int left=0;
   int right=0;
   int i,j,k,l,n;
   n=t.size();
   for(int k=1;k<n;k++)
   {
   	if(k>right)
   	{
   		right=k;
   		left=k;
   		while(k<n&&t[right-left]==t[right])
   			right++;
   		z[k]=right-left;
   		right--;

   	}
   	else
   	{
   		int k1=k-left;
   		if(z[k1]<right-k+1)
   			z[k]=z[k1];
   		else
   		{
   			left=k;
   			while(k<n&&t[right-left]==t[right])
   			right++;
   		     z[k]=right-left;
   		   right--;

   		}
   	}
   }
   k=r.size();
   k1=k;
   for(i=r.size();i<=t.size()-r.size();i++)
   {
   	k1=min((int)k1,k-z[i]);
   }
}
int main()
{
	fastio;
	int t;
	ll i,j,k,l,n;
	cin>>n;
	ll a[n+1]={},b[n+1]={};
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=a[i]%mod;
		b[i]=b[i-1]+a[i];
		b[i]=b[i]%mod;

	}
	l=0;
	for(i=1;i<n;i++)
	{
		l=(l+((b[n]-b[i]+mod)*a[i]%mod))%mod;
	}
	cout<<l;
	

}
//Lordvishnu@almighty

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

int My_Calc(int A,int B,int index){
    
    if(index == 0) return A+B;
    else return A-B;
}
bool My_Calc_All(int i,int j,int k,int A,int B,int C,int D){
    
    char s[2]; s[0] = '+'; s[1] = '-';
    int sum = 0;
    sum += My_Calc(A,B,i);
    sum += My_Calc(0,C,j);
    sum += My_Calc(0,D,k);
    
    if(sum == 7) { cout << A << s[i] << B << s[j] << C << s[k] << D << "=" << sum << endl; return true; }
    else { return false; }
}
int main(){
  
  string s; cin >> s;
  int A = s[0] - 48;
  int B = s[1] - 48;
  int C = s[2] - 48;
  int D = s[3] - 48;
  
  for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
          for(int k=0;k<2;k++){
              if(My_Calc_All(i,j,k,A,B,C,D)) return 0;
          }
      }
  }
} 

Measured memory_bytes: 3568
#include<stdio.h>
//#include<conio.h>
//#include<string.h>
//#include<math.h>
//#include<stdlib.h>
//#define pi acos(0.0)*2
int main()
{
    long long int a,b,x,i,j,k,l=0,m;
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a==0) {l++;a=1;}
    i=b/x;
    j=a/x;
    if(a%x==0) j--;
    printf("%lld\n",(i-j)+l);
}


Measured memory_bytes: 128
import java.util.Scanner;

public  class Main {
	public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int d = stdIn.nextInt();
	int t = stdIn.nextInt();
	int s = stdIn.nextInt();
	if (d<=t*s){
	System.out.println("Yes");
	}
	else {System.out.println("No");}
	}

}

Measured memory_bytes: 35704
import java.util.*;
import java.util.Map.Entry;
 
class Main {
//	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
//       int B = sc.nextInt();
//       String S = sc.next();
//       String T = sc.next();
//       char[] s = S.toCharArray();
//       char[] t = T.toCharArray();
       long[] a = new long[(int)N];
       for (int i=0 ; i<N; i++) {
           a[i] = sc.nextLong();
       }
       
       int ans=Integer.MAX_VALUE;
       for(int i=0;i<=100;i++) {
    	   int sum=0;
    	   for(int j=0;j<N;j++) {
    		   sum=(int) (sum+Math.pow(a[j]-i,2));
    	   }
    	   ans=Math.min(ans, sum);
       }
       
       
       System.out.println(ans);
   }
      
}

Measured memory_bytes: 23764