akhauriyash/Code-Regression huggingface dataset:
package main

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

func bubbleSort(arr []int, length int) (int, []int) {
	count := 0
	// 未ソートの先頭を記録
	for i := 0; i < (length - 1); i++ {
		// bubble
		for j := 0; j < (length - i - 1); j++ {
			if arr[length-j-1] < arr[length-j-2] {
				arr[length-j-1], arr[length-j-2] = arr[length-j-2], arr[length-j-1]
				count++
			}
		}
	}
	return count, arr
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var length int
	var arr []int
	if sc.Scan() {
		s := sc.Text()
		i, _ := strconv.Atoi(s)
		length = i
	}
	if sc.Scan() {
		s := sc.Text()
		va := strings.Split(s, " ")
		for _, v := range va {
			vi, _ := strconv.Atoi(v)

			arr = append(arr, vi)
		}
	}

	count, sortedArr := bubbleSort(arr, length)
	fmt.Print(sortedArr[0])
	for _, v := range sortedArr[1:] {
		fmt.Print(" ", v)
	}
	fmt.Println()
	fmt.Println(count)
}



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

int main()
{
	int n;
	cin>>n;
	vector<int>a(n,0),b(n,0),c(n,0);
	for(int i=0;i<n;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		a[i]=x;b[i]=y;c[i]=z;
	}
	for(int i=1;i<n;i++)
	{
		a[i]=a[i]+max(b[i-1],c[i-1]);
		b[i]=b[i]+max(a[i-1],c[i-1]);
		c[i]=c[i]+max(a[i-1],b[i-1]);
	}
	cout<<max({a[n-1],b[n-1],c[n-1]});
}

Measured memory_bytes: 4568
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define Need_for_speed ios_base::sync_with_stdio(0);
using namespace std;
//cout<<fixed<<setprecision()
int main(){
	Need_for_speed;
	int n;
	cin>>n;
	if(n % 4 == 0 || n % 11 == 0){
		cout<<"Yes";
		return 0;
	}
	else if(n % 7 == 0){
		cout<<"Yes";
		return 0;
	}
	else if(n < 4 || n > 4 && n < 7){
		cout<<"No";
		return 0;
	}
	while(n > 0){
		if(n % 4 == 0){
			cout<<"Yes";
			return 0;
		}
		n-=7;
	}
	cout<<"No";
	exit(0);
}


Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        H:usize,
        W:usize,
        D:usize,
        A:[[usize;W];H],
        Q:usize,
        LR:[(usize,usize);Q],
    }

    let mut YX = vec![(0,0);H*W+10];
    for i in 0..H{
        for j in 0..W{
            let a = A[i][j];
            YX[a] = (i as isize,j as isize);
        }
    }
    let mut Cost = vec![0;H*W+10];
    for i in D+1..=H*W{
        Cost[i] = (YX[i].0-YX[i-D].0).abs() + (YX[i].1-YX[i-D].1).abs();
    }
    for i in D+1..=H*W{
        Cost[i] += Cost[i-D];
    }
    for &(l,r) in &LR{
        println!("{}",Cost[r]-Cost[l]);
    }
}


Measured memory_bytes: 8056
import kotlin.math.abs
import kotlin.math.min

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val (n, k) = intList()
    val x = longList()
    val b = (x.indexOfFirst { it >= 0 } + 1).takeIf { it > 0 } ?: n - 1
    var m = Long.MAX_VALUE
    ((b - k).takeIf { it > 0 } ?: 0).until(b + 1).forEach {
        if (it >= 0 && it + k <= n) {
            val l = x[it]
            val r = x[it + k - 1]
            m = if (l < 0) {
                if (r < 0) {
                    min(m, abs(l))
                } else {
                    min(m, min(abs(l) * 2 + r, abs(l) + r * 2))
                }
            } else {
                min(m, abs(r))
            }
        }
    }
    if (m == Long.MAX_VALUE) {
        println("0")
    } else {
        println(m.toString())
    }
}


Measured memory_bytes: 52996
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define LIM 100005
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define vi vector <int>
#define pb push_back
#define sz(x) x.size()
#define all(x) x.begin(), x.end()


int32_t main()
{
  IOS;
  int t,x,m,y,k,n,i,j;
  cin>>n>>m>>k;
  char a[n+1][m+1];
  int r[n+1], c[m+1];
  int cnt=0;
  for(i=0;i<n;i++)
  { cnt=0;
    for(j=0;j<m;j++)
    {
        cin>>a[i][j];
        if(a[i][j]=='#')cnt++;
    }
    r[i]=cnt;
  }
  int tot=0;
  for(j=0;j<m;j++)
  { cnt=0;
    for(i=0;i<n;i++)
    {
        //cin>>a[i][j];
        if(a[i][j]=='#'){cnt++; tot++;}
    }
    c[j]=cnt;
  }
  int ans=0;
  for(i=0;i<(1<<n);i++)
  {
      for(j=0;j<(1<<m);j++)
      { cnt=0;
        for(int kkk=0;kkk<n;kkk++)
        {
            for(int kk=0;kk<m;kk++)
            {
                if((i>>kkk & 1)==0 && (j>>kk&1)==0 && a[kkk][kk]=='#') cnt++;
            }
        }
          if(cnt==k)ans++;
      }
  }

  cout<<ans;



}


Measured memory_bytes: 3556
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[60][60];
char str[60][60];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int use[60][60];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a+2;i++)for(int j=0;j<b+2;j++)str[i][j]='#';
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)
		str[i+1][j+1]=in[i][j];
	int row=0;
	int col=0;
	int dir=0;
	a+=2;
	b+=2;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(str[i][j]=='^'){
			row=i;col=j;dir=0;
		}
		if(str[i][j]=='>'){
			row=i;col=j;dir=1;
		}
		if(str[i][j]=='v'){
			row=i;col=j;dir=2;
		}
		if(str[i][j]=='<'){
			row=i;col=j;dir=3;
		}
	}
	int ret=-1;
	int t=0;
	use[row][col]=1;
	while(t<100000){
		t++;
		if(str[row+dx[(dir+1)%4]][col+dy[(dir+1)%4]]!='#'){
			dir=(dir+1)%4;
			row+=dx[dir];
			col+=dy[dir];
		}else if(str[row+dx[dir]][col+dy[dir]]!='#'){
			row+=dx[dir];
			col+=dy[dir];
		}else dir=(dir+3)%4;
		
		use[row][col]=1;
		if(str[row][col]=='G'){ret=t;break;}
	}
	if(ret==-1){
		printf("-1\n");return 0;
	}
	ret=0;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)ret+=use[i][j];
	printf("%d\n",ret);
}

Measured memory_bytes: 1048
h,w = gets.chomp.split(" ").map(&:to_i)
a = h.times.map{gets.chomp.split(" ").map(&:to_i)}
ans = []
p = a[0][0].even? ? false : true
for i in 0..h-1
  if i%2 == 0
    for j in 0..w-1
      next if i == 0 && j == 0
      if p
        if j == 0
          ans << "#{i} #{j+1} #{i+1} #{j+1}"
        else
          ans << "#{i+1} #{j} #{i+1} #{j+1}"
        end
        p = false if a[i][j].odd?
      else
        p = true if a[i][j].odd?
      end
    end
  else
    (w-1).downto(0) do |j|
      if p
        if j == w-1
          ans << "#{i} #{j+1} #{i+1} #{j+1}"
        else
          ans << "#{i+1} #{j+2} #{i+1} #{j+1}"
        end
        p = false if a[i][j].odd?
      else
        p = true if a[i][j].odd?
      end
    end
  end
end
puts ans.size,ans

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

int debug = 0;

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

    string sta="", stb="";
    rep(i,b){
        sta += to_string(a);
    }
    rep(i,a){
        stb += to_string(b);
    }

    if(a<b)
        cout << sta << endl;
    else if(a>b)
        cout << stb << endl;
    else
        cout << sta << endl;
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  int K,N;
  cin >> K >> N;

  vector<int> A(N);
  for(int i = 0;i < N;i++) cin >> A[i];

  vector<int> S(0);
  for(int i = 0;i < N-1;i++) {
    S.push_back(A[i+1]-A[i]);
  }
  S.push_back(K-A[N-1]+A[0]);

  int ans = 1000000000;
  for(int i = 0;i < S.size();i++) {
    ans = min(ans,K-S[i]);
  }

  cout << ans << endl;


}


Measured memory_bytes: 2168
#include<iostream>
using namespace std;
int main()
{
	unsigned long long x;
	while(cin>>x)
	{
		long long sum=0;
		sum+=2*(x/11);
		x%=11;
		sum+=2*(x/10);
		x%=10;
		sum+=2*(x/9);
		x%=9;
		sum+=2*(x/8);
		x%=8;
		sum+=2*(x/7);
		x%=7;
		if(x==0)
		cout<<sum<<endl;
		else
		cout<<sum+1<<endl; 
	}
	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  vector<int> abc(26,0);
  rep(i,s.size()) abc[s[i]-'a']++;
  bool ans=true;
  rep(i,26) if(abc[i]%2!=0) ans=false;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  cin >> A;
  sort(A.begin(), A.end());
  int mx = A.back();
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    if (mp.count(A[i]))
      mp[A[i]]++;
    else
      mp[A[i]] = 1;
  }
  vector<int> v(mx + 1);
  for (auto m : mp) {
    if (m.second > 1) {
      for (int j = m.first; j <= mx; j += m.first) {
        v[j]++;
      }
    }
  }
  int64 ans = 0;
  for (int i = 0; i < N; i++) {
    if (v[A[i]] == 0) {
      ans++;
      for (int j = A[i]; j <= mx; j += A[i]) {
        v[j]++;
      }
      debug(A[i], v);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17076
#include<stdio.h>

int main(void)
{
   char x;

   scanf("%c",&x);
   if(x=='A'){
        printf("T\n");
   }
   else if(x=='T'){
        printf("A");
   }
   else if(x=='C'){
        printf("G");
   }
   else if(x=='G'){
        printf("C");
   }
   return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in); 
		String n = sc.nextLine(); 
		
		if (n.charAt(5)==n.charAt(4) && n.charAt(3)==n.charAt(2))
		    System.out.println("Yes");
		    
		else
		    System.out.println("No");
	}
}


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

ll knapsack1(int n, int W){
    
    ll mat[n][2] = {};
    for(int i = 0; i < n; i++){
        cin >> mat[i][0] >> mat[i][1];
    }
    
    ll dp[n+1][W+1] = {};
    for(int i = 1; i < n+1; i++){
        int w = mat[i-1][0];
        ll value = mat[i-1][1];
        for(int j = 1; j < W+1; j++){
            
            if(j < w) dp[i][j] = dp[i-1][j];
            else{
                dp[i][j] = max(dp[i-1][j], value + dp[i-1][j-w]);
            }
        }
    }
    return dp[n][W];
}


int main(){
    int n,W ; cin >> n >> W;
    cout << knapsack1(n,W);

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a=n%10;
    if(a==2 || a==4 || a==7 || a==5 || a==9)
        cout<<"hon";
    else if(a==0|| a==1|| a==6|| a==8)
        cout<<"pon";
    else
        cout<<"bon";
    return 0;
}


Measured memory_bytes: 3580
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long N = arr[0], A = arr[1], B = arr[2];
        var count = N / (A + B);
        var mod = A < N % (A + B) ? A : N % (A + B);
        var answer = A * count + mod;
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27544
#include<bits/stdc++.h>
int main()
{
    int a,b,s,d,m;
    std::cin>>a>>b;
    s=a+b;
    d=a-b;
    m=a*b;
    if(s>d&&s>m)
    std::cout<<s;
    else if(s>d&&s<m)
    std::cout<<m;
    else if(s<d&&s<m&&d<m)
    std::cout<<m;
    else
        std::cout<<d;

    }


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

int main() {
    int n;
    scanf("%d", &n);
    
    int sn = 0;
    int ncopy = n;
    while (ncopy > 0) {
        sn += ncopy % 10;
        ncopy /= 10;
    }

    if (n % sn == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 16001;

int main()
{
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = s.size();

    bitset<MAX> posX, posY;
    int i = 0;
    while(i < n && s[i] == 'F')
        ++ i;
    posX[n+i] = true;
    posY[n] = true;

    bool isDirX = true;
    while(i < n){
        if(s[i] == 'F'){
            int len = 0;
            while(i < n && s[i] == 'F'){
                ++ len;
                ++ i;
            }
            if(isDirX)
                posX = (posX << len) | (posX >> len);
            else
                posY = (posY << len) | (posY >> len);
        }
        else{
            isDirX = !isDirX;
            ++ i;
        }
    }

    if(posX[n+x] && posY[n+y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

const int N = 1e3 + 5;
ll a[N], b[N], c[N];
int x, y, z, k;

struct elm {
  int u, v, w;
  elm(int _u = 0, int _v = 0, int _w = 0) {
    u = _u;
    v = _v;
    w = _w;
  }
  ll get() const {
    return a[u] + b[v] + c[w];
  }
};

bool operator<(const elm& p, const elm& q) {
  return p.get() < q.get();
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> x >> y >> z >> k;
  for (int i = 1; i <= x; ++i) cin >> a[i];
  for (int i = 1; i <= y; ++i) cin >> b[i];
  for (int i = 1; i <= z; ++i) cin >> c[i];
  sort(a + 1, a + 1 + x);
  sort(b + 1, b + 1 + y);
  sort(c + 1, c + 1 + z);
  priority_queue<elm, vector<elm>, less<elm> > heap;
  for (int i = 1; i <= x; ++i)
    for (int j = 1; j <= y; ++j)
      heap.push(elm(i, j, z));
  while (k--) {
    elm t = heap.top();
    heap.pop();
    cout << t.get() << '\n';
    t.w--;
    if (t.w >= 1)
      heap.push(t);
  }
  return 0;
}


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

int main() {
  string a;
  cin>>a;
  int b=a.size();
  int c=0;
  for(int i=0;i<b;i++){
    if((i+1)%2==0){
      if(a.at(i)=='R'){
        c++;
      }
    }
    else{
      if(a.at(i)=='L'){
        c++;
      }
    }
  }
  if(c>0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

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

int main(){
    string S, T;
    cin >> S >> T;

    int lenS = S.length();
    int lenT = T.length();

    if (T.substr(0, lenS) == S){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111



int main(void) {
  vll a;
  cin >> n;
  FOR(i, 0, 2*n) {
	cin >> tmp;
	a.pb(tmp);
  }
  sort(ALL(a));
  FOR(i, 0, 2*n) {
	if (i % 2 == 0) ans += a[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t,a,b,ans=0,cnt=0;
	cin>>t;
	while(t--){
		cin>>a>>b;
		if(a==b){
			cnt++;
		}
		else{
			ans=max(cnt,ans);
			cnt=0;
		}
	}
	ans=max(cnt,ans);
	if(ans>=3){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3628
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: u64 = iterator.next().unwrap().parse().unwrap();
    let b: u64 = iterator.next().unwrap().parse().unwrap();
    let c: u64 = iterator.next().unwrap().parse().unwrap();
    let d: u64 = iterator.next().unwrap().parse().unwrap();

    // 遅い
    // let lcm = kobaisu(c, d, b);

    let lcm = lcm(c, d);

    let x = b / c + b / d - b / lcm;
    let y = (a - 1) / c + (a - 1) / d - (a - 1) / lcm;

    let ans = (b - x) - (a - 1 - y);

    return ans.to_string();
}

// 遅い
fn kobaisu(s: u64, t: u64, max: u64) -> u64 {
    let mut u: u64 = s;
    let mut v: u64 = t;
    while u != v {
        if u > max || v > max {
            return std::u64::MAX
        }
        if u < v {
            u += s;
        } else {
            v += t;
        }
    }
    u
}

/// 最大公約数（greatest common divisor）を求める
fn gcd(m: u64, n: u64) -> u64 {
    if n > m {
        gcd(n, m)
    } else if n == 0 {
        m
    } else {
        gcd(n, m % n)
    }
}

/// 最小公倍数（least common multiple）を求める
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	ll N, M;
	cin >> N >> M;

	ll g = 1;
	
	for(ll i=1; i*i<=M; i++) {
		if(M%i==0) {
			// 候補i, M/i
			if(M/i >= N) {
				g = max(g, i);
			}
			if(i>=N) {
				g = max(g, M/i);
			}
		}
	}

	cout << g << endl;

	return 0;
}

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

int main(){
    
    int n;
    cin>>n;
    
    vector<int> dp(n);
    vector<int> v(n);
    
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(i==1)
        dp[i] = dp[i-1]+ abs(v[i]-v[i-1]);
        else
        dp[i] = min(dp[i-1]+ abs(v[i]-v[i-1]),dp[i-2]+ abs(v[i]-v[i-2]));
    }
    
    cout<<dp[n-1]<<endl;
    
    
}

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

int n, m;
string s, t;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> s >> t;
	int g = __gcd(n, m);
	long long k = 1ll * n * m / g;
	int ok = 1;
	for (int i=0;i<g;i++){
		ok &= s[i * n/g] == t[i * m/g];
	}
	if (!ok){
		k = -1;
	}
	cout << k << "\n";
}

Measured memory_bytes: 640
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))
numlist = []

for i in range(102):
  if not i in p:
    numlist.append(i)
m = 500
for j in numlist:
  sa = abs(X-j)
  if sa < m:
    m = sa
    num = j

print(num)

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

	bool chpal(string s){
		int n=sz(s);
		rep(i,n/2) if(s[i]!=s[n-1-i]) return false;
		return true;
	}

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c,d;
	cin >>a >>b >>c >>d;
	
	int mn = max(a,c);
	int mx = min(b,d);
	
	if(mx -mn >=0) cout << mx -mn <<endl;
	else puts("0");
	return 0;
}


Measured memory_bytes: 256
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll ans = n / (a + b) * a + min(a, n % (a + b));
    cout << ans << endl;
}



Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1400;
int main() {
	ll fib[87];
	fib[0] = 2;
	fib[1] = 1;
	for (int i = 2; i < 87; i++) {
		fib[i] = fib[i - 1] + fib[i - 2];
	}
	int N;
	cin >> N;
	cout << fib[N] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <queue>
#include<map>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include<set>

using namespace std;
#define _USE_MATH_DEFINES
# define M_PI 3.14159265358979323846
# define MOD 1000000007
#define ll long long int
#define pii pair<ll, ll>
#define pb push_back
#define MIN -9,223,372,036,854,775
#define N 100005
#define all(v) v.begin(),v.end()

void solve(){
    ll i,j,k,n,ans=0,m,mx=0,my=0,a,b,x,y;
    cin>>n>>m>>k;
    set<pii> s;
    unordered_map<ll, ll> tx,ty;
    vector<ll> vx,vy;
    for(i=0;i<k;i++){
        cin>>a>>b;
        s.insert({a,b});
        tx[a]++;
        ty[b]++;
        if( tx[a]>mx ){
            vx.clear();
            mx=tx[a];
            vx.push_back(a);
        }
        else if(tx[a]==mx){
            vx.push_back(a);
        }
        
        if( ty[b]>my ){
            my=ty[b];
            vy.clear();
            vy.push_back(b);
        }
        else if(ty[b]==my){
            vy.push_back(b);
        }
    }

    if(k<=2){
        cout<<k;
        return;
    }
    ans=mx+my;
    ll f=0;
    for(i=0;i<vx.size();i++){
        for(j=0;j<vy.size();j++){
            if( s.find({vx[i], vy[j]}) == s.end() ){
                f=1;
                break;
            }
        }
    }
    
    if( !f )
        ans--;
    

    cout<<ans;

}

int main() {
    ll t=1;
	//cin>>t;
	while( t-- ){
	    solve();
	    cout<<"\n";
	}
	return 0;
}

/*
5 5 10
2 5
4 3
2 3
5 5
2 2
5 4
5 3
5 1
3 5
1 4
*/


Measured memory_bytes: 60764
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
F = gets.chomp.split.map(&:to_i)

A.sort!
F.sort!.reverse!

def s(p)
  sum = 0
  N.times do |i|
    u = (A[i] - (p.to_f / F[i])).ceil
    sum += u if u > 0
  end
  return false if sum > K
  true
end

p (0..10**12).bsearch { |p| s(p) }

Measured memory_bytes: 34172
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(ll x=in;x<n;x+=r)
#define ifr(x,n) for(ll x=0;x<n;x++)
#define dfr(x,n) for(ll x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

ll a[100001];

ll fun(ll i){
	while(a[i]!=i){
		a[i]=a[a[i]];
		i=a[i];
	}
	return i;
}

void uni(ll x,ll y){
	ll u=fun(x);
	ll v=fun(y);
	if(u==v)
		return ;
	a[v]=u;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll n,m;
	cin>>n>>m;
	ll x,y,r;
	fr(i,1,n+1,1)
		a[i]=i;
	ifr(i,m){
		cin>>x>>y>>r;
		uni(x,y);
	}
	ll ans=0;
	fr(i,1,n+1,1){
		if(a[i]==i)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
ln = len(s) - 1
pat = []

for i in range(2**ln):
    tmp = ['']
    for j in range(ln):
        if i >> j & 1:
            tmp.append('+')
        else:
            tmp.append('')
    pat.append(tmp)

ans = 0
for p in pat:
    tmp = ''
    for i, j in zip(p, s):
        tmp += i+j
    ans += eval(tmp)

print(ans)

Measured memory_bytes: 3064
gets
as = gets.split.map(&:to_i)
rates = Array.new(8, nil)
free = 0

as.each do |a|
  case a
  when 1..399;    rates[0] = 1
  when 400..799;  rates[1] = 1
  when 800..1199; rates[2] = 1
  when 1200..1599;rates[3] = 1
  when 1600..1999;rates[4] = 1
  when 2000..2399;rates[5] = 1
  when 2400..2799;rates[6] = 1
  when 2800..3199;rates[7] = 1
  else;           free += 1
  end
end

rates.compact! 
if rates.size.zero?
  puts [1, free].join(' ')
else
  puts [rates.size, rates.size + free].join(' ')
end


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

int main() {
  long long N;
  cin >> N;
  int a = sqrt(N) + 1;
  for(int i = a; i > 0; i--) {
    if(N%i == 0) {
      cout << i + (N/i) - 2 << endl;
      break;
    }
  }
}


Measured memory_bytes: 384
n , k = map(int, input().split())

if k==0:
    ans = (1+n-1)*(n-1)//2
else:
    ans = (1+n-k)*(n-k)//2


if k==0:
    for i in range(1,n+1):
        ans +=n//i

for i in range(k,n):
    if i==0:
        continue
    for j in range(1,n//i+1):
        if j*(i+1)+i<=n:
            ans+=(n-(j*(i+1)+i))//j+1
        if j*(i+1)+i>n:
            break

print(ans)


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

int main()
{
  string day;
  int result = 0;
  cin >> day;
  if (day=="SUN") result = 7;
  else if (day=="MON") result = 6;
  else if (day=="TUE") result = 5;
  else if (day=="WED") result = 4;
  else if (day=="THU") result = 3;
  else if (day=="FRI") result = 2;
  else if (day=="SAT") result = 1;
  cout << result;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,ans;
	cin >> n;
	vll a(n);
	cin >> a[0];
	ans = a[0];
	rep(i, 1, n) {
		cin >> a[i];
		ans = gcd(ans, a[i]);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 1000119
int num[maxn],tree[maxn],booll[maxn],nnn[maxn],N,ww;;
struct tt
{
    int l,r;
    int pos;
};
tt ask[maxn];
bool cmp(tt x,tt y)
{ 
    return x.r<y.r;
}
int lowbit(int n) 
{
    return n&(-n);
}
void add(int n,int now)
{
    while(n<=N)
    {
        tree[n]+=now;
        n+=lowbit(n);
    }
}
int sum(int n)
{
    int ans=0;
    while(n!=0)
    {
        ans+=tree[n];
        n-=lowbit(n);
    }
    return ans;
}
int main()
{
        scanf("%d%d",&N,&ww);
        for(int i=1;i<=N;i++)
            scanf("%d",&num[i]);
        for(int i=1;i<=ww;i++)
        {
            scanf("%d%d",&ask[i].l,&ask[i].r);
            ask[i].pos=i;
        }
        sort(ask+1,ask+1+ww,cmp);
        int next=1;
        for(int i=1;i<=ww;i++)
        {
            for(int j=next;j<=ask[i].r;j++)
            {
                if(booll[num[j]]) 
                    add(booll[num[j]],-1);
                add(j,1);
                booll[num[j]]=j;
            }
            next=ask[i].r+1;
            nnn[ask[i].pos]=sum(ask[i].r)-sum(ask[i].l-1);
        }
    for(int i=1;i<=ww;i++)
      cout<<nnn[i]<<endl;
    return  0;
}

Measured memory_bytes: 17392
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}
int main() {
    ll n, m;
    cin >> n >> m;
    Graph G(n);
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
      a--;
      b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    seen.assign(n, false);  // 初期化
    ll cnt = 0; 
    for (ll i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++; // dfsした回数をカウント
        }
    }
    cout << cnt-1 << endl;
    return 0;
}


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int r, c, n;

int get(int x, int y) {
    if (y == 0)
        return x;
    else if (x == r)
        return r + y;
    else if (y == c)
        return r + c + (r - x);
    else if (x == 0)
        return r + c + r + (c - y);
    else
        return -1;
}

vector<pair<int, int> > ev;

int lb[120000];
int rb[120000];
set<int> ss;

int main() {
    cin >> r >> c >> n;
    for (int i = 0; i < n; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int a = get(x1, y1);
        int b = get(x2, y2);
        if (a == -1 || b == -1)
            continue;
        if (a > b)
            swap(a, b);
        ev.push_back(make_pair(a, i));
        ev.push_back(make_pair(b, i));
        lb[i] = a;
        rb[i] = b;
    }
    sort(ev.begin(), ev.end());
    for (int i = 0; i < ev.size(); ++i) {
        int k = ev[i].second;
        if (ss.count(lb[k])) {
            ss.erase(lb[k]);
            if (!ss.empty() && *ss.rbegin() > lb[k]) {
                cout << "NO\n";
                return 0;
            }
        }
        else {
            ss.insert(lb[k]);
        }
    }
    cout << "YES\n";
    return 0;
}




Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
long long int a[200000];
long long int b[200000];
int main(){
	long long int n, k;
	cin >> n >> k;
	for(long long int i = 0;i < n;i++){
		cin >> a[i];
	}
	long long int r = 0;
	long long int count = 0;
	b[0] = 0;
	for(long long int i = 1;i < n;i++){
		b[i] = -1;
	}
	while(1){
		count++;
		r = a[r] - 1;
		if(b[r] != -1){
			break;
		}
		b[r] = count;
	}
	long long int mod = k % (count - b[r]);
	if(k < b[r]){
		for(long long int i = 0;i < n;i++){
			if(b[i] == k){
				cout << i + 1 << endl;
				return 0;
			}
		}
	}else{
		for(;mod < b[r];mod += (count - b[r])){
			n = n;
		}
		for(long long int i = 0;i < n;i++){
			if(b[i] == mod){
				cout << i + 1 << endl;
				return 0;
			}
		}
	}
}

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

int main(){
  string A;
  cin >> A;
  if(A.at(2)==A.at(3)&&A.at(4)==A.at(5)){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
import math

(a, b, C) = [float(i) for i in input().split()]
S = 0.5 * a * b * math.sin(math.radians(C))
c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(C)))

print("%8f" %(S))
print("%8f" %(a + b + c))
print("%8f" %(S / a * 2))

Measured memory_bytes: 6868
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int a = 0;
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			a++;
			if (x < a)x = a;
		}
		else a--;
	}
	cout << x;
	return 0;
}



Measured memory_bytes: 384
#include <iostream>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 10000000;
using namespace std;
typedef long long  ll;
/** Problem0195 : What is the Most Popular Shop in Tokaichi? **/
int main()
{
	string list = "ABCDE";
	int s1, s2, max=0, i=0;
	char maxN;
	while (1) {
		cin >> s1 >> s2;
		if (s1 == 0 && s2 == 0)
			break;
		
		if (max < s1+s2) {
			max = s1 + s2;
			maxN = list[i%5];
		}
		
		if (i%5==4) {
			cout << maxN << " " << max << endl;
			max = 0;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	vector<int>in;
	while(cin>>n){
		if(n)in.pb(n);
		else {
			cout<<in[in.size()-1]<<endl;
			in.erase(in.end()-1);
		}
	}
}

Measured memory_bytes: 1212
n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)

Measured memory_bytes: 19948
maisu,goukei=map(int ,input().split())
cou=0
for i in range(maisu+1):
  for r in range(maisu+1):
    if i+r>maisu:
      break
    if i*10000+r*5000+(maisu-i-r)*1000==goukei:
      cou=1
      print(i,r,maisu-i-r)
      break
  if cou==1:
    break
  if i==maisu:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;// 1e9 + 7;

ll a[100001];
int main(){
	ll n, m; cin >> n >> m;

	rep(i, 0, m) {
		ll m; cin >> m;
		a[m] = -1;
	}

	ll ans = 0;
	if (a[1] == -1 && a[2] == -1) {
		cout << 0 << endl;
		return 0;
	}

	if (a[1] == -1 && a[2] != -1) {
		a[1] = 0;
		a[2] = 1;
	}
	else if(a[1] != -1 && a[2] == -1){
		a[1] = 1;
		a[2] = 0;
	}
	else if (a[1] != -1 && a[2] != -1) {
		a[1] = 1;
		a[2] = 2;
	}

	repe(i, 3, n) {
		if (a[i] != -1) {
			ll x = a[i - 1];
			ll y = a[i - 2];
			if (x == -1) x = 0;
			if (y == -1) y = 0;
			
			a[i] = (x  + y ) %MOD;
		}
	}

	cout << a[n] << endl;
	return 0;
}

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

int main()
{
  ll l;
  cin >> l;

  long double edge = l / 3.0;
  long double ans = edge * edge * edge;

  cout << fixed << setprecision(12) << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	int cnt = 0;
	for (int ia = 1; ia <= N; ia++) {
		if (N % ia == 0&&1<=ia&&ia<=9&&1<=N/ia&&N/ia<=9) {
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int x = Math.max(Math.abs(a - c), Math.abs(b - d));
		int y = Math.min(Math.abs(a - c), Math.abs(b - d));
		int wari = gcd(x, y);
		x /= wari;
		y /= wari;
		System.out.println(wari * (Math.min(x, y) - 1 + Math.max(x, y)));
	}
	static int gcd(int a, int b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
}

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


int main(void)
{
    int count = 0;
    int N;
    cin >> N;
    int a[N];
    int b[N] = {0};
    int sum = 0;
    for( int i = 0; i < N; i++){
        cin >> a[i];
    }
    for( int i = 0; i < N; i++){
        if( a[i] % 4 == 0){
            b[i] = 2;
        }
        else if( a[i] % 2 == 0){
            b[i] = 1;
            count++;
        }
        sum += b[i];
    }
    if( N % 2 == 1 && count < 2){
        if( sum / (double)(N-1) >= 1){
            printf("Yes");
        }else{
            printf("No");
        }
    }else if( N % 2 == 1 && count >= 2){
        if( sum / (double)(N-1) > 1){
            printf("Yes");
        }else{
            printf("No");
        }
    }else{
        if( sum / (double)N >= 1){
            printf("Yes");
        }else{
            printf("No");
        }
    }

    return 0;
}

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

int R,G,B,N;
int main(){
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int r=0;r<=N;r++){
        for(int g=0;g<=N;g++){
            if(0<=N-r*R-g*G && (N-r*R-g*G)%B==0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long a = l[0], b = l[1], c = l[2];

        var d = c - a - b;
        Console.WriteLine(d > 0 && d * d > 4 * a * b ? "Yes" : "No");
    }
}


Measured memory_bytes: 13268
/*
 * ID:  ITP1_10_C
 * Problem: Standard Deviation
 */

#include <stdio.h>
#include <math.h>

int main(void)
{
    double x, sum, sumx2, sd;
    int n, i;

    while (1) {
        scanf("%d", &n);
        if (n == 0)
            return 0;
        sum = sumx2 = 0.0;
        for (i = 0; i < n; i++) {
            scanf("%lf", &x);
            sum += x;
            sumx2 += x * x;
        }
        sd = sqrt((sumx2 - sum * sum / n) / n);
        printf("%.8f\n", sd);
    }

    return 0;
}



Measured memory_bytes: 2044
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    vll a(n);
    vll m(n);
    REP(i,n){
        cin >> a[i];
        m[i]=a[i];
    }
    ll ans = LLINF;
    REP(k,n){
        ll tmp = x*k;
        REP(i,n){
            m[i] = min(m[i],a[(i+n-k)%n]);
            tmp+=m[i];
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int, input().split()))
Max = 0
count = collections.Counter(a)
for i in range(N):
    c = 0
    X = a[i]
    c += count[X-1]
    c += count[X]
    c += count[X+1]
    if c > Max:
        Max = c
print(Max)

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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, v[20], c[20];
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> c[i];
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (v[i] > c[i])
      ans += v[i] - c[i];
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int a[20];
int main(){
  string n;
  cin>>n;
  int x=n.size();
  for(int i=0;i<n.size();i++){
    a[i]=n[i]-'0';
  }

  int ans=0;
  rep(i,x)ans+=a[i];
  rep(i,x){
    if(a[i]>0){
      int temp=0;
      temp+=a[i]-1;
      FOR(j,i+1,x){
        temp+=9;
      }
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;


}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

struct edge {
	int to, cost, id;
};

vector<vector<edge>> g;
vi dist;

void dfs(int v, int p = -1, int d = 0) {
	rep(i, g[v].size()) {
		edge tmp = g[v][i];
		int nv = tmp.to, c = tmp.cost, id = tmp.id;

		if (nv == p) continue;

		dist[nv] += c + d;
		dfs(nv, v, dist[nv]);
	}
}

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

	g.resize(n), dist.resize(n);
	rep(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		edge tmp1 = { a, c, i };
		edge tmp2 = { b,c,i };

		g[b].push_back(tmp1);
		g[a].push_back(tmp2);
	}

	dfs(0);

	rep(i, n) {
		if (dist[i] % 2 == 0) cout << 0 << endl;
		else cout << 1 << endl;
	}
}

Measured memory_bytes: 8960
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let xs : Vec<usize> = get_vec();
    let _n = xs[0];
    let k = xs[1];
    let mut v : Vec<i32> = get_vec();

    v.sort();
    v.reverse();
    let mut ans = 0;
    for i in 0..k {
        ans += v[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352