akhauriyash/Code-Regression huggingface dataset:
//
// Created by Kiran Chavhan on 05/07/2020.
//

#include<bits/stdc++.h>


#define int long long
#define MOD 1000000007
using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin>>x>>n;
    vector<int>v(n);
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>v[i];
        mp[v[i]]++;
    }
    sort(v.begin(),v.end());
    int flag=1;
    int i=x,z=0;
    //++;
    int min2=INT_MAX,min1=INT_MAX;
    while(flag){
        if(mp[i]==0){
            z=i;
            flag=0;
        }
        i++;
    }
    flag=1;
    i=x;
    int k=0;
    //i--;
    while(flag){
        if(mp[i]==0){
           k=i;
            flag=0;
        }
        i--;
    }
    min1=abs(x-k);
    min2=abs(x-z);
    if(min1<min2)cout<<k;
    else if(min1>min2) cout<<z;
    else cout<<min(z,k);

}

Measured memory_bytes: 3648
import Data.List

step :: (Integer, Integer) -> (Integer, Integer) -> (Integer, Integer)
step (a, b) (k, c) = (k + min a (b+c), max 0 (min b (b+c-a)))

main = do
  n <- readLn :: IO Int
  aa <- map read . words <$> getLine :: IO [Integer]
  bb <- map read . words <$> getLine :: IO [Integer]
  putStrLn . show $ fst $ foldr step (0, 0) $ zip aa (0:bb)


Measured memory_bytes: 167292
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s, t; cin >> s >> t;
	if(s == t.substr(0, s.size())) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    cout1(N/3);
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 1005
using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;
int h, w;
// bool maze[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main() {
    scanf("%d%d", &h, &w);
    char temp;
    getchar();
    dp[0][1] = 1;
    for (int i = 1; i <= h; ++i, getchar()) {
        for (int j = 1; j <= w; ++j) {
            scanf("%c", &temp);
            if (temp == '.') {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    printf("%lld\n", dp[h][w]);
    return 0;
}

Measured memory_bytes: 8064
n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)

for c in ['S','H','C','D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)



Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;

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

    if (a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var result int
	if k%2 == 1 {
		i := n / k
		result = i * i * i
	} else {
		i := n / k
		j := (n + k/2) / k
		result = i*i*i + j*j*j
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
#define All(v) (v).begin(),(v).end()
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define REPS(i,n) for(int i = 1; i <= (int)n; i++)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define FORS(i,m,n) for(int i = m; i <= n; i++)
#define INF 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

int gcd(int a, int b){
    int dividend = max(a,b);
    int divisor = min(a,b);
    while(1){
        int amari = dividend%divisor;
        if(!amari) break;
        dividend = divisor;
        divisor = amari;
    }
    return divisor;
}

int main (){
    int n,xx;
    cin >> n >> xx;
    vector<int> x(n);
    vector<int> def(n);
    REP(i,n) cin >> x[i];
    if(n == 1){
        cout << abs(x[0]-xx) << "\n";
        return 0;
    }
    int mi;
    REP(i,n){
        def[i] = abs(x[i]-xx);
    }
    int ans = gcd(def[0],def[1]);
    FOR(i,2,n){
        ans = gcd(ans,def[i]);
    }
    cout << ans << "\n";
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int an = 0;
  string sum;
  for (int i = 1; i <= n; i++) {
    sum = to_string(i);
    int sum_i = 0;
    for (char c : sum) {
      sum_i += (int)(c - '0');
    }
    if (sum_i >= a && sum_i <= b) {
      an += i;
    }
  }
  cout << an << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n, d; std::cin >> n >> d;
  auto a = std::vector<std::vector<int>>(n, std::vector<int>(d));
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < d; j++) {
      std::cin >> a.at(i).at(j);
    }
  }
  constexpr int mx = 2000;
  std::vector<int> square(mx + 1);
  std::iota(square.begin(), square.end(), 0);
  std::for_each(square.begin(), square.end(), [](int& x){x *= x;});
  auto is_square = [&] (int x) {
    return std::find(square.begin(), square.end(), x) != square.end();
  };
  auto check = [&] (size_t i, size_t j) {
    return is_square(std::inner_product(
      a.at(i).begin(), a.at(i).end(),
      a.at(j).begin(), 0,
      [](const int& x, const int& y){return x + y * y;},
      [](const int& x, const int& y){return x - y;}));
  };
  int ret = 0;
  for (size_t i = 0; i < n; i++) {
    for (size_t j = i + 1; j < n; j++) {
      ret += check(i, j);
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

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

int main(){
	int n, x,count;
	while (1){
		count = 0;
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		for (int i = 1; i <= n-2; i++){
			for (int j = i+1; j <= n-1; j++){
				for (int k = j+1; k <= n; k++){
						if (i+j+k == x){
							count++;
						}
					}
				}
			}
		cout << count << endl;
		}
		
	return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
int tbl[100010];
bool chk(int w,vector<P> c){
  int n = c.size();
  memset(tbl,0,sizeof(tbl));
  for(int i=0;i<n;++i){
    tbl[c[i].first]++;
    tbl[c[i].second+1]--;
  }
  for(int i=0;i<=w;++i) tbl[i+1]+=tbl[i];
  for(int i=1;i<=w;++i)
    if(tbl[i]<=0) return false;
  return true;
}

int main(){
  int n,w,h;
  scanf("%d%d%d",&n,&w,&h);
  vector<P> rng1,rng2;
  for(int i=0;i<n;++i){
    int x,y,d;
    scanf("%d%d%d",&x,&y,&d);
    rng1.push_back(P(max(1,x-d+1),min(w,x+d)));
    rng2.push_back(P(max(1,y-d+1),min(h,y+d)));
  }
  if(chk(w,rng1) || chk(h,rng2)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 4748
N = int(input())
cmin = N
for i in range(1,N//2):
    j = N-i
    a = str(i)
    b = str(j)
    cnt = 0
    for k in range(len(a)):
        cnt += int(a[k])
    for k in range(len(b)):
        cnt += int(b[k])
    cmin = min(cmin,cnt)
print(cmin)

Measured memory_bytes: 67828
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define int ll
#define mp make_pair
#define infi 1e12
const ll mod = 1e9 + 7;
vector<ll> lol;
ll n;
ll dfs(vector<vector<ll>> &v, ll node, ll p)
{
    ll count = 0;
    for (auto itr : v[node])
    {
        if (itr != p)
        {
            count += dfs(v, itr, node);
        }
    }
    if (p != -1)
    {
        ll x = (count + 1) * (n - count - 1);
        lol.pb(x);
    }
    return count + 1;
}
signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    ll n;
    cin >> n;
    ll a[n];
    For(i, 0, n) cin >> a[i];
    ll res = 0;
    ll mh = a[0];
    For(i, 1, n)
    {
        if (a[i] >= mh)
            mh = a[i];
        else
            res += mh - a[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBingo solver = new BBingo();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBingo {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[][] grid = new int[3][3];
            for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) grid[i][j] = in.nextInt();
            int n = in.nextInt();
            int[] b = new int[n];
            for (int i = 0; i < n; i++) b[i] = in.nextInt();
            boolean[][] grid2 = new boolean[3][3];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int k = 0; k < 3; k++) {
                        if (grid[j][k] == b[i]) {
                            grid2[j][k] = true;
                        }
                    }
                }
            }
            for (int i = 0; i < 3; i++) {
                boolean flag = true;
                for (int j = 0; j < 3; j++) {
                    if (grid2[i][j] == false) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    out.println("Yes");
                    return;
                }
                flag = true;
                for (int j = 0; j < 3; j++) {
                    if (grid2[j][i] == false) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    out.println("Yes");
                    return;
                }
            }
            if (grid2[0][0] == true && grid2[1][1] == true && grid2[2][2] == true) {
                out.println("Yes");
                return;
            }
            if (grid2[0][2] == true && grid2[1][1] == true && grid2[2][0] == true) {
                out.println("Yes");
                return;
            }
            out.println("No");
        }

    }
}



Measured memory_bytes: 23124
#include <stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if (a <= b){
    if (a <= c){
      if (c <= b){
        printf("%d %d %d\n",a,c,b);
      }
      else{
        printf("%d %d %d\n",a,b,c);
      }
      }
    else{
      printf("%d %d %d\n",a,b,c);
    }
    }
  else{
    if (c<=a){
      if(b<=c){
        printf("%d %d %d\n",b,c,a);
      }
      else{
        printf("%d %d %d\n",c,b,a);
      }
    }
    else{
      printf("%d %d %d\n",b,a,c );
    }
    }
    return(0);
  }
  
  

Measured memory_bytes: 596
#include<stdio.h>
int main(){
  long int n,a,b=1,i,f=0,g=1;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a);
    if(a==0)g=0;
    else if(b>(long int)1000000000000000000/a)f=-1;
    b*=a;
  }
  if(f)printf("%ld",f*g);else printf("%ld",b);
}


Measured memory_bytes: 1736
N, M = map(int, input().split())
edges = []
for i in range(0, M):
	edges.append(list(map(int, input().split())))
cnt = 0
for i in range(0, M):
	grp = []
	for j in range(0, N):
		lst = []
		for k in range(0, N):
			lst.append(False)
		grp.append(lst)
	for j in range(0, M):
		if i != j:
			grp[edges[j][0]-1][edges[j][1]-1] = True
			grp[edges[j][1]-1][edges[j][0]-1] = True
	memo = []
	for j in range(0, N):
		memo.append(True)
	queue = [0]
	while queue != []:
		now = queue.pop(0)
		memo[now] = False
		if True not in memo:
			break
		for j in range(0, N):
			if grp[now][j] and memo[j]:
				queue.append(j)
	if True in memo: cnt += 1
print(cnt)

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

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long tmp = N+1;
        long ans = 0;

        for(long i = 1; i < Math.sqrt(N)+1; i++){
            if(N % i == 0){
                ans = N / i;
                tmp = Math.min(tmp,ans+i);
            }
        }

        /*for(long i = 1; i < (N/2); i++){
            if(N % i == 0){
                ans2 = N / i;
                //ans2 = (int)ans;
                tmp = Math.min(tmp,ans2+i);
            }
        }*/

        System.out.println(tmp - 2);
    }
}

Measured memory_bytes: 22740
rc = input()
rc = rc.split()
r,c = int(rc[0]),int(rc[1])
rc_list = list()
c_list = [[] for i in range(c)]
for i in range(r):
    rc_set = input()
    rc_set = rc_set.split()
    rc_list.append([])
    r_text = ''
    for j,n in enumerate(rc_set):
        rc_list[-1].append(int(n))
        r_text = r_text + n + ' '
        c_list[j].append(int(n))
    else:
        r_text = r_text + str(sum(rc_list[-1]))
        print(r_text)
else:
    c_text = ''
    t_sum = 0
    for c in c_list:
        s = sum(c)
        t_sum += s
        c_text = c_text + str(s) + ' '
    else:
        c_text = c_text + str(t_sum)
        print(c_text)



Measured memory_bytes: 5824
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = 0;
    rep(i, s.size()) {
        if (s[i] == '+') 
            n++;
        else 
            n--;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3576
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int N;
vector<vector<pair<int,int>>> testimony(15);

bool check(int bit){

    rep(i, N){
        if(!(bit & (1 << i))) continue;

        for(pair<int,int> p : testimony[i]){
            if(p.second == 1 && !(bit & (1 << p.first))) return false;

            if(p.second == 0 && (bit & (1 << p.first))) return false;
        }
    }

    return true;
}

int main()
{
    int ans = 0;
    cin >> N;

    rep(i, N){
        int A;
        cin >> A;

        rep(j, A){
            int x,y;
            cin >> x >> y;
            testimony[i].push_back(make_pair(x, y));
            --testimony[i][j].first;
        }
    }

    for(int bit = 0; bit < (1 << N); bit++){

        if(check(bit)){
            int count = 0;
            rep(i, N){
                if(bit & (1 << i)){
                    count++;
                }
            }
            ans = max(ans,count);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

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

int main()
{
  long long N,M;
  cin>>N>>M;
  string S,T;
  cin>>S>>T;
  long long tmp = gcd(N,M);
  long long ans = N/tmp*M;
  long long m = ans/N;
  long long n = ans/M;

  bool flag = true;
  for(int i=0;i<tmp;i++){
    if(S[n*i]!=T[m*i])flag=false;
  }
  if(flag!=true)ans=-1;
  cout<< ans <<endl;
}



Measured memory_bytes: 512
package main

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

func main() {
	a, b := readInt(), readInt()
	var s string
	var n int
	if a > b {
		s = strconv.Itoa(b)
		n = a
	} else {
		s = strconv.Itoa(a)
		n = b
	}
	for i := 0; i < n; i++ {
		fmt.Print(s)
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

	
    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();

      
        String[] name = new String[10]; 
        int[] count = new int[10];

        for(int i=0;i<N;i++){
        	String line = in.next();
        	for(int j=0;j<10;j++){
        		if(name[j]==null){
        			name[j] = line;
        			count[j]++;
        			break;
        		}else if(line.equals(name[j])){
        			count[j]++;
        			break;
        		}
        		
        	}
        }
        
        int M = in.nextInt();
        
        for(int i=0;i<M;i++){
        	String line = in.next();
        	for(int j=0;j<10;j++){
        		if(name[j]==null){
        			count[j]--;
        			break;
        		}else if(name[j].equals(line)){
        			count[j]--;
        			break;
        		}
        		
        	}
        }
        int max = 0;
        
        for(int i=0;i<10;i++){
        	if(max<count[i])
        		max = count[i];
        }
        	System.out.println(max);
        in.close();
    }

	
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, K;
    ll mini = LONG_MAX;
    vector<ll> X;
    vector<ll> D;
    cin >> N >> K;
    X.resize(N);
    for(ll i = 0;i < N;i++) cin >> X[i];
    for(ll i = K - 1;i < N;i++) {
        ll start = i - K + 1;
        ll current = X[i] - X[start];
        mini = min(mini, current + min(abs(X[start]), abs(X[i])));
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 1024
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()

def judge(n, h, N1):
    fraction = n * h * N1
    denominator = (4 * h * n) - (N1 * n) - (N1 * h)
    if denominator > 0 and fraction % denominator == 0 and 0 < fraction // denominator <= 3500:
        return fraction // denominator
    return -1

for i in range(1, 3501):
    for j in range(1, 3501):
        res = judge(i, j, N)
        if res > 0:
            print(i, j, res)
            break
    else:
        continue
    break

Measured memory_bytes: 62936
S = input()

B = []
W = []
for i in range (len(S)):
    if i % 2 == 0:
        B += ["0"]
        W += ["1"]
    else:
        B += ["1"]
        W += ["0"]
        
aB = 0
aW = 0

for i in range(len(S)):
    if B[i] != S[i]:
        aB += 1
    if W[i] != S[i]:
        aW += 1
print(min(aB, aW))

Measured memory_bytes: 4852
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N+1];
    for (int i = 1; i <= N; i++) {
      a[i] = sc.nextInt();
    }
    int count = 0;
    int i = 1;
    while (i != 2 && a[i] != 0) {
      int next = a[i];
      a[i] = 0;
      i = next;
      count++;
    }
    System.out.println(i == 2 ? count : -1);
  }
}

Measured memory_bytes: 51064
XS = open(0).read().split()
i = 0
while True:
    t = XS[i]
    i += 1
    if t == "-":
        break
    n = int(XS[i])
    i += 1
    m = sum(map(int, XS[i:i+n])) % len(t)
    i += n
    print(t[m:] + t[:m])


Measured memory_bytes: 5592
#include <iostream>

int a[3][3];
int c[3][3];

void solve() {
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			std::cin >> a[i][j];

	int n;
	int b;
	std::cin >> n;
	
	for (int i = 0; i < n; i++) {
		std::cin >> b;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (b == a[j][k]) {
					c[j][k] = 1;
					break;
				}
			}
		}
	}
	bool ans = false;
	// 横方向
	for (int i = 0; i < 3; ++i) {
		int cnt = 0;
		for (int j = 0; j < 3; ++j) {
			if (c[i][j] == 1) cnt++;
		}
		if (cnt == 3) ans = true;
	}
	// 縦方向
	for (int i = 0; i < 3; ++i) {
		int cnt = 0;
		for (int j = 0; j < 3; ++j) {
			if (c[j][i] == 1) cnt++;
		}
		if (cnt == 3) ans = true;
	}
	// 左上から左下
	for (int i = 0; i < 1; ++i) {
		int cnt = 0;
		for (int j = 0; j < 3; ++j) {
			if (c[j][j] == 1) cnt++;	
		}
		if (cnt == 3) ans = true;
	}
	// 右上から左下
	for (int i = 0; i < 1; ++i) {
		int cnt = 0;
		for (int j = 0; j < 3; ++j) {
			if (c[j][2-j] == 1) cnt++;
		}
		if (cnt == 3) ans = true;
	}
	std::cout << (ans?"Yes":"No") << std::endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int D;
    cin >> D;
    vector<int> c(26);
    REP (i, 26) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>((26)));
    REP (i, D) {
        REP (j, 26) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D);
    REP(i,D) {
        t[i] = rand() % 26 + 1;
        cout << t[i] << endl;
    }

    /*

    int M;
    cin >> M;
    vector<int> d(M), q(M);
    REP(k,M) {
        ans = 0;
        cin >> d[k] >> q[k];
        d[k]--;
        q[k]--;
        t[d[k]] = q[k];
        vector<int> last(26,0);

        REP(i,D) {
            last[t[i]] = i+1;
            ans += s[i][t[i]];
            REP(j,26) {
                ans -= c[j] * (i+1 - last[j]);
            }
        }
        cout << ans << endl;
    }
    */



    


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/intro-heuristics/intro_heuristics_a && sh shellscripts/submit_cpp.sh
*/


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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int a, b, x, sisa, total;
	double y, angle;
	scanf("%d %d %d", &a, &b, &x);
	total = a * a * b;
	sisa = total - x;
	if (x < sisa) {
		y = (2.0 * (double) x) / ((double) a * (double) b);
		angle = 180.0 * atan((double) b / y) / acos(-1.0);
	}
	else {
		y = (2.0 * (double) sisa) / ((double) a * (double) a);
		angle = 180.0 * atan((double) y / a) / acos(-1.0);
	}
	printf("%.10lf\n", angle);
	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int INF = 1001001001;
const ll LINF = 1e18;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

string makeDigit(ll N, string res)
{
    if(N == 0)
        return res;
    
    ll l = 0, r = 0, idx = 0;
    ll nextN = N; ll maxDig = 0;
    vi v(100, 0);
    while(abs(nextN) >= 1){
        if(idx % 2 == 0) r += pow(2, idx);
        else l += - pow(2, idx);
        if(l <= nextN && nextN <= r){
            v[idx] = 1;
            maxDig = max(maxDig, idx);
            nextN = (idx % 2 == 0) ? nextN - pow(2, idx) : nextN + pow(2, idx);
            idx = 0; l = 0; r = 0;
        }
        else idx++;
    }
    
    string ret = "";
    for (int i = 0; i <= maxDig; i++) {
        ret = to_string(v[i]) + ret;
    }
    return ret;
}

int main() {
    ll N; cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << makeDigit(N, "") << endl;
    return 0;
}



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

int app[26];

int main() {
  string s; cin >> s;
  for ( int i = 0; i < s.length(); i++ ) {
    app[s[i]-'a']++;
  }
  //  for ( int i = 0; i < 26; i++ ) cout << app[i] << endl;
  for ( int i = 0; i < 26; i++ ) {
    if ( app[i] > 1 ) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int flag=0;
  if(s.at(0) == s.at(1)){
    if(s.at(1) == s.at(2)) flag = 1;
  }
  if(flag) cout << "No" << endl;
  else cout << "Yes" << endl;
       
}

Measured memory_bytes: 256
#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)

int main(){
    ll n;
    cin >> n;
    vector<double> d(n, 0);
    REP(i, n){
        double xi;
        cin >> xi;
        d.at(i) += xi;
    }
    REP(i, n){
        double yi;
        cin >> yi;
        d.at(i) -= yi;
    }
    transform(d.begin(), d.end(), d.begin(), ::abs);

    const double d1 = accumulate(d.begin(), d.end(), 0.0);
    const double dinf = accumulate(d.begin(), d.end(), 0.0,
        [](double acc, double x){ return max(acc, x); });
    const double d2 = sqrt(accumulate(d.begin(), d.end(), 0.0,
        [](double acc, double x){ return acc + x * x; }));
    const double d3 = pow(accumulate(d.begin(), d.end(), 0.0,
        [](double acc, double x){ return acc + x * x * x; }), 1.0 / 3);

    printf("%.10f\n%.10f\n%.10f\n%.10f\n",
        d1, d2, d3, dinf);

    return 0;
}



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

int main(){
	int N;
	cin >> N;
	vector<ll> b(N+1);
	rep(i,N) {
		ll a;
		cin >> a;
		b[i+1] = b[i] + a;
	}
	ll ans = 1e15;
	for (int i = 1; i < N; i++) {
		ll x = b[i];
		ll y = b[N] - x;
		ans = min(ans, abs(y-x));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4696
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var vis = CRL().ArrayInts();
        var cis = CRL().ArrayInts();

        var max = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            var v = 0;
            var c = 0;
            for (int j = 0; j < n; j++)
            {
                if (((i >> j) & 1) == 1)
                {
                    v += vis[j];
                    c += cis[j];
                }
            }

            max = Math.Max(max, v - c);
        }

        CWL(max);
    }
}

public static partial class Program
{
    //テンプレここから
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static string RL() => ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static void WL(object obj) => WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);

    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    //テンプレここまで
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  vector<ll> v(201);
  for (ll i = 0; i <= 200; i++) {
    ll a = 1;
    for (int j = 0; j < 5; j++) a *= i;
    v[i] = a;
  }

  ll x;
  cin >> x;

  for (int i = 0; i <= 200; i++) {
    for (int j = 0; j <= 200; j++) {
      if (v[i] + v[j] == x) {
        cout << i << " -" << j << endl;
        return 0;
      } else if (v[i] - v[j] == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return -1;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
    double r=Double.parseDouble(sc.next());
    double S=Math.pow(r, 2)*Math.PI;
    double R=2*r*Math.PI;
    System.out.printf("%.5f",S);System.out.print(" ");System.out.println(R);
}
}


Measured memory_bytes: 26344
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);

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

  sort(h.begin(), h.end());

  int ans = 1000000000;
  for (int i = 0; i <= n-k; i++) {
    ans = min(ans, h[i+k-1] - h[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;

using namespace std;
using pint = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(200005);

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

  rep(i, min(50, k))
  {

    vector<int> b(200005, 0);
    rep(j, n)
    {
      // 累積和
      int left = max(0, j - a[j]);
      int right = min(n - 1, j + a[j]);
      // cout << "===" << endl;
      // cout << left << right << endl;

      b[left]++;
      b[right + 1]--;
    }

    // cout << b[0] << " ";
    repi(i, 1, n)
    {
      // cout << b[i] << " ";
      b[i] += b[i - 1];
    }
    // cout << endl;
    a = b;
  }

  rep(i, n)
  {
    cout << a[i] << " ";
  }

  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Node
{
	ll v;
	ll weizhi;
};
Node a[5005];
bool cmp(Node a,Node b)
{
	if(a.v>b.v)return true;
	else if(a.v==b.v&&a.weizhi<b.weizhi)return true;
	else return false;
}
ll dp[5005][5005];
long long ans;
ll zuo;
ll you;
ll max(ll a,ll b)
{
	if(a>b)return a;
	else return b;
}
int main()
{
	int n;cin>>n;zuo=1;you=n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].v;
		a[i].weizhi=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]+abs(a[i+j+1].weizhi-n+i)*a[i+j+1].v);if(i+1<=n&&j<=n)ans=max(ans,dp[i+1][j]);
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]+abs(a[i+j+1].weizhi-j-1)*a[i+j+1].v);if(i<=n&&j+1<=n)ans=max(ans,dp[i][j+1]);
		}
	}
	cout<<ans;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int d, w;
    while (cin >> d >> w, d) {
        int board[11][11];
        rep(i, d) rep(j, w) cin >> board[i][j];
        int ans = 0;
        for (int c = 2; c < w; ++c) {
            for (int r = 2; r < d; ++r) {
                rep(y, d) rep(x, w) {
                    // 外側のminをとって、内側の容量を見る。作れなかった場合は、０となる
                    if (y+r >= d or x+c >= w) continue;
                    int minv = 1e8;
                    for (int xx=x; xx<=x+c; ++xx) {
                        minv = min({minv, board[y+r][xx], board[y][xx]});
                    }
                    for (int yy=y; yy<=y+r; ++yy) {
                        minv = min({minv, board[yy][x+c], board[yy][x]});
                    }
                    bool ok = true;
                    int tmp = 0;
                    for (int yy = y+1; yy<y+r; ++yy) {
                        for (int xx = x+1; xx<x+c; ++xx) {
                            if (minv <= board[yy][xx]) ok = false;
                            tmp += (minv - board[yy][xx]);
                        }
                    }
                    if (ok) ans = max(ans, tmp);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
if(__name__ == "__main__"):
    a, b =[int(i) for i in input().split()]
    #print(a,b)
    if(a > 0 and b > 0):
        if((a+b) % 3 == 0 or a % 3 == 0 or b % 3 == 0):
            print("Possible")
        else:
            print("Impossible")
    else:
        print("Impossible")
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
// int64_tは9*10^18まで、intは2*10^9まで

#define MAX_N 200001

int par[MAX_N]; // 親
int rk[MAX_N];  // 木の深さ

void init(int n) { // n要素で初期化
  for (int i = 0; i < n; i++) {
    par[i] = i;
  }
}

int find(int x) { // 木の根を求める
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) { // xとyの属する集合を併合
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (rk[x] < rk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rk[x] == rk[y])
      rk[x]++;
  }
}

bool same(int x, int y) { // xとyが同じ集合に属するか否か
  return find(x) == find(y);
}

int main(){
  int n, m, ans=0;
  cin >> n >> m;
  int ct[n+1]={0};
  init(n+1);
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    unite(a, b);
  }
  for(int i=1; i<=n; i++){
    ct[find(i)]++;
  }
  for(int i=1; i<=n; i++){
    if(ct[i]>ans)
      ans=ct[i];
  }
  cout << ans;
  return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll N, A, B;

int main(void) {
    cin >> N >> A >> B;

    if (A == 0 && B == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll t = N / (A + B);
    ll mod = N % (A + B);

    ll ans = t * A;
    ans += min(A, mod);

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

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	long long sum = 0;
	for (auto&& si : s) sum += si - '0';
	if (stoll(s) % sum == 0) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    try {
      val r = sc.nextDouble
      val area:Double = Pi * r * r
      val around:Double = Pi * r * 2
      println(f"$area%f $around%f")
    } catch {
      case e: NoSuchElementException =>
        println("error: stdin is not found. Please take numbers.")
    }
  }
}

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

int main() {
    int N;
    cin >> N;
    int64_t ryuka_i_minus2 = 2;
    int64_t ryuka_i_minus1 = 1;
    if(N == 0){
        cout << ryuka_i_minus2 << endl;
        return 0;
    }
    else if(N == 1){
        cout << ryuka_i_minus1 << endl;
    }
    else{
        for(int i=2;i<=N;i++){
            int64_t ryuka_i = ryuka_i_minus2 + ryuka_i_minus1;
            ryuka_i_minus2 = ryuka_i_minus1;
            ryuka_i_minus1 = ryuka_i;
            if(i == N){
                cout << ryuka_i << endl;
            }
        }
    }    
    return 0;
}


Measured memory_bytes: 256
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int arr[105];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (arr[i] == arr[i + 1]) {
            res++, i++;
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
int N;
  cin >> N;
  int result = 1;
vector<long long> H(N);
  for(int a = 0;a < N;a++)cin >> H[a];
    H[0]--;
  for(int a = 1;a < N;a++){
    if(H[a] - H[a-1] >= 1){
     H[a]--; 
    }else if(H[a] < H[a-1]){
      result = 0;
      break;
    }
  }
  if(result == 0)cout << "No" << endl;
  if(result == 1)cout << "Yes" << endl;
}

Measured memory_bytes: 1024
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

#nが大きいがa,bが小さいので、a,bを個別に計算する

def main():
  n, a, b = map(int, readline().split())
  def nCr(r):
    bunshi = 1
    bunbo = 1
    for i in range(r):
      bunshi = (bunshi * (n-i)) % MOD
      bunbo = (bunbo * (i+1)) % MOD
    return bunshi * pow(bunbo, MOD - 2, MOD) % MOD
  
  if n==2:
    print(0)
  else:
    total = pow(2, n, MOD) %MOD
    nca = nCr(a)
    ncb = nCr(b)
    ans = (total-nca-ncb-1)%MOD
    print(int(ans))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5856
import numpy as np

H,W=map(int,input().split())
S=np.array([list(input()) for _ in range(H)]) == "."

ups=np.zeros((H,W),dtype=int)
downs=np.zeros((H,W),dtype=int)
rights=np.zeros((H,W),dtype=int)
lefts=np.zeros((H,W),dtype=int)

for i in range(1,H):
    ups[i,:]=(ups[i-1,:]+1)*S[i-1,:]

for i in range(H-2,-1,-1):
    downs[i,:]=(downs[i+1,:]+1)*S[i+1,:]

for i in range(1,W):
    rights[:,i]=(rights[:,i-1]+1)*S[:,i-1]

for i in range(W-2,-1,-1):
    lefts[:,i]=(lefts[:,i+1]+1)*S[:,i+1]

ans=((ups+downs+lefts+rights)*S).max()+1
print(ans)

Measured memory_bytes: 217492
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	int n;
	cin >> n;
	int a[(int)1e5+1]={};

	int tmp,ans=0;
	for(int i=0;i<n;i++){
		cin >> tmp;
		a[tmp]++;
		if(a[tmp] == 1) ans++;
	}//カードの種類の大きさを求める
	int amari=0;
	for(int i=1;i<=(int)1e5;i++){
		if(a[i] >= 3){
			a[i] -= ((a[i]-1)/2)*2;
		}
		if(a[i] == 2) amari++;
	}
	cout << ans-(amari%2 == 1) << "\n";

	return 0;
}


Measured memory_bytes: 640
X,K,D = map(int,input().split())
X = abs(X)

if X >= K*D:
  ans = X - K*D
else:
  k = X // D
  if (K - k) % 2 == 0:
    ans = X - k*D
  else:
    ans = abs(X-(k+1)*D)

print(ans)


Measured memory_bytes: 8952
#include<iostream>
#include <string.h>
#include <algorithm>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

double gcd( double m, double n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    double p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd

int main()
{
    ll r,d,x;
    cin >> r >> d >> x;

    for(int i = 0; i < 10; i++)
    {
        x = r*x - d;
        cout << x <<endl;
    }

    return 0;
}

Measured memory_bytes: 256