akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
//BIT
#define M 500010
ll dat[M];
void init(){
  rep(i, M) dat[i] = 0;
}
void add(ll i, ll x){
  for(; i<M; i += i&-i) dat[i] += x;
}
ll sum(ll i){
  ll res = 0;
  for(; i>0; i -= i&-i) res += dat[i];
  return res;
}
ll rangesum(ll L, ll R){
  return sum(R) - sum(L-1);
}

ll A[M] = {};
vector<ll> QL[M], QID[M];
ll ans[M];

ll N, Q, C[M];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> N >> Q;
  for(ll i = 1; i <= N; i++) cin >> C[i];
  rep(i, Q){
    ll L, R;
    cin >> L >> R;
    QL[R].push_back(L);
    QID[R].push_back(i);//後続、sortしないで順番に出せる
  }
  init();
  for(ll i = 1; i <= N; i++){
    if (A[C[i]] > 0) add(A[C[i]], -1);
    add(i, +1);
//rep(i, Q+10) cout<<dat[i]; cout<<endl;
    A[C[i]] = i;
    rep(j, QL[i].size())
      ans[QID[i][j]] = rangesum(QL[i][j], i);
  }

  rep(i, Q) cout << ans[i]<< endl;
}

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

#define int double

int32_t main()
{
	int nn, dd;
	cin >> nn >> dd;
	int rii = 0, x, y;
	for (int i = 0; i < nn; i++)
	{
		cin >> x >> y;
		int sum = sqrt(x*x + y*y);
		if (sum <= dd)
		{
			rii++;
		}
	}
	cout << rii;

	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define FI freopen ("inp.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
#define FOR(v) for(int i : v) {printf("%d ", i);} printf("\n");
#define what_is(x) cerr << #x << " = " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/*---------------------------Codes-----------------------------*/

const int nax = 1005;
const int mod = 1e9 + 7;
int R, C;
char grid[nax][nax];
long long mem[nax][nax];

long long dp(int i, int j) {
    if (i == R-1 && j == C-1) return 1;

    if (mem[i][j] != -1) return mem[i][j];

    long long ans1 = 0, ans2 = 0;
    if (i < R-1 && grid[i+1][j] == '.') {
        ans1 = dp(i + 1, j);
    }
    if (j < C-1 && grid[i][j+1] == '.') {
        ans2 = dp(i, j + 1);
    }

    return mem[i][j] = (ans1%mod + ans2%mod) % mod;
}

int main() {
    //FI;

    memset(mem, -1, sizeof(mem));
    scanf("%d %d", &R, &C);
    for (int i = 0; i < R; ++i) {
        scanf("%s", grid[i]);
    }

    error(R, C);

    long long ans = dp(0, 0);
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

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

	string S;
	cin >> S;

	vector<int> list(S.size());
	list[0] = 0;
	for (int i = 1; i < S.size(); i++)
	{
		list[i] = list[i - 1];
		if (S[i - 1] == 'A' && S[i] == 'C')
		{
			list[i]++;
		}
	}

	vector<int> ans(Q);
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		cin >> l >> r;
		l--; r--;

		ans[i] = list[r] - list[l];
	}

	for (int i = 0; i < Q; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
def main():
    a, b = map(int, input().split())

    if a == 0 or b == 0:
        print("Zero")
    elif a <= b < 0:
        if (b - a + 1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")
    elif a < 0 < b:
        print("Zero")
    elif 0 < a <= b:
        print("Positive")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61876
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n,x,m;
    cin>>n>>x>>m;
    vector<int> a(m+1,0);
    a[0]=x;
    int memo,sum=x;
    map<int,int> mp;
    mp[x]=0;
    rep(i,1,1+m){
        a[i]=a[i-1]*a[i-1]%m;
        if(mp[a[i]]){
            memo=i;
            break;
        }
        if(a[i]==0){
            cout<<sum<<endl;
            return 0;
        }
        sum+=a[i];
        mp[a[i]]=i;
    }

    int ans=0;
    rep(i,min(mp[a[memo]],n)){
        ans+=a[i];
    }
    sum=0;
    rep(i,mp[a[memo]],memo){
        sum+=a[i];
    }
    if(memo==mp[a[memo]]){
        ans+=max(0ll,n-mp[a[memo]])*a[memo];
    }
    else{
    ans+=(max(n-mp[a[memo]],0ll))/(memo-mp[a[memo]])*sum;
        rep(i, max(n - mp[a[memo]], 0ll) % (memo - mp[a[memo]] )) {
            ans += a[i + mp[a[memo]]];
        }

    }
    cout<<ans<<endl;
}


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

int main(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    
}

Measured memory_bytes: 3648
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    if s[i] != s[-(i+1)]:
        ans += 1
print(ans)


Measured memory_bytes: 65580
N,M = map(int,input().split())
H = list(map(int, input().split()))
A=[0]*M
B=[0]*M
ans=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if (H[A-1]>H[B-1]):
    ans[B-1]=1
  elif(H[A-1]<H[B-1]):
    ans[A-1]=1
  else:
    ans[B-1]=1
    ans[A-1]=1
print(ans.count(0))

 

Measured memory_bytes: 20124
#include<stdio.h>
int main (){
  int a,coin=0,b,c500,c100,c50,c10,c5,c1;
  while(1){
    scanf("%d",&a);
    b=1000-a;
    if(a==0)break;
    c500=b/500;
    c100=(b%500)/100;
    c50=((b%500)%100)/50;
    c10=(((b%500)%100)%50)/10;
    c5=((((b%500)%100)%50)%10)/5;
    c1=b-( c500*500  +c100*100  +c50*50  +c10*10 + c5*5);
    printf("%d\n",c500+c100+c50+c10+c5+c1);
  }
  return 0;
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long

#define maxn 1000005

int ans[maxn] ;
pair<int,int> a[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++)
    {
        scanf("%d",&a[i].xx) ;
        a[i].yy = i ;
    }

    sort( a+1,a+n+1 ) ;

    if( a[n].xx - a[1].xx > 1 )
    {
        printf("No\n") ;
        return 0 ;
    }

    if( a[1].xx == a[n].xx )
    {
        if( a[1].xx==n-1 )
        {
            printf("Yes\n") ;
/*            for(int i=1 ; i<=n ; i++)
            {
                printf("%d",i) ;
                if( i==n ) printf("\n") ;
                else printf(" ") ;
            } */
            return 0 ;
        }

        if( a[1].xx*2 > n )
        {
            printf("No\n") ;
            return 0 ;
        }

        for(int i=1 ; i<=a[1].xx ; i++) ans[i] = i ;
        for(int i=a[1].xx+1 ; i<=n ; i++) ans[i] = ans[i-a[1].xx] ;

        printf("Yes\n") ;
      /*  for(int i=1 ; i<=n ; i++)
        {
            printf("%d",ans[i]) ;
            if( i==n ) printf("\n") ;
            else printf(" ") ;
        } */
        return 0;
    }

    int small = 0 , large = 0 ;

    for(int i=1 ; i<=n ; i++)
    {
        if( a[i].xx == a[1].xx ) small++ ;
        else large++ ;
    }

//    printf("%d\n",small) ;

    if( a[n].xx <= small || (a[n].xx-small)*2 > large )
    {
        printf("No\n") ;
        return 0 ;
    }

    printf("Yes\n") ;
/*
    for(int i=1 ; i<=a[n].xx ; i++) ans[ a[i].yy ] = i ;

    int i=a[n].xx+1 , j=1 ;

    for( ; i<=n ; i++ ) ans[ a[i].yy ] = ans[ a[i- (a[n].xx-small) ].yy ] ;

    for( i=1 ; i<=n ; i++)
    {
        printf("%d",ans[i]) ;
        if( i==n ) printf("\n") ;
        else printf(" ") ;
    } */

    return 0 ;
}


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

class UnionFindTree {
  private:
    vector<long long int> par;   // 親
    vector<long long int> depth; // 木の深さ

  public:
    // n要素で初期化
    UnionFindTree(long long int n) {
        for (long long int i = 0; i < n; i++) {
            par.push_back(i);
            depth.push_back(0);
        }
    }

    // 木の根を求める
    long long int find(long long int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(long long int x, long long int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (depth[x] < depth[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }

    // xとyが同じ集合に属するか否か
    bool same(long long int x, long long y) { return find(x) == find(y); }
};

// u,v : 始点と終点
struct edge {
    long long int u, v, cost;
};

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

vector<edge> es;
long long int V;

long long int kruskal() {
    sort(es.begin(), es.end(), comp); // edge.costが小さい順にソートする
    UnionFindTree uft = UnionFindTree(V);
    long long int res = 0;
    for (long long int i = 0; i < es.size(); i++) {
        edge e = es[i];
        if (!uft.same(e.u, e.v)) {
            uft.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

struct Point{
    long long int x, y, num;
};

bool compareByX(Point lhs, Point rhs){
    return lhs.x < rhs.x;
}

bool compareByY(Point lhs, Point rhs){
    return lhs.y < rhs.y;
}

int main(){
    cin >> V;
    vector<Point> v;
    for(int i=0;i<V;++i){
        long long int x, y;
        cin >> x >> y;
        v.push_back((Point){x, y, i});
    }

    sort(v.begin(), v.end(), compareByX);
    for(int i=1;i<V;++i){
        es.push_back((edge){v[i].num, v[i-1].num, min(abs(v[i].x-v[i-1].x), abs(v[i].y-v[i-1].y))});
    }

    sort(v.begin(), v.end(), compareByY);
    for(int i=1;i<V;++i){
        es.push_back((edge){v[i].num, v[i-1].num, min(abs(v[i].x-v[i-1].x), abs(v[i].y-v[i-1].y))});
    }

    cout << kruskal() << endl;

    return 0;
}


Measured memory_bytes: 12396
n = int(input())
s = input() + "@"
t = input() + "@"
mod = 10 ** 9 + 7

# 情報を1次元にして処理しやすくするぜ
# 縦で一致 True 横で一致 False
b = []
for i in range(n):
    if s[i] == s[i + 1]:
        continue
    b.append(s[i] == t[i])

# 処理するぜ
if b[0]:
    ans = 3
else:
    ans = 6

for i in range(1, len(b)):
    if b[i]:
        if b[i - 1]:
            ans *= 2
    else:
        if b[i - 1]:
            ans *= 2
        else:
            ans *= 3

print(ans % mod)



Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  int n;cin>>n;
  
  vector<int> h(n+1);
  rep(i,n) cin>>h[i];
  h[n]=0;
  int ans =0;
  
  for (int i=0;i<n;i++) {
    if (h[i]>h[i+1]) {
      ans+=h[i]-h[i+1];
    }
  }
  cout<<ans<<endl;
}

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

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

    int length = s.size();
    cout << s.at(0) << length - 2 << s.at(length - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] R = new int[n];
    for(int i = 0; i < n; i++) {
      R[i] = sc.nextInt();
    }

    int minv = 2000000000;
    int maxp = -2000000000;
    int t;
    for(int i = 1; i < n; i++) {
      if (R[i - 1] < minv)  minv = R[i - 1];
      t = R[i] - minv;
      if(t > maxp)  maxp = t;
    }

    System.out.println(maxp);

  }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  const ll N = 61;

  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  vll bit(N, 0);
  REP(i, n){
    REP(j, N){
      if((a[i]>>j) & 1)
        bit[j]++;
    }
  }

  vll ans(N, 0);
  REP(i, n-1){
    vll target(N, 0);
    REP(j, N){
      if((a[i]>>j) & 1)
        target[j] = 1;
    }

    REP(j, N)
      bit[j] -= target[j];

    REP(j, N){
      if(target[j] == 0)
        ans[j] += bit[j];
      else
        ans[j] += target[j]*(n-1-i) - bit[j];
    }
  }


  ll sum = 0;
  REP(i, N){
    ll f = ll(pow(2, i)) % MOD;
    sum += (f * (ans[i]%MOD))%MOD;
    sum %= MOD;
  }

  cout << sum << endl;
}


Measured memory_bytes: 2688
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    println!(
        "{}",
        (1..n + 1)
            .map(|i| i * i)
            .take_while(|&i| i <= n)
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  string a = "abcdefghijklmnopqrstuvwxyz";
  
  string ans;
  
  
  while(N > 0) {
    N--;
    ans += a[N%26];
    N /= 26;
  }
  
  reverse(all(ans));
  cout << ans << endl;
  

}

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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

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

	int n, k;
	set<int> d;
	vi num;
	cin >> n >> k;
	for(int i=0; i<k; i++) {
		int temp;
		cin >> temp;
		d.insert(temp);
	}
	while(n) {
		num.push_back(n%10);
		n/=10;
	}
	reverse(num.begin(), num.end());
	vi sol;
	bool in = false;
	for(int i = 0; i < num.size(); i++) {
		int a = (in ? 0 : num[i]);
		while(d.find(a) != d.end()) {
			a++;
			in = true;
		}
		
		if(a <= 9) sol.push_back(a);
		else {
			a = 1;
			while(d.find(a) != d.end()) a++;
			cout << a;
			int b = 0;
			while(d.find(b) != d.end()) b++;
			for(int j = 0; j < num.size(); j++) cout << b;
			cout << endl;
			return 0;
		}
	}
	for(int a : sol) cout << a;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
//#pragma GCC optimize("Ofast")
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 fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    ll ans = 0, last = 0;
    rep(i,N){
        cin>>A;
        ans += max(0LL, last - A);
        last = max(last, A);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


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

#define MOD (1000 * 1000 * 1000 + 7)
typedef long long ll;
typedef long double ld;

int main() {
	
	int n = 3;
	
	vector<int> abc(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &abc[i]);
		
	sort(abc.begin(), abc.end());
	
	if(abc[0] == 5 && abc[1] == 5 && abc[2] == 7)
		printf("YES\n");
	else
		printf("NO\n");
	
	
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOutput(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	n, q := iScan(), iScan()
	b := newBIT(n)
	a := iSScan(n)
	for i, v := range a {
		b.add(i, v)
	}
	for i := 0; i < q; i++ {
		t, l, r := iScan(), iScan(), iScan()
		if t == 0 {
			b.add(l, r)
		} else {
			fmt.Println(b.rangeSum(l, r-1))
		}
	}
}

type BIT struct {
	v []int
}

func newBIT(n int) *BIT {
	b := new(BIT)
	b.v = make([]int, n)
	return b
}
func (b BIT) sum(a int) int {
	ret := 0
	for i := a + 1; i > 0; i -= i & -i {
		ret += b.v[i-1]
	}
	return ret
}
func (b BIT) rangeSum(x, y int) int {
	if x == 0 {
		return b.sum(y)
	} else {
		return b.sum(y) - b.sum(x-1)
	}
}
func (b BIT) add(a, w int) {
	n := len(b.v)
	for i := a + 1; i <= n; i += i & -i {
		b.v[i-1] += w
	}
}


Measured memory_bytes: 20920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	cin>>s;
	int N=s.size();
	int x=0;
	int ans=N;
	rep(i,N){
		if(s[i]=='S') x++;
		else{
			if(x>0) ans-=2;
			x--;
			if(x==-1) x=0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


map<ll, int> primeFactors(ll n) {
    map<ll, int> ret;
    for(ll i=2; i*i <= n; i++) {
        while(n%i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n!=1) ret[n] = 1;
    return ret;
}

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

    ll N;
    cin >> N;
    map<ll, int> primes = primeFactors(N);

    ll ret = 0;
    for(auto p=primes.begin(); p!=primes.end(); p++){
        ll n = p->second;
        for(ll i=1; i < INF; i++){
            n -= i;
            if(n>=0) ret++;
            else break;
        }
    }
    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main() {
    int x, y;   cin >> x >> y;

    for (int i = 0; i <= x; i++) {
        if (2*i + 4 * (x-i) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N , M ;
    cin >> N >> M ;
    
    string A, B ;
    cin >> A >> B ;
    
    if( N < M){
        swap(N, M);
        swap(A, B);
    }

    bool flag = true;
    ll n = N / gcd(N, M);
    ll m = M / gcd(N, M);
    
    rep(i, M/m){
        if(A[i * n] != B[i * m]){
            flag = false;
            break;
        }
    }
    
    if(flag)cout << lcm(N, M ) << endl;
    else cout << -1 << endl;

    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
//#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<sstream>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
#define PA pair<int,int>
#define asd signed QP;scanf("%d",&QP);while(QP--)
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;}
int lowbit(int x){return x&-x;}
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
//
const double eps=1e-6;
const int mod=1e9+7;
const int modd=mod-1;
//
const int maxm=3e6+5;
int a[maxm];
void solve(){
    const double pi=acos(-1);
    int r=re;
    cout<<r*pi*2;
}
signed main(){
//    while(1)
        solve();
    return 0;
}
/*

*/


Measured memory_bytes: 3792
#include <stack>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    string c;
    vector<string> inst;
    while (cin >> c)
        inst.push_back(c);

    stack<ll> nums;
    for (auto p : inst)
    { 
        //cout << "check=" << p << endl;
        if (p == "*" || p == "+" || p == "-") 
        {
            ll reg1 = nums.top(); nums.pop();
            ll reg2 = nums.top(); nums.pop();
            if (p == "*")
            {
                //cout << reg2 << p << reg1 << endl; 
                nums.push(reg2 * reg1);
            }
            else if (p == "+")
            {
                nums.push(reg2 + reg1);
                //cout << reg2 << p << reg1 << endl; 
            }
            else if (p == "-")
            {
                nums.push(reg2 - reg1);
                //cout << reg2 << p << reg1 << endl; 
            }
        }
        else
            nums.push(atoi(p.c_str())); 
    }

    cout << nums.top() << endl;
    nums.pop();

    return 0;
}



Measured memory_bytes: 3208
#include <iostream>

using namespace std;

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

	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R >= 1200 && R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

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

typedef long long lli;

const lli M = 60;
const lli S = 60;
lli H, h, m, s;

/*
  (?§???????degree)
  ?§?????§???? = 6s
  ???????§???? = 1/10 * (60m + s)
  ???????§???? = 1/(10H) * (3600h + 60m + s)

  ???????§???? - ?§?????§???? == ?§?????§???? - ???????§???? ?????????
  s = (3600h + (1+H)60m) / (119H - 1)
  ?????£???????????????119H-1 ??

  ?????°???????????????????????¢????????????????????§???????????§???????????????????????????????????£??¨?????????????????£???????°?????????????
 */

bool is_same_deg(const lli &sa, const lli &sb){
  // s??§??????sa????????§????????????sb??????????????????
  // ?????°?????????????????????10*H??????????????????
  lli h_s = 3600*h*sb + 60*m*sb + sa - 60*H*sa; 
  lli s_m = 60*H*sa - 60*H*m*sb - H*sa;

  // ?§??????\?????????????????????????§?????????????
  for(lli i=0;i<=1;i++){
    for(lli j=0;j<=1;j++){
      if (h_s + 360*10*H*sb*i == s_m + 360*10*H*sb*j) return true;
    }
  }
  return false;
}

bool is_overlap(const lli &sa, const lli &sb){
  lli h_deg_mul10h = 3600*h*sb + 60*m*sb + sa;
  lli s_deg = 6*sa;
  lli m_deg_mul10 = 60*m*sb + sa;
  return (s_deg*10*H == h_deg_mul10h || s_deg*10 == m_deg_mul10);
}

void solve(){
  lli sa, sb = 119 * H - 1;
  sa = s * sb;
  // 1 / (119H-1) ?§??????????????????¨??¢?´¢
  for(int i=0;i<=H*M*S*sb;i++){
    if(is_same_deg(sa, sb) && !is_overlap(sa, sb)){
      lli g = __gcd(sa, sb);
      cout << h << ' ' << m << ' ' << sa/g << ' ' << sb/g << endl;
      return;
    }
    
    // failed
    sa++;
    if(sa >= S * sb){
      sa -= S * sb;
      m++;
      if(m >= M){
        m -= M;
        h++;
        if(h >= H){
          h = m = sa = 0;
        }
      }
    }
  }

  cout << -1 << endl;
}

int main(){
  while(cin >> H >> h >> m >> s && (H|h|m|s)) solve();
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(void) {
  int turn, one = 0, two = 0;
  string char1, char2;
  cin >> turn;
  for(int i = 0; i < turn; i++) {
    cin >> char1 >> char2;
    if(char1 > char2) one += 3;
    else if (char2 > char1) two += 3;
    else { one++; two++; }
  }
  cout << one << ' ' << two << endl;
  return 0;
}



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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		map<int,int> f;
		rep(i,n) f[a[i]]++;
		int res=0;
		for(auto i=rbegin(f);i!=rend(f);i++){
			int x,c; tie(x,c)=*i;
			int y=(1<<32-__builtin_clz(x))-x;
			if(c==0||!f.count(y))
				continue;
			if(x==y){
				i->second%=2;
				res+=c/2;
			}
			else{
				int e=min(c,f[y]);
				i->second-=e;
				f[y]-=e;
				res+=e;
			}
		}
		cout<<res<<endl;
	}
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A > B) {
    cout << B << endl;
  }
  else if (N * A < B) {
    cout << N * A << endl;
  }
  else if (N * A == B) {
    cout << B << endl;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define rloopl(i,a,b)           for(ll i=(ll)a;i<=(ll)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
// #define max(x,y)                (x>y)?x:y
// #define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                    *min_element(a.begin(), a.end())
#define maxa(a)                    *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>             mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>              pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>              vi;
typedef  vector<string>          vs;
typedef  vector<char>             vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

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

    ll n,W;
    cin>>n>>W;
    vector<ll> v(n+1);
    std::vector<ll> w(n+1);
    // int dp[n+5];
    loopl(i,0,n)
    {
        cin>>w[i]>>v[i];
    }    
    ll dp[n+1][W+1];
    rloopl(i,0,n)
    {
        rloopl(j,0,W)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(w[i-1]<=j)
                dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
            else 
                dp[i][j] = dp[i-1][j];
        }
    }


    cout<<dp[n][W]<<endl;


    return 0;
}

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





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

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


    cin>>a>>b;
    if(b%2==0)
    {

        if((a*4)<b || (a*2)>b)
        {
            cout<<"No\n";
            return 0;
        }

        cout<<"Yes\n";

    }
    else
        cout<<"No\n";


    return 0;


}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
using namespace std;

struct _point
{
    int x;
    int y;
    int t;
}p[100010];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&p[i].t,&p[i].x,&p[i].y);
    }
    int ret=1;
    p[0].x=0;
    p[0].y=0;
    p[0].t=0;
    for(int i=1;i<=n;i++)
    {
        int len=abs(p[i].x-p[i-1].x)+abs(p[i].y-p[i-1].y);
        int now=p[i].t-p[i-1].t;
        int x=now-len;
        if(x<0||x%2!=0)
        {
            ret=0;
            break;
        }
    }

    if(ret)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long int
#define MOD1		1000000007
#define MOD2		998244353
#define BOOST		ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

ll n, ans;
set<ll> divisors;
void compute(ll i)
{
    ll temp = n;
    if(i == 1)
        return;
    while((temp % i) == 0)
        temp /= i;
    if(temp % i == 1)
        ans++;
}

void solve()
{
   cin >> n;    
    for(ll i = 1; i * i <= n; ++i)
    {
        if(n % i == 0)
        {
            compute(i);
            divisors.insert(i);
            if(i * i != n)
            {
                compute(n / i);
                divisors.insert(n / i);
            }
        }
    }
   n--;
   for(ll i = 1; i * i <= n; ++i)
   {
        if(n % i == 0)
        {
            if(divisors.find(i) == divisors.end())
                ++ans;
            if(i * i != n)
            {
                if(divisors.find(n/i) == divisors.end())
                    ++ans;
            }
        }
   }
   cout << ans << "\n";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}
template<class tt> struct counter {
	map<tt, int>mp;
	bool add(tt t, int xx) {
		if (!mp.count(t)) {
			mp[t] = xx;
			return true;
		}
		mp[t] += xx;
		if (!mp[t]) {
			mp.erase(t);
		}
		return false;
	}
};

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a=0,t=0,ans=INF;
	string s;
	cin >> n >> s;
	vector<int>vec(s.size() + 1);
	rep(i, s.size()) {
		if (s[i] == 'R') {
			a++;
			t++;
			vec[i + 1] = t;
		}
	}
	rep(i, a + 1) {
		chmin(ans, (a - i) + (i-vec[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 5180
//gcc -std=gnu11 -O2 -o a.out Main.c -lm

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	
	int n, i, j;
	int a[100];
	int ret;
	int min, max;
	int ans, minAns;
	
	ret = scanf("%d", &n);
	for(i = 0 ; i < n ; i++){
		ret = scanf("%d", &a[i]);
		if(i == 0){
			min = a[i];
			max = a[i];
		} else {
			if(min > a[i]) min = a[i];
			if(max < a[i]) max = a[i];
		}
	}
	
	minAns = 0x7fffffff;
	for(j = min ; j <= max ; j++){
		ans = 0;
//		printf("%d ", j);
		for(i = 0 ; i < n ; i++){
			ans += ((a[i] - j) * (a[i] - j));
//			printf("%d ", ans);
		}
//		printf("%d ", ans);
		if(minAns > ans){
			minAns = ans;
//			printf("%d ", ans);
		}
//		printf("\n");
	}
	
	printf("%d\n", minAns);
	
	return 0;
}


Measured memory_bytes: 128
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();

    string s;
    cin>>s;
    ll N=s.size();
    vector<ll>ans(N+1,0);
    for (int i = 0; i < N; i++)
    {
        if(s[i]=='<'&&!(ans[i+1]>ans[i]))ans[i+1]=ans[i]+1;
    }
    for (int i = N-1; i >= 0; i--)
    {
        if(s[i]=='>'&&!(ans[i]>ans[i+1]))ans[i]=ans[i+1]+1;
    }
    for (int i = 0; i < N; i++)
    {
        if(s[i]=='<'&&!(ans[i+1]>ans[i]))ans[i+1]=ans[i]+1;
    }
    for (int i = N-1; i >= 0; i--)
    {
        if(s[i]=='>'&&!(ans[i]>ans[i+1]))ans[i]=ans[i+1]+1;
    }
    ll num=0;
    for(auto&& i:ans){
        num+=i;
        ///cout<<i;
    }
    //cout<<endl;
    cout<<num<<endl;

    
}

Measured memory_bytes: 4764
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        int w = 0;
        for (int i = 0; i < H; i++) {
        	char[] map = sc.next().toCharArray();
        	for (int j = 0; j < W; j++) {
        		if (map[j] == '#' && w <= j) {
        			w = j;
        		} else if (map[j] == '#' && w > j) {
        			System.out.println("Impossible");
        			return;
        		}
        	}
        }
        
        System.out.println("Possible");
    }
}

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

long read_long() {
	long ret=0;char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret;
}

const long MAXN=200100;
int expect,prefix[MAXN],ans;
long n,k;

int main() {
	n=read_long();k=read_long();
	register long i;
	long p;
	for(i=1;i<=n;++i) {
		p=read_long();
		expect=p+1;
		prefix[i]=prefix[i-1]+expect;
	}

	for(i=k;i<=n;++i)
		ans=max(ans,prefix[i]-prefix[i-k]);
	printf("%lf",ans*0.5);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int c=1;c<=n-1;c++){
        int x = n-c;
        int cnt = 0;
        for(int a=1;a<=sqrt(x);a++){
            if(x%a==0) cnt++;
            if(a==sqrt(x) && x%a==0) ans--;
        }
        ans += cnt*2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3672
N = int(input())
s = [input() for _ in range(N)]

M = int(input())
t = [input() for _ in range(M)]

sdict = {k:s.count(k) for k in set(s)}
tdict = {k:t.count(k) for k in set(t)}

stkeys = set( list(sdict.keys()) + list(tdict.keys()) )

maxV = 0
for st in stkeys:
    sv = sdict[st] if st in sdict else 0
    tv = tdict[st] if st in tdict else 0
    maxV = max(maxV, sv-tv)

print(maxV)

Measured memory_bytes: 3064
# include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double n,val,t,ans=9999999,i,num,item;
    cin>>n;
    cin>>t>>val;
    vector<double>a;
    for(i=0;i<n;i++){cin>>item;a.push_back(item);};
    if(n==1)cout<<"1";
    else{
      vector<double>b(n);
    for(i=0;i<n;i++){b[i]=t-a[i]*0.006;}
   for(i=0;i<n;i++){b[i]=abs(val-b[i]);}
    for(i=0;i<n;i++){if(b[i]<ans){ans=b[i];num=i;}}
    cout<<num+1;}
    
    return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N, a[200001], ans[200001];
  int num = 0;
  cin >> N;
  for (int i=1; i<=N; i++) {
    cin >> a[i];
  }
  for (int i=N; i>0; i--) {
    int c=0;
    for (int j=i+i; j<=N; j+=i) {
      if (ans[j]) c++;
    }
    if (a[i]) {
      ans[i] = c%2 ? 0 : 1;
      num += ans[i];
    } else {
      ans[i] = c%2 ? 1 : 0;
      num += ans[i];
    }
  }

  cout << num << endl;
  for (int i=1; i<=N; i++) {
    if (ans[i]) cout << i << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <array>

using namespace std;

typedef long long ll;

int main(int argc, const char * argv[]) {
    int A, B;
    cin >> A >> B;
    
    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String args[]) {
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			int sum = 0;
			for(int i = 0; i < n; i++) {
				a *= 10;
				sum += (a / b) % 10;
				a %= b;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String strings = sc.next();
        int count = 0;
        for(char string: strings.toCharArray()) {
            if (string == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v[i].first = a;
        v[i].second = i + 1;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        cout << v[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664