akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Long = long long;
using pii = pair<int,int>;
#define ff first
#define ss second

const int N = 1e3 + 1;

int n , m;
int Cx , Cy;
int Dx , Dy;
char grid[N][N];
int moves[N][N];
const int INF = 1e9;

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

int bfs( int x , int y ){
    for( int i = 0 ; i < n ; ++i ){
        for( int j = 0 ; j < m ; ++j ){
            moves[i][j] = INF;
        }
    }
    moves[x][y] = 0;
    deque<pii> Q;
    Q.push_front({x , y});

    while( !Q.empty() ){

        pii nx = Q.front();
        int x0 = nx.ff;
        int y0 = nx.ss;
        Q.pop_front();

        for( int i = 0 ; i < 4 ; ++i ){
            
            int x1 = x0 + dx[i];
            int y1 = y0 + dy[i];

            if( x1 >= 0 && y1 >= 0 && x1 < n && y1 < m && grid[x1][y1] == '.'){
                if( moves[x1][y1] > moves[x0][y0] ){
                    moves[x1][y1] = moves[x0][y0];
                    Q.push_front({x1 , y1});
                }
            }
        }

        for( int i = -2 ; i <= 2 ; ++i ){
            for( int j = -2 ; j <= 2 ; ++j ){
                int x2 = x0 + i;
                int y2 = y0 + j;

                if( x2 >= 0 && x2 < n && y2 >= 0 && y2 < m && grid[x2][y2] == '.' ){
                    if( moves[x2][y2] > moves[x0][y0] + 1 ){
                        moves[x2][y2] = moves[x0][y0] + 1;
                        Q.push_back({x2 , y2});
                    }
                }
            }
        }
    }

    if( moves[Dx][Dy] == INF ) return -1;
    return moves[Dx][Dy];
}

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

    cin >> n >> m;
    cin >> Cx >> Cy;
    --Cx ; --Cy;
    cin >> Dx >> Dy;
    --Dx ; --Dy;

    for( int i = 0 ; i < n ; ++i ){
        for( int j = 0 ; j < m ; ++j ){
            cin >> grid[i][j];
        }
    }

    cout << bfs( Cx , Cy );
    return 0;
}

Measured memory_bytes: 8604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll a, b, c, d, n, m, ans = 0, ret = M;
	string s, t;
	bool flag = false;
	cin >> n >> m;
	vll v(m), w(m),res(m);
	rep(i, m) cin >> v[i] >> w[i];
	reverse(all(v));
	reverse(all(w));
	UnionFind tree(n);

	rep(i, m) {
		res[i] = n * (n - 1) / 2 - ans;
		v[i]--, w[i]--;
		if (tree.root(v[i]) != tree.root(w[i])) {
			ans += tree.size(v[i])*tree.size(w[i]);
			tree.unite(v[i], w[i]);
		}
	}
	repr(i, m) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 4096
var n,m,k:longint;
    i,j:longint;
    x:longint;
begin
  read(n,m,k);
  for i:=0 to m do
  begin
    x:=i*n;
    for j:=0 to n do
    begin
      if x-(2*j*i)+j*m=k then
      begin
        writeln('Yes');
        exit;
      end;
    end;
  end;
  writeln('No');
end.

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

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

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	ll count = 0;
	ll a_num, c_num;
	for (int i = 0; i < n; i++) {
		a_num = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		c_num = n - (lower_bound(c.begin(), c.end(), b[i] + 1) - c.begin());
		count += a_num * c_num;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1408
import math

if __name__ == '__main__':
    a, b, C = [int(i) for i in input().split()]
    theta = math.radians(C)
    S = a * b * math.sin(theta) / 2
    c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta))
    L = a + b + c
    h = b * math.sin(theta)
    [print("{0:.5f}".format(i)) for i in [S, L, h]]

Measured memory_bytes: 6868
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	class Item
	{
		public int Weight { get; set;}
		public long Cost { get; set;}
	}
	public static void Main(string[] args)
	{
		string[] p = Input();
		int n = p[0].ToInt();
		int w = p[1].ToInt();
		int[] weights = new int[n];
		long[] costs = new long[n];
		Item[] items = new Item[n];
		for(int i = 0; i < n; i++)
		{
			p = Input();
			var item = new Item();
			item.Weight = p[0].ToInt();
			item.Cost = p[1].ToLong();
			items[i]=item;
		}
		
		long[,] dp = new long[n+1, w+10];
		for(int i = 0; i < n; i++)
		{
			for(int j =0 ; j <= w; j++)
			{
				if(j - items[i].Weight >= 0)
				{
					dp[i+1,j] = Math.Max(dp[i,j-items[i].Weight]+items[i].Cost, dp[i+1,j]);
				}
				dp[i+1,j] = Math.Max(dp[i,j], dp[i+1,j]);
			}
		}
		Console.WriteLine(dp[n,w]);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

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

int main() {
  long int n, k;
  cin >> n >> k;

  if (k == 1) {
    cout << '0' << endl;
    return 0;
  } else {
    cout << min(n % k, k - (n % k)) << endl;
  }
}


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

int main() {
	int n,x;
	int h[23];
	//
	{
		h[0] = 0;
		h[1] = 0;
		h[2] = 0;
		h[3] = 0;
		h[4] = 0;
		h[5] = 0;
		h[6] = 0;
		h[7] = 0;
		h[8] = 0;
		h[9] = 0;
		h[10] = 0;
		h[11] = 0;
		h[12] = 0;
		h[13] = 0;
		h[14] = 0;
		h[15] = 0;
		h[16] = 0;
		h[17] = 0;
		h[18] = 0;
		h[19] = 0;
	}
	for (int i = 0; i < 20; i++){
		cin >> n;
		if (n == 0){
			x = i;
			break;
		}
		for (int j = 1; j < (n + 1); j++){
			if (j % 5 == 0) {
				h[i] += 1;
				if ((j / 5) % 5 == 0){
					h[i] += 1;
					if ((j / 25) % 5 == 0){
						h[i] += 1;
						if ((j / 125) % 5 == 0) {
							h[i] += 1;
							if ((j / 625) % 5 == 0){
								h[i] += 1;
								if ((j / 3125) % 5 == 0){
									h[i] += 1;
								}
							}
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < x; i++){
		cout << h[i] << endl;
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3044
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, k, h[100100];
ll dp[100100];

ll rec(ll i) {
    if(dp[i] != inf) return dp[i];

    if(i == 0) return 0;

    ll res = inf;
    for(int j = 1; j <= k; j++){
        if(i - j >= 0) res = min(res, rec(i-j) + abs(h[i] - h[i-j]));
    }

    return dp[i] = res;
}

int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];

    for(int i = 0; i < 100100; i++) dp[i] = inf;

    cout << rec(n-1) << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<string>
using namespace std;


int main() {
	long long int N, T[1000000], X[1000000], Y[10000000];
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> T[i] >> X[i] >> Y[i];
	}
	T[0] = 0;
	X[0] = 0;
	Y[0] = 0;
	int R = 0;
	for (int i = 0; i < N; i++) {
		if (T[i + 1] - T[i] >= ((X[i + 1] - X[i]) + (Y[i + 1] - Y[i]))) {
			if (T[i+1] % 2 == (X[i+1] + Y[i+1]) % 2) {

			}
			else {
				R++;
			}
		}
		else {
			R++;
		}
	}
	if (R == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
namespace fastio{
	char in[100000];
	int itr=0,llen=0;
	char get(){
		if(itr==llen)llen=fread(in,1,100000,stdin),itr=0;
		if(llen==0)return EOF;
		return in[itr++];
	}
	char out[100000];
	int itr2=0;
	void put(char c){
		out[itr2++]=c;
		if(itr2==100000){
			fwrite(out,1,100000,stdout);
			itr2=0;
		}
	}
	int clear(){
		fwrite(out,1,itr2,stdout);
		itr2=0;
		return 0;
	}
	int getint(){
    	int r=0; bool ng=0; char c; c=get();
    	while (c!='-'&&(c<'0'||c>'9')) c=get();
   		if (c=='-') ng=1, c=get();
    	while (c>='0'&&c<='9') r=r*10+c-'0', c=get();
    	return ng?-r:r;
	}
	string getstr(){
		string ret="";
		char ch=get();
		while(ch==' '||ch=='\n')ch=get();
		while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get();
		return ret;
	}
	void putstr(string s){
		for(int i=0;i<s.size();i++)put(s[i]);
	}
	void putint(int x){
		if(x<0){
			put('-');
			x=-x;
		}
		if(x==0){
			put('0');
			return;
		}
		char c[20];int pos=0;
		while(x){
			c[pos++]='0'+x%10;
			x/=10;
		}
		for(int i=pos-1;i>=0;i--)put(c[i]);
	}
	void getarr(int arrname[],int size){
		 for(int i=0;i<size;i++)arrname[i]=getint();
	}
}
using namespace fastio;
#define fastio
int n;
int a[200005];
int dp[200005][5];
signed main(){
	n=getint();
	for(int i=1;i<=n;i++)a[i]=getint();
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]+a[i];
		dp[i][1]=min(dp[i][0],(a[i]==0?2:0)+min(dp[i-1][0]+(a[i]&1),dp[i-1][1]+(a[i]&1)));
		dp[i][2]=min(dp[i][1],min(dp[i-1][1]+1-(a[i]&1),dp[i-1][2]+1-(a[i]&1)));
		dp[i][3]=min(dp[i][2],(a[i]==0?2:0)+min(dp[i-1][2]+(a[i]&1),dp[i-1][3]+(a[i]&1)));
		dp[i][4]=min(dp[i][3],min(dp[i-1][4],dp[i-1][3])+a[i]);
	}
	cout<<dp[n][4]<<endl;
	clear();
	return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
inline ll rit(){
    ll f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
ll ar[300005];
int main(void){
	ll n;
	RI(n);
	for(int i=0;i<n*3;++i) RI(ar[i]);
	sort(ar,ar+n*3);
	ll ans=0;
	for(ll i=1;i<=n;++i) ans+=ar[3*n-i*2];
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;
import std.numeric;

void main() {
  long n;
  readf("%d\n", &n);

  auto xs = readln.strip.split(" ").map!(to!long).array;
  xs = sort(xs).array;

  writeln(reduce!(gcd)(xs[0], xs));
}


Measured memory_bytes: 6964
#include<stdio.h>

int max=100;

int main(){
  int x[max][max];
  int n, i, j, u, v, num;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      x[i][j]=0;
    }
  }
  for(i=0 ; i<n ; i++){
    scanf("%d%d",&u, &num);
    u=u-1;
    for(j=0 ; j<num ; j++){
      scanf("%d", &v);
      v=v-1;
      x[u][v]=1;
    }
  }
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      if(j!=0)printf(" ");
      printf("%d", x[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];
char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;
	int result = 0;

	i = strlen(s);
	j = strlen(t);
	if (i > j) {
		result = +1;
	} else if (i < j) {
		result = -1;
	} else {
		for (i = 0; s[i]; i++) {
			if (s[i] > t[i]) {
				result = +1;
			} else if (s[i] < t[i]) {
				result = -1;
			} else {
				continue;
			}
			break;
		}
	}

	switch (result) {
	case -1:
		puts("LESS");
		break;
	case 0:
		puts("EQUAL");
		break;
	case +1:
		puts("GREATER");
		break;
	}

	return 0;
}
 
int main(void){
	int i, j;
	int x;

	scanf("%s%s", s, t);

	solve();

	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	static int mod = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		ArrayList<Integer> plus = new ArrayList<Integer>();
		ArrayList<Integer> minus = new ArrayList<Integer>();
		int zero_cnt = 0;
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			if (A[i]>0) plus.add(A[i]);
			if (A[i]<0) minus.add(-A[i]);
			if (A[i]==0) zero_cnt++;
		}

		if (N==K) {
			long ans = 1L;
			for (int i=0;i<N;i++) {
				long val = A[i];
				if (val<0) {
					val += mod;
				}
				ans = ans*val%mod;
			}
			System.out.println(ans);
			return;
		}

		if (plus.size()==0 && K%2==1) {
			if (zero_cnt>0) {
				System.out.println(0);
				return;
			} else {
				Collections.sort(minus);
				long aaa = 1L;
				for (int i=0;i<K;i++) {
					aaa = aaa*(mod-minus.get(i))%mod;
				}
				System.out.println(aaa);
				return;
			}
		}

		Collections.sort(plus, (o1, o2)->Integer.compare(o2, o1));
		Collections.sort(minus, (o1, o2)->Integer.compare(o2, o1));
		long ans = 1L;
		if (K%2==1) {
			ans = plus.get(0);
			plus.remove(0);
		}
		TreeMap<Long, Integer> map = new TreeMap<Long, Integer>();
		for (int i=0;i<plus.size()/2;i++) {
			long tmp = (long)plus.get(2*i)*plus.get(2*i+1);
			if (map.containsKey(tmp)) {
				map.put(tmp, map.get(tmp)+1);
			} else {
				map.put(tmp, 1);
			}
		}
		for (int i=0;i<minus.size()/2;i++) {
			long tmp = (long)minus.get(2*i)*minus.get(2*i+1);
			if (map.containsKey(tmp)) {
				map.put(tmp, map.get(tmp)+1);
			} else {
				map.put(tmp, 1);
			}
		}
		for (int i=0;i<K/2;i++) {
			if (map.size() == 0) {
				if (zero_cnt>0) System.out.println(0);
				return;
			}
			long last_key = map.lastKey();
			ans = ans*(last_key%mod)%mod;
			if (map.get(last_key)>1) {
				map.put(last_key, map.get(last_key)-1);
			} else {
				map.remove(last_key);
			}
		}
		System.out.println(ans);
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; ++i) cin >> x[i];
  sort(x.begin(), x.end());

  vector<int> v(m - 1);
  for (int i = 0; i < m - 1; ++i) v[i] = x[i + 1] - x[i];
  sort(v.begin(), v.end());

  ll ans = 0;
  for (int i = 0; i < m - n; ++i) ans += v[i];
  cout << ans << endl;

  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;cin>>d;
    int n;cin>>n;
    int ans = 0;
    if(d==0){
        if(n==100) ans = 101;
        else ans = n;
    }else if(d==1){
        ans = 100*n;
        if(n==100) ans+=100;
    }else{
        ans = 10000*n;
        if(n==100)ans+=10000;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n, a[101][101], i, j, k, l, t, max;

  cin >> n;
  for(j = 0; j <= n; j++) a[0][j] = 0;
  for(i = 1; i <= n; i++) {
    a[i][0] = 0;
    for(j = 1; j <= n; j++) {
      cin >> t;
      a[i][j] = a[i-1][j]+a[i][j-1]-a[i-1][j-1]+t;
    }
  }
  max = a[1][1];
  for(i = 1; i <= n; i++)
    for(j = 1; j <= n; j++)
      for(k = 0; k < i; k++)
	for(l = 0; l < j; l++) {
	  t = a[i][j] - a[i][l] - a[k][j] + a[k][l];
	  if (t > max) max = t;
	}
  cout << max << endl;
  return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int p = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == '.')
			p++;
	int ans = p;
	for (int i = 0; i < n; i++) {
		if (s[i] == '#') p++;
		else p--;
		ans = min(ans, p);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

bool chk(char c1,char c2) {
    return c1=='?' || c2=='?' || c1==c2;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin>>a>>b>>c;
    vector<bool> ab(30000,false), ac(30000,false), bc(30000,false);
    int alen = a.size();
    int blen = b.size();
    int clen = c.size();
    rep(i,alen) rep(j,blen) if (!chk(a[i], b[j])) ab[i-j+15000] = true;
    rep(i,alen) rep(j,clen) if (!chk(a[i], c[j])) ac[i-j+15000] = true;
    rep(i,blen) rep(j,clen) if (!chk(b[i], c[j])) bc[i-j+15000] = true;
    int mx = 2000;
    int ans = 6000;
    for(int i=mx*-2;i<=mx*2;i++) {
        for(int j=mx*-2;j<=mx*2;j++) {
            if (!ab[i+15000]&&!ac[j+15000]&&!bc[j-i+15000]) {
                int l = min(0, min(i,j));
                int r = max(alen, max(blen+i,clen+j));
                chmin(ans, r-l);
            } 
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int main() {
	int a, b;
	cin >> a >> b;
	
	cout << (a - 1) * (b - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[2*100002];
int main(){
   ll n,ans=0;
   cin>>n;
   map<ll,ll> m;

    for1(i,n){
        cin>>a[i];
    }

    for(ll i=n;i>=1;i--){
        auto it=m.find(i-a[i]);
        if(it==m.end()) m.insert(mp(i-a[i],1));
        else (it->se)++;
        it=m.find(a[i]+i);
        if(it!=m.end()) ans+=(it->se);
    }
    cout<<ans;
}


Measured memory_bytes: 16688
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
#define over ((1ll << 32))
using namespace std;
#define N 2005

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define int ll 
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)

//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl

typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;

signed main()
{
    int n;
    cin >> n;
    vector<int> mo(n + 1);
    vector<int> he(n);
    for (int i = 0 ; i <= n ; i++)
        cin >> mo[i];
    for (int i = 0 ; i < n ; i++)
        cin >> he[i];
    int ans = 0;
    for (int i = 0 ; i < n ; i++)
    {
        int temp = min(he[i] , mo[i]);
        he[i] -= temp;
        ans += temp;
        mo[i] -= temp;
        temp = min(he[i] , mo[i + 1]);
        he[i] -= temp;
        ans += temp;
        mo[i + 1] -= temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n;
 cin>>n;
 ll a[n];
 vector<ll>v1,v2;
 f(n)
 {
  cin>>a[i];
  v1.pb(i+a[i]);
  v2.pb(i-a[i]);
 }
 map<ll,ll>mp1,mp2;
 f(n)
 {
  mp1[v1[i]]++;
  mp2[v2[i]]++;
 }
 ll ans=0;
 for(auto x:mp1)
  ans+=(mp1[x.ff]*mp2[x.ff]);
 cout<<ans<<"\n";
 return 0;

}


Measured memory_bytes: 42176
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
const int M=2e5+10;
LL a[M],b[M],c[M];
int n;
int main(){
	n=read();
	F(i,1,n){
		a[i]=read();
		b[i]=b[i-1]+a[i];
	}
	DF(i,n,1){
		c[i]=c[i+1]+a[i];
	}
	LL ans=LONG_LONG_MAX;
	F(i,1,n-1){
//		cout<<b[i]<<" "<<c[i+1]<<"\n";
		LL cos=abs(b[i]-c[i+1]);
		ans=min(ans,cos);
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 4992
#include <iostream> 
#include <cstdio>
#include <deque>
#include <iomanip>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;

int n;
int L;

void ReadData() {
	cin >> n >> L;
} 

deque<pair<long double, long long> > qu;
void Process() {
	cout << fixed << setprecision(6);

	long long sumRem = 0;
	long double sumTV = 0;
	For(i,1,n) {
		int t,v; cin >> t >> v;
		if (sz(qu) == 0) {
			qu.push_back(make_pair(t,v));
			sumRem += v;
			sumTV += 1LL * v * t;
			cout << t << "\n";
			continue;
		}
		while (sumRem + v > L) {
			auto &cur = qu.front();
			if (cur.second <= (sumRem + v) - L) {
				sumRem -= cur.second;
				sumTV -= 1LL * cur.first * cur.second;
				qu.pop_front();
			} else {
				cur.second -= ((sumRem + v) - L);
				sumTV -=  cur.first *((sumRem + v) - L);
				sumRem -= ((sumRem + v) - L);
			}
		}
		long double res = (sumTV + 1LL * v * t) / (sumRem + v);
		cout << (double) res << "\n";

		pair<long double, long long> add = make_pair(t,v);
		while (sz(qu) && qu.back().first >= add.first) {
			add = make_pair( (qu.back().first * qu.back().second 
				+ add.first * add.second) / (qu.back().second + add.second),
				qu.back().second + add.second  );
			sumRem -= qu.back().second;
			sumTV -= qu.back().first * qu.back().second;
			qu.pop_back();
		}
		qu.push_back(add);
		sumRem += add.second;
		sumTV += add.first * add.second;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.inp" , "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

Measured memory_bytes: 24884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;
const int MAX_V = 100005;

int anim[MAX_V];
int n;
string s;

bool dfs(int x) {
  int prev, next;
  if (x == 0) {
    prev = n-1;
    next = 1;
  } else if (x == n-1) {
    prev = n-2;
    next = 0;
  } else {
    prev = x-1;
    next = x+1;
  }

  bool same;
  if (anim[x] == 1 && s[x] == 'o') {
    same = true;
  } else if (anim[x] == -1 && s[x] == 'x') {
    same = true;
  } else {
    same = false;
  }

  if (same) {
    if (anim[prev] && anim[next] && (anim[prev] != anim[next])) {
      return false;
    } else if (anim[prev] && anim[next]) {
      return true;
    } else if (anim[prev]) {
      anim[next] = anim[prev];
      return dfs(next);
    } else {
      anim[prev] = anim[next];
      return dfs(prev);
    }
  } else {
    if (anim[prev] && anim[next] && (anim[prev] == anim[next])) {
      return false;
    } else if (anim[prev] && anim[next]) {
      return true;
    } else if (anim[prev]) {
      anim[next] = -anim[prev];
      return dfs(next);
    } else {
      anim[prev] = -anim[next];
      return dfs(prev);
    }
  }
}

void init() {
  rep(i, n) {
    anim[i] = 0;
  }
}

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

  cin >> n;
  cin >> s;

  bool res = false;

  for(int i : {1, -1}) {
    for(int j : {1, -1}) {
      init();
      anim[0] = i;
      anim[1] = j;
      res = dfs(1) && dfs(0);
      if(res) break;
    }
    if(res) break;
  }

  if (res) {
    rep(i, n) {
      if (anim[i] == 1) {
        cout << "S";
      } else {
        cout << "W";
      }
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 960
double x,y,s,t,u,v,a,b,c,X,Y;main(){scanf("%*d");for(;~scanf("%lf%lf%lf%lf%lf%lf",&x,&y,&s,&t,&u,&v);printf("%.3f %.3f %.3f\n",X,Y,hypot(X-x,Y-y)))c=x*x+y*y,a=c-s*s-t*t,b=c-u*u-v*v,s-=x,t-=y,u-=x,v-=y,c=s*v-t*u,X=(t*b-a*v)/2/c,Y=(a*u-s*b)/2/c;}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a < b) {
    	cout << "a < b" << endl;
    } else if(a > b){
    cout << "a > b" << endl;
    } else {
    	cout << "a == b" << endl;
    }
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {
    int n;
    cin >> n;
    vector<int> reversi(n);
    rep(i, n) cin >> reversi[i], reversi[i]--;
    vector<mint> counts(100000 * 2 + 1, 0);

    counts[reversi[0]] = 1;

    vector<mint> dp(n);
    dp[0] = 1;

    rep(i, n) {
        if (i == 0) continue;
        dp[i] = dp[i - 1];
        if (reversi[i - 1] == reversi[i]) continue;
        dp[i] += counts[reversi[i]];
        counts[reversi[i]] = dp[i];
    }

    cout << dp.back() << endl;

}


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

int main(){
    unsigned long a,b;
    cin >> a >> b;
    unsigned long i=2;
    map<unsigned long,int> table;
    while(i*i <= a){
        while( a % i == 0){
            a /= i;
            table[i] = 1;
        }
        i += 1;
    }
    if(a > 1){
        table[a] = 1;
    }
    i = 2;
    unsigned long sum = 1;
    while(i*i <= b){
        while( b % i == 0){
            b /= i;
            if(table.count(i) == 1 && table[i] == 1){
                table[i]++;
                sum++;
            }
        }
        i += 1;
    }
    if(b > 1){
        if(table.count(b) == 1 && table[b] == 1){
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
class SegmentTree:
  def __init__(self, l, func=min, init_val=float("inf")):
    self.func = func
    self.init_val = init_val
    n = 1
    while n < len(l):
      n *= 2
    self.nodes = [init_val for _ in range(2*n-1)]
    self.n = n
    for i in range(len(l)):
      self.nodes[i+n-1] = l[i]
    for i in range(n-2, -1, -1):
      self.nodes[i] = self.func(self.nodes[2*i+1], self.nodes[2*i+2])

  def update(self, x, val):
    x += self.n - 1
    self.nodes[x] = val
    while x > 0:
      x = (x - 1) // 2
      self.nodes[x] = self.func(self.nodes[2*x+1], self.nodes[2*x+2])

  def get(self, a, b):
    return self._get(a, b)

  def _get(self, a, b, k=0, l=0, r=-1):
    if (r < 0):
      r = self.n
    if (r <= a or b <= l):
      return self.init_val
    if (a <= l and r <= b):
      return self.nodes[k]
    return self.func(
      self._get(a, b, 2*k+1, l, (l + r) // 2),
      self._get(a, b, 2*k+2, (l + r) // 2, r)
    )

n, q = map(int, input().split())
alist = [pow(2, 31)-1 for _ in range(n)]
minsegt = SegmentTree(alist, init_val=pow(2, 31)-1)
for _ in range(q):
  c, x, y = map(int, input().split())
  if c == 0:
    minsegt.update(x, y)
  else:
    print(minsegt.get(x, y+1))



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 10000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define nooo cout<<"NO\n"
#define yess cout<<"Yes\n"
#define no cout<<"No\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,10000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
void solve()
{
    string s;
    cin>>s;
    string a,b;
    int n=s.length(),i;
    a=s.substr(0,n/2);
    b=s.substr(n-n/2,n/2);
    reverse(b.begin(),b.end());
    int ans=0;
    rep(i,n/2)
    {
        if(a[i]!=b[i])
            ans++;
    }
    cout<<ans;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
# フェルマーの小定理
N, K = map(int, input().split())

n = max(K, N - K + 1)
fac = [0] * (n + 1)
fac[0] = 1
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) % 1000000007


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], 1000000005, 1000000007) * pow(fac[k], 1000000005, 1000000007) % 1000000007


result = []
for i in range(1, K + 1):
    result.append(mcomb(K - 1, i - 1) * mcomb(N - K + 1, i) % 1000000007)
print('\n'.join(str(i) for i in result))


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t1,t2; cin>>t1>>t2;
    ll a1,a2; cin>>a1>>a2;
    ll b1,b2; cin>>b1>>b2;
    if (a1<b1){
        swap(a1,b1);
        swap(a2,b2);
    }
    ll s1 = a1*t1+a2*t2;
    ll s2 = b1*t1+b2*t2;
    ll v1 = a1-b1;
    ll v2 = a2-b2;

    if (s1==s2){
        cout<<"infinity\n";
        return 0;
    }
    if (s1>s2){
        cout<<"0\n";
        return 0;
    }
    ll diff = s2-s1;
    ll ans = v1*t1/diff;
    ans*=2;
    if (v1*t1 % diff == 0) ans--;
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 256
def bubbleSort(A,N):
    flag = 1
    sortedIndex = 0
    i = 0
    while flag == 1:
        flag = 0
        for j in range(N-1,sortedIndex,-1):
            if int(A[j][1]) < int(A[j-1][1]):
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
                flag = 1
                i += 1

def selectionSort(A,N):
    for i in range(N):
        minj = i
        for j in range(i+1,N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        v = A[i]
        A[i] = A[minj]
        A[minj] = v

def isStable(before,after,N):
    for i in range(N):
        for j in range(i+1,N):
            for a in range(N):
                for b in range(a+1,N):
                    if before[i][1] == before[j][1] and before[i] == after[b] and before[j] == after[a]:
                        #print("i={} j={} a={} b={}".format(i,j,a,b))
                        return False
    return True

def bubble_is_stable(A,N):
    bubble = A.copy()
    bubbleSort(bubble,N)
    bubble_is_stable = isStable(A,bubble,N)
    bubblestr = ''
    for i in range(N):
        bubblestr += "{} ".format(bubble[i])
    print(bubblestr[:len(bubblestr)-1])
    if bubble_is_stable:
        print('Stable')
    else:
        print('Not stable')

def selection_is_stable(A,N):
    selection = A.copy()
    selectionSort(selection,N)
    selection_is_stable = isStable(A,selection,N)
    selectionstr = ''
    for i in range(N):
        selectionstr += "{} ".format(selection[i])
    print(selectionstr[:len(selectionstr)-1])
    if selection_is_stable:
        print('Stable')
    else:
        print('Not stable')

if __name__ == '__main__':
    N = int(input())
    A = [ _ for _ in input().split()]
    bubble_is_stable(A,N)
    selection_is_stable(A,N)



Measured memory_bytes: 5620
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s1, s2;
    cin >> s1;
    cin >> s2;
    int ans = 0;
    for (int i = 0; i < s1.size(); ++i)
    {
        if (s1[i] != s2[i])
            ans += 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3928
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::string;

int gcd(int x, int y) {
  return (x % y)? gcd(y, x % y): y;
}

int main(){
  int n;
  int tmp, ans;
  int sum=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
	tmp=gcd(j,k);
	sum+=gcd(tmp,i);
      }
    }
  }
  cout << sum << endl;
}


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

class Rectangle implements Comparable<Rectangle> {
	int height;
	int width;
	int diag;
	
	Rectangle(int h,int w){
		height= h;
		width = w;
		diag  = h*h+w*w;
	}
	
	public int compareTo(Rectangle rec) {
		if( this.diag==rec.diag ){
			return this.height-rec.height;
		} else{
			return this.diag-rec.diag;
		}
	}
	
	@Override
	public String toString(){
		return height+" "+width;
	}
}

public class Main{
	public static TreeSet<Rectangle> prepare() {
		final int MAX_WIDTH= 100;
		final int MAX_DIAG= 2*MAX_WIDTH*MAX_WIDTH;
		TreeSet<Rectangle> result= new TreeSet<Rectangle>();
		for(int h=1; h*h<=MAX_DIAG; h++){
			for(int w=h+1; w*w+h*h <= MAX_DIAG; w++){
				result.add(new Rectangle(h,w));
			}
		}

		return result;
	}
    public static void main(String args[]) throws Exception{
    	Scanner sc= new Scanner(System.in);
    	TreeSet<Rectangle> ans= prepare();
    	int h,w;
    	while( (h= sc.nextInt())>0 && (w= sc.nextInt())>0 ){
        	System.out.println( ans.higher(new Rectangle(h,w)) );
    	}
    }
}

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

int main(){
    int cnt=0;
    int n, x;
    cin >> n >> x;
    while(!(n==0 && x==0)){
        cnt=0;
        for(int i=1;i<=x/3 && i<=n;++i){
            for(int j=i+1;j<=x/2 && j<=n;++j){
                int k=x-i-j;
                if(k>j && k<=n){
                    ++cnt;
                }
            }
        }
        cout<<cnt<<"\n";
        cin >> n >> x;
    }
}

Measured memory_bytes: 3112
N = int(input())
R = [0]*N
B = [0]*N
L = [0]*N
for i in range(N):
    R[i] = list(map(int,input().split(" ")))

for i in range(N):
    B[i] = list(map(int,input().split(" ")))
    
R = sorted(R,key=lambda x:x[1],reverse=True)
B = sorted(B,key=lambda x:x[0])

for b in B:
    for i in range(N):
        r = R[i]
        if not(L[i]) and r[0] < b[0] and r[1] < b[1]:
            L[i] = 1
            break

print(sum(L))

Measured memory_bytes: 3064
a = list(input())
b = list(input())
c = len(a)
d = len(b)
if d > c:
    print("UNRESTORABLE")
    exit()
ans = []
   
for i in range(c-d+1):
    #print(a[i:i+d])
    flag = False
    for j in range(d):
        if a[i:i+d][j] == b[j] or a[i:i+d][j] == "?":
            flag = True
        else:
            flag = False
            break
    li = [] 
    if flag:
        #print(a[i:i+d])
        li = a[:i] + b + a[i+d:]
        for k in range(len(li)):
            if li[k] == "?":
                li[k] = "a"
        ans.append("".join(li))
if ans:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 8956