akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <limits>

using namespace std;

int64_t x[50];
int64_t y[50];

int64_t xCand[50];
int64_t yCand[50];

int main()
{
    int N, K;

    cin >> N >> K;

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
        xCand[i] = x[i];
        yCand[i] = y[i];
    }

    sort(xCand, xCand + N);
    sort(yCand, yCand + N);

    int64_t minArea = numeric_limits<int64_t>::max();
    for (int xLo = 0; xLo < N; xLo++)
    {
        for (int xHi = xLo; xHi < N; xHi++)
        {
            for (int yLo = 0; yLo < N; yLo++)
            {
                for (int yHi = yLo; yHi < N; yHi++)
                {
                    const int64_t x0 = xCand[xLo];
                    const int64_t x1 = xCand[xHi];
                    const int64_t y0 = yCand[yLo];
                    const int64_t y1 = yCand[yHi];

                    int pCnt = 0;
                    for (int i = 0; i < N; i++)
                    {
                        if (x0 <= x[i] && x[i] <= x1 && y0 <= y[i] && y[i] <= y1)
                        {
                            pCnt++;
                        }
                    }
                    if (pCnt < K)
                    {
                        continue;
                    }

                    const int64_t area = (y0 - y1) * (x0 - x1);
                    minArea = min(minArea, area);
                }
            }
        }
    }

    cout << minArea << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

ans = 1<<60

for i in range(-101,101):
    v = 0
    for ai in a:
        v += (ai-i)**2
    #print(v,i)
    ans = min(ans,v)


print(ans)





Measured memory_bytes: 9092
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main(){
    int q,M,i;
    
    scanf("%d", &n);
    for(i=0; i<n; i++)scanf("%d", &A[i]);
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &M);
        if(solve(0, M))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2624
#include <unistd.h>
#include <stdlib.h>

char ibuf[2000010];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(long long int x){
  int i;
  static char tmp[23];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


int n;
int A[200000];

inline void swap(int *a, int *b){
  int z;
  z = *a;
  *a = *b;
  *b = z;
}

int median(int *A, int n){
  int ll = 0;
  int rr = n;
  const int k = n/2;
  while(1){
    int i, l, r, pivot;
    swap(A+ll, A+(ll+rr)/2);
    pivot = A[ll];
    l = ll;
    r = rr;
    i = ll+1;
    while(i < r){
      if(A[i] < pivot) swap(A+l++, A+i++);
      else if(A[i] > pivot) swap(A+--r, A+i);
      else i++;
    } 
    if(k < l) rr = l;
    else if(k >= r) ll = r;
    else return pivot;
  }
}

int main(){
  int i, m;
  long long int r;
  readall();
  n = read_uint();
  for(i=0;i<n;i++){
    A[i] = read_uint()-(i+1);
  }
  m = median(A, n);
  r = 0;
  for(i=0;i<n;i++) r += abs(A[i] - m);
  write_uintln(r);
  writeall();
  return 0;
}


Measured memory_bytes: 2944
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

s = input()
ans = 0
for i in range(1<<(len(s)-1)):
    tmp = int(s[0])
    for j in range(len(s)-1):
        if i & 1<<j:
            ans += tmp
            tmp = int(s[j+1])
        else:
            tmp = tmp*10 + int(s[j+1])
    ans += tmp
print(ans)

Measured memory_bytes: 12492
import std.stdio, std.string, std.conv;
 void main(){
   auto ip = readln.split.to!(int[]);
   if(ip[0] + ip[1] > ip[2] + ip[3]){
     writeln("Left");
   }else if(ip[0] + ip[1] < ip[2] + ip[3]){
     writeln("Right");
   }else{
     writeln("Balanced");
   }
 }

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
	
	cin>>a>>b;

	cout<<a*b;

	
 return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#define N 411111
using namespace std;
int n,m;
int TOT,NE[N],EN[N],LA[N],LE[N];
queue<int>Q;
int dis[N];
bool f[N];
void SPFA()
{
	int i,x,y;
	memset(dis,60,sizeof(dis));
	dis[1]=0;f[1]=1;Q.push(1);
	while(!Q.empty())
	{
		x=Q.front();
		Q.pop();
		f[x]=0;
		for(i=LA[x];i;i=NE[i])
		{
			y=EN[i];
			if(dis[y]>dis[x]+LE[i])
			{
				dis[y]=dis[x]+LE[i];
				if(!f[y])f[y]=1,Q.push(y);
			}
		}
	}
}
void ADD(int x,int y)
{
	TOT++;
	EN[TOT]=y;
	LE[TOT]=1;
	NE[TOT]=LA[x];
	LA[x]=TOT;
}
int main()
{
	int i,x,y;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		ADD(x,y);ADD(y,x);
	}
	SPFA();
	if(dis[n]<=2)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}


Measured memory_bytes: 8832
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    x,t=MI()
    print(max(x-t,0))
main()

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for(int i=0 ; i<=a ; i++)
	{
		for(int j=0 ; j<=b ; j++)
		{
			int temp = x - ( (i*500) + (j*100));
			if(temp >= 0 && temp%50 == 0 && temp/50 <= c)
				ans++;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

constexpr int mod = 1000000007;

map<tuple<int, long long, long long>, int> result;
long long solve(int sz, long long s, long long e) {
  if (sz == 1) return 1;
  if (sz == 2) return s == e ? 1 : 3;
  auto ccheck = result.emplace(make_tuple(sz, s, e), 0);
  if (!ccheck.second) { return ccheck.first->second; }
  long long len = (1ull << (sz-1));
  long long sublen = len / 2;
  long long ans = 0;
  if (e - s >= sublen) ans += solve(sz - 1, s, e - sublen);
  if (s < sublen) ans += solve(sz - 1, s, min(sublen-1, e));
  if (e >= sublen) ans += solve(sz - 1, max(0ll, s - sublen), e - sublen);
  ccheck.first->second = ans % mod;
  return ans % mod;
}

int main() {
  long long L, R;
  scanf("%lld%lld", &L, &R);
  long long ans = 0;
  for (int sz = 1; sz <= 63; sz++) {
    long long beg = (1ull << (sz - 1));
    long long end = (1ull << sz) - 1;
    if (beg > R) continue;
    if (end < L) continue;
    ans += solve(sz, max(0ll, L-beg), min(end - beg, R - beg));
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    long n,W,w[100];
    long dp[100001],v[100];
    scanf("%ld %d",&n,&W);
    dp[0]=0;
    for(long i=1;i<=100000;i++){
        dp[i]=W+1L;
    }
    for(long i=0;i<n;i++){
        scanf("%ld %ld",&w[i],&v[i]);
        for(long j=100000;j>=v[i];j--){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    for(long i=100000;i>=0;i--){
        if(dp[i]<=W){
            printf("%ld\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 896
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
		    int r = sc.nextInt();
		    //符号
		    String n = sc.next();
		    int x = sc.nextInt();
		    if ("+".equals(n)) {
		        System.out.println(r + x);
		    } else if ("-".equals(n)) {
		        System.out.println(r - x);
		    } else if ("*".equals(n)) {
		        System.out.println(r * x);
		    } else if ("/".equals(n)) {
		        System.out.println(r / x);
		    } else {
		        break;
		    }
		    
		}
    }
}


Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
vector <int> a;
int k;
bool check(int num){
    rep(i,k){
        if(num < a[i]) {return false;}
        num = (num/a[i]) * a[i];
    }
    
    if(num>=2) return true;
    else return false;
}
bool check2(int num){
    rep(i,k){
        if(num < a[i]) {return false;}
        num = (num/a[i]) * a[i];
    }
    
    if(num>=3) return true;
    else return false;
}
signed main(void){
    cin>>k;
    a.resize(k);
    rep(i,k) cin>>a[i];
    int l=-1, r = 1000000000000000002;
    //二人未満残るライン
    while(abs(l-r)>1LL){
        int mid = (l+r)/2LL;
        if(check(mid) == false) l = mid; //二人未満なら
        else r = mid;
    }
    int ans1 = r;
    
    l=-1, r = 1000000000000000002;
    ///三人以上残る最大ライン
    while(abs(l-r)>1LL){
        int mid = (l+r)/2LL;
        if(check2(mid)) r = mid;
        else l = mid;
    }
    itn ans2 = l;
    if(ans1>ans2) {cout<<-1<<endl;}
    else cout<<ans1<<' '<<ans2<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int i;
  int array[5], a, b, c, d, e, ave, sum;
  a = array[0];
  b = array[1];
  c = array[2];
  d = array[3];
  e = array[4];

    scanf("%d %d %d %d %d",&a, &b, &c, &d, &e);
   
    if( a < 40 ) a = 40;
    if( b < 40 ) b = 40;
    if( c < 40 ) c = 40;
    if( d < 40 ) d = 40;
    if( e < 40 ) e = 40;
    
    sum = a + b + c + d + e;
    ave = sum / 5;
    printf("%d\n", ave);
  
  
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int n;
vector<int> a;

int partition(int p,int r)
{
	int sta = a[r];
	int j = p-1;
	for(int i = p;i<r;i++)
	{
		if(sta>=a[i])
		{
			j++;
			swap(a[j],a[i]);
		}
		else
		{
			
		}
		
	}
	j++;
	swap(a[r],a[j]);
	return j;
}

int main()
{
	cin >> n;
	a = vector<int>(n);
	for(int i =0;i<n;i++)
	{
		cin >>a[i];
	}
	int k = partition(0,n-1);
	for(int i = 0;i<n;i++)
	{
		if(i)cout<<' ';
		if(i==k)cout<<'['<<a[i]<<']';
		else
		cout<<a[i];
	}
	cout<<endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
ll n;

int main() {
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = (v[0] + v[1]) / 2.0;
  if (n > 2)
    for (int i = 2; i < n; i++) ans = (ans + v[i]) / 2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)


ans = Float::INFINITY

A.min.upto(A.max) do |i|
  tmp = 0
  A.each do |a|
    tmp += (a-i)**2
  end
  
  ans = [tmp, ans].min
end

puts ans

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

int main(void)
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for(int i{0}; i<H; ++i){
        cin >> a[i];
    }
    for(int i{0}; i<W+2; ++i){
        cout << '#';
    }
    cout << endl;

    for(int i{0}; i<H; ++i){
        cout << '#' << a[i] << '#' << endl;
    }

    for(int i{0}; i<W+2; ++i){
        cout << '#';
    }
    cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    int h,w; cin >> h >> w;
    vector<vector<char>> g(h+2,vector<char>(w+2));
    rep(i,h+2){
        if(i == 0 || i == h+1) rep(j,w+2) g[i][j] = '.';
        else {
            g[i][0] = '.'; g[i][w+1] = '.';
            for(int j = 1; j<= w; j++) cin >> g[i][j];
        }
    }
    rep(i,h+2)rep(j,w+2){
        if(g[i][j] == '#'){
            int cnt = 0;
            if(g[i][j-1] == '#') cnt++;
            if(g[i-1][j] == '#') cnt++;
            if(g[i+1][j] == '#') cnt++;
            if(g[i][j+1] == '#') cnt++;
            if(!cnt){
                no();
                return 0;
            }
        }
    }
    yes();
    return 0;
}

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

char conv(char c){
    if(c == '0')c = '1';
    else c = '0';
    return c;
}

int main() {
    string s;
    cin >> s;

    string s2 = s;

    int ans1 = 0;
    int ans2 = 0;

    for(int i = 1; i < s.size(); i++)
    {
        if(s[i-1] == s[i]){
            s[i] = conv(s[i]);
            ans1++;
        }

        if(s2[s2.size()-i] == s2[s2.size()-i-1]){
            s2[s2.size()-i-1] = conv(s2[s2.size()-i-1]);
            ans2++;
        }

    }
    
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>

using namespace std;


int main(){

	int r;
	char c;
	float x, y;
	double th0,th1;

	th1 = M_PI_2;
	x = 0.0;
	y = 0.0;

	while (1){
		cin >> r >> c >> th0;
		if (r == 0 && th0 == 0)break;

		x += r * cos(th1);
		y += r * sin(th1);

		th1 -= th0 * M_PI / 180.0;
	}
	cout << (int)x << endl << (int)y << endl;


	return 0;
}

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

int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  
  if(S == U){
    A--;}
  else {
    B--;}
  cout << A << " " << B << endl;
  
}


Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

int k;
string n;

vector<vector<vector<int> > > dp(105,vector<vector<int> >(2,vector<int>(105,-1)));

int rec(int t = 0,bool tight = true,int sum = 0){
    if(t == n.size()){
        return (sum == k);
    }
    auto &ret = dp[t][tight][sum];
    if(~ret) return ret;
    int lim = (tight ? n[t] - '0' : 9);
    ret = 0;
    for(int i = 0; i <= lim; ++i){
        ret += rec(t+1, tight && (i == lim), sum + (i != 0));
    }

    return ret;
}

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

    cin >> n >> k;

    cout << rec() << '\n'; 

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(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)];
    }
};
class KRK{//c++11
	public:
	struct edge{
		int from,to;
		double cost;
	};
	vector<edge>G;
	int n;
	KRK(int size){
		n=size;
	}
	void add_edge(int a,int b,double c){
		edge e={a,b,c};
		G.pb(e);
	}
	double krk(){
		double sum=0;
		sort(all(G),[](edge a,edge b){
			return a.cost<b.cost;
		});
		UnionFind uf(n);
		rep(i,G.size()){
			edge e=G[i];
			if(!uf.findSet(e.from,e.to)){
				sum+=e.cost;
				uf.unionSet(e.from,e.to);
			}
		}
		return sum;
	}
};
int main(){
	int n;
	while(cin>>n,n){
		double in[110][4];
		rep(i,n)rep(j,4)cin>>in[i][j];
		double dis[110][110];
		rep(i,n)rep(j,n)if(i!=j)
			dis[i][j]=max<double>(0,sqrt((in[i][0]-in[j][0])*(in[i][0]-in[j][0])+(in[i][1]-in[j][1])*(in[i][1]-in[j][1])+(in[i][2]-in[j][2])*(in[i][2]-in[j][2]))-in[i][3]-in[j][3]);
		KRK krk(n);
		rep(i,n)loop(j,i+1,n){
			krk.add_edge(i,j,dis[i][j]);
			krk.add_edge(j,i,dis[j][i]);
		}
		printf("%.3f\n",krk.krk());
	}
}
 
 

Measured memory_bytes: 3544
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

r, D, x = readmi()
for i in range(10):
    x = r * x - D
    print(x)

Measured memory_bytes: 6736
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,p;
  cin >> a >> p;
  a=a*3+p;
  cout << a/2 << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#define llint long long
#define mod 998244353
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

const int FACT_MAX = 10000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	make_fact();
	
	llint ans = 0, mul = modpow(2, n/2), inv2 = modpow(2, mod-2);
	for(int i = n/2+1; i <= n; i++){
		mul *= inv2, mul %= mod;
		ans += mul * comb(n, i) % mod, ans %= mod;
	}
	ans *= 2, ans %= mod;
	ans = modpow(3, n) - ans + mod, ans %= mod;
	cout << ans << endl;

	return 0;
}

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

int main() {
	int n,k;
	cin>>n>>k;
	string s;
	//cin>>s;
	if(n>=13)
	cout<<k;
	else if(n>=6)
	cout<<k/2;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string c[] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"}, s;
    cin >> s;
    for (int i = 0; i < 7; i++) {
        if (s == c[i]) {
            cout << i + 1;
        }
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] P = new int[N];
		for(int i=0;i<N;i++) {
			P[i]=scan.nextInt();
		}
		scan.close();
		Arrays.parallelSort(P);
		int result = 0;
		for(int i=0;i<K;i++) {
			result += P[i];
		}
		System.out.println(result);
	}

}

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

long long N,T,Q;
long long A[100001],D[100001];
long long X[10001];
vector<long long> stp;

int main(){
	scanf("%lld%lld%lld",&N,&T,&Q);
	for(int i = 0; i < N; i++){
		scanf("%lld%lld",&A[i],&D[i]);
	}
	for(int i = 0; i < Q; i++){
		scanf("%lld",&X[i]);
		X[i]--;
	}
	stp = vector<long long>();
	for(int i = 0;i < N-1; i++){
		if(D[i] == 1 && D[i+1] == 2){
			stp.push_back((A[i] + A[i+1])/2);
		}
	}


	for(int i = 0; i < Q; i++){
		if(stp.size() == 0){
			printf("%lld\n",D[X[i]] == 1 ? A[X[i]]+T : A[X[i]]-T);
		}
		else if(D[X[i]] == 2 && A[X[i]] < stp[0]){
			printf("%lld\n",D[X[i]] == 1 ? A[X[i]]+T : A[X[i]]-T);
		}
		else if (D[X[i]] == 1 && A[X[i]] > stp[stp.size()-1]){
			printf("%lld\n",D[X[i]] == 1 ? A[X[i]]+T : A[X[i]]-T);
		}
		else{
			vector<long long>::iterator itr = lower_bound(stp.begin(),stp.end(),A[X[i]]);	
			int east = distance(stp.begin(),itr);
			int west = east-1;
			if(D[X[i]] == 1){ // east
				printf("%lld\n",min(stp[east],A[X[i]]+T));
			}
			else{ // west
				printf("%lld\n",max(stp[west],A[X[i]]-T));
			}
		}
	}

	return 0;
}



Measured memory_bytes: 4880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n + 1, 0);
    REP(i, n){
        cin >> a.at(i);
    }

    REP(i, k){
        vector<ll> a2(n + 1, 0);
        REP(j, n){
            a2.at(max(j - a.at(j), 0LL))++;
            a2.at(min(j + a.at(j) + 1, n))--;
        }
        for(ll j = 1; j <= n; ++j){
            a2.at(j) += a2.at(j - 1);
        }
        a2.back() = 0;
        swap(a, a2);

        bool is_all_n = true;
        REP(j, n){
            if(a.at(j) < n){
                is_all_n = false;
            }
        }
        if(is_all_n){ break; }
    }

    REP(i, n){
        cout << a.at(i);
        if(i + 1 < n){
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 6724
#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) cerr << #x << ": " << x << endl;
#define whatis2(x, y) wt(x); wt(y); cout << endl;
#define whatis3(x, y, z) wt(x); wt(y); wt(z); cout << endl;
#define whatis4(x, y, z, a) wt(x); wt(y); wt(z); wt(a); cout << endl;

using namespace std;
using ll = long long;

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

    // cout << "HELOOOOOOOOOOOOOOOOOOOOOOOOOOOOO" << endl;
    int a, b;
    cin >> a >> b;
    int mx = max (a, b);
    int cnt = 0;
    int c, d;
    while (1) {
        c = (cnt * 8)/100;
        d = (cnt * 10)/100;
        if (c == a && d == b) {
            cout << cnt << endl;
            return 0;
        } else if  (c > a && d > b) {
            cout << "-1" << endl;
            return 0;
        }
        ++cnt;
    }
    


    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
grid = []
for _ in range(H):
    grid.append(input())
mod = 10**9+7

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        if grid[i][j] == '.':
            upper = dp[i-1][j] if i > 0 else 0
            left = dp[i][j-1] if j > 0 else 0
            dp[i][j] = (upper + left) % mod

print(dp[-1][-1])


Measured memory_bytes: 54492
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a-1) / b+1 << endl;
}

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

#define k 10000

void CountingSort(int *,int);

int main(){
  int *A;
  int n;
  int i;

  /* Input */
  scanf("%d",&n);
  A=(int *)malloc((n)*sizeof(int)+1);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  CountingSort(A,n);

  free(A);

  return 0;
}

void CountingSort(int* A,int n){
  int C[k];
  int *B;
  int i,j;

  B=(int*)malloc(n*sizeof(int)+1);

  for(i=0;i<k;i++){
    C[i]=0;
  }

  /* C */
  for(j=0;j<n;j++){
    C[A[j]]++;
  }

  /* C' */
  for(i=1;i<k;i++){
    C[i]+=C[i-1];
  }

  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  free(B);
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    string s; cin >> s;

    string tmp = "";
    rep(i, n / 2){
        tmp += s[i];
    }

    if(s == tmp + tmp){
        OP("Yes");
    }else{
        OP("No");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
double dp[301][301][301]={0};
int A[200001];
int main(){
    int n;
    cin>>n;
    int num[4]={0};
    rep(i,n) cin>>A[i],num[A[i]]++;
    rep(i,n+1)rep(j,n+1)rep(k,n+1){
        if(i+j+k>n) continue;
        if(k>0) dp[i][j][k]+=(dp[i][j][k-1]+double(n)/(i+j+k))*(double(k)/(i+j+k));
        if(j>0) dp[i][j][k]+=(dp[i][j-1][k+1]+double(n)/(i+j+k))*(double(j)/(i+j+k));
        if(i>0) dp[i][j][k]+=(dp[i-1][j+1][k]+double(n)/(i+j+k))*(double(i)/(i+j+k));
    }
    cout<<setprecision(10)<<dp[num[3]][num[2]][num[1]]<<"\n";
}

Measured memory_bytes: 212480
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N);
  for(int i=0; i<N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<pair<int, int>> AB(N);
  for(int i=0; i<N; i++) {
    AB[i]=make_pair(A[i], B[i]);
  }
  sort(AB.begin(), AB.end());
  long long ans=0, cnt=0;
  for(int i=0; i<N; i++) {
    for(int j=0; j<AB[i].second; j++) {
      ans+=AB[i].first;
      cnt++;
      if(cnt==M) {
        break;
      }
    }
    if(cnt==M) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
n,*a=map(int,open(0).read().split())
b=[((i+1)==_) for i,_ in enumerate(a)]
cnt=0
for i in range(n-1):
  if b[i]==True:
    cnt+=1
    b[i]=False
    b[i+1]=False

if b[-1]==True:
  cnt+=1
print(cnt)

Measured memory_bytes: 14068
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

string dp[11000];
ll n, m, u[10] = { 0,2,5,5,4,5,6,3,7,6 };
char a[10];
int main() {
	cin >> n >> m;
	REP(i, m) cin >> a[i];
	REP(i, n) {
		if (dp[i].size() > 0 or i == 0) {
			REP(j, m) {
				string s = dp[i] + a[j];
				ll t = i + u[a[j] - '0'];
				if (s.size() == dp[t].size())dp[t] = max(dp[t], s);
				else if (s.size() > dp[t].size())dp[t] = s;
			}
		}
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 43648
#include<iostream>
#include<vector>
#include<complex>
#define rep(i,n) for(int i = 0;i < n ; ++i)

using namespace std;

using ll = long long;
using Point = complex<double>;


void solve(int n){
    Point p[n];
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        --a;
        p[a] = Point(b,c);
    }
    double dist[n][n];
    double d[n][n];
    rep(i,n)dist[i][i]=0;
    rep(i,n)rep(j,n){
        if(i==j)continue;
        if(abs(p[i]-p[j])<=50)dist[i][j]=abs(p[i]-p[j]);
        else dist[i][j]=1e9;
    }
    rep(i,n)rep(j,n){
        d[i][j]=dist[i][j];
    }
    rep(i,n)rep(j,n)rep(k,n){
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
    }
    int m;
    cin>>m;
    while(m--){
        int s,t;
        cin>>s>>t;
        --s;--t;
        if(dist[s][t]>=1e8){
            cout<<"NA"<<endl;
            continue;
        }
        while(s!=t){
            cout<<s+1<<" ";
            rep(i,n){
                if(s!=i&&abs(d[s][i]+dist[i][t]-dist[s][t])<1e-5){
                    s=i;
                    break;
                }
            }
        }
        cout<<t+1<<endl;
    }
}

int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
}


Measured memory_bytes: 3288
N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**5+1)
for i in range(0,N):
    B[A[i]]=B[A[i]]+1
m=B[0]
for i in range(0,10**5):
    x=0
    if i==0:
        x=B[0]+B[1]
        if x>m:
            m=x
    else:
        x=B[i-1]+B[i]+B[i+1]
        if x>m:
            m=x
print(m)

Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string a,b,c;
    cin>>a>>b>>c;
    int x=a.length(),y=b.length(),z=c.length();
    if(a[x-1]==b[0] && b[y-1]==c[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

/*
void small() {
 
    rep3(i, 2, 20) rep3(j, 2, 20) rep3(k, 2, 20) rep3(l, 2, 20) rep3(m, 2, 20) {
        if (gcd(i, gcd(j, gcd(k, gcd(l, m)))) != 1) continue;
        int sum = i + j + k + l + m;
        if (gcd(i, sum) == 1 || gcd(j, sum) == 1 || gcd(k, sum) == 1 || gcd(l, sum) || gcd(m, sum) == 1) continue;
        cout << i << " " << j << " " << k << " " << l << " " << m << '\n';
        return;
    }
 
    int a[] = {2, 5, 20, 63};
    int sum = 0;
    rep(i, 4) sum += a[i];
    rep3(i, 2, 100) {
        if (gcd(sum, i) == 1) continue;
        int flg = 0;
        rep(j, 4) if (gcd(sum + i, a[j]) == 1) flg = 1;
        if (flg) continue;
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << " " << i << '\n';
        return;
    }
}
*/
const int maxn = 30011;
void calc(int now, vector<int> v, int table[], int key, int key2) {
    rep3(i, now, maxn) {
        if (table[i] && i % 6 == key2) {
            v.eb(i);
            break;
        }
    }
    rep(i, sz(v)) {
        if (v[i] == key) continue;
        if (i) cout << " ";
        cout << v[i];
    }
    cout << '\n';
}

int main() {
    
    
    
    int table[maxn] = {0};
    int n;
    cin >> n;
    
    if (n <= 5) {
        if (n == 3) cout << "2 5 63" << '\n';
        else if (n == 4) cout << "2 5 20 63" << '\n';
        else // small();
            cout << "2 5 20 30 63" << '\n';
        return 0;
    }
    
    rep3(i, 2, maxn) {
        if (i % 6 == 2 || i % 6 == 3 || i % 6 == 4 || i % 6 == 0) {
            table[i] = 1;
        }
    }
    
    vector<int> v;
    int sum = 0;
    int now = 0, cnt = 0;
    rep(i, maxn) {
        if (table[i] == 1) {
            v.eb(i);
            sum += i;
            cnt++;
            if (cnt == n) { now = i + 1; break; }
        }
    }
    
    if (sum % 6 == 2) calc(now, v, table, 8, 0);
    else if (sum % 6 == 3) calc(now, v, table, 9, 0);
    else if (sum % 6 == 5) calc(now, v, table, 9, 4);
    else { // % 6 == 0
        rep(i, sz(v)) cout << v[i] << " "; cout << '\n';
    }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    vc fnt;
    vc bck;
    string s;
    char x;
    int q,a,f;
    bool hanten=true;
    cin>>s>>q;
    REP(i,q){
        cin>>a;
        if(a==1) hanten=!hanten;
        else{
            scanf("%d %c",&f,&x);
            if(hanten){
                if(f==1) fnt.push_back(x);
                else bck.push_back(x);
            }
            else{
                if(f==2) fnt.push_back(x);
                else bck.push_back(x);
            }
            
        }
    }



    if(hanten){
        for(int i=fnt.size()-1;i>=0;i--) printf("%c",fnt[i]);
        cout<<s;
        REP(i,bck.size()) printf("%c",bck[i]);
    }
    else{
        for(int i=bck.size()-1;i>=0;i--) printf("%c",bck[i]);
        for(int i=s.length()-1;i>=0;i--) printf("%c" ,s[i]);
        REP(i,fnt.size()) printf("%c",fnt[i]);
    }
    cout<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)


const int N=2e6+5;
const int mod=1e9+7;


int main(){
      int x,y;
      cin>>x>>y;
      for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                  if(i+j==x  && i*2+j*4==y) {
                        cout<<"Yes\n";
                        return 0;
                  }
            }
      }     
      cout<<"No";
      
      return 0;
}

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

int lis(vector<int>&A)
{
	int N = A.size();
	vector<int>L(N);

	L[0] = A[0];
	int len = 1;

	for (int i = 1; i < N; i++)
	{
		if (L[len - 1] <= A[i])
		{
			L[len++] = A[i];
		}
		else
		{
			*upper_bound(L.begin(), L.begin()+len, A[i]) = A[i];
		}
	}

	return len;
}

int main() {
	int N;cin>>N;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	reverse(A.begin(), A.end());

	cout<<lis(A)<<endl;

	return 0;
}

Measured memory_bytes: 1024
import sys

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    print('NO')
    sys.exit()

D = abs(A - B)
X = V - W

if D / X <= T:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9040
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        Set<String> set = new HashSet<>();
        for(int i=0; i<N; i++){
            set.add(next());
        }
        println(set.size());
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 77340
n, *h = map(int, open(0).read().split())
dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13876
#! python3
# counting_characters.py

import sys

sents = [line.strip() for line in sys.stdin.readlines()]
dic = {chr(x):0 for x in range(ord('a'), ord('z')+1)}

for sent in sents:
    for c in sent:
        x = c.lower()
        if ord('a') <= ord(x) and ord(x) <= ord('z'):
            dic[x] += 1

for k, v in dic.items():
    print(k + ' : ' + str(v))



Measured memory_bytes: 5568
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(input().split())
haba = a[0]
for i in a:
    if int(haba[0]) <= int(i[0]) <= int(haba[1]):
        haba[0] = i[0]
    elif int(haba[1]) < int(i[0]):
        print(0)
        exit()
    if int(haba[0]) <= int(i[1]) <= int(haba[1]):
        haba[1] = i[1]
    elif int(i[1]) < int(haba[0]):
        print(0)
        exit()
if n < int(haba[0]):
    ans = 0
elif int(haba[0]) <= n <= int(haba[1]):
    ans = n - int(haba[0]) + 1
else:
    ans = int(haba[1]) - int(haba[0]) + 1
print(ans)

Measured memory_bytes: 38316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
int ans = -1;

int main(){
	cin >> s;
	if (s.size() == 2){
		if (s[0] == s[1])cout << 1 << " " << 2 << endl;
		else cout << -1 << " " << -1 << endl;
		return 0;
	}
	REP(i, s.size() - 2){
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]){
			ans = i + 1;
			break;
		}
	}
	if (ans == -1){
		cout << ans << " " << ans << endl;
	}
	else{
		cout << ans << " " << ans + 2 << endl;
	}
}

Measured memory_bytes: 512
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        s: chars,
    }
    let mut x = 0;
    let mut max_x = 0;
    for c in s.iter() {
        if *c == 'I' {
            x += 1
        } else if *c == 'D' {
            x -= 1
        }
        max_x = max(x, max_x);
    }
    println!("{}", max_x);
}


Measured memory_bytes: 4352
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        m = n // i
        ans += i * m * (m + 1) // 2
    return ans


def main():
    N = int(input())

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 108968
def SCC_Tarjan(g):
    n = len(g)
    order = [-1]*n # 負なら未処理、[0,n) ならpre-order, n ならvisited
    low = [0]*n
    ord_now = 0
    parent = [-1]*n
    gp = [0]*n
    gp_num = 0
    S = []
    q = []
    for i in range(n):
        if order[i] == -1:
            q.append(i)
            while q:
                v = q.pop()
                if v >= 0:
                    if order[v] != -1: continue
                    order[v] = low[v] = ord_now
                    ord_now += 1
                    S.append(v)
                    q.append(~v)
                    for c in g[v]:
                        if order[c] == -1: 
                            q.append(c)
                            parent[c] = v
                        else:
                            low[v] = min(low[v], order[c])
                else:
                    v = ~v
                    if parent[v] != -1:
                        low[parent[v]] = min(low[parent[v]], low[v])
                    if low[v] == order[v]:
                        while True:
                            w = S.pop()
                            order[w] = n
                            gp[w] = gp_num
                            if w==v: break
                        gp_num += 1
 
    return gp

class TwoSAT:
    def __init__(self, n):
        self._n = n
        self._answer = [False]*n
        self._g = [[] for _ in range(2*n)]

    def add_clause(self, i: int, f: bool, j: int, g: bool) -> None:
        self._g[2*i+1-f].append(2*j+g)
        self._g[2*j+1-g].append(2*i+f)

    def satisfiable(self) -> bool:
        scc_id = SCC_Tarjan(self._g)
        for i in range(self._n):
            if scc_id[2*i] == scc_id[2*i+1]:
                return False
            self._answer[i] = scc_id[2*i] < scc_id[2*i+1]
        return True

    def answer(self):
        return self._answer

###########################################################################                        
###########################################################################                        

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,d = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]

g = TwoSAT(n)
for i in range(n):
    xi,yi = xy[i]
    for j in range(i+1,n):
        xj,yj = xy[j]
        if abs(xi-xj) < d:
            g.add_clause(i,0,j,0)
        if abs(xi-yj) < d:
            g.add_clause(i,0,j,1)
        if abs(yi-xj) < d:
            g.add_clause(i,1,j,0)
        if abs(yi-yj) < d:
            g.add_clause(i,1,j,1)

tf = g.satisfiable()
if tf:
    print("Yes")
    ans = g.answer()
    #print(ans)
    for xyi,ai in zip(xy,ans):
        print(xyi[ai])

else:
    print("No")


Measured memory_bytes: 70056
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int t = sc.nextInt();
			int n = sc.nextInt();
			if(t==0 && n==0) break;
			
			boolean[][] map = new boolean[150][150];
			boolean[][] visit = new boolean[150][150];
			int p, q, r;
			for(int i=0;i<n;i++){
				p = sc.nextInt()+75;
				q = sc.nextInt()+75;
				map[q][p] = true;
			}
			p = sc.nextInt()+75;
			q = sc.nextInt()+75;
			
			int cnt = 1;
			LinkedList<Integer> x = new LinkedList<Integer>();
			LinkedList<Integer> y = new LinkedList<Integer>();
			int[] a = new int[]{1,1,0,-1,-1,0};
			int[] b = new int[]{1,0,1,-1,0,-1};
			x.offer(p);
			y.offer(q);
			visit[q][p] = true;
			for(int i=0;i<t;i++){
				r = x.size();
				for(int j=0;j<r;j++){
					p = x.poll();
					q = y.poll();
					for(int k=0;k<6;k++){
						if(visit[q+b[k]][p+a[k]]==false && map[q+b[k]][p+a[k]]==false){
							visit[q+b[k]][p+a[k]] = true;
							x.offer(p+a[k]);
							y.offer(q+b[k]);
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt);
		}	
	}	
}

Measured memory_bytes: 61668
(let ((N (read))
      (K (read))
      (tmp (make-hash-table))
      (result 0))
  (loop for i below N
        do (setf (gethash (1+ i) tmp) 0))
  (dotimes (x K)
    (dotimes (y (read))
      (incf (gethash (read) tmp))))
  (maphash (lambda (key value) (when (= value 0) (incf result))) tmp)
  (princ result))

Measured memory_bytes: 29824