akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		
		int cnt =0;
		boolean isWin = false;
		for( int i=0 ; i < n ; i++ ) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if( d1 == d2 ) {
				cnt++;
				if( cnt == 3) {
					isWin =true;
				}
			}else {
				cnt =0;
			}
		}
		System.out.println( isWin ? "Yes" :"No");

	}

}



Measured memory_bytes: 36000
a = $<.map{|s| s.split(",").map(&:to_i)}
(1..a.size-1).each{|i|
    (0..a[i].size-1).each{|j|
        if a[i-1].size < a[i].size
            a[i][j] = [a[i-1][j] || 0, j > 0 ? a[i-1][j-1] : 0].max + a[i][j]
        else
            a[i][j] = [a[i-1][j], a[i-1][j+1]].max + a[i][j]
        end
    }
}
p a[-1][0]

Measured memory_bytes: 6108
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = (res*x)%md;
        x = (x*x)%md;
        y = y/2;
    }
    return res;
}


void solve(){
	string o,e;
	cin>>o>>e;
	for(int i =0;i<o.size() + e.size() ;i++){
		if(i%2 == 0)
			cout<<o[i/2];
		else
			cout<<e[i/2];
	}
}

int main()
{
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;
vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s;
    cin>>s;
    ll ans = 0;
    int x = 1;
    mod_build(1234567);
    while(s - 3 * x >= 0){
        ans += comb(s-2*x-1, x-1);
        ++x;
    }
    cout << ans % mod <<endl;
    return 0;
}

Measured memory_bytes: 32240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final int n = in.nextInt();
            final int k = in.nextInt();
            int[] a = new int[n];

            for (int i = 0; i < n; i++) a[i] = in.nextInt();

            int ans = 1;
            ans += (n - 1) / (k - 1);
            if ((n - 1) % (k - 1) == 0) ans--;

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 23380
#include<iostream>
#include<cmath>

using namespace std;

int check(double chk,int pow,int riv)
{
    riv *=pow;
    //printf("%lf | %d:%d\n",chk,pow,riv);
    if((chk-riv)<0)
        return (riv/=pow); 
    else 
        return check(chk,pow,riv);
}
int main()
{
    int X;
    cin >> X;

    int sq=sqrt((double)X);
    int max=1;
    if(X>4){
    for(int i=4;i<=X;i++){
        int buf;
        for(int j=2;j<=sq;j++){
            buf=check(i,j,j);
            //printf("%d | %d:%d\n",i,j,buf);
            if((max<buf))
                max=buf;
        }

    }
    }
    else {}
    cout << max;


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif



int main()
{
	int N;
	static int s[100];
	int i;
	cin >> N;
	rep (i, N)
		cin >> s[i];
	static int dp[2][10];
	int x = 0;
	ran (i, 1, 10)
		dp[1][i] = -1000000000 + i;
	rep (i, N) {
		int j;
		rep (j, 10) {
			dp[x][(s[i]+j)%10] = max(dp[x^1][j]+s[i], dp[x^1][(s[i]+j)%10]);
			//assert(dp[x][(s[i]+j)%10]%10 == (s[i]+j)%10);
		}
		x ^= 1;
	}
	x ^= 1;
	int ans = 0;
	ran (i, 1, 10) {
		ans = max(ans, dp[x][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll X;
    cin >> X;

    ll now = 100;
    ll ans = 0;
    while (now < X) {
        now *= 1.01;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
map<long long,long long> cnt;
long long n,a[1000001],ans;
int main() {
    scanf("%lld",&n);
    for (long long i = 1;i <= n;i++) {
        scanf("%lld",&a[i]);
        a[i] += a[i-1];
        ans += cnt[a[i]]++;
    }
    printf("%lld",ans+cnt[0]);
    return 0;
}


Measured memory_bytes: 14336
import sys
input = sys.stdin.readline
import fractions
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main():
    A, B = [int(x) for x in input().split()]
    x = fractions.gcd(A, B)
    divisors = make_divisors(x)

    ans = 0
    for k in divisors:
        if k == 1:
            ans += 1
            continue

        factor = 0
        if k % 2 == 0 and k != 2:
            continue

        # 繰り返しの上限を対象の平方根にする
        for x in range(2, math.floor(math.sqrt(k)) + 1):
            if k % x == 0:
                factor += 1

        if factor == 0:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 5304
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;



int main() {
	int n; cin >> n;
	vector<vector<int>> a(2);
	rep(i, 0, 2) {
		a[i].resize(n);
		rep(j, 0, n) {
			cin >> a[i][j];
		}
	}
	ll ans = 0;
	rep(i, 0, n) {
		ll sub = 0;
		rep(j, 0, i + 1) {
			sub += a[0][j];
		}
		rep(j, i, n) {
			sub += a[1][j];
		}
		ans = max(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  list($n,$m) = explode(" ", trim(fgets(STDIN)));

  $ans = [];
  for($i=0;$i<$m;$i++){
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    if(!isset($ans[$a])) $ans[$a]=[];
    if(!isset($ans[$b])) $ans[$b]=[];
    if(!isset($ans[$a][$b])) $ans[$a][$b]=0;
    if(!isset($ans[$b][$a])) $ans[$b][$a]=0;
    $ans[$a][$b]++;
    $ans[$b][$a]++;
  }

  for($i=1;$i<=$n;$i++){
    if(isset($ans[$i])) {
      $cnt=0;
      foreach($ans[$i] as $K => $V){
        $cnt+=$V;
      }
      echo $cnt.PHP_EOL;
    }
    else echo "0".PHP_EOL;
  }

Measured memory_bytes: 16276
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
vector<int> a, b;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        int u, v;
        cin >> u >> v;
        a.push_back(u);
        b.push_back(v);
    }
    sort(ALL(a));
    sort(ALL(b));
    if (n % 2) {
        int l = a[n / 2], r = b[n / 2];
        cout << r - l + 1;
    }
    else {
        FOR(i,0,n-1) {
            a[i] *= 2;
            b[i] *= 2;
        }
        ll l = ((ll) a[n / 2 - 1] + a[n / 2]) / 2, r = ((ll) b[n / 2] + b[n / 2 - 1]) / 2;
        cout << r - l + 1;
    }
    return 0;
}


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int stone_num, coord;
  cin >> stone_num >> coord;
  
  int length, l_coo; // r_coo
  length = (stone_num-1)*2+1;
  l_coo = coord-(stone_num-1);
  // r_coo = coord+(stone_num-1);
  
  int ans;
  for (int i = 0; i<length; i++) {
    ans = l_coo+i;
    cout << ans;
    if (i == length)
      continue;
    cout << " ";
  }
   cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
double ans[1000];
int main()
{
    int n;
    cin>>n;
    for(int i = 1;i<=n;++i)
    {
        cin>>ans[i];
    }
    sort(ans+1,ans+n+1);
    long double sum = ans[1]+ ans[2];
    long double k = 2;
    for(int i = 3;i<=n;++i)
    {
        sum += k*ans[i];
        k *= 2;
    }
    cout<<fixed<<setprecision(15)<<(long double)sum/k;
}


Measured memory_bytes: 256
from collections import Counter
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
A=[A1,A2,A3]
N=int(input())
for _ in range(N):
  b=int(input())
  #穴をあける
  for tmpA in A:
    if b in tmpA:
      index=tmpA.index(b)
      tmpA[index]=-1
      break
  
#bingoチェック
#中央が空いている
if A[1][1]==-1:
  #ななめ
  if A[0][0] == A[2][2] or A[0][2]==A[2][0]:
    print("Yes")
    exit()
  #たてよこ
  elif A[0][1]==A[2][1] or A[1][0]==A[1][2]:
    print("Yes")
    exit()
  
#中央が空いていないor中央が空いている場合の特殊パターン
 
#たて
if A[0][0]==A[1][0] and A[1][0]==A[2][0] or A[0][2]==A[1][2]and A[1][2]==A[2][2]:
  print("Yes")
 #よこ
elif len(Counter(A[0]))==1or len(Counter(A[2]))==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int n, k;
char s[10004], res[10004], c = 'z';
int l[10004], len, mx, vis;

void cpy(int p) {
    for (int i = 1; i <= n; ++i) res[i] = s[p + i - 1];
}

void check(int p) {
    if (!vis) cpy(p), vis = 1;
    for (int i = 1; i <= n; ++i) {
        if (res[i] < s[p + i - 1]) return;
        if (res[i] > s[p + i - 1]) return cpy(p);
    }
}

int main() {
    scanf("%d%d%s", &n, &k, s + 1);
    for (int i = 1; i <= n; ++i) c = min(c, s[(n << 1) + 1 - i] = s[i]);
    if (k >= 15) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    if (k == 1) {
        for (int i = 1; i <= n + 1; ++i) check(i);
        for (int i = 1; i <= n; ++i) putchar(res[i]);
        return 0;
    }
    for (int i = 1; i <= n + n; ++i)
        (s[i] == c) ? mx = max(mx, l[i] = l[i - 1] + 1) : 0;

    if ((len = mx << k - 1) >= n) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    for (int i = 1; i <= n + mx; ++i)
        if (l[i] == mx) check(i - l[i] + 1);
    for (int i = 1; i <= len; ++i) putchar(c);
    for (int i = len + 1; i <= n; ++i) putchar(res[i - len + mx]);
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll f(ll h) {
  static map<ll, ll> memo;
  if (memo.find(h) != memo.end()) {
    return memo[h];
  }
  if (h == 1) {
    return memo[h] = 1;
  } else {
    return memo[h] = 1 + 2 * f(h / 2);
  }
}

signed main() {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    vector<ll> X(100010, 0);
    ll Ans=0;
    rep(i, N){
        cin>>A[i];
        X[A[i]]++;
        Ans+=A[i];
    }
    ll Q;
    cin>>Q;
    rep(i, Q){
        ll B, C;
        cin>>B>>C;
        Ans+=(C-B)*X[B];
        X[C]+=X[B];
        X[B]=0;
        cout<<Ans<<endl;
    }

}

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

int main(){
  char c;
  cin >> c;
  
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let w: Vec<String> = read![String; n];

    let w: Vec<Vec<char>> = w.into_iter().map(|s| s.chars().collect()).collect();

    let mut h = HashSet::new();

    let mut last_char = w[0][0];

    for word in &w {
        if word[0] != last_char {
            println!("No");
            return;
        }

        if h.contains(word) {
            println!("No");
            return;
        }

        last_char = word[word.len() - 1];
        h.insert(word);
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, y) = (v[0], v[1]);

    for i in 0..n + 1 {
        for j in 0..n + 1 {
            if i + j > n {
                continue;
            }
            let k = n - i - j;
            if i * 10 + j * 5 + k == y / 1000 {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#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;
    cin >> S;

    int len = int(S.size());

    int res = 0;
    string pre = "0";
    bool f = false;
    rep(i, len) {
        //cout << pre << endl;
        string temp = "";
        temp.push_back(S[i]);
        if(pre.size() > 1) {
            res++;
            pre = temp;
            continue;
        }
        if(i == len-1 && S[i] == pre[0]) break;
        rep(j, pre.size()) {
            if(S[i] == pre[j]) {
                temp.push_back(S[++i]);
            } else {
                break;
            }
        }
        res++;
        pre = temp;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    int v[20], c[20];
    cin >> n;
    rep(i, n){
        cin >> v[i];
    }
    rep(i, n){
        cin >> c[i];
    }

    int ans = 0;
    rep(i, n){
        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;

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int r = -1;
    FOR(i, 1, 6) {
        int x;
        cin >> x;
        if(x == 0) {
            r = i;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3588
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toLong() }

    fun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)
    fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

    println(lcm(a,b))
}


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

const int MOD = 1e9 + 7;

int mul(int a, int b) {
	return (long long) a * b % MOD;
}
// O(log(b))
int my_pow(int a, int b) {
	int r = 1;
	while(b) {
		if(b % 2) {
			r = mul(a, r);
		}
		a = mul(a, a);
		b /= 2;
	}
	return r;
}
int my_inv(int a) {
	return my_pow(a, MOD-2);
}

const int MAX = 1e6 + 5;

int main() {
	int n;
	cin >> n;
	vector<int> answer(MAX);
	vector<int> a(n);
	// O(N * sqrt(X) * log)
	for(int j = 0; j < n; j++) {
		int x;
		cin >> x;
		a[j] = x;
		map<int,int> cnt;
		
		// 20 -> 2*2*5     24 -> 2*2*2*3
		for(int i = 2; i * i <= x; i++) {
			while(x % i == 0) {
				++cnt[i];
				x /= i;
			}
		}
		if(x != 1) {
			++cnt[x];
		}
		for(pair<int,int> p : cnt) {
			answer[p.first] = max(answer[p.first], p.second);
		}
	}
	// lcm/a[0] + lcm/a[1] + lcm/a[2] + ...
	int lcm = 1;
	for(int i = 0; i < MAX; i++) {
		int prime = i;
		int k = answer[i];
		for(int _ = 0; _ < k; _++) {
			lcm = mul(lcm, prime);
		}
	}
	cerr << "lcm = " << lcm << endl;
	int sum = 0;
	for(int x : a) {
		if(n <= 10) cerr << "add " << mul(lcm, my_inv(x)) << " x = " << x << endl;
		sum = (sum + mul(lcm, my_inv(x))) % MOD;
	}
	cout << sum << endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
int counter = 0,i;
int a,b,c;
cin >> a >> b >> c;

for(i=a;i<=b;i++){
	if(c%i == 0){
		counter++;
	}
}
cout << counter << endl;



return 0;
}

Measured memory_bytes: 1164
x, k, d = gets.chomp.split.map(&:to_i)

x = x.abs
t = x / d
a = x - t * d

res =
  if t <= k
    if (k - t) % 2 == 0
      a
    else
      d - a
    end
  else
    (t - k) * d + a
  end

puts res

Measured memory_bytes: 14420
n,m = gets.split.map(&:to_i)
xyz = []
n.times do |i|
  xyz << gets.split.map(&:to_i)
end

def score(list, sign="111", m)
  xyz = Array.new(3, 0)
  list = list.sort_by do |e|
    sum = 0
    3.times{|i| sum += sign[i] == '1' ? e[i] : -e[i]}
    -sum
  end
  list[0...m].each do |e|
    3.times do |i|
      xyz[i] += e[i]
    end
  end
  xyz.inject(0){|s,e| s+e.abs}
end
ans = []
["111", "011", "101", "110", "001", "100", "010", "000"].each do |sign|
  ans << score(xyz, sign, m)
end
puts ans.max


Measured memory_bytes: 4216
#include <stdio.h>
int main () {
    int n ;
    int x = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        x = i;
        if ((x % 3) == 0) printf(" %d", x);
        else {
            while (x != 0) {
                if ((x % 10) == 3) {
                    printf(" %d", i);
                    break;
                }
                x = x / 10;
            }
        }
    }
    printf("\n");
    return 0;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' ' << endl; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/
ll gcd(ll a, ll b) {
    if (a == b || a == 0)
        return b;
    else if (a < b)
        return gcd(b%a, a);
    else
        return gcd(b, a);
}

int main() {
    cin >> n >> m;
	ll lcm = n * m / gcd(n,m);
    cout << lcm << endl;
}


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

using namespace std;

int x, a, b;

int main(){
  cin >> x >> a >> b;
  b -= a;
  if(b <= 0)cout << "delicious" << endl;
  else if(b <= x)cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from itertools import accumulate
N, M, K = mapint()
As = [0]+list(accumulate(list(mapint())))
Bs = list(accumulate(list(mapint())))
from bisect import bisect_right

ans = 0
for i, a in enumerate(As):
    if a>K:
        break
    idx = bisect_right(Bs, K-a)
    ans = max(ans, i+idx)
print(ans)

Measured memory_bytes: 123892
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
long long x;
	scanf("%lld", &x);
x=x*(x-1);
  x=x/2;

	printf("%lld\n", x);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[100];
bool dp[100005];
int main() {
    init();
    ll N, K;
    cin >> N >> K;
    rep(i, N) cin >> A[i];

    rep(i,K+1){
        rep(j, N) if (i - A[j] >= 0 and dp[i - A[j]] == 0) dp[i] = 1;
    }
    cout << (dp[K] ? "First" : "Second") << endl;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    while(cin>>a && cin>>b){
        if(a==0 && b==0) break;
        for(int i=0; i<a; i++){
            for(int j=0; j<b; j++){
                if((i+j)%2==0) cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    
    
}


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

int main(){
  map<int,int>a;
  int n;
  for(int i=0;i<3;i++){
    cin >> n;
    a[n]+=1;
  }
  n=0;
  for(auto x:a)
    n++;
  cout << n << endl;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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 (b<a) { a=b; return 1; } return 0; }




int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);

  ll k; cin>>k;

  cout<<(k/2)*((k+1)/2)<<endl;


}






Measured memory_bytes: 764
n,m = map(int,input().split())
a = []
b = []

for i in range(m):
  l,r = list(map(int,input().split()))
  a.append(l) 
  b.append(r)

a_max = max(a)
b_min = min(b)

if b_min < a_max:
 print(0)
else:
 print(b_min - a_max + 1)


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

int H, W, Ch, Cw, Dh, Dw;
char grid[1005][1005];

int memo[1005][1005];

void bfs()
{
	deque<pair<int, int> > q;
	q.push_front(make_pair(Ch, Cw));
	
	memo[Ch][Cw] = 0;
	while(!q.empty())
	{
		pair<int, int> curr = q.front();
		q.pop_front();
		
		for(int i = -2; i <= 2; i++)
		{
			for(int j = -2; j <= 2; j++)
			{
				if(i == 0 && j == 0)
					continue;
					
				int newX = curr.first + i, newY = curr.second + j;
				if(1 <= newX && newX <= H && 1 <= newY && newY <= W && grid[newX][newY] == '.')
				{
					if(abs(i) + abs(j) == 1 && memo[curr.first][curr.second] < memo[newX][newY])
					{
						memo[newX][newY] = memo[curr.first][curr.second];
						q.push_front(make_pair(newX, newY));
					}
					
					else if(memo[curr.first][curr.second] + 1 < memo[newX][newY])
					{
						memo[newX][newY] = memo[curr.first][curr.second] + 1;
						q.push_back(make_pair(newX, newY));
					}
				}
			}
		}
	}
}

int main()
{
	scanf("%d%d", &H, &W);
	scanf("%d%d%d%d", &Ch, &Cw, &Dh, &Dw);
	
	for(int i = 1; i <= H; i++)
	{
		for(int j = 1; j <= W; j++)
		{
			scanf(" %c", &grid[i][j]);
			memo[i][j] = INT_MAX;
		}
	}
	
	bfs();
	
	if(memo[Dh][Dw] == INT_MAX)
		memo[Dh][Dw] = -1;
		
	printf("%d", memo[Dh][Dw]);
}


Measured memory_bytes: 8608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
using Graph = vector<vector<int> >;

/* next combination
 * usage:repc(bit,k,n)
 * */
inline int next_combination(int sub) {
  int x = sub & -sub, y = sub + x;
  return (((sub & ~y) / x) >> 1) | y;
}

/* uniq
 * usage:uniq(vec)
 * */
void uniq(vector<int> &vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return;
}

/* BinaryIndexedTree
 * usage:update and sum of 1~N
 * */
int N;
int bit[1000010];
void add(int a, int w) {
  for (int x = a; x <= N; x += x & -x) bit[x] += w;
}
int sum(int a) {
  int ret = 0;
  for (int x = a; x > 0; x -= x & -x) ret += bit[x];
  return ret;
}

/* DP
 * usage: chmin(dp[i],dp[i-1]+v);
 * */
const ll INF = 1LL << 60;
ll dp[100010];

template<class T> inline bool chmin(T& a, T b) {
      if (a > b) {
                a = b;
                        return true;
                            }
          return false;
}
template<class T> inline bool chmax(T& a, T b) {
      if (a < b) {
                a = b;
                        return true;
                            }
          return false;
}
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
  int n,x,t;
  cin >> n >> x >>t;
  if(n%x==0)cout << n*t/x<<'\n';
  else cout << ((n/x)+1)*t<<'\n';

        return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS
int arr[100000+5];

//FUNCTIONS


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k; cin >> n >> k;
	vector<int> h(n);
	for(int i = 0; i< 100000+5; i++){
		arr[i] = INT_MAX;
	}
	arr[0] = 0;
	for(int i = 0; i < n; i++) cin >> h[i];
	

	for(int i = 0; i< n; i++){
		for(int j = i-k; j < i; j++){
			if(j >= 0)
				arr[i] = min(arr[i],arr[j] + abs(h[j]-h[i]));
		}
	}
	cout << arr[n-1] << endl;



	return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

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

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans = 0
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		y := smaller(x, abs(k-x))
		ans += (y * 2)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
num = input().split(" ")

W = int(num[0])
H = int(num[1])
x = int(num[2])
y = int(num[3])
r = int(num[4])

a = x + r
b = x - r
c = y + r
d = y - r

if 0 <= b and a <= W:
    if 0 <= d and c <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,N) for(long long int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

int k;
int c, s;

int main(){
	while (cin >> k){
		if (k == 0)break;
		s = 0;
		REP(i, k*(k - 1) / 2){
			cin >> c;
			s += c;
		}
		cout << s / (k - 1) << endl;
	}
}

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

int main(int argc, char *argv[]){
  //int factorial();
  int n;
  scanf("%d", &n);

  int base = pow(10, 9) + 7;

  long power = 1;
  for(int i=1; i<=n; i++){
    power = power * i;
    if(power > base) power = power % base;
  }

  printf("%d\n", power);
}

int factorial(int x){
  if(x == 1) return 1;
  return factorial(x-1) * x;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int a,b,A,B,r;
    while (scanf("%d %d",&a,&b) != EOF) {
        int G,L;
        if(a>b){
            A=a;
            B=b;
        }
        else{
            A=b;
            B=a;
        }
        r=A%B;
        while (r != 0) {
            A=B;
            B=r;
            r=A%B;
        }
        G=B;
        
        L=(a/G)*b;
        printf("%d %d\n",G,L);
    }
    return 0;
}



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

int main() 
{
    int n, k, total = 0;
    cin >> n >> k;
    
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    for(int i = 0; i < n; ++i)
    {
        int min1, min2;
        min1 = a[i] - 0;
        min2 = k - a[i];
        total += min(min1, min2);
    }
    
    cout << total * 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char c;
	int a[26]={0},i;
	while(~scanf("%c", &c))
		a[c-97]++;
	for(i=0; i<26; i++)
		if(a[i]==0)
		{
			printf("%c\n", i+97);
			break;
		}
	if(i==26) printf("None\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		x = std::max(x, a);
	}
	for(int i = 0; i < m; i++) {
		int a; cin >> a;
		y = std::min(y, a);
	}
	
	if(x < y) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}


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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX
#define N 2003
#define Mod 1000000007
int exp(int x,int y,int mod){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x,int mod){return exp(x,mod-2,mod);}

int dp[N];

int fun(int n)
{
	int ret=0;
	if(dp[n]!=-1)
		return dp[n];
	if(n==0)
		return 1;
	if(n<3)
		return 0;
	for(int i=3;i<=n;i++)
	{
		int val=fun(n-i);
		ret=(ret+val)%Mod;
	}
	return dp[n]=ret;
}


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	cout<<fun(n);
	return 0;
}


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

int main() 
{
	string s;
	cin >> s;
	long long count = 0 , ans = 0;
	for(int i = 0 ; i < s.length()-1 ; i++)
	{
		if(s[i]=='A')
			count++;
		else if(s[i]=='B' && s[i+1]=='C')
			ans += count , i++;
		else
			count = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[5];

void solve()
{
    scanf("%s", str);
    int i;
    int cnt=0;
    for(i=0; i<3; i++) {
        if(str[i]=='1') cnt++;
    }
    printf("%d\n",cnt);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

typedef long long ll;

ll N;

map<ll, vector<ll>> XY;
// y, x
map<ll, ll> YX;

map<ll, ll> Par, Rank;

// root x, (#x's, ys)
map<ll, pair<ll, set<ll>>> Rect;
ll R;

ll find(ll x) {
  if (!Par.count(x)) return x;
  return Par[x] = find(Par[x]);
}
void merge(ll x, ll x2) {
  x = find(x);
  x2 = find(x2);
  if (x == x2) return;
  if (Rank[x] > Rank[x2]) {
    Par[x2] = x;
  } else {
    Par[x] = x2;
    if (Rank[x] == Rank[x2]) ++Rank[x2];
  }
}
int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    XY[x].push_back(y);
  }
  for (const auto &x_ys : XY) {
    ll x = x_ys.first;
    for (ll y : x_ys.second) {
      if (YX.count(y)) merge(x, YX[y]);
      YX[y] = x;
    }
  }
  for (const auto &x_ys : XY) {
    ll x = find(x_ys.first);
    ++Rect[x].first;
    for (ll y : x_ys.second) Rect[x].second.insert(y);
  }
  for (const auto &x_rect : Rect) {
    const auto &rect = x_rect.second;
    R += rect.first * rect.second.size();
  }
  R -= N;
  cout << R << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  rep(i, N) cin >> a[i] >> b[i] >> c[i];
  
  vector<int> max_a(N, 0), max_b(N, 0), max_c(N, 0);
  max_a[0] = a[0];
  max_b[0] = b[0];
  max_c[0] = c[0];
  for (int i = 1; i < N; ++i) {
    max_a[i] = max(max_a[i], max_b[i - 1] + a[i]);
    max_a[i] = max(max_a[i], max_c[i - 1] + a[i]);
    max_b[i] = max(max_b[i], max_a[i - 1] + b[i]);
    max_b[i] = max(max_b[i], max_c[i - 1] + b[i]);
    max_c[i] = max(max_c[i], max_a[i - 1] + c[i]);
    max_c[i] = max(max_c[i], max_b[i - 1] + c[i]);
  }
  
  int ans = -1;
  ans = max(ans, max_a[N - 1]);
  ans = max(ans, max_b[N - 1]);
  ans = max(ans, max_c[N - 1]);
  cout << ans << endl;
  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    ll minimum = LONG_LONG_MAX;
    ll maximum = 0;
    NREP() {
        cin >> tmp;
        minimum = min(tmp, minimum);
        maximum = max(tmp, maximum);
    }
    MSG(maximum - minimum);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[9]={-2,-1,-1,0,0,0,1,1,2},dy[9]={1,1,2,1,2,3,1,2,1};
typedef pair<int,int> P;
typedef pair<P,P> P2;
typedef pair<P,P2> PP;

int d[2][61][31][61][31];
void Main() {
  int n,m;
  while(cin >> m >> n && n) {
    int a[n][m];
    rep(i,n)rep(j,m) {
      char c;
      R c;
      if(isdigit(c)) a[i][j]=c-'0';
      else if(c=='X') a[i][j]=-1;
      else a[i][j]=0;
    }
    rep(i,2)rep(i2,n)rep(i3,m)rep(i4,n)rep(i5,m)d[i][i2][i3][i4][i5]=MAX;
    priority_queue<PP,vector<PP>,greater<PP> > que;
    rep(i,m) {
      if(!a[n-1][i]) {
        rep(k,2) {
          que.push(PP(P(0,k),P2(P(n-1,i),P(n-1,i))));
          d[k][n-1][i][n-1][i]=0;
        }
      }
    }
    int ans=MAX;
    while(!que.empty()) {
      PP p=que.top();que.pop();
      int nx1=p.S.F.F,ny1=p.S.F.S,nx2=p.S.S.F,ny2=p.S.S.S,c=p.F.F,t=p.F.S;
      if(!nx1&&!a[0][ny1]) ans=min(ans,c);
      if(!nx2&&!a[0][ny2]) ans=min(ans,c);
      if(d[t][nx1][ny1][nx2][ny2]<c) continue;
      int s=t^1;
      rep(i,9) {
        if(!t) {
          int x=nx1+dx[i],y=ny1+dy[i];
          if(!check(n,m,x,y)||a[x][y]==-1||d[s][nx1][ny1][x][y]<=c+a[x][y]) continue;
          d[s][nx1][ny1][x][y]=c+a[x][y];
          que.push(PP(P(c+a[x][y],s),P2(P(nx1,ny1),P(x,y))));
        } else {
          int x=nx2+dx[i],y=ny2-dy[i];
          if(!check(n,m,x,y)||a[x][y]==-1||d[s][x][y][nx2][ny2]<=c+a[x][y]) continue;
          d[s][x][y][nx2][ny2]=c+a[x][y];
          que.push(PP(P(c+a[x][y],s),P2(P(x,y),P(nx2,ny2))));
        }
      }
    }
    if(ans==MAX) ans=-1;
    pr(ans);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 29004
#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

int main() {
  INIT;
  
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b == c ||a+c == b ||c+b == a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256