akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	var total int
	fmt.Scan(&total)

	var sc = bufio.NewScanner(os.Stdin)

	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	cnt := 0.0
	for {
		for _, value := range strings.Split(s, " ") {
			valueInt, _ := strconv.Atoi(value)
			valueInt = valueInt / int(math.Pow(2.0, cnt))

			if valueInt%2 != 0 {
				fmt.Println(cnt)
				return
			}
		}
		cnt++
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM(f:power)
// --> f:power
// ---- inserted function power from util.cc
/* *** WARNING ***  
      ll x = power(10, 12) 
   does not work since it is interpreted as 
      ll x = power<int>((int)10, 12)
   Use power<ll>(10, 12) or power(10LL, 12).
 */
template<typename T>
T power(T a, ll b) {
  T twoPow = a;
  T rv(1);
  while (b > 0) {
    if (b & 1LL) rv *= twoPow;
    twoPow *= twoPow;
    b >>= 1;
  }
  return rv;
}

// ad-hoc power function
template<typename T, typename Op>
T ah_power(T a, ll b, const T& unit_t, Op op) {
  T two_pow = a;
  T ret = unit_t;
  while (b > 0) {
    if (b & 1LL) ret = op(ret, two_pow);
    two_pow = op(two_pow, two_pow);
    b >>= 1;
  }
  return ret;
}
// ---- end power
// @@ !! LIM  -- end mark --

string solve() {
  ll n; cin >> n; n--;

  ll k = 1;
  ll lim = 26;
  
  while (true) {
    if (n < lim) {
      string ans;
      for (ll i = 0; i < k; i++) ans += 'a';
      ll p = k-1;
      while (n > 0) {
	ll x = n % 26;
	ans.at(p) = 'a' + x;
	n /= 26;
	p--;
      }
      return ans;
    }
    n -= lim;
    k ++;
    lim *= 26;
  }
}




int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);


  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 3644
Q, H, S, D = map(int, input().split())  # 0.25, 0.5, 1, 2
H = min(H, 2 * Q)   # 0.5
S = min(S, 2 * H)   # 1
N = int(input())
if 2 * S <= D:
    print(S * N)
else:
    if N % 2 == 0:
        print(D * N // 2)
    else:
        print(D * (N // 2) + S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

int bin(vector<int> &a, int target){
    int l = 0, r = sz(a)-1;

    while (r >= l){
        int m = (l+r)/2;
        if (a[m] == target) return m;
        if (a[m] > target) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int type;
    string t, f, c;
    bool flag = true;
    for (int i = 0; i < q; i++){
        cin >> t;
        if (t[0] == '1') flag = !flag;
        else{
            cin >> f >> c;
            if (f[0] == '1') {
                if (flag) s = c + s;
                else s += c;
            }
            else if (flag) s += c;
            else s = c + s;
        }
    }
    if (!flag) reverse(all(s));
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 4704
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int s=0;
	while(1/*a<=b||b<=c*/)
	{
		if(a>=b)b*=2,s++;
		else if(b>=c)c*=2,s++;
		else break;
	}
	//printf("s=%d\n",s);
	if(s<=k)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3632
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n, m;
    scan(n, m);
    auto a = readln.split.to!(int[]);

    int[int] asc;
    int[] b = new int[](n + 1);

    asc[0] = 1;
    b[n] = 0;

    int val;
    long sum;

    foreach_reverse (i ; 0 .. n) {
        val += a[i];
        val %= m;

        if (val in asc) {
            asc[val]++;
        }
        else {
            asc[val] = 1;
        }

        b[i] = val;
        sum += a[i];
    }

    debug {
        writeln(asc);
        writeln(b);
    }

    long ans;

    foreach (i ; 0 .. n) {
        if (sum % m in asc) {
            ans += asc[sum % m];
        }

        asc[b[i]]--;

        sum -= a[i];
    }

    writeln(ans - n);
}


























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X;
    ll t;
    cin >> X >> t;

    if(X-t > 0){
        cout << X-t << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

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

int main(void){
  int c[3][3];
  rep(i, 3) rep(j, 3) cin >> c[i][j];

  bool flag = true;
  int tmp1 = c[0][0] - c[0][1], tmp2 = c[0][0] - c[0][2];
  for(int i = 1; i < 3; i++){
    if(c[i][0] - c[i][1] != tmp1 || c[i][0] - c[i][2] != tmp2) flag = false;
  }
  tmp1 = c[0][0] - c[1][0];
  tmp2 = c[0][0] - c[2][0];
  for(int i = 1; i < 3; i++){
    if(c[0][i] - c[1][i] != tmp1 || c[0][i] - c[2][i] != tmp2) flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<char, vector<char>> input;
	input['1'] = {'.', ',', '!', '?', ' '};
	input['2'] = {'a', 'b', 'c'};
	input['3'] = {'d', 'e', 'f'};
	input['4'] = {'g', 'h', 'i'};
	input['5'] = {'j', 'k', 'l'};
	input['6'] = {'m', 'n', 'o'};
	input['7'] = {'p', 'q', 'r', 's'};
	input['8'] = {'t', 'u', 'v'};
	input['9'] = {'w', 'x', 'y', 'z'};
	rep (i, n) {
		string s;
		cin >> s;
		string ans;
		int idx = [&] {
			rep (i, s.size()) {
				if (s[i] != '0') return i; 
			}
			return 0;
		}();
		int cnt = -1;
		REP (i, idx, s.size()) {
			if (i != 0 && s[i] == '0' && s[i - 1] != '0') {
				ans += input[s[i - 1]][cnt];
				cnt = -1;
			} else if (s[i] != '0') {
				cnt = (cnt + 1) % input[s[i]].size();
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
open System

let flip f a b = f b a
let read() = Console.ReadLine()

[<EntryPoint>]
let main _ =
    let s = read() |> int
    let k = read()
    if k.Length > s then k.Substring(0, s) + "..."
    else k
    |> printfn "%s"
    
    0 


Measured memory_bytes: 29668
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         2000000014
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int solve()
{
  int n, sum = 0, sq = 0;
  cin >> n;
  int a[n];
  rep0(n)cin >> a[i], sum = (sum + a[i]) % mod, sq = (sq + (a[i] * a[i]) % mod) % mod;
  sum = (sum * sum) % mod;
  cout << ((sum - sq + mod) % mod) / 2;
  return 0;
}
signed main()
{
  OJ();
  IOS
  //tc
  solve();
  //extime
  return 0;
}

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

ll gcd(ll a, ll b){
    ll x = max(a,b);
    ll y = min(a,b);
    ll r = x % y;
    while(r!=0){
     x = y;
     y = r;
     r = x % y;
  }
  return y;
}

int main() {
    ll a,b;
    ll c,d;
    cin >> a >> b >> c >> d;
    ll ans = b-a+1;
    ll lcm = (c*d)/gcd(c,d);
    ll small = a-1;
    small = small-(a-1)/c-(a-1)/d+(a-1)/lcm;
    ll big = b;
    big = big-b/c-b/d+b/lcm;
    cout << big - small << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n int
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	rate := make([]int, n)
	for i := range rate {
		scanner.Scan()
		rate[i], _ = strconv.Atoi(scanner.Text())
	}
	minRate := rate[0]
	maxValue := 1 - 10*10*10*10*10*10*10*10*10 - 1

	for i := 1; i < n; i++ {
		maxValue = max(maxValue, rate[i] - minRate)
		minRate = min(minRate, rate[i])
	}

	fmt.Println(maxValue)
}


Measured memory_bytes: 5356
#include<stdio.h>

int main(void)
{
  int n;
  double x[11]={0};
  double sum=0;
  char u[11];
  scanf("%d",&n);
 for(int i=0;i<n;i++)
 {
   scanf("%lf %s",&x[i],&u[i]);
   if(u[i]=='B'){
     sum=sum+(x[i]*380000.0);
   }
   else{
    sum=sum+x[i];
   }
 }
  printf("%f",sum);
  return 0;
}

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

int main(){
  int n;
  string s,a;
  cin >> n >> s;
  for(int i=0; i<n; i++){
    if(s[i] != s[i-1]){
    a = a + s[i];
    }
  }
  cout << a.size() << endl;
}

Measured memory_bytes: 696
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

def sol():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d = A[i][k] + A[k][j]
                if d < A[i][j]:
                    return - 1

    INF = 10**18

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if k == i or k == j:
                    continue

                if A[i][k] + A[k][j] == A[i][j]:
                    A[i][j] = INF

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if A[i][j] < INF:
                ans += A[i][j]

    return ans

print(sol())


Measured memory_bytes: 45148
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int dp[101][10001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, W;
    cin >> n >> W;
    int v[n], w[n];
    rep(i, n) cin >> v[i] >> w[i];

    rep(i, n) {
        rep(j, 10001) {
            if (j < w[i]) dp[i+1][j] = dp[i][j];
            else if (j >= w[i]) dp[i+1][j] = max(dp[i][j], dp[i + 1][j-w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;

    return 0;
}



Measured memory_bytes: 7148
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int hit[504][200004];
int sum[504][200004];
int main() {
  int N, M, Q;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &Q);
  std::vector<int > L(M), R(M), p(Q), q(Q);
  for (int i=0; i<M; i++){
    scanf("%d", &L[i]);
    scanf("%d", &R[i]);
  }
  for (int i=0; i<Q; i++){
    scanf("%d", &p[i]);
    scanf("%d", &q[i]);
  }
  for (int i=0; i<M;i++){
    hit[L[i]][R[i]]++;
  }
  for (int i=1; i<=N; i++){
    for (int j=1; j<=N; j++){
      sum[i][j]=hit[i][j]-sum[i-1][j-1]+sum[i][j-1]+sum[i-1][j];
    }
  }
  for (int i=0; i<Q; i++){
    int ans = sum[q[i]][q[i]]-sum[p[i]-1][q[i]]-sum[q[i]][p[i]-1]+sum[p[i]-1][p[i]-1];
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 785664
import java.io.*;
import java.util.*;
  
public class Main{
    public static void main(String[] args)throws IOException, NumberFormatException{
        BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        ArrayList<Integer> h = new ArrayList<Integer>();
        ArrayList<Integer> w = new ArrayList<Integer>();
          
        while(true){
            String[] s = br.readLine().split(" ");
            if( "0".equals(s[0]) && "0".equals(s[1]) ) break;
              
            h.add( Integer.parseInt(s[0]) );
            w.add( Integer.parseInt(s[1]) );
        }
          
        StringBuilder builder = new StringBuilder();
        for( int i=0 ; i<h.size() ; i++ ){
            for( int j=0 ; j<h.get(i) ; j++ ){
                for( int k=0 ; k<w.get(i) ; k++ ){
                    builder.append("#");
                }
                builder.append("\n");
            }
            builder.append("\n");
        }
        System.out.print(builder);
    }
}

Measured memory_bytes: 25588
#include<stdio.h>
#define N 10000

int main(void){
  int i,num;
  double xa1[N],ya1[N],xa2[N],ya2[N],
         xb1[N],yb1[N],xb2[N],yb2[N];

  for(i=0;
      scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
        &xa1[i],&ya1[i],&xa2[i],&ya2[i],
        &xb1[i],&yb1[i],&xb2[i],&yb2[i])==8;
      i++){}
  num=i;
  for(i=0;i<num;i++){
    if(
        (
         (xa1[i]<=xb1[i] && xb1[i]<=xa2[i]  &&  ya1[i]<=yb1[i] && yb1[i]<=ya2[i]) ||
         (xa1[i]<=xb1[i] && xb1[i]<=xa2[i]  &&  ya1[i]<=yb2[i] && yb2[i]<=ya2[i]) ||
         (xa1[i]<=xb2[i] && xb2[i]<=xa2[i]  &&  ya1[i]<=yb1[i] && yb1[i]<=ya2[i]) ||
         (xa1[i]<=xb2[i] && xb2[i]<=xa2[i]  &&  ya1[i]<=yb2[i] && yb2[i]<=ya2[i])
        )
        ||
        (
         (xb1[i]<=xa1[i] && xa1[i]<=xb2[i]  &&  yb1[i]<=ya1[i] && ya1[i]<=yb2[i]) ||
         (xb1[i]<=xa1[i] && xa1[i]<=xb2[i]  &&  yb1[i]<=ya2[i] && ya2[i]<=yb2[i]) ||
         (xb1[i]<=xa2[i] && xa2[i]<=xb2[i]  &&  yb1[i]<=ya1[i] && ya1[i]<=yb2[i]) ||
         (xb1[i]<=xa2[i] && xa2[i]<=xb2[i]  &&  yb1[i]<=ya2[i] && ya2[i]<=yb2[i])
        )
        ||
        (
         (xa1[i]<=xb1[i] && xb1[i]<=xa2[i]  &&  xa1[i]<=xb2[i] && xb2[i]<=xa2[i]) &&
         (ya1[i]>=yb1[i] && yb2[i]>=ya2[i])
        )
        ||
        (
         (ya1[i]<=yb1[i] && yb1[i]<=ya2[i]  &&  ya1[i]<=yb2[i] && yb2[i]<=ya2[i]) &&
         (xa1[i]>=xb1[i] && xb2[i]>=xa2[i])
        )
        ||
        (
         (xb1[i]<=xa1[i] && xa1[i]<=xb2[i]  &&  xb1[i]<=xa2[i] && xa2[i]<=xb2[i]) &&
         (yb1[i]>=ya1[i] && ya2[i]>=yb2[i])
        )
        ||
        (
         (yb1[i]<=ya1[i] && ya1[i]<=yb2[i]  &&  yb1[i]<=ya2[i] && ya2[i]<=yb2[i]) &&
         (xb1[i]>=xa1[i] && xa2[i]>=xb2[i])
        )
        ){
          printf("YES\n");
        }else{
          printf("NO\n");
        }
  }
  return 0;
}

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

vector<int> diff(2);
void diffgene(int a, int b, int c) {
  diff.at(0) = a - b;
  diff.at(1) = b - c;
}

vector<int> input() {
  vector<int> vec(3);
  for (int i = 0; i < 3; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  vector<int> A1,A2,A3;
  A1 = input();
  A2 = input();
  A3 = input();
  
  int n = 0;
  
  vector<int> A1diff(2), A2diff(2), A3diff(2), B1diff(2), B2diff(2), B3diff(2);
  
  diffgene(A1.at(0), A1.at(1), A1.at(2));
  A1diff = diff;
  
  diffgene(A2.at(0), A2.at(1), A2.at(2));
  A2diff = diff;
  
  diffgene(A3.at(0), A3.at(1), A3.at(2));
  A3diff = diff;
  
  diffgene(A1.at(0), A2.at(0), A3.at(0));
  B1diff = diff;
  
  diffgene(A1.at(1), A2.at(1), A3.at(1));
  B2diff = diff;
  
  diffgene(A1.at(2), A2.at(2), A3.at(2));
  B3diff = diff;
  
  if (A1diff != A2diff || A2diff != A3diff || B1diff != B2diff || B2diff != B3diff) n++;
  
  if (n) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(map.containsKey(a)){
                map.put(a, map.get(a)+1);
            }else {
                map.put(a, 1);
            }
        }
        int ans = 0;

        for(int p : map.keySet()){
            int count = map.get(p);
            if(map.containsKey(p-1)){
                count += map.get(p-1);
            }
            if(map.containsKey(p+1)){
                count += map.get(p+1);
            }
            ans = Math.max(ans, count);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63336
#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 int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  ll v[n][3], dp[n+1][3] = {0};
  rep(i, n) cin >> v[i][0] >> v[i][1] >> v[i][2];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){ //更新対象
      for(int k = 0; k < 3; k++){
        if(j == k)continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k]+v[i][k]);
      }
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  system("pause");
}

Measured memory_bytes: 5120
#include<stdio.h>
#define m 45

int N[m];

int F(int n){
  if(n==0 || n==1)return N[n]=1;
  if(N[n]!=-1)return N[n];
  return N[n]=F(n-1)+F(n-2);
}

int main(){
  int i, n;
  for(i=0 ; i<m ; i++)N[i]=-1;
  scanf("%d", &n);
  printf("%d\n", F(n));
  return 0;
}


Measured memory_bytes: 2104
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <random>
#include <chrono>
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define int long long
using namespace std;

const int INF = 2e17;
const int MOD = 1e9 + 7;

void solve() {
	string s, t;
	cin >> s >> t;
	vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
	vector<vector<pair<int, int>>> p(s.size() + 1, vector<pair<int, int>>(t.size() + 1));
	for (int i = 1; i <= s.size(); i++) {
		for (int j = 1; j <= t.size(); j++) {
			if (s[i - 1] == t[j - 1]) {
				p[i][j] = { -1, -1 };
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			if (dp[i][j] <= dp[i - 1][j]) {
				dp[i][j] = dp[i - 1][j];
				p[i][j] = { -1, 0 };
			}
			if (dp[i][j] <= dp[i][j - 1]) {
				dp[i][j] = dp[i][j - 1];
				p[i][j] = { 0, -1 };
			}
		}
	}

	int nowX = s.size();
	int nowY = t.size();
	string ans;

	while (nowX && nowY) {
		if (p[nowX][nowY].first == -1 && p[nowX][nowY].second == -1) {
			ans.pb(s[nowX - 1]);
		}
		auto w = p[nowX][nowY];
		nowX += w.first;
		nowY += w.second;
	}
	reverse(ans.begin(), ans.end());

	cout << ans;
}



signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 211584
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <climits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

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

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  string s;
  cin>>s;
  if (s[s.size() - 1] == 's') cout << s + "es" << endl;
  else
    cout << s + "s" << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main(){
	int x;
	cin >> x;
	int ma = 0;
	if(x == 1) ma = 1;
	else{
		for(int i = 2; i*i <= x; i++){
			for(int j = 2; pow(i,j) <= x; j++){
				ma = max(ma,(int)(pow(i,j)+EPS));
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy";
	else if(s == "Cloudy") cout << "Rainy";
	else if(s == "Rainy") cout << "Sunny";
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	string S;
	cin >> N >> S;

	int result = 1;
	char ch = S[0];

	for( int i = 1; i < N; ++i ) {
		if( S[i] != ch ) {
			ch = S[i];
			result += 1;
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#define ll long long
#define inf 0x7fffffff;
#define maxn 600005
using namespace std;
set<ll>s;
ll a[maxn],n,k,cnt[maxn],vis[maxn],sum[maxn],num,b[maxn],ans;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll read()
{
    int l=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        else
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        l*=10;
        l+=ch-'0';
        ch=getchar();
    }
    return l*w;
} 
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(!sum[a[i]]) b[++num]=a[i];
		sum[a[i]]++;
		cnt[i]=a[i];
	}
	for(int i=1;i<=num;i++)
	{
		ans+=sum[b[i]]*(sum[b[i]]-1)/2;
	} 
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n",ans-sum[cnt[i]]+1);
	}
	return 0;
}

Measured memory_bytes: 12800
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int h=ni();
        int w=ni();
        long[][]dp=new long[h+1][w+1];
        dp[1][1]=1;
        for(int i=1;i<=h;i++)
        {
            String s=nln();
            for(int j=1;j<=w;j++)
            {
                if(s.charAt(j-1)=='.')
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                dp[1][1]=1;
            }
        }
        // pn(Arrays.deepToString(dp));
        pn(dp[h][w]);
    }
    static long mod=(long)1e9+7;
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 33816
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto dl = DList!long();

  foreach (_; 0..n) {
    auto rd = readln.splitter, cmd = rd.front; rd.popFront;
    switch (cmd) {
    case "insert":
      auto x = rd.front.to!long;
      dl.insertFront(x);
      break;
    case "delete":
      auto x = rd.front.to!long;
      auto r = dl[].find(x).take(1);
      if (!r.empty) dl.linearRemove(r);
      break;
    case "deleteFirst":
      dl.removeFront;
      break;
    case "deleteLast":
      dl.removeBack;
      break;
    default:
      assert(0);
    }
  }

  writeln(dl[].map!(to!string).join(" "));
}

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


int main() {
    string S;
    cin >> S;
    long long n = S.size();
    long long res = 0;
    long long num = 0;
    for (long long i = 0; i < n; ++i) {
        if (S[i] == 'W') {
            res += num;
        }
        else {
            ++num;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>

#define endl '\n'
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

void solve()
{

    string a, b, c;

    cin >> a >> b >> c;

    cout << a[0] << b[1] << c[2];

}

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

//    int t; cin >> t; while(t--){
        solve();
//    }
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        double x1=sc.nextDouble();
        double y1=sc.nextDouble();
        double x2=sc.nextDouble();
        double y2=sc.nextDouble();
        System.out.println(Math.sqrt(Math.pow(Math.abs(x1-x2),2)+Math.pow(Math.abs(y1-y2),2)));
    }
}



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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e3+10,MOD=1e9+7;
int n,cnt[MAXN],pri[MAXN],vis[MAXN],tot;

int main()
{
	for(int i=2;i<=1000;i++)
	{
		if(!vis[i]) pri[++tot]=i;
		for(int j=1;j<=tot;j++)
		{
			if(pri[j]*i>1000) break;
			vis[pri[j]*i]=1;
			if(i%pri[j]==0) break;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int t=i;
		for(int j=1;j<=tot;j++)
			while(t%pri[j]==0)
				t/=pri[j],cnt[j]++;
	}
	ll res=1;
	for(int i=1;i<=tot;i++)
		res=res*(cnt[i]+1)%MOD;
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,dp[2][605][605],C[606][606],fac[606];
int A[605],cnt;
bool vis[605],used[605];
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
void update(int &x,int y) {
	x = inc(x,y);
}
void Init() {
	read(N);
	for(int i = 1 ; i <= 2 * N ; ++i) read(A[i]);
	cnt = 0;
	for(int i = 1 ; i <= N ; ++i) {
		if(A[2 * i] == -1 && A[2 * i - 1] == -1) ++cnt;
		if(A[2 * i] != -1 && A[2 * i - 1] != -1) {
			vis[A[2 * i]] = vis[A[2 * i - 1]] = 1;
		}
		else if(A[2 * i] != -1) used[A[2 * i]] = 1;
		else if(A[2 * i - 1] != -1) used[A[2 * i - 1]] = 1;
	}
	C[0][0] = 1;
	for(int i = 1 ; i <= 2 * N ; ++i) {
		C[i][0] = 1;
		for(int j = 1 ; j <= i ; ++j) {
			C[i][j] = inc(C[i - 1][j - 1],C[i - 1][j]);
		}
	}
	fac[0] = 1;
	for(int i = 1 ; i <= 2 * N ; ++i) fac[i] = mul(fac[i - 1],i);
}
void Solve() {
	int cur = 0;
	dp[0][0][0] = 1;
	for(int i = 2 * N ; i >= 1 ; --i) {
		if(vis[i]) continue;
		memset(dp[cur ^ 1],0,sizeof(dp[cur ^ 1]));
		int t = (2 * N) - i;
		if(used[i]) {
			for(int j = 0 ; j <= t ; ++j) {
				for(int k = 0 ; k <= t - j ; ++k) {
					if(dp[cur][j][k]) {
						update(dp[cur ^ 1][j][k + 1],dp[cur][j][k]);
						if(j) update(dp[cur ^ 1][j - 1][k],dp[cur][j][k]);
					}
				}
			}
		}
		else {
			for(int j = 0 ; j <= t ; ++j) {
				for(int k = 0 ; k <= t - j ; ++k) {
					if(dp[cur][j][k]) {
						update(dp[cur ^ 1][j + 1][k],dp[cur][j][k]);
						if(k) update(dp[cur ^ 1][j][k - 1],mul(k,dp[cur][j][k]));
						if(j) update(dp[cur ^ 1][j - 1][k],dp[cur][j][k]);
					}
				}
			}
		}
		cur ^= 1;
	}
	int ans = dp[cur][0][0];
	ans = mul(ans,fac[cnt]);
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Init();
	Solve();
}


Measured memory_bytes: 4480
string = list(input())
len_s = len(string)

string_rev = ""
for i in range(len_s):
    string_rev += string[len_s - 1 - i]
string_rev = list(string_rev)


#print(string)
#print(string_rev)
count = 0
for i in range(len_s):
    if string[i] != string_rev[i]:
        string[i] = string_rev[i]
        string[len_s - 1 - i] = string_rev[len_s - 1 - i]
        #print(string)
        count += 1
        
print(count)
    

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W;
string s[50];
int dy[] = {-1, 0, 0, 1};
int dx[] = {0, -1, 1, 0};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  int cnt = 0;
  for (int i = 0; i < H; i++) {
    cin >> s[i];
    for (int j = 0; j < W; j++) {
      cnt += (s[i][j] == '#');
    }
  }  

  queue<pii> que;
  que.emplace(0, 0);
  map<pii, int> d;
  d[pii(0, 0)] = 1;
  while (!que.empty()) {
    pii p = que.front(); que.pop();
    for (int i = 0; i < 4; i++) {
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];
      if (ny >= 0 && ny < H && nx >= 0 && nx < W && s[ny][nx] == '.' && d.find(pii(ny, nx)) == d.end()) {
        que.emplace(ny, nx);
        d[pii(ny, nx)] = d[p] + 1;
      }
    }
  }
  if (d.find(pii(H - 1, W - 1)) == d.end()) {
    cout << -1 << endl;
  } else {
    cout << H * W - cnt - d[pii(H - 1, W - 1)] << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

const char* table[] = {
    "",
    ".,!? ", "abc", "def",
    "ghi", "jkl", "mno",
    "pqrs", "tuv", "wxyz"
};

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n--){
        char key[2048] = "0";
        int num;
        int now = 0;
        int i;

        scanf("%s", key + 1);
        for (i = 1; key[i]; i++){
            if (key[i - 1] == '0'){
                now = key[i] - '0';
                num = 0;
            }
            else if (key[i] == '0' && now != 0) putchar(table[now][num % strlen(table[now])]);
            else num++;
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 592
N = int(input().strip())
C = [c for c in input().strip()]

if "W" not in C or "R" not in C:
    print(0)
    import sys; sys.exit(0)

cnt = 0

i = 0
j = len(C) - 1
while i < j:
    while C[i] == "R":
        i += 1
    while C[j] == "W":
        j -= 1
    if i > j:
        break
    cnt += 1
    C[i] = "R"
    C[j] = "W"
    i += 1
    j -= 1

print(cnt)

Measured memory_bytes: 10864
from bisect import bisect_right
from itertools import product


def bisectsearch_right(L, a):
    i = bisect_right(L, a)
    return(i)


N = input()
d = len(N)
N = int(N)
a = [0]*d
for i in range(1, d):
    a[i] = 3**i-3*2**i+3
# print(a)
S = {3, 5, 7}

L = set()
for k in product(S, repeat=d):
    l = set(k)
    if S == l:
        t = [None]*d
        for i in range(d):
            t[i] = str(k[i])
        L.add(int(''.join(t)))
# print(L)
L = list(L)
L.sort()
ct = bisectsearch_right(L, N)
print(sum(a)+ct)


Measured memory_bytes: 75796
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String ret = "No";
		int[] iline = new int[4];
		for(int i=0;i<4;i++){
			iline[i]=line.charAt(i);
		}
		if(iline[0]==iline[1]){
			if(iline[0]==iline[2]){
				ret = "Yes";
			}
		}
		else if(iline[1]==iline[2]){
			if(iline[1]==iline[3]){
				ret = "Yes";
			}
		}
		System.out.println(ret);
    }
}


Measured memory_bytes: 21844
n=int(input())
a_list = list(map(int,input().split()))

ans = [1000, 0]

for i in range(n-1):
    if a_list[i] < a_list[i+1]:
        # 買っておいて
        ans[1] = ans[1] + ans[0] // a_list[i]
        ans[0] = ans[0] - (ans[0] // a_list[i]) * a_list[i]
        # 売る
        ans[0] = ans[0] + ans[1] * a_list[i+1]
        ans[1] = 0
    elif a_list[i] > a_list[i+1]:
        # 売っておいて
        ans[0] = ans[0] + ans[1] * a_list[i]
        ans[1] = 0
        # 買う
        ans[1] = ans[0] // a_list[i+1]
        ans[0] = ans[0] - (ans[0] // a_list[i+1]) * a_list[i+1]

print(ans[0] + ans[1]*a_list[-1])

Measured memory_bytes: 9236
#include <stdio.h>
int main()
{
    int n, res = 0;
    scanf("%d", &n);
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);
    for (int i = 0; i < n - 1; i++)
        scanf("%d", &c[i]);
    for (int i = 0; i < n; i++)
    {
        res += b[a[i] - 1];
        if (a[i] == a[i+1]-1)
        {
            res += c[a[i]-1];
        }
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 128
<?php
  
  $n = trim(fgets(STDIN));
  $a = explode(" ",  trim(fgets(STDIN)));
  
  $b = [];
  for($i=0;$i<$n;$i++){
    if($a[$i]%2==0){
      $b[] =$a[$i];
    }
  }
  $count=count($b);
  $ap = true;
  for($i=0;$i<$count;$i++){  
    if($b[$i]%3!=0 && $b[$i]%5!=0){
      $ap = false;
      break;
    }
  }
  if($ap){
    echo "APPROVED";
  }else{
    echo "DENIED";
  }


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

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

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

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

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

struct Place {
    int x, y;
};

int main() {
    ll h, w, d;
    cin >> h >> w >> d;

    vector<vector<ll>> grid(h, vector<ll>(w));
    rep(y, h) rep(x, w) cin >> grid[y][x];
    rep(y, h) rep(x, w) grid[y][x]--;

    vector<Place> places(h * w);
    rep(y, h) rep(x, w) {
            ll i = grid[y][x];
            places[i].y = y;
            places[i].x = x;
        }

    auto diff = [](Place &p, Place &q) {
        return abs(p.x - q.x) + abs(p.y - q.y);
    };

    vector<ll> distances_sum(h * w, 0);
    for (ll i = 0; i < h * w; i++) {
        if (i - d < 0) continue;
        distances_sum[i] = diff(places[i], places[i - d]);
    }
    for (ll i = 0; i < h * w; i++) {
        if (i - d < 0) continue;
        distances_sum[i] += distances_sum[i - d];
    }


    int q;
    cin >> q;
    rep(i, q) {
        ll l, r;
        cin >> l >> r;
        l--;
        r--;
        ll end = distances_sum[r];
        ll start = distances_sum[l];

        cout << end - start << endl;
    }

}




Measured memory_bytes: 3200
// B.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = a.back() - a.front();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for x in range(k if k < 50 else 50):
        B = [0] * n
        for j in range(n):
            l = max(0, j - A[j])
            r = min(n - 1, j + A[j])
            B[l] += 1
            if r + 1 < n:
                B[r + 1] -= 1

        for x in range(1, n):
            B[x] += B[x - 1]
        A = B

    print(*A)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 166876
#include<cmath>
#include<iostream>
#include<algorithm>
#include <string>
#include <stdexcept>
using namespace std; 
int main(){
  int a,b,c,d,e;
 	cin >>a>>b;
	if(a%b==0)cout <<0;
  else cout <<1;
  	
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int main(){
    ll x,a,b;
    cin>>x;
    a=100;
    ll count=0;
    ll c=0;
    while(a<x){
    
        a+=a/100;
        count++;
    }
    cout<<count;
}


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

int main()
{
   string s1,s2,s3;
   cin>>s1>>s2>>s3;
  putchar(toupper(s1[0]));
  putchar(toupper(s2[0]));
  putchar(toupper(s3[0]));

   return 0;
}


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

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

    int counter = 0;
    for(int i=0; i<str.size(); i++){
        if(str[i] == '1')
            counter++;
    }

    printf("%d\n", counter);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	int count=0;	//素数カウント変数
	int[] A;
	
	public void input() {
		n = sc.nextInt();
		A = new int[n];
		for(int i=0; i<n; i++) {
			A[i] = sc.nextInt();
		}
	}
	
	//0で素数を返す
	public int conpute(int number) {
		if(number<2) return 0;
		if(number==2) return 0;
		if(number%2==0) return 1;
		double a = Math.sqrt(number);
		for(int i=3; i<=a; i++) {
			if(number%i == 0) return 1;
		}
		return 0;
	}
	
	public void output() {
		for(int i=0; i<n; i++) {
			if( conpute(A[i]) == 0 ) count++;
		}
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.output();
	}
}



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), w = in();
    vvint c(10, vint(10));
    rep(i, 10) rep(j, 10)
    {
        cin >> c[i][j];
    }
    rep(k, 10) rep(i, 10) rep(j, 10)
    {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    ll ans = 0;
    rep(i, h) rep(j, w)
    {
        int a = in();
        if (a == -1)
            continue;
        ans += c[a][1];
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<double> AA(N, 0);
	
	for(int i = 0; i < N; i++){
		
		cin >> AA[i];		
	}
	
	double B = 0;
	for(int i = 0; i < N; i++){
		
		B += 1/AA[i];		
	}	
	
	cout << 1/B << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,mod=1e9+7;
int aa[N+2];

int big(int b,int p,int m=mod)
{
  int ret=1;
  while(p){if(p&1)ret=(1LL*ret*b)%m;b=(1LL*b*b)%m;p/=2;}
  return ret;
}
int fac[N+2];
void init(int n)
{
  fac[0]=1;
  for(int i=1;i<=n;i++)fac[i]=(1LL*fac[i-1]*i)%mod;
}
int ncr(int n,int r)
{
  int a=fac[n];a=(1LL*a*big(fac[r],mod-2))%mod;
  return (1LL*a*big(fac[n-r],mod-2))%mod;
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>aa[i];
  sort(aa+1,aa+n+1,greater<int>());

  if(k==1)cout<<0<<endl,exit(0);

  // for(int i=1;i<=n;i++)cout<<aa[i]<<" ";
  //   cout<<endl;

  init(n);long ans=0;
  for(int i=1;i<=n;i++)
  {
    int rgt=n-i;
    if(rgt>=k-1)ans=(1LL*ans+1LL*ncr(rgt,k-1)*aa[i])%mod;

    int lft=i-1;
    if(lft>=k-1)ans=(1LL*ans-1LL*ncr(lft,k-1)*aa[i])%mod;

  }
  ans=(ans+mod)%mod;cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4736
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int n;
int l;
int len = n;
string str;

int main() {
	cin >> n;
	l = 0;
	len = n;
	string ans;
	cout << 0 << endl;
	cin >> str;
	if (str == "Vacant") return 0;
	while (len > 2) {
		int mid = l + len / 2;
		cout << mid << endl;
		cin >> ans;
		if (ans == "Vacant") return 0;
		if (str == ans) {
			if ((mid - l) % 2 == 1) len = mid - l;
			else {
				len = l + len - mid;
				l = mid;
			}
		} else {
			if ((mid - l) % 2 == 0) len = mid - l;
			else {
				len = len + l - mid;
				l = mid;
				str = ans;
			}
		}
	}
	cout << l + 1 << endl;
	return 0;
}

Measured memory_bytes: 852
# coding: utf-8
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
k = list(cnt.keys())
k.sort()
if len(k) == 1:
    if k[0] == 0:
        print("Yes")
    else:
        print("No")
    exit()
elif len(k) == 2:
    if cnt[k[0]] == N // 3 and N % 3 == 0:
        print("Yes")
    else:
        print("No")
    exit()
elif len(k) == 3:
    if cnt[k[0]] == cnt[k[1]] == cnt[k[2]] and k[0] ^ k[1] == k[2]:
        print("Yes")
    else:
        print("No")
    exit()
else:
    print("No")
    exit()

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

int main() {
  cout <<fixed <<setprecision(15);
  double n,k; cin >>n >>k;
  double ans;
  for (int i=1; i<=min(n,k-1); i++){
    int buf = i;
    double p = 1;
    while(buf<k){ buf *= 2; p /= 2;}
    ans += p;
  }
  for (int i=k; i<=n; i++){
    ans++;
  }
  ans /= n;
  cout <<ans;
  cout <<endl;
}

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

#define ll long long
#define ar array

int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (s[0]==s[2])
                cout << "No";
        else
                cout << "Yes";
}

Measured memory_bytes: 256