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

using namespace std;

int main()
{
    double D,S,T,A;
    cin>>D;
    cin>>S;
    cin>>T;
    A=D/S;
    if(T>=A)
    {
        cout<<"Yes";
    }
    else if(T<A)
    {
        cout<<"No";
    }

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cnt++;
    } else {
      if (cnt >= 3) {
        cout << "Yes" << '\n';
        return 0;
      }
      cnt = 0;
    }
  }
  if (cnt >= 3) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
	
	vector<int> v,w;
	string s;
	int i;
	
	cin>>s;
	v.push_back(-1);
	bool ch=true;
	
	s.push_back('D');
	
	for(i=0;i<s.length();i++){
		if(s[i]!='A'&&s[i]!='C'&&s[i]!='G'&&s[i]!='T'){
			v.push_back(i);
			ch=false;
		}
	}
	
	for(i=0;i<v.size()-1;i++){
			w.push_back(v[i+1]-v[i]-1);
			
		}	
	
	sort(w.begin(),w.end());
	if (ch)cout<<s.length()<<endl;
	else cout<<w[w.size()-1]<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
//ミス enqueue(startx,starty);
//配列サイズ
#include<stdio.h>
#include<stdlib.h>
#define min(x,y) (x<y)?(x):(y);
#define N 100000000
#define INF 1000000000
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
typedef struct{
    int w;
    int h;
}Point;
Point queue[N];
int head,num;
void enqueue(int w,int h){
    if(num<N){
        queue[(head+num)%N].w=w;
        queue[(head+num)%N].h=h;
        num++;
    }else{
        printf("エラー\n"); exit(1);
    }
}
Point dequeue(){
    Point d={-1,-1};
    if(num>0){
        d=queue[head];
        head=(head+1)%N;
        num--;
    }
    return d;
}
int w,h;
char c[20][22];
int dx[4]={ 0,1,0,-1};
int dy[4]={-1,0,1, 0};
int bfs(Point p,Point q){
    head=num=0;
    int map[20][20]={0};
    int starty=p.h,startx=p.w;
    enqueue(p.w,p.h);
    while(1){
        Point tmp=dequeue();
        int y=tmp.h,x=tmp.w;
        if(y+x==-2) break;
        if(q.w==x&&q.h==y){
            return map[y][x];
        }
        for(int d=0;d<4;d++){
            int ny=y+dy[d],nx=x+dx[d];
            if(ny==starty&&nx==startx) continue;
            if(ny<0||ny>=h||nx<0||nx>=w) continue;
            else if(map[ny][nx]>0||c[ny][nx]=='x') continue;
            else{
                enqueue(nx,ny);
                map[ny][nx]=map[y][x]+1;
            }
        }
    }
    return INF;
}
int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        getchar();
        rep(i,h) fgets(c[i],22,stdin);
        /*rep(i,h){rep(j,w){
            printf("%c",c[i][j]);
        }puts("");}*/
        int cnt=0;
        Point pos[10]={0};
        Point s={0};
        rep(i,h){
            rep(j,w){
                if(c[i][j]=='*'){
                    pos[cnt].h=i; pos[cnt].w=j;
                    cnt++;
                }
                else if(c[i][j]=='o'){
                    s.h=i,s.w=j;
                }
            }
        }
        int dist[10][10]={0};
        rep(i,cnt)rep(j,cnt)dist[i][j] = bfs(pos[i],pos[j]);
        /*rep(i,cnt){
            rep(j,cnt){
                printf("%2d ",dist[i][j]);
            }puts("");
        }puts("");*/
        // 巡回セールスマン初期化
        int dp[1<<10][10];
        rep(i,1<<10)rep(j,10)dp[i][j] = INF;
        
        // 巡回セールスマン
        rep(i,cnt) dp[1<<i][i] = bfs(s,pos[i]);
        rep(i,1<<cnt)rep(j,cnt)rep(k,cnt)
        dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k],dp[i][j]+dist[j][k]);
        
        // 出力
        int ans = INF;
        rep(i,cnt)ans = min(ans,dp[(1<<cnt)-1][i]);
        printf("%d\n",(ans<INF)?ans:-1);
    }
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> height(n);
  for(int i = 0; i < n; ++i) cin >> height[i];
  vector<int> dp(n, INF);
  dp[0] = 0;
  for(int i = 1; i < n; ++i){
    for(int j = 1; j <= k; ++j){
      if(i - j < 0) continue;
      dp[i] = min(dp[i], dp[i - j] + abs(height[i] - height[i - j]));
    }
  }
  cout << dp[n - 1] << endl;
}

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

double a[100000];

double rec(int n,double k){
  double tmp,ans;
  if(k<10e-6)return 0.0;
  if(n<1)return 0.0;
  if(n==1)return 1.0;
  tmp = k/2;

  ans = 1.0;
  ans += tmp * rec(n-1,tmp);
  if(!a[n-2])a[n-2] = rec(n-2,1.0);
  ans += (1.0-tmp) * a[n-2];

  return ans;
}

int main(){
  int n;
  double d;

  while(1){
    cin >> n;
    if(!n)break;
    for(int i=0;i<=n;i++)a[i] = 0;
    d = rec(n,1.0);
    printf("%.6lf\n",d);
  }
}

Measured memory_bytes: 7216
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	bool four = false;
	for (int i = 0; i < N; ++i) {
		char c;
		cin >> c;
		if (c == 'Y') {
			four = true;
		}
	}
	if (four) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 3005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, a[MAXN];

struct Edge {
	int v, nxt;
}e[MAXN<<1];
int first[MAXN], eCnt;

inline void AddEdge(int u, int v) {
	e[++eCnt].v = v;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

bool DFS(int u, int fa) {
	for (int i=first[u];i;i=e[i].nxt) {
		int v = e[i].v;
		if (v == fa) continue;
		if (a[u] > a[v] && !DFS(v, u)) return 1;
	}
	return 0;
}

void init() {
	read(n);
	for (int i=1;i<=n;++i) {
		read(a[i]);
	}
	for (int i=1,u,v;i<n;++i) {
		read(u); read(v);
		AddEdge(u, v);
		AddEdge(v, u);
	}
}

void solve() {
	for (int i=1;i<=n;++i) {
		if (DFS(i, 0)) {
			printf("%d ", i);
		}
	}
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long[] H = new long[N];
        for (int i = 0; i < N; i++) {
            H[i] = scan.nextInt();
        }
        Arrays.sort(H);
        for (int i = 0; i < K; i++) {
            if (N-1-i < 0) {
                break;
            }
            H[N-1-i] = 0;
        }
        long answer = Arrays.stream(H).sum();
        System.out.println(answer);
    }
}


Measured memory_bytes: 94804
MOD = 10**9+7
n, k, *a = map(int, open(0).read().split())
s = t = 0
for i in range(n):
  s += sum(j>i and a[j]<a[i] for j in range(n))
  t += sum(a[j]<a[i] for j in range(n))
print((s*k + k*~-k//2*t) % MOD)

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

int main() {
  int N, A, B;
  cin >> N;
  A = N % 1000;
  B = N / 10;
  
  if (A % 111 == 0) {
    cout << "Yes";
  }else if (B % 111 == 0) {
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int mina = INT32_MAX, minb = INT32_MAX;
  rep(i, A)
  {
    cin >> a[i];
    mina = min(a[i], mina);
  }
  rep(i, B)
  {
    cin >> b[i];
    minb = min(b[i], minb);
  }
  long long ans = mina + minb;
  rep(i, M)
  {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    long long price = a[x] + b[y] - c;
    ans = min(ans, price);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++)
        cin >> d[i];
    
    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

ll N;
vector<vector<ll>> G;
ll A[200000];
ll L[200000];
vector<ll> v;
ll INF = 1e15;

void dfs(ll n){
    ll ind = lower_bound(v.begin(),v.end(),A[n]) - v.begin();
    ll backup = v[ind];
    v[ind] = A[n];
    L[n] = lower_bound(v.begin(),v.end(),INF) - v.begin();
    for(auto &e : G[n]){
        if(L[e] != 0) continue;
        dfs(e);
    }
    v[ind] = backup;
}

int main(){
    cin >> N;
    G.resize(N);
    v.resize(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N-1;i++){
        ll a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(int i=0;i<N;i++) v[i] = INF;
    dfs(0);
    for(int i=0;i<N;i++) cout << L[i] << endl;
    return 0;
}

Measured memory_bytes: 27472
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 5005;
int n, A[N], ok[N], F[N], sz[N];
long long dp[N][N], dpt[N];
vector < int > Adj[N];
void DFS(int v, int p)
{
    sz[v] = 1;
    for (int i = 0; i < Adj[v].size(); i++)
        if (Adj[v][i] == p)
            swap(Adj[v][i], Adj[v].back()), Adj[v].pop_back();

    if (!Adj[v].size())
    {
        ok[v] = 0;
        if (A[v] > 0)
            F[v] = 0;
        for (int i = 0; i < 1; i++)
            dp[v][i] = A[v];
        return ;
    }

    for (int &u : Adj[v])
        DFS(u, v);

    dp[v][0] = A[v];
    for (int &u : Adj[v])
    {
        memset(dpt, 63, sizeof(dpt));
        for (int i = 0; i < sz[v]; i++)
            for (int j = 0; j < sz[u]; j++)
                dpt[i + j] = min(dpt[i + j], dp[v][i] + dp[u][j]);
        for (int i = 0; i < sz[v]; i++)
            dpt[i + ok[u] + 1] = min(dpt[i + ok[u] + 1], dp[v][i]);
        sz[v] += sz[u];
        for (int i = 0; i < sz[v]; i++)
            dp[v][i] = dpt[i];
    }
    for (int i = 0; i < N; i++)
        if (dp[v][i] < 0)
            ok[v] = min(ok[v], i);

    if (A[v] > 0)
    {
        F[v] = 0;
        for (int &u : Adj[v])
            F[v] += min(ok[u] + 1, F[u]);
        ok[v] = min(ok[v], F[v]);
    }
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]);
    for (int i = 1, v, u; i < n; i++)
        scanf("%d%d", &v, &u), Adj[v].pb(u), Adj[u].pb(v);
    memset(ok, 63, sizeof(ok));
    memset(F, 63, sizeof(F));
    memset(dp, 63, sizeof(dp));
    DFS(1, 0);
    return !printf("%d", ok[1]);
}

Measured memory_bytes: 196736
r1,c1,r2,c2 = map(int, input().split())
mod = int(1e9+7)

# f(i,j) = cmb(i+j,i)

def cmb(n, r, mod=mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def init_cmb(Nmax):
    #mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] # 逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, Nmax + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    return g1, g2
  
g1, g2 = init_cmb(max(r1,r2) + max(c1,c2) + 10)

def solve(r1,c1,r2,c2):
  def f(r,c):
    return cmb(r+c,min(r,c))
  
  res = 0
  # S[r2,c2] - S[r2,c1-1] - S[r1-1,c2] + S[r1-1,c1-1]
  # S[r2,c2] = cmb(r2,0) + cmb(r2+1,1) + ... + cmb(r2+c2, c2)
  r2,c2 = r2, c2
  res += f(r2,c2)
  res -= f(r2,c1)
  res -= f(r1,c2)
  res += f(r1,c1)
  
  """
  for c in range(0,c2+1):
    res += (c+1) * cmb(r2+c, c)
    res %= mod
  for c in range(0,c1):
    res -= (c+1) * cmb(r2+c, c)
    res %= mod
  for r in range(0,r1):
    res -= (r+1) * cmb(c2+r,r)
    res %= mod
  for r in range(0,r1):
    res += (r+1) * cmb(c1-1+r,r)
    res %= mod
  """  
  return res % mod

def solve2(r1,c1,r2,c2):
  res = 0
  for r in range(r1,r2+1):
    for c in range(c1,c2+1):
      res += cmb(c+r,c)
      res %= mod
  return res

#print(solve(r1,c1,r2,c2))
print(solve(r1,c1,r2+1,c2+1))
#print(solve2(r1,c1,r2,c2))

Measured memory_bytes: 222868
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}
 
fn main() {
    let n: usize = read().unwrap();
    let mut d: Vec<u64> = Vec::new();
 
    for _i in 0..n {
        let x: u64 = read().unwrap();
        d.push(x);
    }
    d.sort();

    let m: usize = read().unwrap();
    let mut t: Vec<u64> = Vec::new();
 
    for _i in 0..m {
        let x: u64 = read().unwrap();
        t.push(x);
    }
    t.sort();

    let mut used_d: HashSet<usize> = HashSet::new();

    let mut i: usize = 0;
    for x in &t {
        while i < n && d[i] < *x {
            i += 1;
        }
        if i < n && d[i] == *x {
            used_d.insert(i);
            i += 1;
            continue;
        } else { // x < d[i]
            break;
        }
    }
    if used_d.len() == m {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 13908
#include <cstdio>
#include <cstring>

#define MAX_N	51
/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int 	N;			// 文字列長
char S[MAX_N];	// 文字列

int main () {

	int cnt = 0;

	// 個数と長さの読込み
	scanf("%d %s", &N, S);

	//
	for(int i = 0; i < N; i++) 
		if(strncmp(S+i, "ABC", 3) == 0) cnt++;

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

	return 0;
}

Measured memory_bytes: 128
import java.util.*;
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 k = sc.nextInt();

        for(int i = 0; i < k ; i++){
        	if(a>=b){
            	b = b * 2;
            }else{
            	c = c * 2;
            }
        
        }
		if(a < b && b <c){
			// 出力
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 35748
# -*- coding: utf-8 -*-
"""
Created on Wed May 29 22:49:19 2019

@author: Yamazaki Kenichi
"""

# -*- coding: utf-8 -*-
"""
Created on Sat May 25 21:24:29 2019

@author: Yamazaki Kenichi
"""

N, M, K = map(int,input().split())
mod = 10**9+7

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, N*M+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

ans1 = 0
def c(N,M):
    res = 0
    for i in range(1,N):
        res += i*(N-i)*M*M
    return res
ans1 += c(N,M) + c(M,N)
ans1 %= mod

ans1 *= cmb(N*M-2,K-2,mod)
ans1 %= mod

print(ans1)


Measured memory_bytes: 27024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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


	long long x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1) cout << "Brown";
	else cout << "Alice";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll>   vl;
#define f(i,n)  for(i=0;i<n;i++)
#define f1(i,n)  for(i=1;i<n;i++)
#define fr(i,n) for(i=n-1;i>=0;i--)
#define em emplace_back
#define mp make_pair
#define in insert
#define fi first
#define sc second
#define b begin
#define e end
#define er erase
#define l length
#define c clear
#define si size
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
const double pi=3.141592653;
const ll infi=1000000001;
const ll MOD=1000000007;
const ll mod=998244353;
const string no="NO\n",yes="YES\n";

// ll gcd(ll a,ll b){
//     if(a==0)    return b;
//     gcd(b%a,a);
// }

// void dfs(vl v[],ll node,ll hai[]){
//     hai[node]=1;
//     for(auto i:v[node]){
//         if(hai[i]==0){
//             dfs(v,i,hai);
//         }
//     }
// }

// ll con(vl v[],ll hai[],ll sz){
//     ll count=0;
//     for(int i=1;i<sz;i++){
//         if(hai[i]==0){
//             count++;
//             dfs(v,i,hai);
//         }
//     }
    // return count;
// }

// void gcde(int a,int b,int *x,int *y){
//     if(a==0){
//         *x=0;
//         *y=1;
//         return;
//     }    
//     int x1,y1;
//     gcde(b%a,a,&x1,&y1);
    
//     *x=y1-(b/a)*x1;
//     *y=x1;
// }


// ll recur(vl v,ll in,ll m,ll n){
//     if(in==-1)  return 1000000000001;
//     ll d,e,c;
//     d=max(m/v[in],n*v[in]);
//     c=recur(v,in-1,m/v[in],n*v[in]);
//     e=recur(v,in-1,m,n);
//     return min(c,min(e,d));
// }

// ll bexpo(ll a,ll p){
//     ll x=1;
//     while(p){
//     if(p&1){
//         x=(x*a)%mod;
//     }
//     a=(a*a)%mod;
//     p>>=1;
//     }
//     return x;
// }
// int dx[8]{-1,0,0,1,-1,-1,1,1};
// int dy[8]{0,-1,1,0,-1,1,-1,1};


int main() {
    fastio
    int t=1;
    // cin>>t;
    ll n,m,i,l,r,d,bank,s,k,j,x,y,ans,q;

    while(t--){ans=0;
        cin>>n>>k;
        ll a[n+1] {0};
        a[1]=1;
        // cout<<a[1];
        pair<ll,ll> p[k];
        f(i,k){
            cin>>l>>r;
            p[i].fi=l;
            p[i].sc=r;
        }
        f1(i,n+1){
            if(i==1)    continue;
            ans=0;
            for(auto j:p){
                if(j.fi>=i) continue;
                l=max(i-j.sc,1LL);
                r=i-j.fi;
                ans= (ans + (a[r]-a[l-1] +mod)%mod)%mod;
            }    
            a[i]=(a[i-1]+ans)%mod;
        }
        // f(i,n+1)    cout<<a[i]<<' ';
        // cout<<endl;
        cout<<(a[n]-a[n-1]+mod)%mod;
    }
    
    
	return 0;
}

Measured memory_bytes: 5204
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;
    cin>>n;
    ll res=0;
    ll rmin=INF,lmax=-INF;
    vector<pair<ll,ll>> a;
    ll li,ri;
    for(int i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        r++;
        if(rmin>r)
        {
            rmin=r;
            ri=i;
        }
        if(lmax<l)
        {
            lmax=l;
            li=i;
        }
        a.push_back(make_pair(l,r));
    }
    sort(all(a));
    if(li==ri){
        ll y2=-INF;
        for(ll i=0;i<n;i++){
            chmax(y2,a[i].se-a[i].fi);
        }
        res=rmin-lmax+y2;
    }
    else{
        ll x=-1;
        ll y=INF;
    for(ll i=0;i<n;i++){
        chmax(res,mmax(0,rmin-lmax)+a[i].se-a[i].fi);
    }
    for(ll i=n-1;i>=0;i--){
        x=a[i].fi;
        if(i<n-1)chmax(res,mmax(0,y-lmax)+mmax(0,rmin-x));
        chmin(y,a[i].se);
    }
    }
    cout<<res<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    
    while(1){
        cin >> x;
        cin >> y;
        if (x==0&&y==0) break;
        
        if(x<y){
            cout << x <<" "<< y << endl;
        }
        else{
            cout << y <<" "<< x << endl;
        }
    }
    
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 998244353;
int n;
string s;

void Minus(vector<int> &x) {
	int i;
	
	x[0]--;
	if (x[0] < 0) {
		i = 1;
		while (true) {
			x[i - 1] += 2;
			x[i]--;
			if (x[i] >= 0) break;
			i++;
		}
	}
}

bool check(vector<int> &x, int d) {
	vector<int> y(n, 0);
	int i, j;
	
	//cout << "d = " << d << ", x = ";
	//for (i = x.size() - 1; i >= 0; i--) cout << x[i];
	//cout << endl;
	
	int shift = 0;
	for (i = 0; i < n / d; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < d; j++) {
				y[shift] += x[j];
				shift++;
			}
		}
		else {
			for (j = 0; j < d; j++) {
				y[shift] += (!x[j]);
				shift++;
			}
		}
	}
	
	//cout << "y = ";
	//for (i = n - 1; i >= 0; i--) cout << y[i];
	//cout << endl;
	
	for (i = n - 1; i >= 0; i--) {
		int p = s[n - 1 - i] - '0';
		int q = y[i];
		if (q != p) {
			if (q > p) return false;
			return true;
		}
	}
	return true;
}

int calc(int d) {
	
	//まずは、2^((n/d)-1) * x <= int(s)なる最大のxを探す
	int i;
	vector<int> x;	//…x2x1x0 (10進数)
	x.resize(d);
	//cout<< "x.size() = " << x.size() << endl;
	
	int xval = 0;
	for (i = 0; i < d; i++) {
		int val = s[d - 1 - i] - '0';
		x[i] = val;
		xval *= 10;
		xval += x[i];
		if (xval >= 100) xval = 100;
	}
	
	//x, x-1, x-2, x-3…あたりを試すと条件を満たす最大のxが分かる
	while (true) {
		if (check(x, d)) break;
		xval--;
		if (xval <= -1) break;
		Minus(x);
	}
	if (xval <= -1) return 0;
	
	int ret = 0;
	int mul = 1;
	for (i = 0; i < x.size(); i++) {
		ret += x[i] * mul;
		ret %= mod;
		mul *= 2;
		mul %= mod;
	}
	ret++;
	ret %= mod;
	return ret;
}

signed main() {
	int i, j, k;
	
	cin >> n >> s;
	
	static int memo[200001];
	for (i = 1; i <= n; i++) {
		if (n % i != 0) continue;
		if ((n / i) % 2 == 0) continue;
		memo[i] = calc(i);
		//cout << "memo[" << i << "] = " << memo[i] << endl;
	}
	
	//約数包除？冷静に考えると包除さえいらない.
	//f(x) = 最小周期xの文字列の個数
	//g(x) = 周期xの文字列の個数
	//とおくとg(x) = sum(d, f(d), where x % d == 0)
	//g(x)からf(x)を求めたい。とりあえず、
	//f(x) = g(x) - sum(d, f(d), where x % d == 0 and d < x)
	//となるが、d < xよりf(0)から順番に求めていけば、これは普通に計算できる。
	//fをgだけで表そうとするとヤバいが、漸化式を使えば簡単という.. (個人的にここが一番山場です）
	static int cnt[200001];	//cnt[x] = f(x). n / xが奇数でないxについてはドントケア(0とは限らない).
	for (i = 1; i <= n; i++) { cnt[i] = memo[i]; }
	for (i = 1; i <= n; i++) {
		for (j = i * 2; j <= n; j += i) {
			cnt[j] -= cnt[i];
			if (cnt[j] < 0) cnt[j] += mod;
		}
	}
	
	int ans = 0;
	for (i = 1; i <= n; i++) {
		if (n % i != 0 || (n / i) % 2 == 0) continue;
		ans += 2 * i * cnt[i] % mod;
		ans %= mod;
		//cout << "cnt[" << i << "] = " << cnt[i] << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int G = sc.nextInt();
    int[] p = new int[D];
    int[] c = new int[D];
    for(int i = 0; i < D; i++){
      p[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    int min = Integer.MAX_VALUE;

    for(int i = 0; i < Math.pow(2, D); i++){
      int max_index = 0;
      int num = i;
      int count = 0;
      int value = 0;
      int temp = 0;

      while(count < D){
        if(num % 2 == 1){
          value = value + p[count] * (count + 1) * 100 + c[count];
          temp += p[count];
        }else{
          max_index++;
        }
        num /= 2;
        count++;
      }
      max_index--;

      if(value < G){
        for(int j = 0; j < p[max_index] - 1; j++){
          value += (max_index + 1) * 100;
          temp++;
          if(value >= G){break;}
        }
      }

      if(value < G){continue;}
      min = Math.min(temp, min);
    }

    System.out.println(min);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    cin >> N;
    rep(i,50000){
        int res = i * 1.08;
        if(res == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

  string s; cin >> s;
  int n = s.size();
  vei cnt(3);
  rep(i,n) cnt[ s[i] - 'a']++;
  sort(all(cnt));
  if(n % 3 == 0) {
    if(cnt[0] == cnt[1] and cnt[1] == cnt[2]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }
  else if(n % 3 == 1) {
    if( cnt[0] == cnt[1] and cnt[1] + 1 == cnt[2] ) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }
  else {
    if(cnt[0] + 1 == cnt[1] and cnt[1] == cnt[2]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
  }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    int H, W;
    int i, j, k, l;

    char s[100][60];
    char a[100][60] = {""};
    int count = 0;

    scanf("%d %d", &H, &W);

    for (i = 0; i < H; i++) {
        scanf("%s", s[i]);
    }

    for (i = 0; i <= H; i++) {
        for (j = 0; j < W; j++) {
            count = 0;
            if (s[i][j] == '#') {
                a[i][j] = '#';
                continue;
            }

            for (k = -1; k < 2; k++) {
                for (l = -1; l < 2; l++) {
                    if (k == 0 && l == 0)
                        continue;
                    if (i + k < 0 || j + l < 0)
                        continue;
                    if (s[i + k][j + l] == '#')
                        count++;
                }
            }

            a[i][j] = '0'+count;

        }
    }





    for (i = 0; i < H; i++) {
        printf("%s\n",a[i]);
    }

    return 0;
}

Measured memory_bytes: 2008
//09
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int na,nb;
  cin>>na>>nb;
  int a[5000],b[5000];
  for(int i=0;i<na;i++){
    cin>>a[i];
  }
  for(int i=0;i<nb;i++){
    cin>>b[i];
  }
  int dp[2][5001]={{}};
  int m=0;
  for(int i=1;i<=nb;i++){
    for(int j=1;j<=na;j++){
      if(a[j-1]==b[i-1]){
	dp[i&1][j]=max(dp[i&1][j-1],dp[i-1&1][j-1]+(a[j-1]==b[i-1]));
      }else{
	dp[i&1][j]=dp[i&1][j-1];
      }
      m=max(m,dp[i&1][j]);
    }
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;

long long merge(vector<int> &A, int left, int mid, int right){
	long long count=0;
	int n1=mid-left;
	int n2=right-mid;
	int i, j;
	vector<int> L(n1+1);
	vector<int> R(n2+1);
	for (i=0;i<=n1-1;i++){
		L[i]=A[left+i];
	}
	for (i=0;i<=n2-1;i++){
		R[i]=A[mid+i];
	}
	L[n1]=INT_MAX;
	R[n2]=INT_MAX;
	i=0;
	j=0;
	int k;
	for (k=left;k<right;k++){;
		if (L[i]<=R[j]){
			A[k]=L[i];
			i++;
		}else{
			A[k]=R[j];
			count+=(n1-i);
			j++;
		}
	}
	
	return count;
}

long long mergeSort(vector<int> &A, int left, int right){
	long long count=0;
	if (left+1<right){
		int mid=(left+right)/2;
		count=mergeSort(A,left,mid)+mergeSort(A,mid,right)+merge(A,left,mid,right);
	}
	return count;
}
int main(){
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> A(n);
	int i;
	for (i=0;i<n;i++){
		cin >> A[i];
	}
	
	long long count=mergeSort(A,0,n);
	
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
 
int main(void)
{
    int n;
    vector<long long> a;
     
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        long long x;
        cin >> x;
        a.push_back(x);
    }
     
    long long max = *max_element(a.begin(), a.end());
    long long  min = *min_element(a.begin(), a.end());
    long long sum = accumulate(a.begin(), a.end(), 0LL);
     
    cout << min << " " << max << " " << sum << endl;
     
     
    return 0; 
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    char s[n][n];
    rep(i,n){
        scanf("%s", s[i]);
    }

    int ans = 0;
    char t[n][n];
    
    rep(i,n){
        rep(j,n){
            rep(k,n){
                t[j][k] = s[j][(k + i)%n];
            }
        }
        int flag = 1;
        rep(j,n){
            rep(k,n){
                if(t[j][k] != t[k][j]){
                    flag = 0;
                    break;
                }
            }
        }
        ans += (n - i) * flag;
    }

    srep(i,1,n){
        rep(j,n){
            rep(k,n){
                t[j][k] = s[(j + i)%n][k];
            }
        }
        int flag = 1;
        rep(j,n){
            rep(k,n){
                if(t[j][k] != t[k][j]){
                    flag = 0;
                    break;
                }
            }
        }
        ans += (n - i) * flag;
    }

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


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

using namespace std;
const int maxn = 100010;

int a[maxn];
int main() {
	int n; scanf("%d", &n);
	int c; scanf("%d", &c);
	int k; scanf("%d", &k);
	for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
	sort(a, a+ n);
	int ans = 0;
	for(int i = 0, j = 0; i < n; i = j) {
		for(j = i + 1; j < n && j - i + 1 <= c && a[j] <= a[i] + k; ++j);
		ans += 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 200007
#define P pair<ll,ll>

using namespace std;

int main(){
    int n,ans=0;
    cin>>n;
    vl a(n);
    pan(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    int count=0;
    ll sum=0,presum=0;
    vl psum(n);
    psum[0]=a[0];
    pans(i,n,1) psum[i]=a[i]+psum[i-1];
    for(int i=0;i<n-1;i++){
        if(2*psum[i]>=a[i+1]){
            count++;
        }
        else {
            count=0;
        }
        // cout<<count<<" "<<psum<<endl;
    }
    ans=count+1;
    cout<<ans;
}   

Measured memory_bytes: 1792
a,b,m = map(int, input().split())
aprice = list(map(int, input().split()))
bprice = list(map(int, input().split()))
c = sorted(aprice)
d = sorted(bprice)
e = c[0]+d[0]
f  =0
for i in range(m):
  x,y,k = map(int, input().split())
  f =aprice[x-1]+bprice[y-1]-k
  if(e>f):
    e = f
print(e)

Measured memory_bytes: 24824
A = int(raw_input())
B = int(raw_input())
C = int(raw_input())
X = int(raw_input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = int(500 * i + 100 * j + 50 * k)
            if int(sum) == int(X):
                cnt += 1

print cnt

Measured memory_bytes: 2568
n,m = map(int,input().split())
p = [0]*m
V = [[] for i in range(n+1)]
for i in range(m):
    p[i] = list(map(int,input().split())) + [i]
    V[p[i][0]].append(p[i][1:])
W = []
for i in range(n+1):
    if V[i] == []:
        pass
    else:
        V[i].sort(key= lambda val : val[0])
        for j in range(len(V[i])):
            K = ["0"]*(6 - len(str(i))) + list(str(i)) + ["0"]*(6 - len(str(j+1))) + list(str(j+1))
            W.append(["".join(K),V[i][j][1]])
W.sort(key= lambda val : val[1])
for ans in W:
    print(ans[0])
        

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  vector<ll>a(n-1);
  rep(i,0,n-1)a[i]=abs(s[i+1]-s[i]);
  bool one=false;
  ll ret=1;
  rep(i,0,n-1){
    if(a[i]==1)one=true;
  }
  if(!one){
    ret=2;  
  }
  ll sum=0;
  ll now=1;
  //debug(a,n-1);
  rep(i,0,n-1){
    bool sw=false;
    sw=(n-2==((n-2-i)|i));
    //if(sw)cout<<i<<endl;
    if(a[i]!=ret)continue;
    ll d=n-2-i;
    
    if(sw){
      sum^=ret;
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

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


return 0;
}


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

using namespace std;


int main()
{
  string S;
  bool dp[100001] = {};

  string K[4] = {
      "dream", "dreamer", "erase", "eraser"
  };

  cin >> S;
  dp[0] = true;
  for(int i = 0; i < S.size(); i++) {
    if(dp[i]) {
      for(int j = 0; j < 4; j++) {
        dp[i + K[j].size()] |= S.substr(i, K[j].size()) == K[j];
      }
    }
  }

  cout << (dp[S.size()] ? "YES" : "NO") << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    char x[] = {'a', 'e', 'i', 'o', 'u'};
    char c;
    cin >> c;
    rep(i, 5) {
        if(x[i] == c) {
            cout << "vowel" << endl;
            return 0;
        }
    }

    cout << "consonant";
    
    cout << endl;
    return 0;
}

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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif

ll bpow(ll a,ll b){
	ll res= 1;
	while(b){
		if(b&1){
			res = res*a%mod;
		}
		a = a*a %mod;
		b >>=1;
	}
	return res;
}

const int maxN = 1e5+2;
int fac[maxN];
void pre(){
	fac[0]=1;
	fac[1]=1;
	for(int i=2;i<maxN ;i++){
		fac[i] = (int)((fac[i-1]*1LL*i)%mod);
	}
}

ll mul(ll a,ll b){
	return (a*b)%mod;
}
ll ncr(ll n, ll r){
	if(r> n){
		return 0;
	}
	return mul(fac[n], mul(bpow(fac[n-r],mod-2),bpow(fac[r],mod-2)));
}
void solve(){
	ll n;
	cin>>n;
	if(n==3){
		cout<<1<<"\n";
		return;
	}
	ll ans=0;
	for(int i=1;n-i*2-1>0;i++){
		// cout<<ncr(n-2*i-1,i-1)<<"\n";
		ans = (ans+ncr(n-2*i-1,i-1))%mod;
	}
	cout<<ans<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	pre();
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define I inline
#define OP operator
#define pb push_back
#define mp make_pair
#define RT return *this
#define dbg(x) cerr<<#x" = "<<x<<endl
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)
I bool IS(char x){return x==10||x==13||x==' ';}
struct Cg{I char OP()(){return getchar();}};struct Cp{I void OP()(char x){putchar(x);}};
#define RX char c,f=1;while(!isdigit(c=P()))f=c!='-';x=c-'0';while(isdigit(c=P()))x=x*10+c-'0';x=f?x:-x
#define TR *this,x;return x
struct Fr{Cg P;I Fr&OP,(int&x){RX;RT;}I OP int(){int x;TR;}I Fr&OP,(ll &x){RX;RT;}I OP ll(){ll x;TR;}
I Fr&OP,(char&x){while(IS(x=P()));RT;}I OP char(){char x;TR;}
I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT;}}in;
#define WI if(x){if(x<0)P('-'),x=-x;char s[22],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
struct Fw{Cp P;I Fw&OP,(int x){WI;RT;}I Fw&OP,(ll x){WI;RT;}I Fw&OP,(char x){P(x);RT;}
I Fw&OP,(const char *x){while(*x)P(*x++);RT;}}out;
const int N=1e5+11,CH=46;
int K;
int f[N][55];
queue<pii> q;
void bfs(){
	rep(i,1,9) if(!f[i%K][i]){
		f[i%K][i]=1;
		q.push(mp(i%K,i));
	}
	while(!q.empty()){
		pii u=q.front();q.pop();
		rep(i,0,9) {
			int x=(u.x*10+i)%K,y=u.y+i;
			if(y<=46&&!f[x][y]) {
				f[x][y]=1;
				q.push(mp(x,y));
			}
		}
	}
}
int main(){
	K=in;
	bfs();
	rep(i,1,CH) {
		if(f[0][i]) {
			printf("%d\n",i);
			break;
		}
	}
//	cout << "OK\n" << endl;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<long long> a(N);
  long long S = 0 ; 
  long long x = 0 ;
  long long ans = 1000000000000000000 ; 
  
  for(int i = 0 ; i < N  ; i++){
    cin >> a.at(i) ; 
    S += a.at(i) ;
  }
  for(int i = 0 ; i < N ; i++){
    x += a.at(i) ; 
    if( i + 1 < N ) ans = min(ans , abs(S - 2*x)) ; 
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4796
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        if (n % 2 != 0) {
            System.out.println("No");
            return;
        }
        
        char c[] = str.toCharArray();
        
        for (int i = 0; i < n / 2; i++) {
            if (c[i] != c[i + n / 2]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23252
/*
 * Range.c
 *
 *  Created on: 2015/02/12
 *
 */

#include <stdio.h>

int main(void){
	int i,j,k;

	scanf("%d %d %d", &i,&j,&k);

	if(i < j && j <k){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    string S;
    cin >> S;

    int pref = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == ')') {
            pref++;
        } else if (S[i] == '(') {
            pref = max(--pref, 0);
        }
    }

    reverse(S.begin(), S.end());
    for (int i = 0; i < pref; i++) {
        S.push_back('(');
    }

    reverse(S.begin(), S.end());

    int suf = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == ')') {
            suf--;
        } else if (S[i] == '(') {
            suf++;
        }
    }

    for (int i = 0; i < suf; i++) {
        S.push_back(')');
    }

    cout << S << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

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 ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main() {
    int s;
    cin >> s;
    //ll dp[s + 1] = {0};
    vector<ll> dp(s + 1);

    dp[0] = 1;
    for (int i = 3; i <= s; i++) {
        for(int j = 0; j <= i - 3; j++) {
            dp[i] = (dp[i] + dp[j]) % MOD;
        }
    }
    cout << dp[s] << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

ll merge_cnt(vector<ll> &a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin()+n/2);
    vector<ll> c(a.begin()+n/2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n) {
        if ( bi < b.size() && (ci == c.size() || b[bi] >= c[ci]) ) {
            a[ai++] = b[bi++];
        } else {
            cnt += n/2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

bool judge(vector<ll> &a, ll x) {
    ll n = a.size();
    ll sum_v = 0;
    vector<ll> s;

    s.push_back(0);
    for (auto &e: a) {
		int t = (e <= x) ? 1 : -1;
		sum_v += t;
        s.push_back( sum_v );
    }

    ll inv_like = merge_cnt(s);

	return inv_like > n*(n+1)/2/2;
}

int main() {
    /*
    vector<ll> s = {3, 1, 5, 4, 2};
    cout << merge_cnt(s) << endl;
    for (auto &e: s) {
        cout << e << " ";
    } cout << endl;
    */
    int n; cin >> n;
    
    vector<ll> a(n);

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

    ll high = 1e18, low = 0; 
 
    while (low < high) {
        ll mid = ( high + low ) / 2;
 
        if ( judge(a, mid) ) {
            high = mid;
        } else {
            low = mid+1;
        }
    }
 
    cout << high << endl;
    
    return 0;
}

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  int tmp=n;
  while(n>0){
    ans+=n%10;
    n/=10;
  }
  if(tmp%ans) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

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

using namespace std;

int main(void){
	
	int n;
	cin >> n;
	string in;
	int x,now=0;
	bool fg=false;
	
	for(int i=0;i<n;i++){
		cin >> in >> x;
		if(in=="(")now+=x;
		else now-=x;
		if(now<0)fg=true;
	}
	if(fg || now>0)cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}

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

#define IN(n) int n;cin>>n
#define IN_(n,n_) int n,n_;cin>>n>>n_;
#define OUT(n) cout << n << endl
#define OUT_(n,n_) cout << n << " " << n_ << endl

#define v_(a,n,n_) vector<vector<a>>(n,vector<a>(n_)) //vector<vector<n>> initialize

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP_(i,n) for(int i=(n)-1;i>=0;i--)
#define SORT(n) sort((n).begin(),(n).end())
#define ALL(n) (n).begin(),(n).end()
#define TRY(n) try{n}catch(...){}

typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<string> vs;
typedef vector<vector<string> > vss;

//vii v = v_(int,5,5);

int main(){
    IN(n);vi l(n*2);REP(i,n*2)cin>>l[i];
    SORT(l);
    int a = 0;
    REP(i,n*2-1){a+=min(l[i],l[i+1]);i++;}
    OUT(a);
}

Measured memory_bytes: 256