akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
n = int(input())
r=[int(input()) for i in range(n)]
rv = r[::-1][:-1]
m = None
p_r_j = None
for j,r_j in enumerate(rv):
    if p_r_j == None or p_r_j < r_j:
        p_r_j = r_j
    if p_r_j > r_j:
        continue
    r_i = min(r[:-(j+1)])
    t = r_j - r_i
    if m == None or t > m:
        m = t
print(m)

Measured memory_bytes: 18452
s = input()

mod = 0
temp = 0
for c in s:
    if int(c) == mod:
        temp += 1
    mod = (mod + 1) % 2

ans = temp

mod = 1
temp = 0
for c in s:
    if int(c) == mod:
        temp += 1
    mod = (mod + 1) % 2

ans = min(ans, temp)

print(ans)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 112345678901234;
LL N, ans;
std::priority_queue<LL, std::vector<LL>, std::greater<LL>>left;
std::priority_queue<LL, std::vector<LL>>right;

int main()
{
	in >> N;
	std::vector<LL>a(3 * N), resL(3 * N), resR(3 * N);
	rep(i, 3 * N) in >> a[i];
	rep(i, N)
	{
		resL[N - 1] += a[i];
		resR[2 * N] += a[3 * N - i - 1];
		left.push(a[i]);
		right.push(a[3 * N - i - 1]);
	}
	for (int i = N; i < 2 * N; ++i)
	{
		resL[i] = resL[i - 1] + a[i];
		resR[3 * N - i - 1] = resR[3 * N - i] + a[3 * N - i - 1];
		left.push(a[i]);
		right.push(a[3 * N - i - 1]);
		resL[i] -= left.top();
		resR[3 * N - i - 1] -= right.top();
		left.pop();
		right.pop();
	}
	ans = -inf;
	for (int i = N - 1; i < 2 * N; ++i) ans = std::max(ans, resL[i] - resR[i + 1]);
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 9344
from collections import deque
K = int(input())
d={1:1}
q = deque()
q.append([1,1])

while q:
    a,c = q.popleft()
    a_ = (a*10)%K
    if(a_ not in d or c < d[a_]):
        d[a_]=c
        q.appendleft([a_,c])
    b_ = (a+1)%K
    if(b_ not in d or c < d[b_]):
        d[b_] = c+1
        q.append([b_,c+1])

print(d[0])
    


Measured memory_bytes: 19724
#include<bits/stdc++.h>
using namespace std;
long long n,l=1,r=3,a[4],Min,s[200010],x,y;
int main(){
	scanf("%d",&n);
	Min=2e9+5;
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		s[i]=s[i-1]+x;
	}
	for(int i=2;i<n;i++){
		while(l<i&&abs(s[i]-s[l+1]*2)<=abs(s[i]-s[l]*2)) l++;
		while(r<n&&abs(s[n]-s[r+1]*2+s[i])<=abs(s[n]-s[r]*2+s[i]))r++;
		a[0]=s[l];
		a[1]=s[i]-s[l];
		a[2]=s[r]-s[i];
		a[3]=s[n]-s[r];
		sort(a,a+4);
		Min=min(Min,a[3]-a[0]);
	}
	printf("%d\n",Min);
	return 0;
}

Measured memory_bytes: 5388
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N >> M;
	vector<int>v(N,-1);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		if (v[L] == -1) {
			v[L] = R;
		}
		else if (v[L] != R) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (N > 1 && v[0] == 0) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (v[i] == -1) {
			if (!i&&N>1)cout << 1;
			else cout << 0;
		}
		else cout << v[i];
	}
	cout << endl;
	return 0;
}

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

int main() {

	int N, X, Y;
	cin >> N>> X>> Y;

	int length, v_length;
	vector<int> len(N);
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			length = j - i;
			v_length = abs(i - X) + 1 + abs(Y - j);
			len[min(length,v_length)]++;
		}
	}
	for (int i = 1; i < N; i++) {
		cout << len[i] << endl;
	}



	

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h, w, cnt = 0;
char s[51][51];
int c[51][51];
queue<pair<int, int>> q;

bool flag = false;

void push(int x, int y, int dist){
  if (s[x][y] == '.'  && c[x][y] == 0){
    q.push(make_pair(x, y));
    s[x][y] = '#';
    c[x][y] = dist;
  }
}


void bfs(){
  c[0][0] = 1;
  q.push(make_pair(0, 0));
  while(!q.empty()){
    pair<int, int> p = q.front();
    q.pop();
    if ( p.first == h-1 && p.second == w-1){
      flag = true;
      break;
    }
    push(p.first+1, p.second, c[p.first][p.second]+1);
    push(p.first-1, p.second, c[p.first][p.second]+1);
    push(p.first, p.second+1, c[p.first][p.second]+1);
    push(p.first, p.second-1, c[p.first][p.second]+1);
  }
}

int main(){
  cin >> h >> w;
  for ( int i = 0; i < h; i++){
    for ( int j = 0; j < w; j++){
      cin >> s[i][j];
      c[i][j] = 0;
      if ( s[i][j] == '#'){
        cnt++;
      }
    }
  }

  bfs();

  if ( flag ){
    cout << h*w - cnt - c[h-1][w-1] << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

constexpr int M = 1000000007;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> cs(n);
  map<int, vector<int>> colors;
  for (int i = 0; i < n; i++) {
    cin >> cs[i];
    colors[cs[i]].push_back(i);
  }
  vector<int> nexts(n);
  for (auto&& p : colors) {
    int s = p.second.size();
    for (int i = 0; i < s - 1; i++)
      nexts[p.second[i]] = p.second[i + 1];
    if (s != 0) nexts[p.second.back()] = -1;
  }

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

  for (int i = 0; i < n; i++) {
    if (nexts[i] >= 0) {
      dp[nexts[i]] += dp[i];
      dp[nexts[i]] %= M;
    }

    if (i == n - 1 || cs[i] != cs[i + 1]) {
      dp[i + 1] += dp[i];
      dp[i + 1] %= M;
    }
  }

  cout << dp[n] << endl;
}


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

int main()
{
    long long n, k;
    cin >> n >> k;
    k = n * (n - 1) / 2 - k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ng = 1e18;
    long long ok = -1e18;
    while (abs(ok - ng) > 1)
    {
        long long mid = (ok + ng) / 2;
        long long tmp = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] >= 0){
                int left = i;
                int right = n;
                while (abs(left - right) > 1)
                {
                    int center = (left + right) / 2;
                    if ((long long)a[i] * a[center] >= mid) right = center;
                    else left = center;
                }
                tmp += n - right;
            }
            else {
                int left = i;
                int right = n;
                while (abs(left - right) > 1)
                {
                    int center = (left + right) / 2;
                    if ((long long)a[i] * a[center] >= mid) left = center;
                    else right = center;
                }
                tmp += left - i;
            }
        }
        if (tmp > k) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

ll dp[100005];
int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		rep(i,n+1) dp[i] = MAX;
		ll gameOver[n+1];
		repA(i,0,n) gameOver[i] = (s[i] == '1');
		dp[n] = 0;
		ll ind = n;
		ll last = n;
		ll continuous = 0;
		ll maxLen = 0;
		repA(i,0,n){
			if(gameOver[i] == 1)
				continuous++;
			else{
				maxLen = max(maxLen,continuous);
				continuous = 0;
			}
		}
		maxLen = max(maxLen,continuous);
		if(maxLen >= k){
			cout<<-1;
			return 0;
		}
		ll ans[n+1];
		ans[n] = 0;
		repD(i,n-1,0){
			if(gameOver[i])
				continue;
			if(ind - i <= k){
				dp[i] = dp[ind]+1;
				last = i;
				ans[i] = ind - i;
			}
			else{
				dp[i] = dp[last] + 1;
				ans[i] = last - i;
				ind = last;
				last = i;
			}
		}
		// rep(i,n+1){
		// 	dbg2(dp[i],ans[i]);
		// }
		ll curr = 0;
		while(curr < n){
			cout<<ans[curr]<<" ";
			curr+=ans[curr];
		}
	}
	return 0;
}


Measured memory_bytes: 6116
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    char prev = S[0];
    for (int i = 1; i < N; i++) {
        if (prev != S[i]) {
            ans++;
            prev = S[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		int[][] a = new int[3][3];
		boolean[][] card = { { false, false, false }, { false, false, false }, { false, false, false } };

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = Integer.parseInt(sc.next());
			}
		}
		int n = Integer.parseInt(sc.next());

		int[] b = new int[n];

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sc.next());
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (a[i][j] == b[k]) {
						card[i][j] = true;
					}
				}
			}
		}

		boolean bingo = false;
		if ((card[0][0] && card[1][1] && card[2][2]) || (card[0][2] && card[1][1] && card[2][0])) {
			bingo = true;
		}
		for (int i = 0; i < 3; i++) {
			if ((card[i][0] && card[i][1] && card[i][2]) || (card[0][i] && card[1][i] && card[2][i])) {
				bingo = true;
			}
		}
		if (bingo) {
			out.println("Yes");
		} else {
			out.println("No");
		}

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 26984
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
		double n=sc.nextDouble();
  		double ans=0;
    
 	if(n<b){
      		ans=Math.floor(n*a/b);
    		System.out.println((int)ans);
    	}else{
      		ans=Math.floor(a*(b-1)/b);
     		System.out.println((int)ans);
   	 }

    }
}


Measured memory_bytes: 37136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec09A
{
    class Program
    {
        static void Main(string[] args)
        {
            int size;
            size = int.Parse(Console.ReadLine());
            int[] array = new int[size];
            string input = Console.ReadLine();
            string[] split = input.Split(' ');

            for ( int i= 0; i < size; i++)
            {
                array[i] = int.Parse(split[i]);

            }

            /*
            foreach (int element in array){
                Console.Write("{0}",element);
            }*/

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: key = {1}, " , i + 1  , array[i]);
                if ( (i + 1 ) /  2 > 0)
                {
                    Console.Write("parent key = {0}, ",array[ ((i+1) / 2 ) - 1 ] );
                }
                if ( (i+1) * 2 <= size )
                {
                    Console.Write("left key = {0}, ", array[ ( i+1)*2 -1]);
                }
                if ((i + 1) * 2  + 1<= size)
                {
                    Console.Write("right key = {0}, ", array[(i + 1) * 2 +1-1]);
                }
                Console.WriteLine();
            }


            Console.ReadLine();
        }
    }
}


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

using namespace std;

int A[200002],B[200002];

int main(){
    int t=1;
//    cin >> t;
    while (t--) {
        int n, m ,ms;
        scanf("%d%d%d", &n, &m, &ms);
 
        for(int A_i = 0; A_i < n; A_i++){
            scanf("%d",&A[A_i]);
        }
        for(int B_i = 0; B_i < m; B_i++){
           scanf("%d",&B[B_i]);
        }

        long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        int ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

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


Measured memory_bytes: 5332
n, k = map(int, input().split())
a_l = sorted(list(map(int, input().split())))
base = list(set(a_l))
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    c_idx = 1
    c_num = a_l[0]
    for idx, v in enumerate(a_l[1:]):
        if c_num == v:
            c_idx += 1
            continue
        else:
            ans.append(c_idx)
            c_idx = 1
            c_num = v
    ans.append(c_idx)

    print(sum(sorted(ans)[:num]))


Measured memory_bytes: 142732
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
priority_queue<int> q;
int main(){
  int k,t;
  cin >> k >> t;
  for(int i=0;i<t;++i){
    int a;cin >> a;
    q.push(a);
  }
  while(q.size()>1){
    int a,b;
    a = q.top(); q.pop();
    b = q.top(); q.pop();
    a-=b;
    q.push(a);
  }
  int c = q.top();
  cout << max(0,c-1) << endl;
  return 0;
}


Measured memory_bytes: 256
// Being an artist , being me. Thats best excuse of me for being Crazy.
// 1 cheez uthao and finish that... 
// dp first... aaw se 
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf = 1e9 + 7ll ;
int main() {
	ll n, W;
	cin >> n >> W ;
	ll dp[2'00'000] ;
	ll wt[n], val[n], V = 0ll ; 
	for(ll i = 0; i < n; i ++ )
		cin >> wt[i] >> val[i] , V += val[i] ;
	
	memset(dp, inf, sizeof(dp));
	dp[0] = 0;
	for(ll i = 1; i <= n; ++i ) { // log
		for(ll j = V; j >= val[i - 1]; --j ) {
			dp[j] = min( dp[j], dp[j - val[i - 1]] + wt[i - 1] ) ;
		}
	}
	for(int j = V; j >=0 ; --j ) {
		if( dp[j] <= W ) {
			cout << j ;
			exit(0);
		}
	}
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#define dprintf(...) printf(__VA_ARGS__)
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#define dprintf(...)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

template <class T>
vec3<T> vec3_init(int n0, int n1, int n2, T x = 0) {
    return vec3<T>(n0, vec2_init(n1, n2, x));
}

/*
 *           U P
 *           - x
 *            ^
 *            |
 * LEFT -y <--+--> +y RIGHT
 *            |
 *            v
 *           + x
 *         D O W N
 */

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

enum {
    DOWN,
    RIGHT,
    UP,
    LEFT,
};

constexpr double inf = numeric_limits<double>::infinity();

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

    int N;
    cin >> N;
    ll result = 0;
    FOR(A, 1, N + 1) {
        result += N / A;
        if (N % A == 0) --result;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
   int n,k;
   cin>>n>>k;
   if((n-1)%(k-1)==0)cout<<(n-1)/(k-1);
   else cout<< (n-1)/(k-1)+1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll n, d;
	cin >> n >> d;
	ll memo = 2 * d + 1;
	cout << (n - 1) / memo + 1 << endl;
	ggr
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
N,d,a = map(int,readline().split())

data0 = [0]*(N+1)
data1 = [0]*(N+1)
# 区間[l, r)に x を加算
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

# 区間[l, r)の和を求める
def get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
  return get(data1,r-1)*(r-1)+get(data0,r-1)-get(data1,l-1)*(l-1)-get(data0,l-1)

xh = []
for _ in range(N):
    x,h = map(int,readline().split())
    xh.append((x,h))

xh = sorted(xh)
xl = [x for x,h in xh]

for i in range(N):
    add(i+1, i+2, xh[i][1])

import bisect,math

ans = 0
for i in range(N):
    hp = query(i + 1, i + 2)
    #print(data0,data1,hp)    
    if hp > 0:
        count = math.ceil(hp/a)
        ans += count
        damage = count * a
        idx = bisect.bisect_right(xl, xl[i] + 2*d)
        add(i+1, idx+1, -damage)
print(ans)

Measured memory_bytes: 123020
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String steps = scan.next();
			if (steps.equals("#")) {
				scan.close();
				break;
			}
			int N = steps.length();
			int[] table = new int[N];
			for (int i = 0; i < table.length; i++) {
				table[i] = Character.getNumericValue(steps.charAt(i));
			}
			// i文字目をkで踏んだ時の踏める回数
			// 右の時k=0、左の時k=1
			int[][] dp = new int[N][2];

			for (int i = 1; i < N; i++) {
				if ((table[i] - 1) % 3 > (table[i - 1] - 1) % 3) {
					// i-1番目が左だったらセーフ
					// i番目がi-1番目より右だった時
					dp[i][0] = Math.min(dp[i - 1][1], dp[i - 1][0] + 1);
					dp[i][1] = Integer.MAX_VALUE - 1;// 左で踏むことは絶対にない
				} else if ((table[i] - 1) % 3 < (table[i - 1] - 1) % 3) {
					// i番目がi-1番目より左だった時
					dp[i][1] = Math.min(dp[i - 1][0], dp[i - 1][1] + 1);
					dp[i][0] = Integer.MAX_VALUE - 1;
				} else {
					dp[i][1] = dp[i - 1][0];
					dp[i][0] = dp[i - 1][1];
				}
			}

			System.out.println(Math.min(dp[N - 1][0], dp[N - 1][1]));
		}

	}
}

Measured memory_bytes: 44820
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    int count = 0;
    while(true){
        sort(a.begin(), a.end());
        int MAX = *max_element(a.begin(), a.end());
        int MIN = *min_element(a.begin(), a.end());
        if(MAX == MIN){
            cout << count << endl;
            return 0;
        }
        if(MAX >= MIN + 2) a[0] += 2;
        else a[2]--;
        count++;
    }
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	scanf("%d",&n);
	vector<vi> AdjList;

	AdjList.assign(110, vi());
	vii listEdge;
	for(i=1;i<=n;i++){
		int ga = n - i;
		if(n % 2 == 0){ga++;}
		for(j=i+1;j<=n;j++){
			if(j == ga){continue;}
			AdjList[i].pb(j);
			AdjList[j].pb(i);
			listEdge.pb(ii(i,j));
		}
	}
	int sum = -1;
	for(i=1;i<=n;i++){
		int curSum = 0;
		for(j=0;j<AdjList[i].size();j++){
			int v = AdjList[i][j];
			curSum += v;
		}
		// printf("i: %d curSum: %d\n",i, curSum);
		if(sum == -1){sum = curSum;}
		else{
			assert(sum == curSum);
		}
	}
	printf("%d\n",(int)listEdge.size());
	for(i=0;i<listEdge.size();i++){
		printf("%d %d\n",listEdge[i].first,listEdge[i].second);
	}

	return 0;
};

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int a = arr[0];
    int b = arr[n-1];
    long long ans = INT_MAX;
    for(int i=a; i<=b; i++){
        long long sum = 0;
        for(int j=0; j<n; j++){
            sum += pow(arr[j] - i,2);
        }
        ans = min(ans , sum);
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
 while(true){
  string s1, s2;
  cin >> s1;
  if(s1 == ".") break;
  cin >> s2;

  //?????¨??????????????´???
  if(s1 == s2){
   cout << "IDENTICAL" << endl;
   continue; //??\??????while?????????????????????????????????while??????????????????
  }

  //??????????????°????????´???
  string t1 = s1;
  string t2 = s2;

  while(true){
   size_t d1b = t1.find('\"'); //t1???"???????§???????
   if(d1b == string::npos) break;
   t1.replace(d1b, 1, "@");
   
   size_t d1e = t1.find('\"'); //t1???"???????????????
   t1.replace(d1e, 1, "@");

   size_t d2b = t2.find('\"'); //t2???"???????§???????
   if(d2b == string::npos) break;
   t2.replace(d2b, 1, "@");
   
   size_t d2e = t2.find('\"'); //t2???"???????????????
   t2.replace(d2e, 1, "@");

   string u1 = s1;
   u1.replace(d1b+1, d1e-d1b-1, ""); //u1?????????????????°?????????
   string u2 = s2;
   u2.replace(d2b+1, d2e-d2b-1, ""); //u2?????????????????°?????????

   if(u1 == u2){
    t1 = u1;
    t2 = u2;
    break;
   }
  }

  if(t1 == t2){
   cout << "CLOSE" << endl;
  }

  //????????\???
  else{
   cout << "DIFFERENT" << endl;
  }
 }

 return 0;
}   

Measured memory_bytes: 3144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] string = line.split(" ");
		int[] is = new int[string.length];
		for (int i = 0; i < is.length; i++) {
			is[i] = Integer.parseInt(string[i]);
		}

		int a = is[0];
		int b = is[1];
		int c = is[2];

		List<Integer> list = new ArrayList<Integer>();

		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				list.add(i);
			}
		}

		System.out.println(list.size());

	}

}

Measured memory_bytes: 26280
#include<iostream>
#include<algorithm>
using namespace std;
int x[110];
int main(){
	int n,a=0,b=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>x[i];
	sort(x+1,x+n+1);
	for(int i=1;i<=n/2;i++)
	swap(x[i],x[n-i+1]); 
	for(int i=1;i<=n;i++)
	if(i%2==1)a+=x[i];
	else b+=x[i];
	cout<<a-b<<"\n";
	return 0;
} 

Measured memory_bytes: 256
/*
 * aoj/dpl_5_b/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* Mod */
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

int N, K;
void solve() {
  cin >> N >> K;
  if (N > K) {
    cout << 0 << endl;
    return;
  }

  mint p = 1;
  loop(n,0,N) p *= (K-n);
  cout << p << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[252], k[252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d%d",a+i,k+i);
  if(false){
    vi nim(a[0]+1,0);
    unordered_set<int> S;
    FOR(x,1,a[0]+1){
      FOR(i,1,x/k[0]+1){
        S.insert(nim[x-i]);
      }
      int it = 0;
      while(S.count(it)==1)it++;
      nim[x] = it;
      S.clear();
    }
    REP(i,a[0]+1){
      printf("%3d:%4d | ",i,nim[i]);
      if(i%9==8)puts("");
    }
    REP(i,a[0]+1){
      int id = i * (k[0]-1) / k[0];
      if(i%k[0]!=0 && nim[i] != nim[id]){
        printf("i:%d, id:%d, nim[i]:%d, nim[id]:%d\n",i,id,nim[i],nim[id]);
      }else if(i%k[0]==0 && nim[i] != i/k[0]){
        printf("i:%d, nim[i]:%d, i/k[0]:%d\n",i,nim[i],i/k[0]);
      }
    }
    return 0;
  }
  int ans = 0;
  REP(i,n){
    int aa = a[i];
    int kk = k[i];
    if(kk < 100000){
      while(aa%kk!=0){
        aa = (ll)aa * (kk-1) / kk;
      }
    }else{
      while(aa%kk!=0){
        int nxta = (aa / kk) * kk;
        int downsize = (aa+kk-1)/kk;
        int sa = aa - nxta;
        int times = sa / downsize;
        aa = aa - times * downsize;
        if(aa%kk==0)break;
        aa = (ll)aa * (kk-1) / kk;
      }
    }
    ans ^= aa / kk;
    // DEBUG(ans);
  }
  // DEBUG(ans);
  if(ans==0)puts("Aoki");
  else puts("Takahashi");
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> Pi;

int main(){
  int n;
  while(cin >> n , n){
    Pi event[n*2+1];
    for(int i=0;i<n;i++){
      int a,b,c;
      cin >> a >> b >> c;
      event[i].first = b;
      event[i].second.first = 1;
      event[i].second.second = a;
      event[i+n].first = c;
      event[i+n].second.first = 0;
      event[i+n].second.second = a;
    }
    sort(event,event+(n*2));
    int now=0;
    bool flg = false;
    for(int i=0;i<n*2;i++){
      if(event[i].second.first == 1) now += event[i].second.second;
      else now -= event[i].second.second;
      
      if(now > 150){
	flg = true;
	break;
      }
    }
    if(flg) cout << "NG" << endl;
    else cout << "OK" << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstring>
#include <algorithm>

char s[4][200] = {"dreamer", "dream", "erase", "eraser"};
char str[200000];
int l[4] = {7, 5, 5, 6};
int len;
bool flg;

void dfs(int idx) {
//    std::cout << cur << " " <<ll <<  std::endl;
    if (flg) return;
    if (idx == len) {
        flg = true;
        return;
    } else if (idx > len) return;
    for (int j = 0; j < 4; ++j) {
        bool fl = true;
        for (int i = 0; i < l[j]; ++i) {
            if (s[j][i] != str[idx + i]) {
                fl = false;
                break;
            }
        }
        if (fl) dfs(idx + l[j]);
    }
}

int main() {
    std::cin >> str;
    len = strlen(str);
    dfs(0);
    puts(flg ? "YES" : "NO");
}

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

constexpr int MAX_N = 8;
int ab[MAX_N+1][MAX_N+1];
int idx[]{1,2,3,4,5,6,7,8};

int main() {
  int N, M;
  cin >> N >> M;
  for (int i{}; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    ab[a][b] = ab[b][a] = true;
  }
  int ans{};
  sort(idx, idx + N); // 昇順にソートしておく必要あり
  do {
    bool path{true};
    for (int i{1}; i < N; ++i) {
      if (!ab[idx[i-1]][idx[i]]) {
        path = false;
        break;
      }
    }
    if (path)
      ++ans;
  } while (next_permutation(idx+1, idx + N));

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


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    if (A>12)
    {
        ans = B;
    }else if (A>5 && A<13)
    {
        ans = B/2;
    }else
    {
        ans = 0;
    }
    
    cout << ans << endl;
    
    }


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int ai[200005];
int bi[200005];
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int q = max(a,b);
    int w = q - min(a,b);
    if(w>(8-(min(a,b))))
        printf(":(");
    else
        printf("Yay!");
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

print(ans)

Measured memory_bytes: 146524
require 'prime'

INF = 10 ** 5
q = gets.to_i
questions = []
q.times do
  questions << gets.split.map(&:to_i)
end

prime_numbers = Array.new(INF + 2, false)

1.upto(INF + 1) do |num|
  prime_numbers[num] = num.prime?
end

cumulative_alike_numbers = Array.new(INF + 1, 0)

1.upto(INF) do |num|
  cumulative_alike_numbers[num] = cumulative_alike_numbers[num - 1]
  cumulative_alike_numbers[num] += 1 if prime_numbers[num] == true && prime_numbers[(num + 1) / 2] == true
end

questions.each do |first, last|
  puts cumulative_alike_numbers[last] - cumulative_alike_numbers[first - 1]
end


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
///(A->to)=cost
struct edge { int to, cost; };
///pii//first...???????????¢///second...????????????
int V;
//onst int MAX_V = 5005;//?¶??????°!!
vector<edge> G[5005];
vector<int> v[5005];
int d[5005];
int can[5005],cost[5005];
int used[5005];
/*void f(int u,int num,int cos){
    //cout << cos << " ";
    if(used[num][u])return;
    used[num][u]=true;
    if(num==V+1)return;
    else {
        if(cos>0)for(int o:v[u]){
            if(!used[num][o]){
            edge ee;
            ee.cost=cost[num];
            ee.to=o;
            G[num].pb(ee);
            f(o,num,cos-1);
            }
        }
        f(num+1,num+1,can[num+1]);
    }
}*/

void dijkstra(int s){
    priority_queue<pii, vector<pii>, greater<pii> > que;
    fill(d,d+V,INF);
    d[s] = 0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,0,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to], e.to));
            }
        }
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> V >> m;
    n=V;
    rep(i,0,V){
        cin >> cost[i] >> can[i];
    }
    rep(i,0,m){
        int to,from;
        cin >> from >> to;
        from--;to--;
        v[from].pb(to);
        v[to].pb(from);
    }

    queue<pii> qu;
    rep(i,0,n){
        qu.push(mp(i,can[i]));
       // cout << "a";
       memset(used,false,sizeof(used));
        while(!qu.empty()){
            pii fg=qu.front();qu.pop();
            int f=fg.first,s=fg.second;
            if(used[f]==true)continue;
            used[f]=true;
            //cout << " " << f << used[i][f] << endl;
            if(s==-1)continue;
            edge e;
            e.cost=cost[i];e.to=f;
            if(i!=f)G[i].pb(e);
            for(int u:v[f]){
                qu.push(mp(u,s-1));
            }
        }
    }
    //rep(i,0,n)G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
    dijkstra(0);
    //rep(i,0,n){cout << d[i] << endl;}
    cout << d[V-1] << endl;
    return 0;
}

Measured memory_bytes: 237484
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
#define m(l,n) (l*)malloc(n*sizeof(l))
typedef struct tree{
  int key;
  struct tree *left;
  struct tree *right;
}tree;
tree *getrootnode(tree*,int);
tree *insert(tree*,int);
void inorderprint(tree*);
void preorderprint(tree*);
bool findkey(tree*,int);
int main(){
  int n,val;
  char command[7];
  tree *root=NULL;
  scanf("%d",&n);
  lpton(i,n){
    scanf("%s",command);
    if(!strcmp(command,"insert")){
      scanf("%d",&val);
      root=insert(root,val);
    }
    else if(!strcmp(command,"find")){
      scanf("%d",&val);
      printf("%s\n",findkey(root,val)!=false?"yes":"no");
    }
    else{
      inorderprint(root);
      printf("\n");
      preorderprint(root);
    printf("\n");
    }
  }
  return 0;
}
tree *getnewnode(tree *root,int value){
  tree *origin=m(tree,1);
  origin->key=value;
  origin->left=origin->right=NULL;
  return origin;
}
tree *insert(tree *root,int v){
  if(root==NULL)root=getnewnode(root,v);
  else if(v<root->key)root->left=insert(root->left,v);
  else root->right=insert(root->right,v);
  return root;
}
void inorderprint(tree *rt){
  if(rt==NULL)return;
  inorderprint(rt->left);
  printf(" %d",rt->key);
  inorderprint(rt->right);
}
void preorderprint(tree *rt){
  if(rt==NULL)return;
  printf(" %d",rt->key);
  preorderprint(rt->left);
  preorderprint(rt->right);
}
bool findkey(tree *ob,int k){
  while(ob){
    if(ob->key==k)return true;
    else if(ob->key<k)ob=ob->right;
    else ob=ob->left;
  }
  return false;
}



Measured memory_bytes: 14236
package main

import (
	"fmt"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	var cnt int
	for i := range s {
		l := i
		r := len(s) - 1 - i
		if l > r {
			break
		}
		if s[l] != s[r] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int h,w,n,t;
    scanf("%d%d%d",&h,&w,&n);
    t=h>w?h:w;
    if(n%t!=0)
        printf("%d",n/t+1);
    else
        printf("%d",n/t);
    return 0;
}


Measured memory_bytes: 128
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------
ll dp[100001] ;

void solve(){
	ll n , k ;
	cin >> n >> k ;
	vector<ll> ar(n) ;
	beg(i , n) cin >> ar[i] ;
	beg1(i , k+1){
		beg(j , n){
			if(ar[j] <= i && !dp[i]){
				dp[i] = !dp[i - ar[j]] ;
				//cout << i << " " << j << " " << dp[i] << " "  << dp[i - ar[j]] << nl ;
			}
		}
	}
	cout << ((dp[k] == true) ? "First" : "Second") ;
}
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

Measured memory_bytes: 1024
ACGT = ['A', 'C', 'G', 'T']
S = input()
countlist = [0]
if S[0] in ACGT:
	countlist[0] += 1
for i in range(1, len(S)):
	if S[i] in ACGT:
		countlist.append(countlist[-1]+1)
	else:
		countlist.append(0)
countlist.sort()
print(countlist[-1])

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
struct sss 
{
	string s;
}dp[10001];
bool flag[10];
bool cmp(string a,string b)
{
	if(a.size()>b.size()) return 1;
	else if(a.size()<b.size()) return 0;
	else return a>b;
}
bool cmp1(char a,char b)
{
    return a>b;
}
int main()
{
	int n,m;
	string x;
	map<int,string> mp;
	map<string,int> vis;
	vis["1"]=2;vis["2"]=5;vis["3"]=5;
	vis["4"]=4;vis["5"]=5;vis["6"]=6;
	vis["7"]=3;vis["8"]=7;vis["9"]=6;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		cin>>x;
		flag[vis[x]]=1;
		if(mp[vis[x]]<x) mp[vis[x]]=x;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=2;j<=7;j++)
		{
			if(flag[j]&&i>=j)
			{
				if(i==j)
				{
					string z=mp[j];
					if(dp[i].s=="") dp[i].s=z;
					else if(cmp(z,dp[i].s)) dp[i].s=z;
				}
				else{
					if(dp[i-j].s=="") continue;
					else{
						string z=dp[i-j].s+mp[j];
						if(dp[i].s=="") dp[i].s=z;
						else{
							if(cmp(z,dp[i].s)) dp[i].s=z;
						} 
					}
				}
			}
		}
	}
	cout<<dp[n].s;
}


Measured memory_bytes: 41344
MOD=10**9+7
S=input()

dp=[]
for i in range(len(S)+1):
  dp.append([0]*13)
dp[0][0]=1
#print(dp)

for i in range(1,len(S)+1):
  if S[i-1]=="?":
    for k in range(13):
      for j in range(10):
        dp[i][(10*k+j)%13]+=dp[i-1][k]
        dp[i][(10*k+j)%13]%=MOD
  else:
    si=int(S[i-1])
    for k in range(13):
      dp[i][(10*k+si)%13]+=dp[i-1][k]
      dp[i][(10*k+si)%13]%=MOD
    
#print(dp)
print(dp[-1][5])

Measured memory_bytes: 62300
import math

if __name__ == "__main__":
    a, b, C = list(map(int, input().split()))

    S = a * math.sin(math.radians(C)) * b * 0.5
    L = a + b + math.sqrt(a ** 2 + b ** 2 - (2 * a * b * math.cos(math.radians(C))))
    h = math.sin(math.radians(C)) * b

    print(S)
    print(L)
    print(h)


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

#define MAX_N 100
#define MAX_W 10000

int main() {
    int N, W;
    cin >> N >> W;
    int w[MAX_N+1], v[MAX_N+1];
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }
    static int dp[MAX_N+1][MAX_W+1];
    fill((int*)dp, (int*)(dp+MAX_N*+1), 0);
    // dp[i+1][j] := i番目までの品物で、 重さjまでで最大価値
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (w[i] <= j)
                dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            else
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7012
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

long[][] mmul(long[][] x, long[][] y)
{
    auto r = new long[][](x.length, y.length);
    foreach (i; 0..x.length) {
        foreach (j; 0..y[0].length) {
            foreach (k; 0..y.length) {
                r[i][j] = (r[i][j] + (x[i][k] * y[k][j]) % P) % P;
            }
        }
    }
    return r;
}

long[][] mpow(long[][] m, long k)
{
    auto r = new long[][](m.length, m[0].length);
    foreach (i; 0..m.length) {
        r[i][i] = 1;
    }
    while (k) {
        if (k%2 == 1) r = mmul(r, m);
        k /= 2;
        m = mmul(m, m);
    }
    return r;
}

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto A = new long[][](N, N);
    foreach (i; 0..N) {
        foreach (j, b; readln.split) {
            if (b == "1") A[i][j] = 1;
        }
    }
    auto m = mpow(A, K);
    long r;
    foreach (mm; m) foreach (e; mm) r = (r + e) % P;
    writeln(r);
}

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

string s1, s2;
int dp[1001][1001];
 
int main() {
    
    cin >> s1 >> s2;
    int len1 = s1.length();
    int len2 = s2.length();
 
    memset(dp,-1,sizeof(dp));
 
    for (int i=0; i<=len1; i++) dp[i][0] = i;
    for (int i=0; i<=len2; i++) dp[0][i] = i;
 
    for (int i=1; i<=len1; i++) {
        for (int j=1; j<=len2; j++) {
            int a = 1;
            if (s1[i-1] == s2[j-1]) a = 0;
            
            dp[i][j] = dp[i-1][j-1] + a;
            dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
            dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
        }
    }
 
    cout << dp[len1][len2] << endl;
}

Measured memory_bytes: 5112
N=gets.to_i
info=[]
N.times do
    x,y,h=gets.chomp.split(" ").map(&:to_i)
    if h==0
        info.push([x,y,h])
    else
        info.unshift([x,y,h])
    end
end
101.times do |x|
    101.times do |y|
        flg=true
        h=nil
        info.each do |xi,yi,hi|
            tmp=(x-xi).abs+(y-yi).abs+hi
            h||=tmp
            if h!=tmp
                flg=false
                break
            end if hi>0
            if h>tmp
                flg=false
                break
            end if hi==0
        end
        if flg
            puts "#{x} #{y} #{h}"
            exit
        end
    end
end


Measured memory_bytes: 14360
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int a = Integer.valueOf(arr01[0]);
        int b = Integer.valueOf(arr01[1]);

        System.out.println(a < 10 && b < 10 ? a * b : -1);

    }

}

Measured memory_bytes: 22356