akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

//lli gcd(lli a,lli b){
//    if(b>a){
//        swap(a,b);
//    }
//    if(a%b==0){
//        return b;
//    }
//    else{
//        return gcd(b,a%b);
//    }
//}

struct domino{
    lli i,j;
    lli n;
    string s,t;
    vector<string> vec;
    domino(){
        cin>>n>>s>>t;
        vec.push_back(s);
        vec.push_back(t);
    }
    
    lli num(char a){
        if(a-'a'>=0){
            return a-'a';
        }
        else{
            return 27+a-'A';
        }
    }
    
    void search(){
        lli sum=3;
        rep(i,0,n){
//            cout<<i+1<<"番目の文字に注目"<<endl;
            if(i==0){
                if(vec[0][i]!=vec[1][i]){
                    sum*=2;
                    i++;
                }
            }
            else{
                if(vec[0][i-1]==vec[1][i-1]){
                    sum*=2;
                    if(vec[0][i]!=vec[1][i]){
                        i++;
                    }
                }
                else{
                    if(vec[0][i]!=vec[1][i]){
                        sum*=3;
                        i++;
                    }
                }
            }
            sum%=N;
        }
        cout<<sum<<endl;
    }
};

int main(){
    lli i,j;
    domino dom;
    dom.search();
}


Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[tuple(map(int,input().split())) for m in range(M)]
for i in range(10**N):
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strs = br.readLine().split(" ");
		int h = Integer.parseInt(strs[0]);
		int w = Integer.parseInt(strs[1]);
		
		int min = Integer.MAX_VALUE;
		for(int i = 0 ; i < 4 ; i++){
			int v = firstSplit(h,w,i<2 , i%2==0);
			min = (min > v)?v:min;
		}
		
		System.out.println(min);
	}
	public static int firstSplit(int h,int w,boolean splitH,boolean ForC){
		int xh,xw;
		if(splitH){
			xh = (int) ((ForC) ? Math.floor((double)h / 3.0) : Math.ceil((double)h / 3.0));
			xw = 0;
		}else{
			xw = (int) ((ForC) ? Math.floor((double)w / 3.0) : Math.ceil((double)w / 3.0));
			xh = 0;
		}
		
		return secondSplit(h - xh , w - xw ,((xh==0)?h:xh) * ((xw==0)?w:xw));
	}
	
	public static int secondSplit(int h,int w,int as){
		int[] vs = new int[4];
		vs[0] = (int)Math.floor((double)h/2.0) * w;
		vs[1] = (int)Math.ceil((double)h/2.0) * w;
		vs[2] = (int)Math.floor((double)w/2.0) * h;
		vs[3] = (int)Math.ceil((double)w/2.0) * h;
		
		int minv = Integer.MAX_VALUE;
		for(int ps : vs){
			int v = getValue(ps,h*w - ps , as);
			if(minv > v){
				minv = v;
			}
		}
		
		return minv;
	}
	
	
	public static int getValue(int a,int b,int c){
		int max = (a > b) ? a : b;
		max = (max > c) ? max : c;
		int min = (a < b) ? a : b;
		min = (min < c) ? min : c;
		
		return max-min;
	}
}


Measured memory_bytes: 21332
sx, sy, _tx, _ty = gets.split.map(&:to_i)
tx, ty = _tx - sx, _ty - sy

# s -> t
ty.times { print "U" }
tx.times { print "R" }

# t -> x
ty.times { print "D" }
tx.times { print "L" }

# s -> t
print "L"
(ty + 1).times { print "U" }
(tx + 1).times { print "R" }
print "D"

# t -> s
print "R"
(ty + 1).times { print "D" }
(tx + 1).times { print "L" }
print "U"

puts



Measured memory_bytes: 1788
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited_set = set([1])
visited_list = [1]
i = 0
loop_pos = 0
for _ in range(len(A)):
    if A[i] in visited_set:
        while A[i] != visited_list[loop_pos]:
            loop_pos += 1
        break
    visited_set.add(A[i])
    visited_list.append(A[i])
    i = A[i] - 1
if K < loop_pos:
    print(visited_list[K])
else:
    loop_len = len(visited_list) - loop_pos
    K -= loop_pos
    pos = loop_pos + (K % loop_len)
    print(visited_list[pos])


Measured memory_bytes: 32180
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll n, t = 0, a, f = 0, i;
    cin >> n;
    vector<ll> v(n + 5);
    for(i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] == 0)
            t = 1;
    }
    if(t){
        cout << 0 << endl;
        return 0;
    }
    a = 1;
    for(i = 0; i < n; i++){
       // cout << a * v[i] << endl;
        if(v[i] <= 1000000000000000000 / a){
                a *= v[i];
        }else{
            f = 1;
            break;
        }

    }
    if(f)
        cout << -1 << endl;
    else
        cout << a << endl;

    return 0;
}


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


using namespace std;

int main () {
  int N;
  cin>>N;
  
  vector<string> veca(N);
  for (int i=0;i<N;i++) {
    cin>>veca.at(i);
  }
  
  map<string,int> counta;
  for (int i=0;i<N;i++) {
    if (counta.find(veca.at(i))==counta.end()) {
      counta[veca.at(i)] = 1;
    }
    else {
      counta[veca.at(i)]++;
    }
  }
  
  int M;
  cin>>M;
  
  vector<string> vecb(M);
  for (int i=0;i<M;i++) {
    cin>>vecb.at(i);
  }
  
  map<string,int> countb;
  for (int i=0;i<M;i++) {
    if (countb.find(vecb.at(i))==countb.end()) {
      countb[vecb.at(i)] = 1;
    }
    else {
      countb[vecb.at(i)]++;
    }
  }
  
  int p = 0;
  for (int i=0;i<N;i++) {
    if (counta[veca.at(i)]-countb[veca.at(i)] >p) {
      p = counta[veca.at(i)]-countb[veca.at(i)];
    }
  }
  
  cout<<p<<endl;
  
  
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 1000000000;

int main()
{
	ios::sync_with_stdio(false);
	int d; ll g;
	cin >> d >> g;
	vector<int> p(d);
	vector<ll> c(d);
	for (int i = 0; i < d; i++)
		cin >> p[i] >> c[i];

	int result = INF;
	for (int mask = 0; mask < (1 << d); mask++)
	{
		int res = 0;
		ll score = 0;
		for (int i = 0; i < d; i++)
		{
			if (mask & (1 << i))
			{
				res += p[i];
				score += p[i] * (i + 1) * 100LL;
				score += c[i];
			}
		}
		if (score < g)
		{
			for (int i = d - 1; score < g && i >= 0; i--)
			{
				if ((mask & (1 << i)) == 0)
				{
					for (int j = 0; score < g && j < p[i]; j++)
					{
						res++;
						score += (i + 1) * 100LL;
						if (j == p[i] - 1)
							score += c[i];
					}
				}
			}
		}
		result = min(result, res);
	}
	cout << result << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) {
                return;
            }
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}


Measured memory_bytes: 35328
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;
  const int maxW = 3 * N;
  vector<int64_t> w(N);
  vector<int64_t> v(N);
  cin >> w[0] >> v[0];
  int64_t w0 = w[0];
  w[0] = 0;
  rep(i, N - 1) {
    cin >> w[i + 1] >> v[i + 1];
    w[i + 1] -= w0;
  }
  vector<vector<int64_t>> DP(N + 1, vector<int64_t>(maxW + 1, 0));
  for (int i = 0; i < N; ++i) {
    for (int j = maxW; j >= 0; --j) {
      if ((j + w[i]) > maxW) continue;
      for (int k = N - 1; k >= 0; --k) {
        DP[k + 1][j + w[i]] = max(DP[k + 1][j + w[i]], DP[k][j] + v[i]);
      }
    }
  }

  int64_t answer = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = maxW; j >= 0; --j) {
      int64_t limW = w0 * (int64_t)i;
      if (limW + j > W) continue;
      answer = max(answer, DP[i][j]);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}



///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(1); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

ll n; cin>>n;
vv<ll> h(n), dp(n+1,0);
for(int i=0;i<n;++i) cin>>h[i];
dp[1]=0;
dp[2]=abs(h[0]-h[1]);
for(int i=3;i<=n;++i){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
}
// for(auto& e: dp) cerr<<e<<' '; cerr<<'\n'; 
cout<< dp[n] <<'\n'; 


return 0;
}


Measured memory_bytes: 1792
A,B,K=list(map(int,input().split()))

max_=A+K-1
min_=B-K+1
if max_<min_:
    for i in range(A,max_+1):
        print(i)
    for i in range(min_,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int c = 0;
	for (int i = a; i <= b; i++) {
		int i1 = i % 10;
		int i2 = (i % 100) / 10;
		int i4 = (i % 10000) / 1000;
		int i5 = i / 10000;
		if (i1 == i5 && i2 == i4) c++;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
long d[1<<18]={0,0,1,6,19,65},M=998244353,m;b,c,N,s[4];
main(f){
	for(m=M-3;read(0,&c,1),c-10;s[c-97]++,f&=b!=c,b=c)
		m=!N|N++%3?m:(m+m)%M,
		d[N+5]=(5*d[N+4]-6*d[N+3]+2*d[N+2]-10*d[N+1]+12*d[N]+M*20)%M;
	printf("%d\n",!*s+!s[1]+!s[2]>1?:N<3?N:(d[N]+(N%3|*s%3-s[2]%3?f:N>3?m+f:m))%M);
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int d = ReadInt();
        int[] c = ReadInt(26).ToArray();
        int[][] s = new int[d][];
        for (int i = 0; i < d; i++) s[i] = ReadInt(26).ToArray();

        int[] t = ReadInt(d).ToArray();

        foreach (int score in Calc(c, s, t, d))
        {
            Console.WriteLine(score);
        }
    }

    IEnumerable<int> Calc(int[] c, int[][] s, int[] t, int d)
    {
        int score = 0;
        int[] last = new int[26];
        for (int i = 1; i <= d; i++)
        {
            score += s[i - 1][t[i - 1] - 1];
            last[t[i - 1] - 1] = i;
            for (int j = 1; j <= 26; j++)
            {
                score -= (i - last[j - 1]) * c[j - 1];
            }
            yield return score;
        }
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 29616
#include <stdio.h>
#include <stdlib.h>

typedef struct List {
	struct List *next;
	int v, len;
} list;

int main()
{
	int i, N, M, L[200001], R[200001], D[200001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d %d", &(L[i]), &(R[i]), &(D[i]));
	
	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *d = (list*)malloc(sizeof(list) * M * 2);
	for (i = 0; i < M; i++) {
		d[i*2].v = R[i+1];
		d[i*2+1].v = L[i+1];
		d[i*2].len = D[i+1];
		d[i*2+1].len = -D[i+1];
		d[i*2].next = adj[L[i+1]];
		d[i*2+1].next = adj[R[i+1]];
		adj[L[i+1]] = &(d[i*2]);
		adj[R[i+1]] = &(d[i*2+1]);
	}
	
	int u, w, flag[100001] = {}, q[100001], head, tail;
	long long dist[100001];
	list* p;
	for (i = 1; i <= N; i++) {
		if (flag[i] == 1) continue;
		flag[i] = 1;
		dist[i] = 0;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (p = adj[u]; p != NULL; p = p->next) {
				w = p->v;
				if (flag[w] == 0) {
					flag[w] = 1;
					dist[w] = dist[u] + p->len;
					q[tail++] = w;
				} else if (dist[w] != dist[u] + p->len) break;
			}
			if (p != NULL) break;
		}
		if (head < tail) break;
	}
	if (i > N) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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

int main()
{
  int a, b, c;
  int res=0;
  cin >> a >> b >> c;

  res = max(0, c-(a-b));
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const ll INF=1e15;
int N;
ll a[16][16];
ll dp[1<<16];
void dfs(int x){
    rep(i,0,N){
        if(x==(1<<i)){
            dp[x]=0;
            return;
        }
    }
    ll ans=0;
    rep(i,0,N){
        rep(j,i+1,N){
            if(x&(1<<i)&&x&(1<<j)) ans+=a[i][j];
        }
    }
    rep(i,1,x){
        if((i|x)==x){
            if(dp[i]==INF) dfs(i);
            if(dp[x-i]==INF) dfs(x-i);
            ans=max(dp[i]+dp[x-i],ans);
        }
    }
    dp[x]=ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N){
        rep(j,0,N){
            cin>>a[i][j];
        }
    }
    fill(dp,dp+(1<<N),INF);
    dfs((1<<N)-1);
    cout <<dp[(1<<N)-1]<<"\n";
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n >>s;
	
	rep(i, 4){
		VI ck(n+1, -1);
		bool ok=true;
		ck[0] = i&1; ck[1] = (i>>1) &1;
		rep2(i, 1, n){
			if(ck[i]==0){
				if(s[i]=='o') ck[i+1]=ck[i-1];
				else ck[i+1] = (ck[i-1]+1)%2;
			}else{
				if(s[i]=='o') ck[i+1] = (ck[i-1]+1)%2;
				else ck[i+1] = ck[i-1];
			}
		}
		if(ck[0] != ck[n]) ok=false;
		if(ck[0]==0 && s[0]=='o'&& ck[1] != ck[n-1]) ok=false;
		if(ck[0]==0 && s[0]=='x'&& ck[1] == ck[n-1]) ok=false;
		if(ck[0]==1 && s[0]=='o'&& ck[1] == ck[n-1]) ok=false;
		if(ck[0]==1 && s[0]=='x'&& ck[1] != ck[n-1]) ok=false;
		if(ok){
			rep(i, n) cout <<(ck[i]==0? 'S':'W');
			cout <<"\n";
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 924
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(int x) {
	if (x % 2 != 0)return 0;
	return 1 + func(x / 2);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,K,x[100010];
	int ans = 3 * 100000000;
	cin >> N >> K;
	REP(i, N)cin >> x[i];

	for (int i = 0; i <= N-K;i++) {
		int l = i;
		int r = i + K -1;
		ans = min(ans,min(abs(x[l]), abs(x[r]))+abs(x[r]- x[l]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

LL gcd(LL a, LL b) {
	if (!b)
		return a;
	return gcd(b, a % b);
}

int main() {
	int N, K;
	LL V, M, x;
	cin >> N >> K;
	cin >> V;
	M = V;
	FOR (i, N - 1) {
		cin >> x;
		V = gcd(V, x);
		M = max(M, x);
	}
	if (K <= M && K % V == 0)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int a=read();
    int sum=a;
    sum+=a*a+a*a*a;
    writeln(sum);
    return 0;
}

Measured memory_bytes: 3616
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,k,ans;

int dp[4010][2010];

void Work(){
	dp[1][1]++;dp[1][k]=(mod-1);
	REP(i,1,n+m)
		REP(j,1,n)if(dp[i][j]=(dp[i][j]+dp[i][j-1])%mod){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			dp[i+1][min(n+1,(int)j+k)]=(dp[i+1][min(n+1,(int)j+k)]+mod-dp[i][j])%mod;
			if((n-j)%(k-1)==0&&(k-1)*i-j<m&&(j+m-1)%(k-1)==0)ans=(ans+dp[i][j])%mod;
		}
	iout(ans);
}

void Init(){
	read(n,m,k);
}

int main(){
	Init();
	Work();
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int l, r, d;
  cin >> l >> r >> d;

  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0) {
      ans++;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int tenth = x % 100;
        int count = 0;
        int i105 = (int)Math.floor(tenth/5.0);
        tenth -= i105*5;
        count += i105;
        int i104 = (int)Math.floor(tenth/4.0);
        tenth -= i104*4;
        count += i104;
        int i103 = (int)Math.floor(tenth/3.0);
        tenth -= i103*3;
        count += i103;
        int i102 = (int)Math.floor(tenth/2.0);
        tenth -= i102*2;
        count += i102;
        int i101 = (int)Math.floor(tenth/1.0);
        tenth -= i101*1;
        count += i101;
        System.out.println(count*100<=x ? 1 : 0);
    }
}


Measured memory_bytes: 23764
/* ex 5_4
   cy_an  */

#include <stdio.h>

int main(void){
    // 10文字以下なので最大の要素数は\0を含めて11
    // ptr: sequenceのポインターを取得する変数
    // score: ACGT文字列の長さ出力用の変数
    // tmp: 一時保存用の変数
    char sequence[11], *ptr;
    int score = 0, tmp = 0;
    // sequenceの入力
    scanf("%s", sequence);
    // ptrの初期化
    ptr = &sequence[0];
    // 文字の判定 \0に当たっても1回はループを回したいのでprt-1
    while(*(ptr-1)){
        // ATGCのとき、tmpをカウントアップ
        if(*ptr == 'A' || *ptr == 'T' || *ptr == 'G' || *ptr == 'C'){
            tmp++;
        }else{
            // ATGC以外のときtmpがscoreより高ければ書き換え
            if(score < tmp){
                score = tmp;
            }
            // tmpの初期化
            tmp = 0;
        }
        ptr++;
    }
    // scoreの出力
    printf("%d\n", score);
    return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 23 22:15:42 2018
ABC050C
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))

a.sort()
flag = 1
if n%2 == 0:
    for i in range(0,n,2):
        if a[i] != i+1:
            flag = 0
            break
        elif a[i+1] != i+1:
            flag = 0
            break
    if flag == 0:
        print(0)
    else:
        ans = 2**(n//2) % (10**9+7)
        print(ans)
else:
    if a[0] != 0:
        flag = 0
    else:
        for i in range(2,n,2):
            if a[i-1] != i:
                flag = 0
                break
            elif a[i] != i:
                flag = 0
                break
    if flag == 0:
        print(0)
    else:
        ans = 2**((n-1)//2) % (10**9+7)
        print(ans)

Measured memory_bytes: 14024
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    bool key = false;
    long long start,goal;
    long long ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'&&key==false){
            key=true;
            start=i;
        }
        else if(s[i]=='Z'&&key==true){
            ans=max(ans,i-start+1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

class ARingring {
public:
    void solve(std::istream& in, std::ostream& out) {
        int a, b, c;
        in >> a >> b >> c;

        out << min(min(a + b, b + c), a + c);
    }
};


int main() {
	ARingring solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  int A[Q];
  for (int i = 0; i < Q; i++) {
    cin >> A[i];
    A[i]--;
  }
  int p[N]{};
  for (int i = 0; i < Q; i++) {
    p[A[i]]++;
  }
  for (int i = 0; i < N; i++) {
    if (K - Q + p[i] <= 0) cout << "No\n";
    else cout << "Yes\n";

  }
  return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    int cnt = 0;
    cin >> h >> w;
    vector<vector<int> > a(h, vector<int>(w, 0));
    vector<int> ope;
    rep (i, h) rep (j, w) cin >> a[i][j];
    rep (i, h) {
        if (i % 2) {
            for (int j = w - 1; j >= 0; --j) {
                if (a[i][j] % 2) {
                    if (j != 0) {
                        a[i][j - 1]++;
                        ope.push_back(i + 1);
                        ope.push_back(j + 1);
                        ope.push_back(i + 1);
                        ope.push_back(j);
                        cnt++;
                    } else {
                        if (i != h - 1) {
                            a[i + 1][j]++;
                            ope.push_back(i + 1);
                            ope.push_back(j + 1);
                            ope.push_back(i + 2);
                            ope.push_back(j + 1);
                            cnt++;
                        }
                    }
                }
            }
        } else {
            rep (j, w) {
                if (a[i][j] % 2) {
                    if (j != w - 1) {
                        a[i][j + 1]++;
                        ope.push_back(i + 1);
                        ope.push_back(j + 1);
                        ope.push_back(i + 1);
                        ope.push_back(j + 2);
                        cnt++;
                    } else {
                        if (i != h - 1) {
                            a[i + 1][j]++;
                            ope.push_back(i + 1);
                            ope.push_back(j + 1);
                            ope.push_back(i + 2);
                            ope.push_back(j + 1);
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    rep (i, ope.size()) {
        if (i % 4 == 3) cout << ope[i] << endl;
        else cout << ope[i] << " ";
    }
    
    
    return 0;
}



Measured memory_bytes: 5236
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

ll N;
vector<ll> A;
vector<pll> retu;
ll vis[100005];
int main() {
	cin >> N;
	A.resize(N);

	rep(i, N) {

		cin >> A[i];
		vis[A[i]] += 1;
	}
	ll ans = 1;
	if (N % 2 == 0) {
		for (int i = 1; i <= N-1; i += 2) {
			if (vis[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			ans *= 2;
			ans %= mod;
		}
	}

	else {
		for(int i = 0; i <= N-1; i += 2){
			if (i != 0 && vis[i] != 2) {
				cout << 0 << endl;
				return 0;
			}

			else if (i == 0 && vis[i] != 1) {
				cout << 0 << endl;
				return 0;

			}
		
			if (i != 0) {
				ans *= 2;
			}
			ans %= mod;
		}


	}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define elif else if
#define rep(i,n) for((int)(i)=0;(i)<(n);++(i))
#define str string
#define Cout(a) cout<<(a)<<endl;
int a,b,c,i,j,k,n,m,x,y,cnt=0,ans=0;
str s,t;

int main(){
  cin>>n;
  cout<<n*(n+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5+1;
string s;
int x;
map<int, int> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  m[0] = 0;
  FOR(i, 0, sz(s)-1){
    x ^= 1<<(s[i]-'a');
    if(m.find(x)==m.end()) m[x] = IINF;
    FOR(j, 0, 26){
      int _x = x^(1<<j);
      if(m.find(_x)!=m.end()) mins(m[x], m[_x]+1);
    }
  }
  x ^= 1<<(s[sz(s)-1]-'a');
  int ans = IINF;
  FOR(j, 0, 27){
    int _x = (j==26 ? x : x^(1<<j));
    if(m.find(_x)!=m.end()) mins(ans, m[_x]+1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9876
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
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; }

// Sieve of Eratosthenes
// 素因数分解のライブラリ
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
ll n;
bool solve(ll y){
    ll temp = n;
    while(temp%y==0){
        temp/=y;
    }
    temp%=y;
    if(temp==1){
        return true;
    }
    return false;
}
vector<ll> f(ll n){
    vector<ll> factor;
    for(ll i=1;i*i<=n;i++){
        if(n%i!=0)continue;
        factor.push_back(i);
        if(i*i!=n)factor.push_back(n/i);
    }
    return factor;
}

int main(){

    cin >> n;
    Sieve si(1e6);
    vector<ll> fo;
    fo=f(n-1);
    vector<ll> po;
    po=f(n);
    ll ans = fo.size();
    ans--;

    rep(i,po.size()){
        if(po[i]==1)continue;
        if(solve(po[i]))ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4732
import numpy as np
import sys

input = sys.stdin.readline


N,M,X = map(int,input().split())

left = 0
right = 0
a = list(map(int,input().split()))

for i in a:
    if i < X:
        left +=1
    else:
        right += 1

print(min( left,right))

Measured memory_bytes: 12392
M, D = map(int, input().split())

ans = 0

for i in range(1, M+1):
    for j in range(1, D+1):
        if len(str(j)) >= 2:
            if int(str(j)[0]) >= 2 and int(str(j)[1]) >= 2 and int(str(j)[0]) * int(str(j)[1]) == i:
                ans += 1


print(ans)


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

using namespace std;

long foo(long first, const vector<long> &vec) {
  long current = 0;
  long limit = first;
  long ret = 0;
  for (auto num: vec) {
    current += num;
    if (limit == 1 and current < 1) {
      ret += limit - current;
      current = limit;
    } else if (limit == -1 and current > -1) {
      ret += current - limit;
      current = limit;
    }
    limit *= -1;
  }
  return ret;
}

void solve() {
  long n;
  cin >> n;
  vector<long> a(n);
  rep (i, n) cin >> a[i];
  cout << min(foo(-1, a), foo(1, a)) << endl;
}

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


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){
	
	int w, h;
	
	string str;
	
	string ans = " ";
	int ans2 = 0;
	
	cin >> h >> w;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> str;
			if(str == "snuke"){
				ans[0] = 'A' + j;
				ans2 = i + 1;
			}
		}
	}
	
	cout << ans << ans2 << endl;
	
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a1(n);
    for (int i = 0; i < n; i++) {
        cin >> a1.at(i);
    }
    vector<int> a2(n);
    for (int i = 0; i < n; i++) {
        cin >> a2.at(i);
    }

    vector<int> a1sum(n);
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            a1sum.at(i) = a1.at(i);
        } else {
            a1sum.at(i) = a1sum.at(i-1) + a1.at(i);
        }
    }
    vector<int> a2sum(n);
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            a2sum.at(i) = a2.at(i);
        } else {
            a2sum.at(i) = a2sum.at(i-1) + a2.at(i);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans = a1sum.at(i) + a2sum.at(n-1);
        } else {
            ans = max(ans, a1sum.at(i) + a2sum.at(n-1) - a2sum.at(i-1));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# vim: set fileencoding=utf-8:


def main():
    H, W = map(int, raw_input().split())
    a = [0] * H
    for i in xrange(H):
        a[i] = list(raw_input())

    b = a
    # 列の圧縮
    for i in xrange(W):
        v = ""
        for j in xrange(len(a)):
            v += a[j][i]

        if set(v) == set(".#") or set(v) == set("#"):
            pass
        else:
            for j in xrange(len(a)):
                a[j][i] = "e"

    b = []
    for ele in a:
        val = ''.join(ele).replace("e", "")
        b.append(list(val))

    for i in xrange(len(b)):
        v = ""
        for j in xrange(len(b[0])):
            v += b[i][j]

        if set(v) == set(".#") or set(v) == set("#"):
            pass
        else:
            for j in xrange(len(b[0])):
                b[i][j] = "e"

    c = []
    for ele in b:
        val = ''.join(ele).replace("e", "")
        if val != '':
            print(val)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2820
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )



int D, N;
int A[200010];
ull DP[200010];
ull PQRS[20010][4];

string S;
int w;

int main() {
    cin >> S;
    cin >> w;
    for(int i = 0; i < S.size(); i+=w) {
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
Sum =0
for i in range(len(A)):
  Sum += (A[0]-A[i])**2
Answer = Sum
for j in range(-100,101):
  Sum =0
  for k in range(len(A)):
    Sum+= (A[k]-j)**2
  Answer =min(Answer, Sum)
print(Answer)
  


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll m;
	cin>>m;
	set<ll>q[26];
	for(ll i=0;i<n;i++){
		ll now=s[i]-'a';
		q[now].insert(i);
	}
	for(ll i=0;i<m;i++){
		ll now;
		cin>>now;
		if(now==2){
			ll l,r;
			cin>>l>>r;
			l--;
			ll cnt=0;
			for(ll j=0;j<26;j++){
				auto itr1=q[j].lower_bound(l);
				auto itr2=q[j].lower_bound(r);
				if(itr1!=itr2){
					cnt++;
				}
			}
			cout <<cnt<<endl;
		}
		if(now==1){
			ll x;
			char z;
			cin>>x>>z;x--;
			char next=s[x];
			ll nextwo=next-'a';
			q[nextwo].erase(x);
			s[x]=z;
			nextwo=z-'a';
			q[nextwo].insert(x);
		}
	}
	// your code goes here
	return 0;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        fsc.close();
        long[][] ht=new long[10][10];
        for(int i=1;i<=n;i++){
            char[] c=Integer.toString(i).toCharArray();
            int h=Integer.valueOf(c[0]-'0');
            int t=Integer.valueOf(c[c.length-1]-'0');
            ht[h][t]++;
        }
        long ans=0;
        for(int ha=1;ha<=9;ha++){
            for(int ta=1;ta<=9;ta++){
                ans+=ht[ha][ta]*ht[ta][ha];
            }
        }
        System.out.println(ans);
    }
    

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


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

int main() {
  int k, ans = 0;std::cin >> k;
  int num[k+1];
  for(int i=0;i<=k;i++) num[i] = 0;
  for(int i=k;i>0;i--){
    num[i] += (k/i)*(k/i)*(k/i);
    for(int j=2;j*j<=i;j++){
      if(i%j!=0) continue;
      num[j] -= num[i];
      if(j*j!=i) num[i/j] -= num[i];
    }
    if(i!=1) num[1] -= num[i];
    ans += num[i] * i;
  }
  std::cout << ans << '\n';
}



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

int main() {
  
  int n, m;
  cin >> n >> m;
  
  int a = 0;
  int b = 0;
  
  if(n >= 2){
    
    a = (n * (n - 1)) / 2;
  }
  
  if(m >= 2){
    b = (m * (m - 1)) / 2;
  }
  
  int total = a + b;
  cout << total << endl;
 
}



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

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

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

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

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

  string s;
  cin >> s;
  ll n = s.size();
  ll ans = 0;
  bool sys_flag;
  REP1(i, n){
    sys_flag = true;
    if((n-i)%2 == 1)
      continue;
    REP(j, (n-i)/2){
      if(s[j] != s[(n-i)/2+j]){
        sys_flag = false;
        break;
      }
    }
    if(sys_flag){
      ans = n-i;
      break;
    }
  }

  cout << ans << endl;





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
inline int read(){char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 1e3 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9+7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ull n,sum = 0;
    cin >> n;
    ull arr[n+5] = {0},ans[n+5] = {00};
    for(int i = 1;i <= n;i++) cin >> arr[i];
    for(int i = 1;i <= n;i++) ans[i] = (arr[i]+ans[i-1]);
    for(int i = 1;i <= n;i++) sum = ((sum + arr[i]*((ans[n]-ans[i])%mod))%mod)%mod;
    cout << sum << endl;
}


Measured memory_bytes: 6776
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Point {
  lli x, y, r;
};

lli n;
Point p[1003];
double mat[1003][1003];
double dist[1003];
bool fix[1003];

int main() {
  cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y >> n;
  p[0].r = p[1].r = 0;
  for (lli i=0; i<n; ++i) {
    lli j=i+2;
    cin >> p[j].x >> p[j].y >> p[j].r;
  }
  lli m = n+2;

  for (lli i=0; i<m; ++i) {
    for (lli j=i+1; j<m; ++j) {
      lli dx = p[i].x-p[j].x, dy = p[i].y-p[j].y;
      double d = sqrt(double(dx*dx + dy*dy));
      mat[i][j] = mat[j][i] = max(0.0, d-p[i].r-p[j].r);
    }
  }

  using P = pair<double, lli>;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.emplace(0.0, 0);
  fill(&dist[0], &dist[1002], 1e18);
  dist[0] = 0.0;

  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    double d = p.first; lli v = p.second;
    if (fix[v]) continue;
    fix[v] = true;
    dist[v] = d;
    for (lli u=0; u<m; ++u) {
      if (fix[u]) continue;
      double e = d + mat[v][u];
      if (e < dist[u]) {
        pq.emplace(e, u);
      }
    }
  }

  printf("%.15lf\n", dist[1]);
  return 0;
}


Measured memory_bytes: 18412
N = int(input())

data1 = []
data2 = []
for i in range(N):
    x,y = map(int,input().split())
    data1.append(x+y)
    data2.append(y-x)

p = max(data1)-min(data1)
q = max(data2)-min(data2)

print(max(p,q))

Measured memory_bytes: 100492