akhauriyash/Code-Regression huggingface dataset:
use std::io::{Write, stdout, BufReader};
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {break;}
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {self.read_line();}
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }
    #[allow(dead_code)]
    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {self.read_line();}
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = BufReader::new(stdin.lock());
    let stdout = std::io::stdout();
    let stdout = stdout.lock();
    let read = Read::new(stdin);
    solve(read, stdout);
}

fn solve<R: std::io::BufRead>(mut r: Read<R>, mut o: std::io::StdoutLock) {
    let n:usize = r.read_until();
    let m:usize = r.read_until();
    let c:i32 = r.read_until();
    let mut b:Vec<i32> = Vec::new();
    let mut a:Vec<Vec<i32>> = Vec::new();
    for i in 0..m {
        b.push(r.read_until());
    }
    for i in 0..n {
        let mut tmp:Vec<i32> = Vec::new();
        for j in 0..m {
            tmp.push(r.read_until());
        }
        a.push(tmp);
    }
    let mut ans = 0;
    for i in 0..n {
        let mut sum:i32 =0;
        for j in 0..m {
            sum+=a[i][j]*b[j];
        }
        if sum + c > 0 {
            ans += 1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
N = int(input())
T= [[0]*9 for i in range(9)]
K= [[0]*9 for i in range(9)]

for i in range(1,N+1):
    S = str(i)
    A = int(S[0])
    B = int(S[-1])
    if A>0 and B>0:
        T[A-1][B-1]+=1

for i in range(9):
    for j in range(9):
        K[i][j] = T[i][j]*T[j][i]

output = 0
for i in range(9):
    output += sum(K[i])
print(output)

Measured memory_bytes: 40428
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))

    difX = [[0]*2]*N

    for i in range(N):
        difX[i] = [abs(X-p[i]),i]

    min_dif_p = p[min(difX)[1]]

    pluslist = [min_dif_p]
    minuslist = [min_dif_p]

    for i in range(100):
        pluslist.append(pluslist[-1]+1)
        if pluslist[-1] not in p:
            break

    for i in range(100):
        minuslist.append(minuslist[-1]-1)
        if minuslist[-1] not in p:
            break

    ans1 = pluslist[-1]
    ans2 = minuslist[-1]

    if abs(ans1-X) < abs(ans2-X):
      print(ans1)
    else:
      print(ans2)

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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));

void work(int T) {
	
	unordered_map<string, int> m;
	m["AC"] = 0;
	m["WA"] = 0;
	m["RE"] = 0;
	m["TLE"] = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};

Measured memory_bytes: 3624
import heapq


def get_tuple(a, b):
    if a > b:
        a, b = b, a
    return -a, b


def main(a, N):
    a.sort(reverse=True)
    h = []
    if N == 1:
        comfort = 0
    else:
        comfort = a[0]
        heapq.heappush(h, get_tuple(a[0], a[1]))
        heapq.heappush(h, get_tuple(a[0], a[1]))
        for i in range(2, N):
            val = heapq.heappop(h)
            comfort -= val[0]
            heapq.heappush(h, get_tuple(a[i], -val[0]))
            heapq.heappush(h, get_tuple(a[i], val[1]))
    print(comfort)


if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    main(a, N)










Measured memory_bytes: 45688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(){
  ll a,b;
  cin >> a >> b;
  if(a>12)cout << b;
  else if(a>5)cout << b/2;
  else cout << 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;

  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 256
// 161-C Replacing Integer

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return -1 * (*(int*)a - *(int*)b);
}


int main() {

    int n, i, j,num_mem;
    int tmp, min;
    int* members;
    long long int sum;

    scanf("%d", &n);
    num_mem = 3 * n;
    members = (int*)malloc(sizeof(int) * num_mem);
    for (i = 0; i < num_mem; i++) {
        scanf("%d", &members[i]);
    }
    
    qsort(members, num_mem, sizeof(int), compare);


    sum = 0;
    for (i = 1; i < 2*n; i = i+2) {
        
        sum += members[i];
        //printf("i:%d sum:%lld", i, sum);

    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 2556
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] nums = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();

		for (int i = 0; i < nums.length; i++) {
			if (nums[i] == 0) {
				System.out.println(i + 1);
				break;
			}
		}
	}




}


Measured memory_bytes: 35952
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,_n;
pii a[200005];
ll tree[200005<<2];
void update(int ind,int val){
    ind+=_n-1;
    tree[ind]+=(ll)val;
    while(ind>1){
        ind/=2;
        tree[ind]=tree[ind*2]+tree[ind*2+1];
    }
}
ll query(int l,int r,int nl,int nr,int ind){
    if(l<=nl && nr<=r) return tree[ind];
    if(l>nr || r<nl) return 0;
    int mid=(nl+nr)>>1;
    return query(l,r,nl,mid,ind*2)+query(l,r,mid+1,nr,ind*2+1);
}
int main(){
    scanf("%d",&n);
    _n=512;
    for(int i=1;i<=n;i++){
        long double now=0;
        scanf("%Lf",&now);
        now*=(long double)1e9;
        a[i].fi+=9,a[i].se+=9;
        ll ha=round(now);
        while(ha%2==0) ha/=2,a[i].fi--;
        while(ha%5==0) ha/=5,a[i].se--;
    }
    sort(a+1,a+n+1);
    int now=1;
    ll ans=0;
    for(int i=n;i>=1;i--){
        while(now<=n && a[now].fi<=-a[i].fi)
            update(a[now].se+200,1),now++;
        ans+=query(1,-a[i].se+200,1,_n,1);
    }
    for(int i=1;i<=n;i++)
        if(a[i].fi<=0 && a[i].se<=0)
            ans--;
    printf("%lld\n",ans/2);
    return 0;
}

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

using namespace std;

int main(){
  int a;
  string s;
  cin >> a;
  cin.ignore();
  cin >> s;
  cin.ignore();

  if(a >= 3200){
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}


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

int main(){
	int HA, HB, MA, MB, K, AL;
	cin >> HA >> MA >> HB >> MB >> K;
	
	if(HA < HB){
		AL = (HB - HA) * 60 + MB - MA;
	}
	else if(HA > HB){
		AL = (HB + 24 - HA) * 60 + MB - MA;
	}
	else{
		if(MA < MB){
			AL = MB - MA;
		}
		else if(MA > MB){
			AL = MB - MA + 24*60;
		}
		else{
			AL = 24 * 60;
		}
	}
	
	AL = AL - K;
	
	cout << AL << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int a,b;
    cin >> a >> b;
    int d = abs(b-a);
    int l = 0;
    for(int i = 1; i <= d-1; i++) l += i;
    int ans = l - a;
    cout << ans << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, M = map(int, raw_input().split())

ans = 1

i = 1
while True:
    if i * i > M:
        break
    if M % i == 0:
        if i >= N:
            ans = max(ans, M / i)
        if M / i >= N:
            ans = max(ans, i)
    i += 1
print ans

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

int main(){
  int n,l,r,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    if(r==l) cnt+=1;
    else cnt+=r-l+1;
  }
  cout<<cnt;
}


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

int main(void) {
    int N,K; cin >> N >> K;
    int R,S,P; cin >> R >> S >> P;
    long long score = 0;
    string T; cin >> T;

    //同じ手あり
    for(int i=0; i<N; i++) {
        if(T[i] == 'r') score += P;
        else if(T[i] == 's') score += R;
        else if(T[i] == 'p') score += S;
    }

    //かぶり削除
    for(int j=0; j<K; j++){
        for(int i=K+j; i<=N; i+=K) {
            if(T[i] == T[i-K]) {
                if(T[i] == 'r') score -= P;
                else if(T[i] == 's') score -= R;
                else if(T[i] == 'p') score -= S;
                i+=K;
            }
        }
    }
cout << score << endl;
}

Measured memory_bytes: 3744
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair
#define pb                  push_back

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int solve(int n, int m){
    short q[1001];
    REP(i,n) q[i] = i + 1;

    int l = 0;
    while(n > 1){
        //REP(i,n) pf("%d,", q[i]); pf("\n");
        l = (l + m - 1) % n;
        //pf("delete n[%d] = %d\n", l, q[l]);
        memmove(q+l, q+l+1, sizeof(q[0]) * (n-l-1));
        n--;
    }
    return q[0];
}

int main(){
    int n, m;
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        cout << solve(n, m) << endl;
    }
    return 0;
}

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

int main() {
	int A, B, C, X, Y, Z;
	cin >> A >> B >> C >> X;
  
	int count = 0;
	for (int i = 0; i < A + 1; i++) {
		Y = X;
		if (500 * i <= Y) {
			Y -= 500 * i;
		}
		else
			break;
		for (int j = 0; j < B + 1; j++) {
          	Z = Y;
			if (100 * j <= Z)
				Z -= 100 * j;
          	else
            	break;
			if (Z / 50 <= C)
				count ++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
  char a[5][5];
  for (int i=0; i<3; i++) {
    scanf("%s", a[i]);
  }
  
  for (int i=0; i<3; i++) {
    printf("%c", a[i][i]);
  }
  printf("\n");
  return 0; 
}


Measured memory_bytes: 128
import string
S = input()
alph = string.ascii_lowercase

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

if set(S) == set(alph):
    L = []
    for i in range(len(S) - 1):
        T = S[:i]
        for a in alph:
            if not a in T and (T + a) > S[:i + 1]:
                L.append(T + a)
                break
    L.sort()
    print(L[0])
else:
    for a in alph:
        if not a in S:
            print(S + a)
            exit()

Measured memory_bytes: 3896
#include <stdio.h>
#include <math.h>

double dist(int x1, int y1, int x2, int y2)
{
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main()
{
    int n; scanf("%d", &n);
    int x[8], y[8];
    double ans = 0.0;
    
    for (int i=0; i<n; i++) scanf("%d %d", &x[i], &y[i]);

    for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            ans += dist(x[i], y[i], x[j], y[j]) * 2 / n;
        }
    }

    printf("%.10lf\n", ans);
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A + B == 3)
    cout << 3 << endl;
  else if (A + B == 4)
    cout << 2 << endl;
  else
    cout << 1 << endl;
  
}

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

int main(void){
    int n,s,sum=0,i=0;
    int ma=0;
    int mi=10000;
    while(true){
        cin>>n;
        sum=0;
        i=0;
        ma=0;
        mi=10000;
        if(n==0)break;
        //cout<<n<<endl;
        while(i<n){
            cin>>s;
            ma=max(ma,s);
            mi=min(mi,s);
            sum+=s;
            i++;
        }
        sum=sum-ma-mi;
        cout<<sum/(n-2)<<endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll Q;
    cin >> Q;

    list<ll> L;
    auto it = L.begin();

    FOR(q, 0, Q){
        ll a;
        cin >> a;

        // insert
        if(a==0){
            ll x; cin >> x;
            it = L.insert(it, x);
        }
        // move
        else if(a==1){
            ll d; cin >> d;
            FOR(i, 0, abs(d)){
                if(d>0){
                    it++;
                }else{
                    it--;
                }
            }
        }
        // erase
        else{
            it = L.erase(it);
        }
    }

    for(ll a : L){
        p(a);
    }
    
    return 0;
}


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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int a, b;
    cin >> a >> b;

    int h = 100,
        w = 100;

    cout << h << " " << w << endl;
    vector<string> ans(h);

    for (int r = 0; r < h; r++) {
        ans[r] = string(100, (r < h / 2 ? '#' : '.'));
    }

    for (int r = 1; r < h / 2; r += 2) {
        for (int c = 1; c + 1 < w and a > 1; c += 2) {
            ans[r][c] = '.';
            a--;
        }
    }

    for (int r = h / 2 + 1; r < h; r += 2) {
        for (int c = 1; c + 1 < w and b > 1; c += 2) {
            ans[r][c] = '#';
            b--;
        }
    }

    for (int r = 0; r < h; r++) {
        cout << ans[r] << endl;
    }

    return 0;
}


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

int main(){

    int x, y, z, tmp;

    cin >> x >> y >> z;
    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    cout << x;
    cout << " ";
    cout << y;
    cout << " ";
    cout << z;
    return 0;

}

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

int sum(string x){
  int y = 0;
  for(int i = 0; i < x.size(); i++){
    if(x[i] == '1'){ y++; }
    else if(x[i] == '2'){ y += 2; }
    else if(x[i] == '3'){ y += 3; }
    else if(x[i] == '4'){ y += 4; }
    else if(x[i] == '5'){ y += 5; }
    else if(x[i] == '6'){ y += 6; }
    else if(x[i] == '7'){ y += 7; }
    else if(x[i] == '8'){ y += 8; }
    else if(x[i] == '9'){ y += 9; }
  }
  return y;  
}

int main(){
  for(int i = 0; i < 10000; i++){
    string n;
    cin >> n;
    if(n != "0"){
      cout << sum(n) << endl;
    }
    else{
      break;
    }
  }
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
long long s_to_ll(string s)
{
  long long a = 0;
  int x = 0;
  for(int i=s.length()-1;i>=0;i--)
  {
    a += (s[i]-'0')*pow(10,x++);
  }
  return a;
}
int get_gaps(int i,int j)
{
  if(i>j)
   return 0;
  return j-i;
}
int main()
{
  string s;
  cin>>s;
  int l =s.length();
  long long int ans=0;
  for(int i=0;i<l;i++)
  {
    for(int j=1;j<=l;j++)
    {
      if(i+j>=l+1)
        break;
      if(i==0||i+j==l)
      {
        if(i==0)
        {
         // cout<<s.substr(i,j)<<" "<<pow(2,get_gaps(i+j,l-1))<<"\n";
          ans += s_to_ll(s.substr(i,j))*pow(2,get_gaps(i+j,l-1));
        }
        else
        {
         // cout<<s.substr(i,j)<<" "<<pow(2,get_gaps(0,i-1))<<"\n";
          ans += s_to_ll(s.substr(i,j))*pow(2,get_gaps(0,i-1));
        }
      }
      else
      {
        //cout<<s.substr(i,j)<<" "<<pow(2,get_gaps(0,i-1)+get_gaps(i+j,l-1))<<"\n";
        ans += s_to_ll(s.substr(i,j))*pow(2,get_gaps(0,i-1)+get_gaps(i+j,l-1));
      }
    }
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  
  int cnt=0;
  for(int i=d;i<=100;i+=d){
    if(i>=l && i<=r) cnt++;
  }
  
  cout<<cnt<<endl;
 
  return 0;
}

Measured memory_bytes: 3592
n , m = map(int,input().split())

#偶数のボールをN個うけとる
#奇数のボールをM個うけとる
#N＋M個の中から２個だけボールを取り出す
#２つの和が偶数になる場合
# 偶数＋偶数
# 奇数+奇数

print(int(n * (n - 1)/2 + m *( m - 1)/2))
# 
#2 1
#4 3
#1 1
#13 3
#0 3

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int a[15];
int main(){
	int n,max=-1,x;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>x;
		sum+=x;
		if(x>max)
			max=x;
	}
	cout<<sum-max/2<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i], j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;
    shellSort(A, n);
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) printf("%d\n", A[i]);
    return 0;
}


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

ll fac[200010], finv[200010], inv[200010];

ll ruijou(ll a,ll b){
  ll s = 1;
  while(b > 0){
    if(b & 1)s=s*a%MOD;
    a=a*a%MOD;
    b >>=1;
  }
  return s;
}


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 200010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll com(int n,int h){
	ll sum=n;
	for(int i=2;i<=h;i++){
		sum=sum*(n-i+1)%MOD;
		sum=sum*inv[i]%MOD;
	}
	return sum;
}

int main(){
	
	ll n;
	cin >> n;
	ll a,b;
	cin >> a >> b;
	ll ans=ruijou(2ll,n)+MOD+MOD;
	COMinit();
	ans=ans-com(n,a);
	ans=ans-com(n,b);
	ans--;
	ans%=MOD;

	cout << ans << endl;

	
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <map>
#include <set>
#define SIZE 2005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char A[SIZE],B[SIZE];
int right[SIZE],left[SIZE];

int solve()
{
	int n=strlen(A);
	vector <int> vx;
	for(int i=0;i<n;i++) if(B[i]=='1') vx.push_back(i);
	for(int i=0;i<n;i++) if(B[i]=='1') vx.push_back(i+n);
	int pos=vx.size()-1;
	for(int i=n-1;i>=0;i--)
	{
		while(pos>0&&vx[pos-1]>=i) pos--;
		right[i]=vx[pos]-i;
	}
	vx.clear();
	for(int i=0;i<n;i++) if(B[i]=='1') vx.push_back(i-n);
	for(int i=0;i<n;i++) if(B[i]=='1') vx.push_back(i);
	pos=0;
	for(int i=0;i<n;i++)
	{
		while(pos+1<vx.size()&&vx[pos+1]<=i) pos++;
		left[i]=i-vx[pos];
	}
	//for(int i=0;i<n;i++) printf("%d %d\n",left[i],right[i]);
	//puts("");
	int ret=n*1000;
	for(int i=0;i<=n;i++)
	{
		int cnt=0;
		vector <P> rg;
		for(int j=0;j<n;j++)
		{
			int to=(i+j)%n;
			if(B[to]!=A[j])
			{
				cnt++;
				rg.push_back(P(right[j],left[j]));
			}
		}
		if(cnt==0)
		{
			ret=min(ret,i);
			continue;
		}
		sort(rg.begin(),rg.end());
		int mx=0,pos=rg.size()-1;
		for(int j=n;j>=i;j--)
		{
			while(pos>=0&&rg[pos].first>j)
			{
				mx=max(mx,rg[pos].second);
				pos--;
			}
			ret=min(ret,(mx+j)*2-i+cnt);
		}
	}
	return ret;
}
int main()
{
	scanf("%s",&A);
	scanf("%s",&B);
	int n=strlen(A);
	bool up=true;
	for(int i=0;i<n;i++) if(B[i]=='1') up=false;
	if(up)
	{
		up=true;
		for(int i=0;i<n;i++) if(A[i]=='1') up=false;
		if(up) puts("0");
		else puts("-1");
		return 0;
	}
	int ret=solve();
	for(int l=0,r=n-1;l<r;l++,r--) swap(A[l],A[r]),swap(B[l],B[r]);
	ret=min(ret,solve());
	printf("%d\n",ret);
	return 0;
}


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

using namespace std;

#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define cas (tc)        cout << "Case " << tc << " :"
#define nl              cout << "\n";
#define pi              acos(-1)
#define mod             1000000007
#define inf             9999999999999999

const ll sz = 2e5;




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

        ll d, n;
        cin>>d>>n;
        vector<ll> x;
        l0(i,n){
            ll it;
            cin>>it;
            x.pb(it);
        }
        sorted(x);
        ll mx=0;
        for(ll i=1; i<n; i++){
            mx=max(mx, x[i]-x[i-1]);
        }
        mx=max(mx, x[0]-x[n-1]+d);

        cout<<d-mx;
        nl
          
    return 0;
}

Measured memory_bytes: 3444
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main()
{
	int x, y, z, w,a=0;
	cin >> x >> y >> z >> w;
	if (abs(x - z) <= w)
		cout << "Yes";
	else if (abs(z - y) <= w&& abs(x - y) <= w)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
    int sum = 0;
    for (int i = 0; i < 2 * n; i += 2) {
      sum += a[i];
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll D, T, S;
    cin>>D>>T>>S;
    cout<<(D>T*S ? "No" : "Yes")<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s,str,s2;
  int n,a,b;
  cin >> s >> n;
  for(int i=0; i<n; i++) {
      cin >> str >> a >> b;
      if(str=="print") {
          cout << s.substr(a,b-a+1) << endl;
      }
      else if(str=="reverse") {
          string s1=s.substr(a,b-a+1);
          reverse(s1.begin(),s1.end());
          s=s.substr(0,a)+s1+s.substr(b+1,s.size()-b-1);
      }
      else {
          cin >> s2;
          s=s.substr(0,a)+s2+s.substr(b+1,s.size()-b-1);
      }
  }
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

ll N;
int h, w, n;

int main() {

	cin >> N;
	n = N;

	for(ll x = 1; x <= 3500; x++) {
		for(ll y = 1; y <= 3500; y++) {
			ll up = n * x * y;
			ll down = 4 * x * y - n * y - n * x;
			if(down != 0 && up % down == 0 && up / down > 0) {
				cout << x << " " << y << " " << up/down << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
n = S.count("N")
s = S.count("S")
w = S.count("W")
e = S.count("E")
ans = "Yes"
if n * s ==0:
    if n != 0 or s != 0:
        ans = "No"

if w * e ==0:
    if w != 0 or e != 0:
        ans = "No"

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;

int f[9][9];
bool t[9][9];

void check(int x, int y)
{
	for(int i=0; i<9; i++)
	{
		if(i!=x&&f[i][y]==f[x][y])
		{
			t[i][y]=1;
			t[x][y]=1;
		}
		if(i!=y&&f[x][i]==f[x][y])
		{
			t[x][i]=1;
			t[x][y]=1;
		}
	}
	for(int i=3*(y/3); i<3*((y/3)+1); i++)
	for(int j=3*(x/3); j<3*((x/3)+1); j++)
	{
		if(j==x&&i==y) continue;
		if(f[j][i]==f[x][y])
		{
			t[j][i]=1;
			t[x][y]=1;
		}
	}
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int k=0; k<N; k++)
	{
		if(k!=0) puts("");

		for(int i=0; i<9; i++)
		for(int j=0; j<9; j++)
		{
			scanf("%d", &f[j][i]);
			t[j][i]=0;
		}
			
		for(int i=0; i<9; i++)
		{
			for(int j=0; j<9; j++)
			{
				check(j,i);
				printf((t[j][i]?"*":" "));
				printf("%d", f[j][i]);
			}
			puts("");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}



int main (){
    ll n;
    cin >> n;
    for (ll i=1;i<=3500;i++){
        for (ll j=1;j<=3500;j++){
            if ((4*i*j)-(n*i)-(n*j)>0 and (n*i*j)%((4*i*j)-(n*i)-(n*j))==0){
                cout << i << " " << j << " " << (n*i*j)/(4*i*j-n*i-n*j) << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
double ap[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  REP(i, n) {
    double p;
    cin >> p;
    ap[i] = ((p * (p + 1.0)) / 2.0) / p;
  }

  double sum_p[200005];
  sum_p[0] = 0;
  FOR(i, 1, n + 1) {
    sum_p[i] = sum_p[i - 1] + ap[i - 1];
  }
  double ans = 0.0;

  REP(i, (n - k) + 1) {
    ans = max(ans, sum_p[i + k] - sum_p[i]);
  }

  cout << fixed << setprecision(7) << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
    else{
        cout << min(A * B, min(B * C, C * A)) << endl;
    }
}

Measured memory_bytes: 3540
word = input().lower()
text = []
c = 0
while True:
    read = input().split()
    if read[0] == 'END_OF_TEXT':
        break
    else:
        text.append(read)
for i in text:
    for n in i:
        if word == n.lower():
            c += 1
print(c)


Measured memory_bytes: 5564
#include <iostream>
#include <string>
using namespace std;
int H, W;
string str, ans;
int main(void) {
	cin >> H >> W;
	int nowW = W + 2;
	for (int i = 0; i < nowW; ++i) {
		str += ".";
	}
	for (int i = 0; i < H; ++i) {
		string s; cin >> s;
		str += ".";
		str += s;
		str += ".";
	}
	for (int i = 0; i < nowW; ++i) {
		str += ".";
	}
	for (size_t i = nowW + 1; i < str.size() - nowW - 1; ++i) {
		int dir[] = { -nowW - 1, -nowW, -nowW + 1, -1, +1, +nowW - 1, +nowW, +nowW + 1 };
		int count = 0;
		if ((i + 1) % nowW == 0 || i % nowW == 0) {
			continue;
		}
		if (str[i] == '#') {
			ans += '#';
			continue;
		}
		for (int j = 0; j < 8; ++j) {
			if (str[i + dir[j]] == '#') {
				++count;
			}
		}
		ans += '0' + count;
	}
	for (size_t i = 0; i < ans.size(); ++i) {
		if (i % W == 0) {
			cout << "\n";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,ct=0;
	string s;
	ll mx=0;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			ct=1;
			for(j=i+1;j<s.size();j++)
			{
				if(s[j]!='R')
				break;
				else
				ct++;
			}
		}
		mx=max(mx,ct);
	}
	cout<<mx<<endl;
}

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

using namespace std;

int main()
{
    string s;
    int a,b,i;
    cin>>a>>b>>s;
    for(i=0;i<a;i++){
        if(s[i]<'0' || s[i]>'9'){
            cout<<"No";
            return 0;
        }
    }
    if(s[i++]!='-'){
        cout<<"No";
        return 0;
    }
    for(;i<s.size();i++){
        if(s[i]<'0' || s[i]>'9'){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    string S;
    cin >> S;

    if(S=="Sunny"){
        show("Cloudy");
    }else if(S=="Cloudy"){
        show("Rainy");
    }else{
        show("Sunny");
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 101
#define KETA 9
#define INF 1000000000
#define KMAX 12


typedef struct MegaNum{
 char str[MAX];
 long num[KMAX];
}MegaNum;


void Convert(MegaNum *X){
 int len=strlen((*X).str);
 char temp[KETA+1];
 int i,j,k;

/*先頭のあまり*/
 for(i=0;i<len%KETA;i++)temp[i]=(*X).str[i];
 temp[len%KETA]='\0';
 (*X).num[len/KETA]=atoi(temp);

 i=len/KETA-1;
 j=len%KETA;

 while(i>=0){

   for(k=0;k<KETA;k++){
     temp[k]=(*X).str[j];
     j++;
   }
   temp[KETA]='\0';
   (*X).num[i]=atoi(temp);
   i--;

 }

/*
for(i=0;i<=len/KETA;i++)printf("%d ",(*X).num[i]);
printf("\n");
*/

return;
}

int Getketa(int x){
 int cnt=0;

 if(x==0)return 1;

 while(x!=0){
  x=x/10;
  cnt++;
 }


 return cnt;

}


void Getsum(MegaNum *A,MegaNum *B,MegaNum *C){
 int a=strlen((*A).str)/KETA;
 int b=strlen((*B).str)/KETA;
 int i,j,x;
 int temp[10];

 for(i=0;i<KMAX;i++)(*C).num[i]=0;


 for(i=0;i<=b;i++){

  (*C).num[i]+=((*A).num[i]+(*B).num[i]);

  if((*C).num[i]>=INF){
    (*C).num[i+1]++;
    (*C).num[i]-=INF;
  }
/*  printf("C.num[%d] is %ld\n",i,(*C).num[i]);*/
 }


 for(i=b+1;i<=a;i++){

  (*C).num[i]+=(*A).num[i];

  if((*C).num[i]>=INF){
    (*C).num[i+1]++;
    (*C).num[i]-=INF;
  }

 }

 if((*C).num[a+1]==1){
   if(a+1>=9){printf("overflow\n");return;}
   printf("1");
   i=a;
 }
 else {
  if(a>=9){printf("overflow\n");return;}
  if(a==8 && (*C).num[a]>=100000000){printf("overflow\n");return;}
  printf("%ld",(*C).num[a]);
  i=a-1;
 }

 while(i>=0){

    x=KETA-Getketa((*C).num[i]);
    for(j=0;j<x;j++)printf("0");
    printf("%ld",(*C).num[i]);
    i--;
 }
 

printf("\n");


return;
}


int main(){
 MegaNum A,B,C,temp;
 int n,i;

 scanf("%d",&n);

 for(i=0;i<n;i++){

  scanf("%s",A.str);
  scanf("%s",B.str);

 if(strlen(A.str)>=81 || strlen(B.str)>=81)printf("overflow\n");
 else{


  if(strlen(A.str) < strlen(B.str)){
    temp=A;
    A=B;
    B=temp;
  }

  if(strlen(A.str)<=KETA && strlen(B.str)<=KETA){
    printf("%ld\n",atoi(A.str)+atoi(B.str));
  }
  else{

   Convert(&A);
   Convert(&B);

   Getsum(&A,&B,&C);

   }
  }
 }
return 0;
}


Measured memory_bytes: 2008
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n;
	double a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	double mx = (a[n - 4] + a[n - 3]) / (a[n - 1] - a[n - 2]);
	mx = max(mx, (a[n - 1] + a[n - 4]) / (a[n - 2] - a[n - 3]));
	double ab = a[n - 1] + a[n - 2];
	for(int i = 1; i < n - 2; i++) mx = max(mx, ab / (a[i] - a[i - 1]));
	printf("%.5lf\n", mx);
	return 0;
}


Measured memory_bytes: 3364
import java.util.Scanner;



public class Main {

public static int fib(int n){
	int fib[]=new int[50];
	fib[0]=1;
	fib[1]=1;
	
	for(int i=0;i<=n-2;i++){
		fib[i+2]=fib[i]+fib[i+1];
	}
		
	return fib[n];
}

  public static void main(String[] args) {

	Scanner sc=new Scanner(System.in);
	
	
	
	int ans,n=Integer.parseInt(sc.next());
	
	ans=fib(n);
	System.out.println(ans);
	
	
	 }


}

Measured memory_bytes: 17316
#include <iostream>

using namespace std;

int main(void){
   int a,b,c,d;
   cin >> a>>b>>c>>d;
   while(a > 0 && c > 0){
      c-=b;
      if(c <= 0){
         cout << "Yes" << endl;
         return 0;
      }
      a-=d;
   }
   cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 3604
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = split(my_readln());
	auto A = to!uint(tokens[0]);
	auto B = to!uint(tokens[1]);
	auto K = to!uint(tokens[2]);

	foreach (i; 0..K)
	{
		if (i % 2 == 0)
		{
			if (A % 2 == 1) --A;
			B += A / 2;
			A /= 2;
		}
		else
		{
			if (B % 2 == 1) --B;
			A += B / 2;
			B /= 2;
		}
	}
	writeln(A, " ", B);
	stdout.flush();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;
int main() {
	long X,Y;
	long result=0;
	cin >> X>>Y;
	
	if(X%Y==0){
	    result=-1;
	}else{
	    result=X*Y+X;
	}

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


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

using namespace std;

const int MAX = 1e5 + 5 ;
int arr[MAX] ;
long long sum[MAX] ;
pair<long long , long long>q[MAX] ;

int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0) ;
    int n , m;
    cin>>n>>m ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    for(int i = 0 ; i < m ; ++i)
        cin>>q[i].second>>q[i].first ;
    sort(q , q + m) ;
    priority_queue<long long , vector<long long> , greater<long long> >qq ;
    long long ans = 0 ;
    for(int i = 0 ; i < n ; ++i)
    {
        ans += arr[i] ;
        qq.push(arr[i]) ;
    }
    for(int i = m-1 ; i >= 0 ; --i)
    {
        for(int j = 0 ; j < q[i].second ; ++j)
        {
            if(qq.empty())
                break ;
            long long x = qq.top() ;
            if(x > q[i].first)
                break ;
            qq.pop() ;
            ans -= x ;
            ans += q[i].first ;
        }
    }
    return cout<<ans<<"\n" , 0 ;
}


Measured memory_bytes: 3320
n = int(input())
vals = list(map(lambda v: int(v), input().split()))
vals.sort(reverse=True)
i = 0
sum = 1

if (0 in vals):
  print(0)
  exit()

while (i < len(vals)):
  sum = sum * vals[i]
  if (sum > 10e17):
    print(-1)
    exit()
  i = i + 1

print(sum)

Measured memory_bytes: 21792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<"No"<<endl;
		return 0;
	}
	else if(a==b||a==c||b==c){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, k;
  	scanf("%d%d%d", &a, &b, &k);
  	if(a > b) swap(a, b);
  	int cnt = 0, i;
  	for(i = a ; i >= 1 && cnt < k; --i)
    	if(!(a % i) && !(b % i)) cnt++;
  	printf("%d\n", i + 1);
}

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

int main() {
  int l, r;
  cin >> l >> r;
  if (l / 2019 != r / 2019) {
    cout << 0 << endl;
    return 0;
  }
  l %= 2019;
  r %= 2019;
  int ans = 2019;
  for (int i = l; i < r; i++) {
    for (int j = l + 1; j <= r; j++) {
      int x = (i * j) % 2019;
      if (x < ans) ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
towns, num_teleports = gets.split.map(&:to_i)
destinations = gets.split.map(&:to_i).map{|x| x - 1 }

# check loop length

loop_start = 0
loop_length = 0

visited = Array.new(towns) { false }

p = 0
while visited[p] == false
  visited[p] = true
  p = destinations[p]
end

loop_start = p

begin
  p = destinations[p]
  loop_length += 1
end while p != loop_start

res = 0

while num_teleports > 0 do
  num_teleports %= loop_length if res == loop_start
  break if num_teleports == 0
  res = destinations[res]
  num_teleports -= 1
end

puts (res + 1)

Measured memory_bytes: 30504
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n, t, a;
    cin >> n >> t >> a;
    t *= 1e3, a *= 1e3;
    int h[n];
    int ans = 1e9;
    rep(i, n){
        cin >> h[i];
        ans = min(ans, abs(t - h[i]*6 - a));
    }
    rep(i, n){
        if(abs(t - h[i]*6 - a) == ans){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}
/*

平均気温 - a の絶対値の最小値を記録しておいて
あとでどこだったのか確認すればオーケー？
pairでsortだとO(NlogN)だけど、
これならO(N)なので実はこっちのほうが早い

*/

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

ll a[100001];

ll solve(int n,int sgn,map<pair<int,int>,ll> &dp)
{
    if(n==1)
        return a[n]*sgn;
    if(dp.find({n,sgn})!=dp.end())
        return dp[{n,sgn}];
    ll x = a[n]*sgn + solve(n-1,1,dp);
    ll y = a[n]*(sgn*(-1)) + solve(n-1,-1,dp);
    dp[{n,sgn}]=max(x,y);
    return dp[{n,sgn}];
}
int main()
{
    flash;
    //sieve();
    int T=1,n,m,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n;
        FOR(i,1,n+1)  cin>>a[i];
        map<pair<int,int>,ll> dp;
        cout<<solve(n,1,dp)<<endl;
    }
}

Measured memory_bytes: 27804
using System;
using System.Collections.Generic;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            var list = new List<int>();

            for(int i = 0; i < N; ++i)
            {
                list.Add(int.Parse(input[i]));
            }

            list.Sort();

            int Alice = 0;
            int Bob = 0;

            for(int i = N - 1; i >= 0; i = i - 2)
            {
                Alice = Alice + list[i];

                if((i - 1) >= 0)
                {
                    Bob = Bob + list[(i - 1)];
                }
            }

            Console.WriteLine((Alice-Bob));

        }
    }
}

Measured memory_bytes: 13140
from collections import Counter
N = int(input())
alist = list(map(int,input().split()))
cc = Counter(alist)
blist = []
clist = []
for c in cc.items():
    if c[1] >= 2:
        blist.append(c[0])
    if c[1] >= 4:
        clist.append(c[0])
blist.sort()
clist.sort()
if len(blist) < 2:
    print(0)
elif len(clist) > 0:
    print(max(blist[-1]*blist[-2],clist[-1]* clist[-1]))
else:
    print(blist[-1]*blist[-2])
   

Measured memory_bytes: 18600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> vi;

int main(void){
	int w;
	string s;
	cin >> s;
	cin >> w;
	for(int i = 0; i < s.size(); i+=w) {
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] number = line.split(" ");
        int n = Integer.parseInt(number[1] + number[2]);
        if(n % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    int n;
    cin >> n;
    vector<int> num(55556, 0);
    for (int i = 2; i * i <= 55555; ++i) {
        if (num[i] == 0) {
            int idx = i;
            while(1) {
                if (idx >= 55555) break;
                num[idx]++;
                idx += i;
            }
        }
    }
    vector<int> ans;
    int cnt = 0;
    rep(i, 55556) {
        if (num[i] == 0 && i % 10 == 1 && i != 1) {
            ans.push_back(i); 
            ++cnt;
        }
        if (cnt == n) break;
    }
    rep(i, (int)(ans.size())) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3552