akhauriyash/Code-Regression huggingface dataset:
#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 pb(x) push_back(x)
#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;
    vvii MAP(n, vii(n));
    rep(i,n){
        string s;
        cin >> s;
        rep(j, n) MAP[i][j] = s[j] - 'a';
    }
    ll ans = 0;
    rep(b,n){
        vvii check(n, vii(n));
        rep(i, n) rep(j, n) check[i][j] = MAP[i][(j + b) % n];
        bool flag=true;
        rep(i,n-1){
            if (!(flag))
                break;
            repf(j,i+1,n){
                if (check[i][j]!=check[j][i]){
                    flag = false;
                    break;
                }
            }
        }
        if (flag)
            ans += n;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1028
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
  int n;
  cin >> n;

  double buff;

  vector<double> a;

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

  double ans = 0;

  for(int i = 0;i < n;i++){
    ans += 1 / a[i];
  }

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


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll X,Y;
int main(){
	cin>>X>>Y;
	int ans=0;
	while(X<=Y){
		ans++;
		X*=(ll)2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp

int main() {
    string s;
    cin >> s;
    rep(i,s.size()){
        cout << "x";
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[200009];
main()
{
    int n,k;
    cin >> n >> k;
    for (int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        f[a]++;
    }
    sort(f,f+n+1);
    int S=0;
    for (int i=0; i<=n-k; i++)
        S+=f[i];
    cout<<S<<endl;

}


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

using namespace std;
typedef long long ll;
#define mp make_pair
const ll INF = 1e17;
typedef pair<ll, ll> pll;

struct Node {
	ll valm;
	ll valp;
	ll add;
	
	Node() {}
};

const ll N = 3e5 + 10;
Node tree[4 * N];

void update_node(ll tv, ll tl, ll tr) {
	if (tr - tl > 1) {
		tree[tv].valm = min(tree[2 * tv + 1].valm, tree[2 * tv + 2].valm);
		tree[tv].valp = min(tree[2 * tv + 1].valp, tree[2 * tv + 2].valp);
	}
}

void build(ll tv, ll tl, ll tr) {
	tree[tv].add = 0;
	if (tr - tl == 1) {
		tree[tv].valm = INF / 2 - tl;
		tree[tv].valp = INF / 2 + tl;
		return;
	}
	ll tm = (tl + tr) / 2;
	build(2 * tv + 1, tl, tm);
	build(2 * tv + 2, tm, tr);
	update_node(tv, tl, tr);
}

void push(ll tv, ll tl, ll tr) {
	tree[tv].valm += tree[tv].add;
	tree[tv].valp += tree[tv].add;
	if (tr - tl > 1) {
		tree[2 * tv + 1].add += tree[tv].add;
		tree[2 * tv + 2].add += tree[tv].add;
	}
	tree[tv].add = 0;
}

void add_num(ll tv, ll tl, ll tr, ll l, ll r, ll val) {
	push(tv, tl, tr);
	if (tr == r && tl == l) {
		tree[tv].add += val;
		push(tv, tl, tr);
		return;
	}
	if (l >= tr || r <= tl)
		return;
	ll tm = (tl + tr) / 2;
	add_num(2 * tv + 1, tl, tm, l, min(r, tm), val);
	add_num(2 * tv + 2, tm, tr, max(l, tm), r, val);
	update_node(tv, tl, tr);	
}

pll get_min(ll tv, ll tl, ll tr, ll l, ll r) {
	push(tv, tl, tr);
	if (tr == r && tl == l) {
		return pll(tree[tv].valm, tree[tv].valp);
	}
	if (l >= tr || r <= tl)
		return {INF, INF};
	ll tm = (tl + tr) / 2;
	pll res1 = get_min(2 * tv + 1, tl, tm, l, min(r, tm));
	pll res2 = get_min(2 * tv + 2, tm, tr, max(l, tm), r);
	return pll(min(res1.first, res2.first), min(res1.second, res2.second));
}

void update_pos(ll tv, ll tl, ll tr, ll pos, ll val) {
	push(tv, tl, tr);
	if (pos < tl || pos >= tr)
		return;
	if (tr - tl == 1) {
		tree[tv].valm = val - tl;
		tree[tv].valp = val + tl;
		return;
	}
	ll tm = (tl + tr) / 2;
	update_pos(2 * tv + 1, tl, tm, pos, val);
	update_pos(2 * tv + 2, tm, tr, pos, val);
	update_node(tv, tl, tr);
}	

ll get_pos(ll tv, ll tl, ll tr, ll pos) {
	push(tv, tl, tr);
	if (tr - tl == 1) 
		return tree[tv].valm + tl;
	ll tm = (tl + tr) / 2;
	if (pos < tm)
		return get_pos(2 * tv + 1, tl, tm, pos);
	else
		return get_pos(2 * tv + 2, tm, tr, pos);
}



int main() {
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);	
	ll n, q, a, b;
	cin >> n >> q >> a >> b;
	a--; b--;
	build(0, 0, n);
	ll last = b;
	update_pos(0, 0, n, a, 0);
	while (q--) {
		ll x;
		cin >> x;
		x--;
		auto p1 = get_min(0, 0, n, 0, x);
		auto p2 = get_min(0, 0, n, x, n);
		add_num(0, 0, n, 0, n, abs(last - x));
		ll cur_val = get_pos(0, 0, n, last);
		update_pos(0, 0, n, last, min(p1.first + x, p2.second - x));
		last = x;
	}
	ll res = INF;
	for (ll i = 0; i < n; i++) {
		res = min(res, get_pos(0, 0, n, i));
	}
	cout << res << endl;
	return 0;
}


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

int main()
{
   int k,n,i,p=0;
   cin>>k>>n;
   vector<int>A(n);
   for(i=0;i<n;i++)
    cin>>A[i];
    A.push_back(k+A[0]);
    for(i=0;i<n;i++)
        p=max(p,A[i+1]-A[i]);
        cout<<k-p<<endl;
    return 0;
}


Measured memory_bytes: 1792
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , B , A , a[N];

int main(){
    scanf("%d%d%d",&n,&A,&B);
    rep(i,0,n) scanf("%d",a + i);
    int l = 0 , r = *max_element(a , a + n);
    while(l + 1 < r){
        int m = (l + r) >> 1;
        ll ex = 0;
        rep(i,0,n) ex += max(0ll , ((a[i] - ll(B) * m) + A - B - 1) / (A - B));
        if(ex <= m) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#define d2r(x) ((x)*3.14159265/180)
using namespace std;
int main()
{
	int n, t, a = 90;
	char c;
	double x = 0.0, y = 0.0;
	while (cin >> n >> c >> t, n || t)
	{
		x += n * cos(d2r((double)a));
		y += n * sin(d2r((double)a));
		a -= t;
	}
	cout << (int)x << endl << (int)y << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
   int A,B;
   cin>>A>>B;

   if((A+B)%2==1)
      cout<<"IMPOSSIBLE"<<endl;
   else{
      int K=(max(A,B)+min(A,B))/2;
      cout<<K<<endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int hight[10];
	for(int i=0; i<10; i++){
		cin >>hight[i];
	}
	for(int i=0; i<10; i++){
		for(int l=0; l<9; l++){
			if(hight[l]<hight[l+1]){
				int c = hight[l];
				hight[l] = hight[l+1];
				hight[l+1] = c;
			}
		}
	}
	cout <<hight[0]<<endl<<hight[1]<<endl<<hight[2]<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int c[]=new int[a];
		for(int i=0;i!=a;i++) {
			c[i]=scan.nextInt();
		}
		int b=scan.nextInt();
		int ans[]=new int[b];
		for(int i=0;i!=b;i++) {
			int e=scan.nextInt();
			int f=scan.nextInt();
			for(int j=0;j!=a;j++) {
				if(j+1==e) {
					ans[i]+=f;
					continue;
				}
				ans[i]+=c[j];
			}
		}
		for(int i=0;i!=b;i++) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
	int card[4][14], n, i, j, d;
	char c;
	scanf("%d", &n);

	for (i = 0; i < 4; i++)
	{
		for (j = 1; j < 14; j++)
		{
			card[i][j] = 0;
		}
	}

	for (i = 0; i < n; i++)
	{
		scanf(" %c %d", &c, &d);
		if (c == 'S') card[0][d] = 1;
		else if (c == 'H') card[1][d] = 1;
		else if (c == 'C') card[2][d] = 1;
		else if (c == 'D') card[3][d] = 1;
	}

	for (i = 0; i < 4; i++)
	{
		for (j = 1; j < 14; j++)
		{
			if (card[i][j] == 0)
			{
				if (i == 0) printf("S");
				else if (i == 1) printf("H");
				else if (i == 2) printf("C");
				else if (i == 3) printf("D");

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

	return 0;
}

Measured memory_bytes: 600
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB")
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return;
}

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


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

int main(){
  int n, m;
  while(cin >> n >> m, n || m){
    map<int, int> mp;
    for(int i = 0; i < m; i++){
      mp[i + 1] = 0;
    }

    int d, v;
    for(int i = 0; i < n; i++){
      cin >> d >> v;
      mp[d] = max(mp[d], v);
    }

    int ans = 0;
    for(auto a : mp){
      ans += a.second;
    }
    cout << ans << endl;
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

constexpr ll inf = ((1<<30)-1)*2+1 ;

class Bucket{
  public:
  vector<ll> buc,v;
  ll N,sqn,K;
  Bucket(){};
  Bucket(ll n){
    N = n;
    sqn = sqrt(N);
    K = (n + sqn - 1) /sqn;
    buc.assign(K,inf);
    v.assign(K * sqn,inf);
  }
  void update(int x,int y){
    v[x] = y;
    ll m = inf;
    int k = x / sqn;
    for(int i = k * sqn; i < (k + 1) * sqn;++i){
      m = min(m,v[i]);
    }
    buc[k] = m;
  }
  ll query(int x,int y){
    ll res = inf;
    for (int k = 0; k < K; ++k) {
      int l = k * sqn, r = (k + 1) * sqn;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        res = min(res,buc[k]);
      } else {
        for (int i = max(x, l); i < min(y, r); ++i) {
          res = min(res,v[i]);
        }
      }
    }
    return res;
  }
  void Debug(){
    for(int i = 0; i < N;++i){
      cout << buc[i/sqn] << ' ';
    }
    cout << endl;
    for(int i = 0; i < N;++i){
      cout << v[i] << ' ';
    }
    cout << endl;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;
  cin >> n >> q;
  Bucket buc(n);
  ll c,x,y;
  rep(i,q){
    cin >> c >> x >> y;
    if(c){
      cout << buc.query(x,y+1) << endl;
    }
    else{
      buc.update(x,y);
    }
  }
  /* buc.Debug(); */
  return 0;
}

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


int main() {
  int a, b, c;
  cin >> a >> b;
  
  if ( a == 1 && b == 2 || a == 2 && b == 1) {
    c = 3;
  }
  if ( a == 2 && b == 3 || a == 3 && b == 2) {
    c = 1;
  }
  if ( a == 3 && b == 1 || a == 1 && b == 3) {
    c = 2;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int d;cin>>d;
    vector<int> t(d+1), c(27);
    vector<vector<int>> s(d+1, vector<int>(27));
    FOR(i, 1, 26) cin>>c[i];
    FOR(i, 1, d) FOR(j, 1, 26) cin>>s[i][j];
    FOR(i, 1, d) cin>>t[i];
    vector<int> last(27, 0);

    int64_t v=0;

    FOR(day, 1, d){
        v+=(int64_t)s[day][t[day]];
        last[t[day]]=day;
        FOR(i, 1, 26){
            v-=(int64_t)c[i]*(day-last[i]);
        }

        cout<<v<<endl;

    } 

}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct State {
  // location, value, numbers
  int l, v, n;
  bool operator<(const State& r) const {
    return l < r.l;
  }
};

int main() {
  int N;
  while (scanf("%d", &N), N) {
    vector<State> data;
    int ub = 0;
    rep(i,N) {
      char op;
      int lop, rop;
      scanf(" %c%d", &op, &lop);

      // rep(i,data.size()) {
      //   printf("{%d,%d,%d}", data[i].l, data[i].v, data[i].n);
      // } puts("");
      
      if (op == 'R') {
        // location について二分探索する
        int l = -1, r = data.size();
        if (r == 0) {
          printf("%d\n", -1); continue;
        }
        while (r - l > 1) {
          int m = (l+r)/2;
          if (data[m].l + data[m].n - 1 >= lop) {
            r = m;
          } else {
            l = m;
          }
        }
        printf("%d\n", (r >= data.size()) ? -1 : data[r].v);
      } else if (op == 'W') {
        scanf("%d", &rop);
        for (int i = 0; i < data.size() && rop > 0; ++i) {
          if (data[i].v != -1) continue;
          State& s = data[i];
          // 空き領域と長さがちょうど
          if (s.n == rop) {
            s.v = lop;
            rop = 0;
          }
          // 空き領域の方が大きい
          else if (s.n > rop) {
            const State cs = s;
            // 現在の領域を上書き
            s.v = lop;
            s.n = rop;
            // 圧縮された空き領域を追加
            inserter(data, data.begin() + i + 1) = (State){cs.l + rop, -1, cs.n - rop};
            rop = 0;
          }
          // 空き領域が足りない場合
          else if (s.n < rop) {
            s.v = lop;
            rop -= s.n;
          }
        }
        // 末尾に追加する必要がある場合
        if (rop > 0) {
          data.push_back((State){ub, lop, rop});
          ub += rop;
        }
        // 最後にソート
      } else {
        rep(i,data.size()) {
          if (data[i].v == lop)
            data[i].v = -1;
        }
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1348
#include <stdio.h>
int main(void){
    int n,i,cnt=1;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    for(i=1;i<n;i++){
        if(s[i-1]!=s[i]) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 256
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    println(if (readLine()!!.toInt() in setOf(7, 5, 3)) "YES" else "NO")
}

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

int main()
{
    long long n;
    long long mini = 10e15;
    cin >> n;
    vector<long long> vec(5);
    for(int i = 0; i < 5; ++i)
    {
        long long t;
        cin >> t;
        if(t < mini)
        {
            mini = t;
        }
    }

    long long ans = ceil(n/(double)mini);
    cout << ans + 4 << endl;
}

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

int a[305][305];
int del[305], pos[305], cnt[305];

int main(){
	int n, m, ans, maxx, rem;
	scanf("%d %d",&n,&m);
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			scanf("%d",&a[i][j]);
		}
	}
	memset(del, 0, sizeof(del));
	ans = n; rem = m;
	for (int i = 1; i <= n; i++) pos[i] = 1;
	while (true){
		memset(cnt, 0, sizeof(cnt));
		for (int i = 1; i <= n; i++) cnt[a[i][pos[i]]]++;
		maxx = 1;
		for (int i = 2; i <= m; i++){
			if (cnt[i] > cnt[maxx]) maxx = i;
		}
		ans = min(ans, cnt[maxx]);
		if (--rem == 0) break;
		del[maxx] = 1;
		for (int i = 1; i <= n; i++){
			if (a[i][pos[i]] == maxx){
				while (del[a[i][pos[i]]]) pos[i]++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    int a,b,c,d;
    cin>>a;
    d=a%10;
    a/=10;
    c=a%10;
    a/=10;
    b=a%10;
    a/=10;
    if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7;
    else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7;
    else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7;
    else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7;
    else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7;
    else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7;
    else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7;
    else if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7;
}

Measured memory_bytes: 256
def lcm(c):
    from fractions import gcd
    x = c[0]
    for i in range(1,len(c)):
        x = (x * c[i]) // gcd(x,c[i])
    return x
    
N = int(input())
a = [int(input()) for i in range(N)]
print(lcm(a))

Measured memory_bytes: 5156
package main

import (
	"fmt"
	"sort"
)

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

	var min = 10000000
	for i := 0; i < N; i++ {
		base := A[i]
		var l, r int
		if i == 0 {
			r = A[N-1]
		} else {
			r = A[i-1] + K
		}
		r1 := r - base

		if r1 < min {
			min = r1
		}
		if i != N-1 {
			l = A[i+1]
		} else {
			l = A[0] + K
		}
		diff := l - base
		if K-diff < min {
			min = K - diff
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int a[100000], w, n, x, y, h, p;
string o;
int main(){
	cin >> w >> n;
	for(int i = 1; i <= w; i++){
		a[i] = i;
	}
	for(int i = 1; i <= n; i++){
		x = 0;
		y = 0;
		cin >> o;
		p = o.find(',');
		for(int i = 0; i < p; i++){
			x *= 10;
			x += (int)o[i] - '0';
		}
		for(int i = p+1; i < o.length(); i++){
			y *= 10;
			y += (int)o[i] - '0';
		}
		h = a[y];
		a[y] = a[x];
		a[x] = h;
	}
	for(int i = 1; i <= w; i++){
		cout << a[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9+7)
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int pow1(int x, unsigned int y) { 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = pow1(x, y/2); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return ((x*temp)%mod*(temp)%mod)%mod; 
} 
int inv_mod(int a){
    int res = 1;
    int mod_temp = mod-2;
    while(mod_temp){
        if(mod_temp&1){
            res = ((res%mod)*(a%mod))%mod;
        }
        a = ((a%mod)*(a%mod))%mod;
        mod_temp >>= 1;
    }
    return res%mod;
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res = ((res%mod)*((n - i)%mod))%mod;
        res = ((res%mod)*(inv_mod(i + 1)%mod))%mod;
    }
    return res%mod;
}
int fibonacci(int n){
    double phi = (1LL + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
#define s set1
signed main(){

    fastIO
    
    int n, m;
    cin >> n >> m;

    int arr[n];
    memset(arr, -1, sizeof(arr));

    for (int i = 0; i < m; i++){
        int s, c;
        cin >> s >> c;
        s--;
        if ((arr[s] != -1 && c != arr[s]) || ( n != 1 && s == 0 && c == 0)){
            cout << "-1\n";
            return 0;
        }
        else{
            arr[s] = c;
        }
    }
    if(arr[0] == -1 && n == 1){
        cout << "0";
        return 0;
    }
    if(arr[0] == -1) arr[0] = 1;
    for(int i = 1; i< n;i++){
        if(arr[i] == -1) arr[i]  = 0;
    }
    for(int i =0 ;i< n;i++) cout << arr[i];


    return 0;
}

Measured memory_bytes: 256
base = input().split()
a = int(base[0])
b = int(base[1])
c = int(base[2])
if c**2+a**2+b**2+2*a*b-2*a*c-2*b*c>4*a*b and c-a-b>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	static int before, w, h;
	static int[][] dir = {{-1,0}, {-1,-1}, {0,-1}, {1,-1}, {1,0}, {1,1}, {0, 1}, {-1,1}};
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0){
				break;
			}
			int[][] c = new int[h][w];
			for(int i = 0; i < h; i++){/* ???????????? */
				for(int j = 0; j < w; j++){
					c[i][j] = sc.nextInt();
				}
			}
			
			int count = 0;
			for(int i = 0; i < h; i++){/* ?????¨????????§?????¢?´¢????§? */
				for(int j = 0; j < w; j++){
					before = 4;
					int z = search(c, i, j);/* ?????° */
					if(z == 1){
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	
	public static int search(int[][] c, int i, int j){
		if(c[i][j] == 0){
			return 0;
		}
		c[i][j] = 0;
		
		int d = before + 4/* ????????°????????????????????´???????§???? */;
		if(d > 7){
			d -= 8;
		}
		
		for(int k = 0; k < 7; k++){
			d++;
			if(d > 7){
				d -= 8;
			}
			
			before = d;
			int x = i + dir[d][0], y = j + dir[d][1];
			if((x >= 0) && (x < h) && (y >= 0) && (y < w)){
				int z = search(c, x, y);
			}
		}		
		return 1;
	}
}

Measured memory_bytes: 44580
H, W, D = map(int, input().split())
C = [None] * (H * W + 1)
for h in range(H):
    m = map(int, input().split())
    for w, x in enumerate(m):
        C[x] = (h, w)

Acc = [[0] for _ in range(D)]
for i in range(D):
    x = i + 1
    while x + D <= H * W:
        Acc[i].append(Acc[i][-1] + abs(C[x + D][0] - C[x][0]) + abs(C[x + D][1] - C[x][1]))
        x += D

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    tmp = Acc[l % D - 1]
    print(tmp[(r - 1) // D] - tmp[(l - 1) // D])


Measured memory_bytes: 19188
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> cnt;
    rep(i, n){
    	string s;
    	cin >> s;
    	cnt[s]++;
    }
    vector<string> ans;
    int mx = 0;
    for(auto p : cnt){
    	chmax(mx, p.second);
    }
    for(auto p : cnt){
    	if(p.second == mx) ans.push_back(p.first);
    }
    sort(ans.begin(), ans.end());
    for(auto p : ans){
    	cout << p << endl;
    }
    return 0;
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    double H,A,ans;

    cin >> H >> A;

    ans = ceil(H/A);

    cout << ans << endl;

    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code
struct UnionFind
{
	// par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
	vector<int> par;
	// sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
	vector<int> sizes;

	UnionFind(int n) : par(n), sizes(n, 1) {
		// 最初は全てのデータiがグループiに存在するものとして初期化
		for(int i = 0;i < n;i++) par[i] = i;
	}

	// データxが属する木の根を得る
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		// sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};

int main(int argc, char const* argv[])
{
	int n,m;
	cin >> n >> m;
	VL x(m),y(m),z(m);
	UnionFind uf(n+1);
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i] >> z[i];
		uf.unite(x[i]-1,y[i]-1);
	}
	VL t(n,0);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp =uf.find(i);
		if (t[tmp] == 0) {
			ans++;
			t[tmp]++;
		}
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll inv[100100];

void init() {
  FOR(i, 1, 100100) inv[i] = modinv(i);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  init();

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0, res = 0;
  FOR(i, 1, n + 1) res = (res + inv[i]) % mod;
  rep(i, n) {
    ans = (ans + res * a[i]) % mod;
    res = (res - inv[n - i] + inv[i + 2] + mod) % mod;
  }
  FOR(i, 1, n + 1) ans = (ans * i) % mod;
  cout << ans << '\n';


  

  




  
  return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];

int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans ^= a[i];
    }
    for (int i = 0; i < n; ++i) {
        cout << (ans^a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3972
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

int a[arr];
int st[arr][20];
int aa[arr];
int bb[arr];
int ans[arr];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    int l;
    cin>>l;
    int q;
    cin>>q;
    for (int i=0;i<q;i++){
        cin>>aa[i]>>bb[i];
        aa[i]--;
        bb[i]--;
    }

    int p=n;
    for (int i=n-1;i>=0;i--){
        while ((p==n?a[n-1]+l:a[p])-a[i]>l){
            p--;
        }
        st[i][0]=p;
    }
    for (int j=1;j<20;j++){
        for (int i=0;i<n;i++){
            st[i][j]=(st[i][j-1]==n?n:st[st[i][j-1]][j-1]);
        }
    }
    for (int i=0;i<q;i++){
        int a=aa[i];
        int b=bb[i];
        if (a<=b){
            int res=0;
            for (int i=19;i>=0;i--){
                if (st[a][i]<=b){
                    res+=(1ll<<i);
                    a=st[a][i];
                }
            }
            ans[i]=res+(a!=b);
        }
    }


    p=-1;
    for (int i=0;i<n;i++){
        while (a[i]-(p==-1?a[0]-l:a[p])>l){
            p++;
        }
        st[i][0]=p;
    }
    for (int j=1;j<20;j++){
        for (int i=0;i<n;i++){
            st[i][j]=(st[i][j-1]==-1?-1:st[st[i][j-1]][j-1]);
        }
    }
    for (int i=0;i<q;i++){
        int a=aa[i];
        int b=bb[i];
        if (a>b){
            int res=0;
            for (int i=19;i>=0;i--){
                if (st[a][i]>=b){
                    res+=(1ll<<i);
//                    cout<<a<<" "<<st[a][i]<<"\n";
                    a=st[a][i];
                }
            }
            ans[i]=res+(a!=b);
        }
    }

    for (int i=0;i<q;i++){
        cout<<ans[i]<<"\n";
    }
}


Measured memory_bytes: 22528
def solve(N, W, WVs):
    Ws = {}
    for w, v in WVs:
        Ws.setdefault(w, []).append(v)
    for w, v in Ws.items():
        Ws[w] = sorted(v, key=lambda x: -x)
    wkeys = sorted(Ws.keys())

    m = 0
    for n1 in range(N + 1):
        w1 = n1 * wkeys[0]
        if w1 > W:
            break
        v1 = sum(Ws[wkeys[0]][:n1])
        for n2 in range(N - n1 + 1):
            if len(wkeys) >= 2:
                w2 = n2 * wkeys[1]
                if w1 + w2 > W:
                    break
                v2 = sum(Ws[wkeys[1]][:n2])
            else:
                w2, v2 = 0, 0
            for n3 in range(N - n1 - n2 + 1):
                if len(wkeys) >= 3:
                    w3 = n3 * wkeys[2]
                    if w1 + w2 + w3 > W:
                        break
                    v3 = sum(Ws[wkeys[2]][:n3])
                else:
                    w3, v3 = 0, 0
                for n4 in range(N - n1 - n2 - n3 + 1):
                    if len(wkeys) >= 4:
                        w4 = n4 * wkeys[3]
                        if w1 + w2 + w3 + w4 > W:
                            break
                        v4 = sum(Ws[wkeys[3]][:n4])
                    else:
                        w4, v4 = 0, 0

                    m = max(m, v1 + v2 + v3 + v4)

    return m

if __name__ == "__main__":
    N, W = map(int, input().split(" "))
    WVs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(N, W, WVs))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define bug(x) cerr << "[" << #x << "] = ["<<x<<"]"<<'\n'
using namespace std;
int main()
{
        int a,b;
        cin>>a>>b;
        if(a==b) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;
int main(){
  ll A,B;cin>>A>>B;
  ll ans=0;
  if(A%2==1 &&B%2==1){
    ans =(((B-A)/2)%2)^A ;
  }
  else if(A%2==1 && B%2==0){
    ans =(((B-1-A)/2)%2)^A^B;
  }
  else if(A%2==0 && B%2==0){
    ans =(((B-A)/2)%2)^B;
  }
  else ans=((B-A+1)/2)%2;

  cout<<ans<<endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int main()
{
    int len, num;
    while(~scanf("%s", s))
    {
        num = 0;
        len = strlen(s);
        for(int i = 0; i < len-2; i++)
        {
            if(s[i] != s[i+2]) num++;
        }
        if(num == 0) {
            printf("Second\n");
            continue;
        }
        if(s[len-1] == s[0])
        {
            if(len % 2 == 0)
                printf("First\n");
            else printf("Second\n");
        }
        else
        {
            if(len%2 == 0)
                printf("Second\n");
            else printf("First\n");
        }
    }
}


Measured memory_bytes: 384
#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<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<b+min(c,a+b+1)<<endl;
}

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

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for (int i = 0; i < strlen(str); i++){
            sum += (str[i] - '0');
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 2572
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;

int n;
int month[]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool run(int n) {
	if(n%4)
		return 0;
	if(n%400==0)
		return 1;
	if(n%100==0)
		return 0;
	return 1;
}
int main() {
	IOS
	map<string,string>m;
	m["ABC"]="ARC";
	m["ARC"]="ABC";
	string s;
	cin>>s;
	cout<<m[s]<<endl;

}

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

using ld = long double;
using point = std::complex<ld>;
using polygon = std::vector<point>;

constexpr ld eps = 1e-10;
constexpr ld pi = std::acos(-1.0);

bool comp(point a, point b) {
    return std::real(a) < std::real(b) || (std::real(a) <= std::real(b) && std::imag(a) < std::imag(b));
}

std::vector<point> unique(std::vector<point> ps) {
    std::sort(std::begin(ps), std::end(ps), comp);
    std::vector<point> res;
    for(auto& p : ps) {
        if(res.empty() || abs(res.back() - p) > eps) {
            res.push_back(p);
        }
    }
    return res;
}

ld dot(point const& a, point const& b) {
    return std::real(std::conj(a) * b);
}
ld cross(point const& a, point const& b) {
    return std::imag(std::conj(a) * b);
}

int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if(cross(b, c) > eps) return 1;            // a -> b -> c : counterclockwise
    if(cross(b, c) < -eps) return -1;          // a -> b -> c : clockwise
    if(dot(b, c) < 0) return 2;                // c -> a -> b : line
    if(std::norm(b) < std::norm(c)) return -2; // a -> b -> c : line
    return 0;                                  // a -> c -> b : line
}

struct segment {
    segment() : a(0, 0), b(0, 0) {}
    segment(point a, point b) : a(a), b(b) {}
    point a, b;
};

struct line {
    line() : a(0, 0), b(0, 0) {}
    line(point a, point b) : a(a), b(b) {}
    line(segment s) : a(s.a), b(s.b) {}
    point a, b;
};

using namespace std;

int main() {
    ld x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    point p1(x1, y1), p2(x2, y2);
    int q; cin >> q;
    while(q--) {
        ld x, y; cin >> x >> y;
        point p3(x, y);
        int ans = ccw(p1, p2, p3);
        if(ans == 1) cout << "COUNTER_CLOCKWISE" << endl;
        if(ans == -1) cout << "CLOCKWISE" << endl;
        if(ans == 2) cout << "ONLINE_BACK" << endl;
        if(ans == -2) cout << "ONLINE_FRONT" << endl;
        if(ans == 0) cout << "ON_SEGMENT" << endl;
    }
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
/*
1
12Fizz4BuzzFizz78Fiz
20
zzBuzz11Fizz1314Fizz
22
Buzz11Fizz1314FizzBu
100
34BuzzFizz3738FizzBu
*/
#define ll long long
vector<ll>V;
ll d[7][20];
void init(){
	for(int i=0;i<20;i++)d[0][i]=i;
	d[1][0]=1;
	for(int i=1;i<20;i++)d[1][i]=d[1][i-1]*10;
	d[2][0]=5;
	for(int i=1;i<20;i++)d[2][i]=d[1][i-1]*48;
	for(int i=0;i<20;i++)d[3][i]=d[2][i]*(i+1);
	d[4][0]=4;
	for(int i=1;i<20;i++)d[4][i]=d[1][i-1]*48;
	for(int i=0;i<20;i++)d[5][i]=d[3][i]+d[4][i]*4;
	d[6][0]=d[5][0];
	for(int i=1;i<20;i++)d[6][i]=d[6][i-1]+d[5][i];
	V.push_back(0);
	for(int i=0;i<17;i++)V.push_back(d[6][i]);
}

string itos(ll num){
	string tmp="";
	for(;num;num/=10)tmp+=('0'+num%10);
	reverse(tmp.begin(),tmp.end());
	return tmp;
}

ll kaga1(ll num){
	ll st,en=num-1,res=0;
	for(int i=0;num>=d[1][i];i++){
		if(i==0)res=0;
		else res=d[6][i-1];
		st=d[1][i];
	}
	/*
	for(int i=16;num<d[1][i];){
		i--;
		st=d[1][i];
		if(i==0)res=0;
		else res=d[6][i-1];
	}
	*/
	ll ko=en-st+1;
	ll tmp=0;
	tmp+=(en/3-(st-1)/3);
	tmp+=(en/5-(st-1)/5);
	tmp-=(en/15-(st-1)/15);
	ko-=tmp;
	tmp+=(en/15-(st-1)/15);
	res+=tmp*4+ko*itos(st).size();
	return res+1;
}

string FB(ll num){
	if(num%15==0)return "FizzBuzz";
	if(num%3==0)return "Fizz";
	if(num%5==0)return "Buzz";
	return itos(num);
}

int main(){
	init();
	ll x;
	cin>>x;
	
	int pos=0;
	for(;x>V[pos+1];pos++);
	ll mn=d[1][pos],mx=d[1][pos+1]-1,len=pos+1,p=(mn+mx)/2;
	
	while(mx-mn>3){
		p=(mn+mx)/2;
		if(kaga1(p)>x)mx=p;
		else mn=p;
	}
	string s="";
	for(int i=0;i<20;i++){
		s+=FB(mn+i);
	}
	for(ll i=0,j=kaga1(mn);i<s.size();i++,j++){
		if(x<=j && j<x+20){
			cout<<s[i];
		}
	}
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 1228
#include<iostream>
using namespace std;
int main()
{
	int ans=0,i,a, b, c;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++){
		if (c%i == 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
N,K=map(int,input().split())
S=input()
if S[K-1]=="A":
    ans=S[:K-1]+"a"+S[K:]
elif S[K-1]=="B":
    ans=S[:K-1]+"b"+S[K:]
if S[K-1]=="C":
    ans=S[:K-1]+"c"+S[K:]
print(ans)



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

const int N = 300005;
const int MOD = 998244353;

int n, a, b;
long long k;

int fact[N], ifact[N];

int main() {
  fact[0] = 1;
  for (int i=1; i<N; i++) fact[i] = 1LL * i * fact[i-1] % MOD;
  ifact[N-1] = 337718740;
  for (int i=N-2; i>=0; i--) ifact[i] = 1LL * ifact[i+1] * (i+1) % MOD;
  
  // assert(ifact[0] == 1);
  
  scanf("%d %d %d %lld", &n, &a, &b, &k);
  
  long long ans = 0;
  for (int i=0; i<=n; i++) {
    if ((k - 1LL * i * a) % b) continue;
    long long nb = (k - 1LL * i * a) / b;
    if (nb < 0 || nb > n) continue;
    
    ans += 1LL * fact[n] * ifact[i] % MOD * ifact[n-i] % MOD *
                 fact[n] % MOD * ifact[nb] % MOD * ifact[n - nb] % MOD;
  }
  printf("%lld\n", ans % MOD);
  
  return 0;
}


Measured memory_bytes: 2560
// AOJ 2839 Ebi-chan and Integer Sequences
// 2019.3.1 bal4u

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

/*
  k = m/(n-1)   小数点以下は切り捨て
  ans = (m+1) + 2*(k*(m+1)-k*(k+1)/2*(n-1))
*/

#define M 1000000007

long long mul(long long a, long long b)
{
	return ((a%M)*(b%M)) % M;
}
int main()
{
	long long n, m, k;
	long long ans, a, b;

	scanf("%lld%lld", &n, &m);

	ans = (m+1) % M, b = 0;
	if (n > 1) {
		k = m / (n - 1);
		if (k & 1) a = mul(k, (k + 1) >> 1);
		else       a = mul(k >> 1, k + 1);
		a = mul(a, n - 1);

		b = mul(k, m + 1);
		b -= a;
		if (b < 0) b += M;
		b <<= 1;
	}
	printf("%d\n", (int)((ans+b) % M));
	return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    int a,b;
  cin>>a>>b;
  if(a+b==3)
  cout<<3<<endl;
  else if(a+b==5)
    cout<<1<<endl;
  else
    cout<<2<<endl;
    return 0;
    
}

Measured memory_bytes: 256