akhauriyash/Code-Regression huggingface dataset:
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

int front(int x) { 
    return x % 10;
}
int back(int x) {
    while (x >= 10) { x /= 10; }
    return x;
}



void solve() {
    long long N;
    cin >> N;
    vector<vector<long long>>c(10, vector<long long>(10, 0));
    for (int i = 1; i <= N; i++){
        if (back(i) != 0)c[front(i)][back(i)]++;
    }

    long long ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++)ans += c[i][j] * c[j][i];
    }

    cout << ans;
}

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

Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[]
for i in range(M):
  sc.append(list(map(int,input().split())))

ans=-1
cnt=10**(N-1)
if cnt==1:cnt-=1
while True:
  if len(str(cnt))>N:break
  if len(str(cnt))!=N:continue
  ret=True
  for i in range(M):
    if str(cnt)[sc[i][0]-1]!=str(sc[i][1]):
      ret=False
      break
  if ret:
    ans=cnt
    break
  cnt+=1
print(ans)

Measured memory_bytes: 63484
#include<stdio.h>

int main(){
	
	char huruf1;
	char huruf2;
	
	scanf("%c %c",&huruf1,&huruf2);
	
	if(huruf1=='H'){
		if(huruf2=='H'){
			printf("H\n");}
		else{
			printf("D\n");
		}
		
	}
	
	if(huruf1=='D'){
		if(huruf2=='H'){
			printf("D\n");}
		else{
			printf("H\n");
		}		
	}
	
	
	return 0;
	
}

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


ll n,x;
vector<pair<ll,pll>> A;
ll sum=0;

ll cul(ll i,ll t){
    if(t<=A[i].F){return (t-A[i].F)*A[i].S.F;}
    return (t-A[i].F)*A[i].S.S;
}

ll cul2(ll i,ll t){
    if(t<=A[i].F){return t*A[i].S.F;}
    return t*A[i].S.S-A[i].F*(A[i].S.S-A[i].S.F);
}

bool can(ll z){
    //cout<<"!"<<z<<endl;
    priority_queue<pll> Q;
    vector<bool> used(n,false);
    ll s=sum;
    for(int i=0;i<n;i++){
        Q.push({x*A[i].S.S-A[i].F*(A[i].S.S-A[i].S.F),i});
    }
    while(z>=x){
        z-=x;
        pll W=Q.top(); Q.pop();
        ll i=W.S;
        s=s-A[i].S.S*x-A[i].F*A[i].S.F+A[i].F*A[i].S.S;
        if(s<=0){return true;}
        used[i]=true;
    }
    if(z==0){return false;}
    ll mx=-1e15,a=-1;
    for(int i=0;i<n;i++){
        if(used[i] && mx<cul(i,z)-cul(i,x)){
            mx=cul(i,z)-cul(i,x);
            a=i;
        }
    }
    //cout<<" "<<s<<" "<<mx<<endl;
    for(int i=0;i<n;i++){
        //cout<<i<<endl;
        if(used[i]){continue;}
        if(cul2(i,z)>=s){return true;}
        if(cul2(i,x)+mx>=s){return true;}
    }
    return false;
}


int main(){
    cin>>n>>x;
    A.resize(n);
    cin>>A;
    for(auto &I:A){sum+=I.F*I.S.F;}
    ll l=0,r=1e15;
    if(sum==0){cout<<0<<endl; return 0;}
    while(r-l>5){
        ll m=l+(r-l)/2;
        if(can(m)){r=m;}
        else{l=m;}
    }
    for(ll i=max(l-10,1LL);;i++){
        if(can(i)){cout<<i<<endl; return 0;}
    }
    
    return 0;
}


Measured memory_bytes: 8288
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type *) calloc ((size), sizeof (type)))

typedef struct union_find_depth {
  i32 *parent;
  i32 *depth;
  i32 size;
} union_find;

union_find* new_union_find (const i32 n) {
  union_find *u = ALLOC (1, union_find);
  u->parent = ALLOC (n, i32);
  u->depth = ALLOC (n, i32);
  u->size = n;
  for (i32 i = 0; i < n; ++i) {
    u->parent[i] = -1;
  }
  return u;
}

i32 root (union_find *u, i32 x) {
  while (u->parent[x] >= 0) {
    x = u->parent[x];
  }
  return x;
}

i32 depth (union_find *u, i32 x) {
  i32 sum = 0;
  while (u->parent[x] >= 0) {
    sum += u->depth[x];
    x = u->parent[x];
  }
  return sum;
}

int unite (union_find *u, i32 x, i32 y, i32 w) {
  i32 rx = root (u, x);
  i32 ry = root (u, y);
  if (rx == ry) {
    return depth (u, x) + w == depth (u, y);
  }
  if (u->parent[rx] > u->parent[ry]) {
    i32 swap = rx;
    rx = ry;
    ry = swap;
    swap = x;
    x = y;
    y = swap;
    w = -w;
  }
  u->depth[ry] = depth (u, x) + w - depth (u, y);
  u->parent[rx] += u->parent[ry];
  u->parent[ry] = rx;
  return 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  union_find *u = new_union_find (n + 1);
  while (m--) {
    i32 l, r, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &l, &r, &d);
    if (!unite (u, l, r, d)) {
      puts ("No");
      return;
    }
  }
  puts ("Yes");
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 1024
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月22日 星期一 23时36分23秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<ll,ll>pii;
#define lson (root<<1)
#define rson (root<<1|1)


const ll INF=1e18;

pii cal(ll h,ll w){
	if(h%2==0 || w%2==0) return pii(h*w/2,h*w/2);
	if(h<w) swap(h,w);
	return pii((h/2)*w,((h+1)/2*w));
}

ll solve(ll h,ll w){

	ll ans=INF;
	for(ll i=1;i<=h/2;i++){
		ll Max=i*w,Min=Max;
		pii ret=cal(h-i,w);
		Max=max(Max,ret.second);
		Min=min(Min,ret.first);
		ans=min(ans,Max-Min);
	}
	return ans;

}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	ll h,w;
	cin>>h>>w;
	cout<<min(solve(h,w),solve(w,h))<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    fast
    #ifdef ANUBHAB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int ans, n, m;
    cin >> n >> m;
    ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  vector<int> A,B;
  A=a,B=b;
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(A==B)cout<<"Yes"<<endl;
  else {
    cout<<"No"<<endl;
    int id;
    B.push_back(n+1);
    B.push_back(0);
    sort(B.begin(),B.end());
    for(int i=0;i<=n;i++)if(B[i+1]-B[i]>1){id=B[i]+1;break;}
    
    for(int i=0;i<n;i++){
      if(i)cout<<' ';
      if(id==a[i])cout<<2;
      else cout<<1;
    }
    cout<<endl;
    for(int i=0;i<n;i++){
      if(i)cout<<' ';
      cout<<1;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 4728
from collections import deque

n, q = [ int(i) for i in input().split(" ") ]

ps = deque()
for i in range(n):
  p = [ i for i in input().split(" ") ]
  ps.append([p[0], int(p[1])])

time = 0
while len(ps) > 0:
  p = ps.popleft()

  tmp = p[1] - q
  if tmp > 0:
    ps.append([p[0], tmp])
    time +=  q
  else:
    time += p[1]
    print(p[0], str(time))


Measured memory_bytes: 13304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
typedef pair<ll,ll> P;
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

double dist(double X,double Y,double x,double y) {
  return sqrt((X-x)*(X-x)+(Y-y)*(Y-y));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  double gx=0,gy=0,d=0,d_=0,pos=0,c=0.1;
  lvector xv(n,0),yv(n,0);
  rep(i,n) {
    cin>>xv[i]>>yv[i];
    gx+=xv[i],gy+=yv[i];
  }
  gx/=n,gy/=n;
  rep(t,30000) {
    d=0;
    for(ll i=0;i<n;++i) {
      d_=dist(gx,gy,xv[i],yv[i]);
      if(d_>d) {d=d_;pos=i;}
    }
    gx-=(gx-xv[pos])*c;
    gy-=(gy-yv[pos])*c;
    c*=0.999;
  }
  d=dist(gx,gy,xv[pos],yv[pos]);
  printf("%.10f",d);
  return 0;
}


Measured memory_bytes: 256
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 = sc.nextInt();
        List<Integer> list = new ArrayList<>();

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (sc.nextInt() == 0) {
                count = 0;
                continue;
            }
            count++;
            list.add(count);
        }

        if (list.isEmpty()) {
            System.out.println(1);
        } else {
            System.out.println(Collections.max(list) + 1);
        }
    }
}


Measured memory_bytes: 26348
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
    ll x,k,d;
    scanf("%lld%lld%lld",&x,&k,&d);
    if(x<0)
        x=-x;
    if(k<=x/d)
    {
        printf("%lld",x-k*d);
        return 0;
    }
    ll h=x/d;
    x-=d*h;
    k=k-h;
    if(k%2==0)
        printf("%lld\n",x);
    else
        printf("%lld\n",d-x);
    return 0;
}


Measured memory_bytes: 3800
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll t[100];
ll gcd(ll c,ll b){
    if(b==0) return c;
    return (gcd(b,c%b));
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    ll ans=t[0];
    for(int i=1;i<n;i++){
        ll temp=gcd(ans,t[i]);
        ans/=temp;
        ans=ans*t[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[4][3][10];

	for(int i = 0; i < 4; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			for(int k = 0; k < 10; k++)
			{
				
				a[i][j][k] = 0;
				
			}
		}
	}
	int n;
	scanf("%d", &n);
	while(n--)
	{
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		a[b-1][f-1][r-1] += v;
		
	}
	for(int i = 0; i < 4; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			for(int k = 0; k < 10; k++)
			{
				printf(" %d", a[i][j][k]);
			
				
			}
			printf("\n");
		}
	
		if(i != 3)
		printf("####################\n");
	}
	
	return 0;
}
 


Measured memory_bytes: 2756
import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(N):
    if b > 0:
        b *= a[i]
    if a[i] == 0:
        b = 0
    if b > 10**18:
        b = -1

print(b, end='')

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

int main() {
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if((i+j)%2 == 0) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
def p_d():
    n = int(input())
    *A, = map(int, input().split())
    mod = 10 ** 9 + 7
    max_bit = len(bin(max(A))) - 2
    ans = 0
    for i in range(max_bit):
        count = [0] * 2
        for a in A:
            count[a >> i & 1] += 1
        ans += (1 << i) * count[0] * count[1]
        ans %= mod
    print(ans)
    
p_d()

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1000000007;
string s;
int flag[100010];
ll dp[100010][4];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') flag[i] = 1;
  }
  dp[0][0] = 1;
  for (int i = 0; i < s.size(); i++) {
    dp[i+1][0] = dp[i][0] * (s[i] == '?' ? 3 : 1) % MOD;
  }
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j+1 < 4; j++) {
      dp[i+1][j+1] += dp[i][j+1] * (s[i] == '?' ? 3 : 1) % MOD;
      dp[i+1][j+1] %= MOD;
      if (s[i] == "ABC"[j] || s[i] == '?') {
        dp[i+1][j+1] += dp[i][j];
        dp[i+1][j+1] %= MOD;
      }
    }
  }
  cout << dp[s.size()][3] << endl;

  return 0;
}

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

using namespace std;

int p[10];
int field[10][10];
int a[10];

int main(){
    const int INF=1000000000;
    int n;
    while(scanf("%d",&n),n!=0){
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                scanf("%d",&field[i][j]);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                field[i][j]=max(field[i][j],field[j][i]);
        for(int i = 0; i < 10; i++)
            a[i]=i;
        int minLength=INF;
        do{
            // »ÝÌÔÅÅáÀKvÈ·³
            int least=0;
            for(int i = 1; i < n; i++)
                least+=field[a[i]][a[i-1]];
            if(least>=minLength)
                continue;
            // aÌÔÉ¨¢Ä¢­
            for(int i = 0; i < n; i++){
                int rightPlace=0;
                if(i==0)
                    rightPlace=0;
                else{
                    // ±±ðÇ¤üP·é©H
                    for(int j = 0; j < i; j++)
                        rightPlace=max(rightPlace,field[a[i]][a[j]]+p[j]);
                }
                p[i]=rightPlace;
                if(p[i]>=minLength)
                    break;
            }
            if(minLength>p[n-1])
                minLength=p[n-1];
        }while(next_permutation(a,a+n));
        printf("%d\n",minLength);
    }
    return 0;
}

Measured memory_bytes: 876
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int d = vs[0];
			int x = vs[1];
			int ans = x;
			for (int i = 0; i < n; i++) {
				int a = int.Parse(Console.ReadLine());
				for (int j = 0; j < d; j+=a) {
					ans++;
				}
			}
			Console.WriteLine(ans);
		}
	}
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<int> d(N);
  vector<int> cum(100001, 0);  
  for ( int i = 0; i < N; i++ ) {
    cin >> d[i];
    cum[d[i]]++;    
  }

  int ans = 0; 
  for ( int i = 1; i <= 100000; i++ ) {
    cum[i] += cum[i-1];
    if ( cum[i] == N-cum[i] ) ans++;
  }

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


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>

int main(void){

	int m,de,nde=0;
	double PI=3.14159265,x=0,y=0;
	
	while(1){
		scanf("%d,%d",&m,&de);
		if(m==0&&de==0) break;

		x=x+m*sin((double)nde*PI/180);
		y=y+m*cos((double)nde*PI/180);

		nde=nde+de;
	}

	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 604
import sys

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2:
        return False

    p = 2

    while p*p <= n:
        if n % p == 0:
            return False

        p += 1

    return True

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7688
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  long long x;
  cin >> n >> x;
  int cur;
  cin >> cur;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int nxt;
    cin >> nxt;
    long long tot = 1LL * cur + nxt;
    if (tot > x) {
      ans += tot - x;
      nxt = max(1LL * nxt - (tot - x), 0LL);
    }
    cur = nxt;
  }
  cout << ans << endl;
  return 0;	
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		String s = fs.next();
		char c[] = s.toCharArray();
		int q = fs.nextInt();
		
		TreeSet<Integer> set[] = new TreeSet[26];
		for(int i=0;i<26;i++) set[i] = new TreeSet<Integer>();
		for(int i=0;i<s.length();i++) {
			int t = s.charAt(i)-'a';
			set[t].add(i);
		}
		for(int i=0;i<q;i++) {
			int a = fs.nextInt();
			if(a==1) {
				int x = fs.nextInt()-1; char ch = fs.next().charAt(0); 
				int t = c[x] - 'a';
				
				set[t].remove(x);
				c[x] = ch;
				int nt = ch - 'a';
				set[nt].add(x);
			}
			else if(a==2) {
				int l = fs.nextInt()-1, r = fs.nextInt()-1;
				int cnt = 0;
				for(int j=0;j<26;j++) {
					if(set[j].ceiling(l)==null)continue;
					int m = set[j].ceiling(l);
					if(m<=r)cnt++;
				}
				System.out.println(cnt);
			}
		}
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    bool c = false, f = false;
    for(int i = 0; i < n; i++){
        if(s[i] == 'C') c = true;
        if(s[i] == 'F' && c) f = true;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n][n];
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
    long long ans = 0;
    for (int i = 0; i < n; i++) 
        for (int j = i+1; j < n; j++) {
            bool rem = false;
            for (int k = 0; k < n; k++) {
                if (i == k || j == k) continue;
                if (a[i][k] + a[k][j] < a[i][j]) { cout << "-1\n"; return 0; }
                if (!rem && a[i][k] + a[k][j] == a[i][j]) { ans -= a[i][j]; rem = true; }
            }
        }
    for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) ans += a[i][j];
    cout << ans << endl;
}


Measured memory_bytes: 640
H, W = [int(_) for _ in input().split()]
memo = {}
for _ in range(H):
    for _ in input():
        memo[_] = memo.get(_, 0) + 1
count = [0] * 4
for k, v in memo.items():
    count[v % 4] += 1
ans = 'No'
if H * W % 2:
    if count[1] + count[3] == 1 and 1 + 2 * count[2] <= H + W - 1:
        ans = 'Yes'
elif H % 2:
    if count[1] == count[3] == 0 and 2 * count[2] <= W and (
            W - 2 * count[2]) % 4 == 0:
        ans = 'Yes'
elif W % 2:
    if count[1] == count[3] == 0 and 2 * count[2] <= H and (
            H - 2 * count[2]) % 4 == 0:
        ans = 'Yes'
else:
    if count[1] == count[2] == count[3] == 0:
        ans = 'Yes'
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,k,a[N],len[N];
pii ma[N<<2],mi[N<<2];

pii add1(pii a, pii b) {
	pii r;
	r.x=min(a.x,b.x);
	r.y=r.x==a.x?a.y:b.y;
	return r;
}
pii add2(pii a, pii b) {
	pii r;
	r.x=max(a.x,b.x);
	r.y=r.x==a.x?a.y:b.y;
	return r;
}
void build(int o, int l, int r) {
	if (l==r) return ma[o]=mi[o]=pii(a[l],l),void();
	build(ls),build(rs);
	mi[o]=add1(mi[lc],mi[rc]);
	ma[o]=add2(ma[lc],ma[rc]);
}
pii qry1(int o, int l, int r, int ql, int qr) {
	if (ql<=l&&r<=qr) return mi[o];
	if (mid>=qr) return qry1(ls,ql,qr);
	if (mid<ql) return qry1(rs,ql,qr);
	return add1(qry1(ls,ql,qr),qry1(rs,ql,qr));
}
pii qry2(int o, int l, int r, int ql, int qr) {
	if (ql<=l&&r<=qr) return ma[o];
	if (mid>=qr) return qry2(ls,ql,qr);
	if (mid<ql) return qry2(rs,ql,qr);
	return add2(qry2(ls,ql,qr),qry2(rs,ql,qr));
}

int main() {
	scanf("%d%d",&n,&k);
	REP(i,1,n) scanf("%d",a+i);
	len[n] = 1;
	PER(i,1,n-1) len[i]=a[i]<a[i+1]?1+len[i+1]:1;
	build(1,1,n);
	int ans = n-k+1, f = 0;
	REP(i,2,n-k+1) { 
		if (len[i]>=k&&f) {--ans;continue;}
		if (len[i]>=k) f = 1;
		ans-=qry1(1,1,n,i-1,i+k-2).y==i-1&&qry2(1,1,n,i,i+k-1).y==i+k-1;
	}
	printf("%d\n",ans);
}








Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    Int d, t, s;
    cin >> d >> t >> s;
    string ans = "No";
    if (d <= t * s) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)

N,M=map(int,input().split())
UF=UnionFind(N);c=0

for i in range(M):
  a,b=map(int,input().split())
  UF.unite(a-1,b-1)

for i in range(UF.n):
  if UF.parents[i]<0:
    c+=1
print(c-1)

Measured memory_bytes: 10644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

struct Item
{
    int value,weight;
};
int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1], G[NMAX+1][WMAX+1];
void compute(int &maxValue, vector<int> &selection)
{
    for(int w=0; w<=W; w++)
    {
        C[0][w] = 0;
        G[0][w] = DIAGONAL;
    }
    for(int i=1; i<=N; i++)
        C[i][0] = 0;
    for(int i=1; i<=N; i++)
    {
        for(int w=1; w<=W; w++)
        {
            C[i][w] = C[i-1][w];
            G[i][w] = TOP;
            if(items[i].weight > w)   continue;
            if(items[i].value+C[i-1][w-items[i].weight] > C[i-1][w])
            {
                C[i][w] = items[i].value+C[i-1][w-items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }
    maxValue = C[N][W];
    selection.clear();
    for(int i=N,w=W; i>=1; i--)
    {
        if(G[i][w] == DIAGONAL)
        {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }
    reverse(selection.begin(),selection.end());
}
void input()
{
    cin >> N >> W;
    for(int i=1; i<=N; i++)
        cin >> items[i].value >> items[i].weight;
}
int main()
{
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue,selection);
    cout << maxValue << endl;
    return 0;
}

Measured memory_bytes: 11036
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = Counter(s).most_common()
m = c[0][1]

ans = []
for x in c:
    if x[1] == m:
        ans.append(x[0])
ans = sorted(ans)
for x in ans:
    print(x)




Measured memory_bytes: 45220
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  rep (i, N) cin >> a[i];
  reverse(a.begin(), a.end());

  bool flag = false;
  rep (i, N) {
    if (flag) cout << " ";
    flag = true;
    cout << a[i];
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
string b, a;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	cin >> a >> b;
	reverse(b.begin(), b.end());
	if(a == b){
		puts("YES");
	} else {
		puts("NO");
	}
	return 0;
}


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

template<typename T> inline void chmax(T &a, T b){
	if(a < b) a = b;
}


int main() {
	
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), v(n);
	rep(i, n) cin >> weight[i] >> v[i];
	
	vector<vector<ll>> dp(n+1, vector<ll>(w+1));
	
	for(int i=0; i<n; i++){
		for(int sum_w=0; sum_w<=w; sum_w++){
			if(sum_w - weight[i] >= 0){
				chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+v[i]);
			}
			chmax(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

struct ev {
    int l, r;
};

bool operator < (const ev &a, const ev &b) {
    return a.l < b.l || (a.l == b.l && a.r < b.r);
}

const int N = 1e5 + 7;

int t[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        t[l]++;
        t[r + 1]--;
    }
    vector <int> res(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += t[i];
        res[i] = sum;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (res[i] == m) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
// (i*j) mod 2019の最小値

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

int main() {
  int64_t L, R;
  int64_t nL, nR;
  cin >> L >> R;

  int64_t ans = 2019;
  if( R-L >= 2019 ) {
    ans = 0;
  } else {
    nL = L % 2019;
    nR = R % 2019;
    if( nL > nR ) {
      ans = 0;
    } else {
      for( int64_t i=nL;i<nR;++i) {
        for( int64_t j=i+1;j<nR+1;++j) {
          ans = min( ans, (i * j)%2019);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, M;
  cin >> N >> M;
  int a, b, inter[N]={};
  bool ans = false;
  REP(i, M) {
    cin >> a >> b;
    if(a == 1) ++inter[b];
    if(b == N) ++inter[a];
  }
  REP(i, N)  if(inter[i]>1) ans=true;

  cout << (ans? "POSSIBLE" : "IMPOSSIBLE") << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
inline void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
inline void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void print(T &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

struct Rectangle {
  int height, pos;
};

int get_largest_rectangle(int w, vi &Tr) {
  stack<Rectangle> S;
  int max_v = 0;
  Tr[w] = 0;

  REP(i, w + 1) {
    Rectangle rect{Tr[i], i};
    if (S.empty()) {
      S.push(rect);
      continue;
    }
    if (S.top().height < rect.height) {
      S.push(rect);
    } else if (S.top().height > rect.height) {
      int target = i;
      while (!S.empty() && S.top().height >= rect.height) {
        const auto pre = S.top();
        S.pop();
        auto area = pre.height * (i - pre.pos);
        chmax(max_v, area);
        target = pre.pos;
      }
      rect.pos = target;
      S.push(rect);
    }
  }
  return max_v;
}

int solve(int w, int h, vector<vi> &C) {
  vector<vi> T(h, vi(w + 1, 0));
  REP(y, h) {
    REP(x, w) {
      if (C[y][x]) continue;
      T[y][x] = (y > 0) ? T[y - 1][x] + 1 : 1;
    }
  }

  int max_v = 0;
  REP(y, h) { chmax(max_v, get_largest_rectangle(w, T[y])); }
  return max_v;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> C(h, vi(w));
  REP(y, h) { REP(x, w) cin >> C[y][x]; }

  cout << solve(w, h, C) << endl;
}


Measured memory_bytes: 18068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	char x;
	cin >> x;
	cout << (('a'<=x and x<='z') ? "a":"A") << endl;




}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int X[100];
int main() {
    int N,M,P;
    while(scanf("%d %d %d",&N,&M,&P),N) {
        int sum=0;
        for(int i=0;i<N;i++) scanf("%d",&X[i]),sum+=X[i]*100;
        sum-=sum*P/100;
        if(X[M-1]==0) printf("0\n"); else printf("%d\n",sum/X[M-1]);        
    }
}

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

long long gcd(long long a, long long b) {
    return a ? gcd(b % a, a) : b;
}

long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

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

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


Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(N,vector<int>(N-1));
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N-1; ++j){
      cin >> A[i][j];
      --A[i][j];
    }
  }
  int V = N*N;
  vector<vector<int>> G(V);
  vector<int> D(V,0);
  for(int i = 0; i < N; ++i){
    for(int j = 1; j < N-1; ++j){
      int a = A[i][j-1], b = i, c = A[i][j], d = i;
      if(a > b) swap(a,b);
      if(c > d) swap(c,d);
      int u = a*N + b, v = c*N + d;
      G[u].push_back(v);
      ++D[v];
    }
  }
  queue<int> Q;
  for(int i = 0; i < V; ++i){
    if(!D[i]) Q.push(i);
  }
  vector<int> dp(V,1);
  while(!Q.empty()){
    int v = Q.front();
    Q.pop();
    for(auto v_ : G[v]){
      --D[v_];
      dp[v_] = max(dp[v_],dp[v]+1);
      if(!D[v_])
        Q.push(v_);
    }
  }
  if(*max_element(D.begin(), D.end()) == 0){
    cout << *max_element(dp.begin(), dp.end()) << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 53120
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n
a1 b1
...
an bn
c1 d1
...
cn dn

n 100
a b c d < 2n
 */
typedef pair<int,int> pp;
int n;
pp red[100],blue[100];
int paired[100];

int main(){
  cin >> n;
  REP(i,n){
    int a,b;
    cin >> a >> b;
    red[i] = make_pair(a,b);
  }
  REP(i,n){
    int c,d;
    cin >> c >> d;
    blue[i] = make_pair(c,d);
  }

  sort(red,red+n);
  sort(blue,blue+n);

  int ans = 0;
  REP(i,n){
    LOG("i = %d\n", i);
    int max_y = -1;
    int max_y_j = 0;
    bool found = false;
    REP(j,n){
      if(red[j].first > blue[i].first){
        break;
      }
        
      if(red[j].first < blue[i].first && red[j].second < blue[i].second && red[j].second > max_y && !paired[j]){
        max_y_j = j;
        max_y = red[j].second;
        found = true;
      }
    }
    if(found){
      LOG("j = %d\n", max_y_j);
      paired[max_y_j] = true;
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
n=int(input())
s=[input() for i in range(n)]
dic={}
for i in range(n):
  for j in s[i]:
    if not(j in dic):
      dic[j]=[0 for i in range(n)]
    dic[j][i]+=1
ans=[]
for i in dic.keys():
  ans.append(i*min(dic[i]))
ans.sort()
print(*ans,sep='')

Measured memory_bytes: 3064
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll solve(ll num){
	if(num==-1)return 0;
	if(num%4==0)return num;
	ll lim=num/4*4;
	ll ans=0;
	for(ll i=lim;i<=num;i++)ans^=i;
	return ans;
}


int main(){	
	fastio;
	ll a,b;
	cin>>a>>b;
	cout<<(solve(b)^solve(a-1))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  int x, y; cin >> x >> y;
  int dp[2][333][666]; minus(dp);
  int const OFFSET = 333;

  dp[0][x][y+OFFSET] = 0;

  rep(i, N) {
    int a, b, c, d; cin >> a >> b >> c >> d;
    rep(j, 333) rep(k, 666) {
      if(dp[i&1][j][k] < 0) { continue; }
      auto& next = dp[(i+1)&1];
      auto& curr = dp[i&1];
      maximize(next[j][k], curr[j][k]);
      if(j-a >= 0 && k+b < 666) {
        maximize(next[j-a][k+b], curr[j][k]);
      }
      if(k-c > 0) {
        maximize(next[j][k-c], curr[j][k] + d);
      }
    }
  }

  int ans = 0;

  rep(i, 333) REP(j, OFFSET, 666) {
    if(dp[N&1][i][j] < 0) { continue; }
    maximize(ans, dp[N&1][i][j]);
  }

  cout << ans << endl;

  return 0;
}

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


int N;
int main(){
	cin >> N;
	int a[N];
	int ans;
	for(int i=0;i<N;i++){
		cin >> a[i];
		while(a[i] % 2 == 0){
			a[i] /=2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  int n;
  int a[21];
  int b[21];
  int c[21];
  int ans = 0;
  
  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i < n; i++){
    scanf("%d", &b[i]);
  }
  for(int i = 0; i < n-1; i++){
    scanf("%d", &c[i]);
  }

  for(int i = 0; i < n - 1; i++){
    ans += b[a[i] - 1];
    if(a[i] + 1 == a[i + 1]){
      ans += c[a[i] - 1];
    }
    //    printf("a[%d] = %d, ans = %d\n", i, a[i], ans);
  }
  ans += b[a[n-1] - 1];
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);
vi v;
void sieve() {
    vector<bool> isPrime(mxN + 1, true);
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i <= mxN; ++i) {
        if (isPrime[i]) {
            v.pb(i);
            for (int j = i * 2; j <= mxN; j += i)
                isPrime[j] = 0;
        }
    }
}
void solve(){
    //11
    int n;
    cin>>n;
    int cnt=1e9;
    loop(n,i,0){
        int x;
        cin>>x;
        int mn=0;
        while(x%2==0)
            x/=2,mn++;
        cnt=min(cnt,mn);
    }
    cout<<cnt<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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

using namespace std;

typedef pair<int, int> P;

int main() {
  int k, t;
  cin >> k >> t;
  priority_queue<P> que;
  for (int i = 0; i < t; i++) {
    int a;
    cin >> a;
    que.emplace(a, i);
  }
  int prev = -1;
  while (1 < que.size()) {
    P p = que.top();
    que.pop();
    P q = que.top();
    que.pop();
    p.first--, q.first--;
    if (p.first != 0) que.emplace(p);
    if (q.first != 0) que.emplace(q);
    prev = q.second;
  }
  if (que.empty()) {
    cout << 0 << endl;
  } else {
    P p = que.top();
    if (p.second == prev) {
      cout << p.first << endl;
    } else {
      cout << p.first - 1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(tmp);
            WriteLine(tmp[0] * tmp[1] / 2);
        }
    }
}

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

int main()
{
	int x = 1, y = 1;
	while (x != 0 || y != 0) {
		int a, b;
		cin >> x >> y;
		if (x != 0 || y != 0) {
			if (x < y) {
				a = x, b = y;
			}
			else if (x >= y) {
				a = y, b = x;
			}
			cout << a << " " << b << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){

   int N;
   string s;
   cin>> N>> s;

   string a[]={"S", "W"}, b[]={"S", "W"};
   for(int i=0; i<2; i++){
      for(int j=0; j<2; j++){
         string t=a[i]+b[j];
         for(int k=2; k<N; k++){
            if(t[k-1]=='S'){
               if(s[k-1]=='o'){
                  if(t[k-2]=='S') t+="S";
                  else t+="W";
               }else{
                  if(t[k-2]=='S') t+="W";
                  else t+="S";
               }
            }else{
               if(s[k-1]=='o'){
                  if(t[k-2]=='S') t+="W";
                  else t+="S";
               }else{
                  if(t[k-2]=='S') t+="S";
                  else t+="W";
               }
            }
         }
         // check
         string _s;
         for(int i=0; i<N; i++){
            if(t[i]=='S'){
               if(t[(i-1+N)%N]==t[(i+1)%N]) _s+="o";
               else _s+="x";
            }else{
               if(t[(i-1+N)%N]==t[(i+1)%N]) _s+="x";
               else _s+="o";
            }
         }

         if(s==_s){
            cout<< t<< endl;
            return 0;
         }
      }
   }

   cout<< -1<< endl;


   return 0;
}


Measured memory_bytes: 864