akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
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 modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


int main(void){
	long long int s,max_l,i,ans=0,t;
	cin >> s;
	COMinit();
	max_l = int(s/3);
	for (i=max_l;i>0;i--){
		t = s-(i*3);
		//ans += modpow(i,t);
//cout << COM(t+i-1,t) << '\n';
		if (t == 0) {
			ans++;
		}
		else {
			ans += COM(t+i-1,t);
		}
		ans %= MOD;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
/*575専用スペース A place only for 575*/
/*人人人人人人人人人人*/
using namespace std;
/*Y^Y^Y^Y^Y^Y^Y^Y^Y*/
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;

ll par[300000], depth[300000];

void init(ll n) {
  REP(i, n) {
    par[i] = i;
    depth[i] = 0;
  }
  return;
}

ll find(ll x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void merge(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return;
  }
  if (depth[x] > depth[y]) {
    par[y] = x;
  } else {
    par[x] = y;
    if (depth[x] == depth[y]) {
      depth[y]++;
    }
  }
}

bool same(ll x, ll y) {
  if (find(x) != find(y)) {
    return false;
  }
  return true;
}
//親を知りたいときは必ずfind()を使う！

map<ll, set<ll>> group;
set<ll> parent;
int main() {
  ll n, m;
  vector<ll> p;
  cin >> n >> m;
  init(n+1);
  REP(i, n) {
    ll h;
    cin >> h;
    h--;
    p.pb(h);
  }
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    merge(a, b);
  }
  REP(i, n) {
    parent.insert(find(i));
    group[find(i)].insert(i);
  }
  
  ll ans = 0;
  for (auto parentNum : parent) {
    //sort(group[parentNum].begin(), group[parentNum].end());
    for (auto groupUnique : group[parentNum]) {
	  if (group[parentNum].count(p[groupUnique])) ++ans;
	  /*
      if (*lb(group[parentNum], p[groupUnique]) == p[groupUnique]) {
        ans++;
        // cout << p[k - 1] << endl;
      }
	  */
    }
  }
  cout << ans << endl;
}
/*
p[i]個目
groupかつi+1




*/


Measured memory_bytes: 22644
a, b, m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li = [list(map(int,input().split())) for i in range(m)]
kouho = [min(a)+min(b)]

for l in li:
    kouho.append(a[l[0]-1] + b[l[1]-1] -l[2])

print(min(kouho))

Measured memory_bytes: 42412
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
  ll n; cin>>n;
  ll a[n]={};
  ll b[n]={};
  rep(i,n) cin>>a[i];
  ll k = 0;
  ll m = 0;
  vl c(n,1);
  for(ll i=0; i<n; i++){
    if(a[i]!=0){
      b[k]=a[i];
      k++;
      continue;}
    else{
      ll ca = 0;
      while(1){
    if(a[i]!=0)break;
        ca++;
        i++;}
      i--;
      b[k]=0;
      c[k]=ca;
      k++;
    }
  }
  ll ans = 0;
  ll f = 0;
  ll cb = 0;
  for(ll i=0; i<k; i++){
    m = b[i];
    f = 0;
    cb = c[i];
    if(m==0) f++;
    for(ll j=i+1; j<k; j++){
      ll q = b[j];
      ll w = q^m;
      if(w!=q+m) break;
      m = w;
      cb += c[j];
    }
    //cout << cb << endl;
    if(f==1){
      if(i==k-1){
        ans += cb*(cb+1)/2;}
      else{
      ans += (cb-c[i]+1+cb)*(c[i])/2;}
    }
    else ans += cb;
    //cout << ans << endl;
  }
  //rep(i,k) cout << b[i] << " " << c[i] << endl;
  cout << ans << endl;}
    


Measured memory_bytes: 8012
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  int ans=753;
  for(int i=0;i<S.size()-2;i++){
    string sub_S=S.substr(i,3);
    int num=atoi(sub_S.c_str());
    ans=min(ans,abs(753-num));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d;
  vector<int>c(26);
  cin >> d;
  vector<vector<int>>s(d,vector<int>(26));
  
  for(int i=0;i<26;i++) cin >> c.at(i);
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++) cin >> s.at(i).at(j);
  }
  
  
  
  for(int i=0;i<d;i++) cout << ((i%26)+1) << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;


int main() {
	int a,b,h;
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

int N, M, ans=0;
vector<pii> edge[100005];
bool visited[100005];
bool used[100005];
int dfs(int n, int b, int S, int T){
	if(n == T) return 1;
	if(n == S && b != -1) return 0;
	int ret = 0;
	for(auto p: edge[n]) if(p.X != b){
		ret += dfs(p.X, n, S, T);
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);

	cin >> N >> M;
	rep(i,M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].emplace_back(b, i);
		edge[b].emplace_back(a, i);
	}

	bool f = true;
	rep(i,N) if(edge[i].size() % 2 != 0){
		cout << "No" << endl;
		return 0;
	}

	rep(i,N) if(edge[i].size() >= 6){
		cout << "Yes" << endl;
		return 0;
	}

	vector<int> four;
	rep(i,N) if(edge[i].size() == 4) four.push_back(i);

	if(four.size() < 2){
		f = false;
	}else if(four.size() == 2){
		int ret = dfs(four[0], -1, four[0], four[1]);
		if(ret == 4) f = false;
	}

	cout << (f ? "Yes" : "No") << endl;

	return 0;
}

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

#define pi 3.1415926536
#define mod 1000000007
#define lli long long int
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repn(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define loop(i, a, b) for(int i = a ; i < b ; i++)
#define mod1 1000003
#define hello "hello"

using namespace std;

//fixed<<setprecision(9);

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}



int main()
{
	int n;

	cin>>n;

	bool flag = false;

	loop(i, 2, 10)
	{
		if(n%i == 0 && n/i <= 9)
		{
			flag = true;
			break;
		}
	}

	if(flag || n == 1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int ret = (n*(n-1)+m*(m-1))/2;
  cout << ret;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(snip_i, n+1) cin >> a.at(snip_i);
  ll sum = 0;
  rep(i, n){
    // rep(j, n+1){
    //   cerr << a.at(j) << " ";
    // }
    // cerr << endl;
    int b;
    cin >> b;
    if(a.at(i) <= b){
      sum += a.at(i);
      b -= a.at(i);
      a.at(i) = 0;
    }else{
      sum += b;
      a.at(i) = a.at(i) - b;
      b = 0;
      continue;
    }
    if(a.at(i+1) <= b){
      sum += a.at(i+1);
      b -= a.at(i+1);
      a.at(i+1) = 0;
    }else{
      sum += b;
      a.at(i+1) = a.at(i+1) - b;
      b = 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[200001];
    ll s[200001] {0};
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    s[0] = a[0];
    for(int i = 0; i < n - 1; i++){
        s[i + 1] = s[i] + a[i + 1];
    }
    ll all = s[n - 1];
    sort(s, s + n - 1);
    for(int i = 0; i < n; i++){
    }
    int mid = lower_bound(s, s + n - 1, all / 2) - s;
    if(mid == n - 1){
        cout << abs(s[n - 2] - (all - s[n - 2])) << endl;
    }
    else if(mid == 0){
        cout << abs(s[0] - (all - s[0])) << endl;
    }   
    else{
        cout << min(abs(s[mid] - (all - s[mid])), abs(s[mid - 1] - (all - s[mid - 1]))) << endl;
    }
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            if (k == 1)
            {
                WriteLine(0);
                return;
            }
            WriteLine(n-k);

        }


    }
}


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

int sum[6000][6000];
int X[6000], Y[6000];
int X1[600000], X2[600000], Y1[600000], Y2[600000];
int n, m;

int compress(int*x, int*X1, int*X2) {
	vector<int>v;
	rep(i, n)v.push_back(x[i]);
	sort(v.begin(), v.end());
	auto it = unique(v.begin(), v.end());
	rep(i, m) {
		X1[i] = lower_bound(v.begin(), it, X1[i]) - v.begin();
		X2[i] = upper_bound(v.begin(), it, X2[i]) - v.begin() - 1;
	}
	rep(i, n) {
		x[i] = lower_bound(v.begin(), it, x[i]) - v.begin();
	}
	return (int)v.size();
}
int main() {
	scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d%d", &X[i], &Y[i]);
	rep(i, m)scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
	int h = compress(X, X1, X2), w = compress(Y, Y1, Y2);
	rep(i, n)sum[X[i]][Y[i]]++;
	rep(i, h + 1)for (int j = 1; j <= w; j++) {
		sum[i][j] += sum[i][j - 1];
	}
	for (int i = 1; i <= h; i++)rep(j, w + 1) {
		sum[i][j] += sum[i - 1][j];
	}
	rep(i, m) {
		if (X2[i] < 0 || Y2[i] < 0) {
			puts("0"); continue;
		}
		int ans = sum[X2[i]][Y2[i]];
		if (X1[i] > 0)ans -= sum[X1[i] - 1][Y2[i]];
		if (Y1[i] > 0)ans -= sum[X2[i]][Y1[i] - 1];
		if (X1[i] > 0 && Y1[i] > 0)ans += sum[X1[i] - 1][Y1[i] - 1];
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128424
#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;

double dp[301][301][301];

double sushi(int x, int y, int z, int &n) {
    // Base Case
    if((x < 0) || (y < 0) || (z < 0)) return 0;
    if((x == 0) && (y == 0) && (z == 0)) return 0;
    // Recursive Case
    if(dp[x][y][z] > -0.9) return dp[x][y][z]; // Look Up
    double exp = (n + (x * sushi((x - 1), y, z, n)) + (y * sushi((x + 1), (y - 1), z, n)) + (z * sushi(x, (y + 1), (z - 1), n)));
    return (dp[x][y][z] = (exp / double (x + y + z)));
}

int main() {
    int n, x;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    int one = 0, two = 0, three = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        if(x == 1) one++;
        else if(x == 2) two++;
        else three++;
    }
    cout << fixed << setprecision(8) << sushi(one, two , three, n);
    return 0;
}

Measured memory_bytes: 216880
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> hs(n);
  for (auto &v : hs)
    cin >> v;
  vector<int> vec(n, 1);

  int a, b;
  while (cin >> a >> b) {
    if (hs[a-1] <= hs[b-1])
      vec[a-1] = 0;
    if (hs[b-1] <= hs[a-1])
      vec[b-1] = 0;
  }
  cout << accumulate(vec.begin(), vec.end(), 0) << endl;
}

Measured memory_bytes: 4056
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
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; }

int main()
{
	cout << fixed << setprecision(18);

	ll a, b, c, k;
	ll ans = 0;

	cin >> a >> b >> c >> k;
	
	if (a <= k) 
		ans += a;
	else 
		ans += k;
	k -= a;

	k -= b;

	if (k > 0)
		ans -= k;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  int n, r; cin >> n >> r;
  cout << (n>=10 ? r : r+100*(10-n)) << endl;
  return 0;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

bool f(string s) {
  bool b = true;
  rep(i ,s.size()) {
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C');
    else b = false;
  }
  return b;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int tmp = 0;
    for(int j = 1; j <= n -i ; j++) {
      string ns = s.substr(i, j);
      if(f(ns)) {
        tmp = ns.size();
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    //llで入力
    ll a,intb;cin>>a;
    
    //doubleで入力
    double b;cin>>b;

    //bを整数として処理する
    b+=0.005;
    b*=100;
    intb=(ll)(b);

    cout<<(a*intb)/100<<endl;
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for (int i=0; i<s.size(); i++) {
		if(i%2) {
			if(s[i]=='R') {
				cout<<"No\n";
				return 0;
			}
		} else {
			if(s[i]=='L') {
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();

		if (S.equals(T.substring(0,S.length()))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		

	}

}

Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&-x
	int n,m;
struct fenwick
{
	int c[1000001];
	void add(int x,int ind)
	{
		while(x<=n)
			c[x]+=ind,x+=lowbit(x);
		return;
	}
	int ask(int x)
	{
		int ans=0;
		while(x)
			ans+=c[x],x-=lowbit(x);
		return ans;
	}
}f[27];
char s[1000001];
signed main() 
{
	scanf("%d",&n);
	cin>>s+1;
	cin>>m;
	for(int i=1;i<=n;i++)
		f[s[i]-'a'].add(i,1);
	for(int i=1;i<=m;i++)
	{
		int op,l,r;
		scanf("%d",&op);
		if(op==1)
		{
			char c;
			cin>>l>>c;
			f[s[l]-'a'].add(l,-1);
			s[l]=c;
			f[s[l]-'a'].add(l,1);
		}
		else
		{
			int ans=0;
			scanf("%d%d",&l,&r);
			for(int j=0;j<26;j++)
				if(f[j].ask(r)-f[j].ask(l-1))
					ans++;
			printf("%d\n",ans);
		}
	}
	return 0;
}
/*
5
1 2 4 9 10
4
1 2
1 3
1 4
1 5
*/

Measured memory_bytes: 102272
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

        int n = Integer.parseInt(sc.next());
        List<Long> list = new ArrayList<>();
        for(int i=0; i<n; i++){
            list.add(Long.parseLong(sc.next()));
        }
        Collections.sort(list, Collections.reverseOrder());
        long total = list.get(0);
        for(int i=2; i<n; i++){
            total += list.get(i/2);
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 65296
# coding; utf-8
def main():
    N = int(input())
    rest = []
    for i in range(N):
        si, tempP = input().split()
        pi = int(tempP)
        rest.append([i+1, si, pi])

    rest.sort(key=lambda x: (x[1], -x[2]))
    # print(rest)
    for r in rest:
        print(r[0])


if __name__ == "__main__":
    main()


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

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int MAX_M = 2001;
const int MAX_S = 3001;
int dp1[MAX_M][MAX_S];
int dp2[MAX_M][MAX_S];

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

    map<char, int> mp;
    mp['J'] = 0;
    mp['O'] = 1;
    mp['I'] = 2;

    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> a(N);
    rep(i, N) {
        a[i] = mp[s[i]];
    }

    const int mod = 10007;
    VV dp(N, V(1<<3, 0));
    rep(s, 1<<3) {
        // at first J has the key
        if ( !((s >> a[0]) & 1) || !(s & 1) ) continue;
        dp[0][s] = 1;
    }
    rep(i, N - 1) {
        rep(s1, 1<<3) {
            if ( !((s1 >> a[i]) & 1) ) continue;
            rep(s2, 1<<3) {
                if ( !((s2 >> a[i + 1]) & 1) ) continue;
                if ( !(s1 & s2) ) continue;
                (dp[i + 1][s2] += dp[i][s1]) %= mod;
            }
        }
    }

    cout << accumulate(all(dp[N - 1]), 0) % mod << endl;

}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){
	int a, b, c, d; cin>>a>>b>>c>>d;
	cout<<(a + b > c + d ? "Left" : a + b == c + d ? "Balanced" : "Right")<<endl;
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vint a(n);vin(a);
  vint ans(n,0);int sum=0;
  for(int i=n-1;i>=0;--i){
    int ansi=0;
    for(int j=(i+1)*2-1;j<n;j+=i+1) ansi+=ans[j];
    if(ansi%2 != a[i]%2){
      ans[i]=1;sum++;
    }
  }
//  rep(i,n)cout << ans[i] <<endl;

  cout << sum << endl;
  rep(i,n) if(ans[i]==1) cout << i+1 << " ";
  cout << endl;
}


Measured memory_bytes: 2432
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
import threading
sys.setrecursionlimit(10**5)
threading.stack_size(10**8)
def dfs(x):
    global l,adj,v
    if v[x]==1:
        return(l[x])
    v[x]=1
    c=0
    for i in adj[x]:
        c=max(c,dfs(i)+1)
    l[x]=c
    return c
def main():
    global l,adj,v
    n,m=map(int,input().split())
    l=[0]*(n+1)
    v=[0]*(n+1)
    adj=[]
    for i in range(n+1):
        adj.append([])
    for i in range(m):
        x,y=map(int,input().split())
        adj[x].append(y)
    ans=0
    for i in range(1,n+1):
        if not v[i]:
            ans=max(ans,dfs(i))
    print(ans)
t=threading.Thread(target=main)
t.start()
t.join()
        
        


Measured memory_bytes: 62420
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[109][109],pas;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(c=1; c<=a; c++){
        for(d=1; d<=b; d++) cin>>f[c][d];
    }
    for(c=1; c<=a; c++){
        for(d=c+1; d<=a; d++){
            long long jm=0;
            for(e=1; e<=b; e++){
                jm=jm+abs(f[c][e]-f[d][e])*abs(f[c][e]-f[d][e]);
            }
            e=sqrt(jm);
            if(e*e==jm) pas++;
        }
    }
    cout<<pas;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;

        for(int x=0; x<k+1; x++){
            for(int y=0; y<k+1; y++){
                if(s-x-y<k+1 && s-x-y>=0){
                    count++;
                }

            }
        }


        System.out.println(count);


    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pc __builtin_popcountll

using namespace std;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int white_count = 0;
    for(int i= 0; i < n; ++i){
        if(s[i] == 'W'){
            white_count++;
        }
    }

    // No whites
    if(white_count == 0){
        cout << 0;
        return 0;
    }

    int red_count = 0;
    for(int i = n - white_count; i < n; ++i){
        if(s[i] == 'R'){
            ++red_count;
        }
    }

    cout << red_count << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int x, A, B; cin >> x >> A >> B;

    if (abs(A - x) < abs(B - x)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int N,A,B;
ll v[NMAX+1];
ll cunt;

//C[n][k]->nCk
ll C[NMAX+2][NMAX+2];
void comb_table(int N){
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j==0 or j==i){
                C[i][j]=1ll;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}

double sum=0.0;
void solve(){
    //一段目の解答

    for(int i=0;i<A;i++) sum+=(double)v[i];
    

    
    //二段目の解答
    int kk1=0,kk2=0;
    for(int i=0;i<N;i++){
        if(v[i]==v[A-1]){
            kk2++; //全体でv[A-1]と同じ個数
            if(i<A) kk1++; //v[0]~v[A-1] でv[A-1]と同じ個数
        }
    }
    
    comb_table(N);
    if(kk1==A){ //v[0]~v[A-1]まで全て同じ
        for(kk1=A;kk1<=B;kk1++)
            cunt+=C[kk2][kk1];
    }else cunt=C[kk2][kk1];
    

    
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>N>>A>>B;
    for(int i=0;i<N;i++) cin>>v[i];
    
    sort(v,v+N,greater<ll>());

    solve();
    
    cout.precision(20);
    cout<<fixed<<sum/A<<"\n";
    cout<<cunt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
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;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


int main()
{
    int n;
    cin >> n;
    vii a(n,0);
    rep(i, n) cin >> a[i];
    vii ans(n,0);
    repr(i,n-1,-1){
        ans[i] = a[i];
        if (a[i]==1){
            int d = 1;
            while (d*d<=(i+1)){
                if (d*d==i+1){
                    a[d-1] = (a[d-1] + 1) % 2;
                }
                else if ((i+1)%d==0){
                    a[d-1] = (a[d-1] + 1) % 2;
                    a[(i + 1) / d-1] = (a[(i + 1) / d-1] + 1) % 2;
                }
                d++;
            }
        }

    }
    int cnt = 0;
    vii res;
    rep(i, n)
    {
        if (ans[i] == 1)
        {
            cnt++;
            res.push_back(i + 1);
        }
    }
    cout << cnt << endl;
    if (cnt > 0)
    {
        rep(i, cnt) cout << res[i] << " ";
        cout << endl;
    }
}


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

using namespace std;

int N, A, B, C;
int l[10];

int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        if (a == 0 | b == 0 | c == 0) {
            return 100000000;
        } else {
            return abs(A - a) + abs(B - b) + abs(C - c) - 30;
        }
    }
    int ret = 10000000;
    ret = min(ret, dfs(cur + 1, a + l[cur], b, c) + 10);
    ret = min(ret, dfs(cur + 1, a, b + l[cur], c) + 10);
    ret = min(ret, dfs(cur + 1, a, b, c + l[cur]) + 10);
    ret = min(ret, dfs(cur + 1, a, b, c));

    return ret;
}

int main() {
    cin >> N >> A >> B >> C;

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

    cout << dfs(0, 0, 0, 0) << endl;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll r; cin >> r;
	cout << 3*r*r << endl;
}



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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

template<typename T> inline void in(T &x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9')
{if(ch=='-')fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){
t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

const int N = 105;

int n, a[N], dp[N][2];

int main(){
	in(n);
	fo1(i, 1, n)	in(a[i]);
	mset(dp, 0x7f);
	dp[1][0] = 0, dp[1][1] = 1;
	fo1(i, 2, n){
		if(a[i] != a[i-1]){
			dp[i][0] = min(dp[i-1][0], dp[i-1][1]);
			dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
		}
		else{
			dp[i][0] = dp[i-1][1];
			dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
		}
	}
	outln(min(dp[n][1], dp[n][0]));
	return 0;
}

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

int main(){
    int N, sum=0, m=0;
    cin >> N;
    for(int i=0; i<N; i++){
        int num;
        cin >> num;
        sum += num;
        m = max(m, num);
    }
    int ans = sum - m/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,a,n) for(int i=n;i>a;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define fs first
#define sc second

#define MOD 1000000007
#define INF 1LL<<55

#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)

using namespace std;

using ll = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<ll,ll>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<ll>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

// please declaration dx[8], dy[8]
#define DX {-1,0,1,0,-1,-1,1,1}
#define DY {0,-1,0,1,-1,1,1,-1}
#define DX2 {-1,0,1,0}
#define DY2 {0,-1,0,1}

signed main() {
  // A B
  // A odd -> A -1
  // A even -> A
  // after A / 2 + B => B
  ll A, B, K;
  in(A, B, K);

  bool flag = true;
  rep(i, K) {
    if (flag) {
      if (A % 2 != 0) {
        A--;
      }
      B = A / 2 + B;
      A = A / 2;
      flag = false;
    } else {
      if (B % 2 != 0) {
        B--;
      }
      A = B / 2 + A;
      B = B / 2;
      flag = true;
    }
  }
  out(A, B);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
	int u[150][150],p,v[150][150],xg,yg,q,dx[]={1,0,-1,0},dy[]={0,1,0,-1},w,h;
void ret(int x,int y){
	int a,b,i;
	v[y][x]=1;
	if(xg==x&&yg==y)
		p++;
	else
	for(i=0;i<4;i++){
		a=x+dx[i];
		b=y+dy[i];
		if(a<1||a>w||b<1||b>h||v[b][a]==1)
			continue;
		else if(u[b][a]==q)
			ret(a,b);
	}
}
int main(){
	int xs,ys,c,d,x,y,n;
	while(cin>>w>>h,w||h){
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
			v[i][j]=0;
		scanf("%d %d",&xs,&ys);
		scanf("%d %d",&xg,&yg);
		scanf("%d",&n);
		for(int k=0;k<n;k++){
			scanf("%d %d %d %d",&c,&d,&x,&y);
			if(d==0)
				for(int i=0;i<2;i++)
				for(int j=0;j<4;j++)
				u[i+y][j+x]=c;
			else 
				for(int i=0;i<4;i++)
				for(int j=0;j<2;j++)
				u[i+y][j+x]=c;
		}
		q=u[ys][xs];
		p=0;
		ret(xs,ys);
		if(p>0)
			printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    long long A,B;
    cin >> A >> B;
    long long out = 0;
    long long c = 0;
    if(A>B) c = A;
    else c = B;
    out = c;
    while(out<=A*B){
        if(out%A == 0 && out%B == 0){
            break;
        }
        out += c;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()


def unbalanced(st):
    for c in st:
        if st.count(c) > (len(st) // 2):
            return True
    return False


def test_str(st):
    r = (-1, -1)
    for j in range(1, 3):
        for i in range(len(s) - j):
            if unbalanced(s[i:i+j+1]):
                r = (i+1, i+j+1)
                return r
    return r


print(test_str(s)[0], test_str(s)[1])

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

const int maxn = 1e5 + 10;
int a[maxn];
int n;
int cmp(int x, int y) {
    return x > y;
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n, cmp);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            ans += a[i];
        } else {
            ans -= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] l = new int[n + 1];
			int[] r = new int[n + 1];
			for (int i = 0; i < n; i++) {
				l[i] = in.nextInt();
				r[i] = in.nextInt();
			}
			Arrays.sort(l);
			Arrays.sort(r);
			long ans = 0;
			for (int i = 0; i < n + 1; i++) {
				ans += Math.max(0, l[n - i] - r[i]);
			}
			ans *= 2;
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int S(long long c)
{
	int ret=0;
	while(c) ret+=c%10, c/=10;
	return ret;
}

void get_next(long long &c)
{
	for(long long i=1;;i*=10) {
		if(c/i%10==9) continue;
		int diff=9-c/i%10;
		long long n=c+diff*i;
		if(c*S(n)<=n*S(c)) return;
		c=n;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int K;
	long long c=1;
	for(cin>>K;K;K--) {
		cout<<c++<<'\n';
		get_next(c);
	}
	return 0;
}

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

int main(){
  int64_t N, K, a, b, cur = 0;
  cin >> N >> K;
  
  int64_t A[100001]  = {};
  
  for (int i = 0; i < N; i++){
    cin >> a >> b;
    A[a] += b;
  }
  
    
  for (int i = 1; i < 100001; i++){
    cur += A[i];
    if (cur >= K){
      cout << i << endl;
      break;
    }
  }
}

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

char group[101][101];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for (int i = 1; i<=h; i++)
    {
        scanf("%s",group[i]+1);
    }
    for (int i = 0; i<=(h+1); i++)
    {
        for (int j = 0; j<=(w+1); j++)
        {
            printf("%c",group[i][j]?group[i][j]:'#');
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D

int main()
{
    char x;
    cin>>x;
    if(x>='a' && x<='z') cout<<"a"<<endl;
    else cout <<"A"<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll X;
    cin >> X;
    ll a, b;
    for(ll i = -200; i <= 200; ++i) {
        for(ll j = -200; j <= 200; ++j) {
            if((i*i*i*i*i)-(j*j*j*j*j) == X) {
                a = i;
                b = j;
                break;
            }
        }
    }
    cout << a << " " << b;
}


Measured memory_bytes: 3640
#include<algorithm>
#include<cstdio>
#include<cmath>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int e;

int main()
{
  while( scanf( "%d", &e ), e )
  {
    int ans = 1000000;
    
    rep( y, sqrt(e)+1 ) rep( z, cbrt(e)+1 ) if( y*y+z*z*z <= e )
      ans = std::min( ans, (e-y*y-z*z*z)+y+z );

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

  return 0;
}

Measured memory_bytes: 2764
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


N = I()
d = divisors(N, sort=True)
ans = len(str(d[len(d) // 2]))
print(ans)

Measured memory_bytes: 38896
#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,k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.rbegin(),l.rend());
  //rep(i,n) cout << l[i] << endl;
  int ans = 0;
  rep(i,k){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r;
    cin >> r;
    print(r*r);

    

}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
  int sum;
  char c;
  while(1){
    c=0,sum=0;
    while((c=getchar())!='\n'){
      sum+=c-48;
    }
    if(sum!=0)printf("%d\n",sum);
    else break;
  }
  return 0;
}

Measured memory_bytes: 2608
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
min_y = min(y)

flag = True
for i in range(X+1, Y+1):
    if i <= min_y and i > max_x:
        flag = False
        break
    
if flag == True:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064