akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;

int main(){
    int x;
    cin >> x;
    string s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 ";
    vector<int> term(32,0);
    int cnt=0;
    int tmp=0;
    for(auto ss: s){
        if(isdigit(ss)){
            if(tmp==0) tmp=ss-'0';
            else tmp=(tmp*10)+(ss-'0');
            // cout << tmp << ' ' << ss << ' ' << ss-'0' << endl;
        }
        else if(tmp!=0){
            term.at(cnt) = tmp;
            // cout << cnt << ' ' << tmp << endl;
            tmp=0;
            cnt+=1;
        }
    }
    cout << term.at(x-1) << endl;
    return 0;
}

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

const int mod = 1e9+7;
int n;
long long a, b, s[100001];

struct Seg{
	int *data, base;
	Seg(int sz){
		for(base=1; base<sz; base*=2);
		data=new int[base*2];
	}
	void update(int p, int v){
		p++;
		p+=base-1;
		data[p]=v;
		for(p/=2; p; p/=2)
			data[p]=(data[p*2]+data[p*2+1])%mod;
	}
	int rangeSum(int s, int e){
		s++, e++;
		int ret=0;
		for(s+=base-1, e+=base-1; s<=e; s/=2, e/=2){
			if(s&1) ret=(ret+data[s++])%mod;
			if(!(e&1)) ret=(ret+data[e--])%mod;
		}
		return ret;
	}
};

int get(int l, int r, long long val){
	if(l>r) return -1e9;
	int mid=(l+r)/2;
	if(mid==0 || s[mid]<=val) return max(mid, get(mid+1, r, val));
	else return get(l, mid-1, val);
}

int main(){
	scanf("%d %lld %lld", &n, &a, &b);
	for(int i=1; i<=n; i++)
		scanf("%lld", &s[i]);

	Seg *x=new Seg(n), *y=new Seg(n);
	int sx=0, sy=0;

	x->update(0, 1), y->update(0, 1);
	for(int i=1; i<n; i++){
		y->update(i, x->rangeSum(sx, get(sx, i-1, s[i+1]-b)));
		x->update(i, y->rangeSum(sy, get(sy, i-1, s[i+1]-a)));
		if(s[i+1]-s[i] < a) sx=i;
		if(s[i+1]-s[i] < b) sy=i;
	}

	int ans = (x->rangeSum(sx, n-1) + y->rangeSum(sy, n-1))%mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long int
#define ci cin>>
#define co cout<<
#define l <<endl
#define mp make_pair
#define v vector<int> v;
#define vv vector<vector<int>> vv
#define v_print for(auto x:v){cout<<x<<"\n";}
#define floop(i,a,b) for(int i=a;i<b;i++)
#define w(n) while(n--)
#define mod 1000000007
using namespace std;

long long int A[100003];
long long int INF= INT_MAX;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	fill(A,A+100003,INF);
	ll n,k,j;	ci n>>k;
	ll h[n];
	floop(i,0,n)
	{
		ci h[i];
	}
	A[0]=0;
	//A[1]=abs(h[1]-h[0]);
	floop(i,0,n)
	{
		j=1;
		while((j<=k)&&((i+j)<n))
		{
			A[i+j]=min(A[i+j],abs(h[i]-h[i+j])+A[i]);
			j++;
		}
	}
	co A[n-1];

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d2 == 1){
        cout << 1 << endl;
    }
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        
        String ss[] = s.split("");
        String ts[] = t.split("");
        
        int ans = 0;
        for(int i = 0; i < s.length();i++){
            if(!ss[i].equals(ts[i])){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 66920
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  int a, b;
  cin >> a >> b;
  for(int i=0; i<max(a,b); ++i) cout << min(a,b);
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

#define mod 998244353

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, d;
	cin >> n >> d;
	ll k = 2 * d + 1;
	ll ans = ceil((double)n /k);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [a, b, c] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  const res = c - (a - b)
  console.log(res >= 0 ? res : 0)
}

ans()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll A;
    long double B;
    cin>>A;
    cin>>B;
    cout<<setprecision(20)<<floor(A*B);
    return 0;
}

Measured memory_bytes: 3796
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_|sc.cin()).collect();
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 100000+10]; 102];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..100002 {
            dp[i+1][j] += dp[i][j];
            if j+xs[i]+1 < dp[0].len(){
                dp[i+1][j+xs[i]+1] -= dp[i][j];
            }
        }
        let mut ac = 0;
        for j in 0..100002 {
            ac += dp[i+1][j];
            ac = (ac + M) % M;
            dp[i+1][j] = ac;
        }
        // trace!((0..103).map(|k|dp[i+1][k]).collect::<Vec<_>>());
    }
    put!(dp[n][k]);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 108796
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
void turn(int&x,int&y)
{
	swap(x,y);
	x=-x;
}
int main()
{
	int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
	int dx=x2-x1,dy=y2-y1;
	turn(dx,dy);
	int x3=x2+dx,y3=y2+dy;
	turn(dx,dy);
	int x4=x3+dx,y4=y3+dy;
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<Endl;
}

Measured memory_bytes: 256
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	s := []int{}
	t := 0
	for i := 0; i < n; i++ {
		var a int
		con.Scan(&a)
		t += a
		if a%10 != 0 {
			s = append(s, a)
		}
	}
	sort.Ints(s)
	if t%10 == 0 {
		if len(s) > 0 {
			t -= s[0]
		}
		if t%10 == 0 {
			t = 0
		}
	}
	con.Println(t)
	return nil
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;


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

int main(){
	int w, h;
	while(cin >> w >> h, w|h){
		w+=2, h+=2;
		vector<vi> v(h, vi(w, 0));
		int xs, ys, xg, yg;
		cin >> xs >> ys >> xg >> yg;
		int n;
		cin >> n;
		while(n--){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			int bw = d?2:4;
			int bh = d?4:2;
			rep(i, bh) rep(j, bw) v[y+i][x+j] = c;
		}

		queue<P> q;
		q.push(MP(xs, ys));
		int c = v[ys][xs];
		bool ok = false;
		if(c) while(!q.empty()){
			P p = q.front();
			q.pop();

			if(v[p.Y][p.X] != c) continue;
			v[p.Y][p.X] = 0;

			if(p == MP(xg, yg)){
				ok = true;
				break;
			}

			rep(i, 4){
				int x = p.X + dx[i];
				int y = p.Y + dy[i];
				q.push(MP(x, y));
			}
		}
		cout << (ok?"OK":"NG") << endl;
	}

	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x, y;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> y;
	cout << x + y / 2 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<vector>
#include<list>
#include<deque>
#include<functional>
#include<sstream>
#include<numeric>
#include<complex>

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DUMP(x) if(DBG){cerr << #x << " = " << (x) << endl;}
#define CLR(a) memset((a), 0 ,sizeof(a))
#define rep(i,n) for(int i=0;i<(int)n;i++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define INF 1<<27
#define EPS 1e-8

#define DBG 0

using namespace std;

inline int to_int(string s) {int v; istringstream istr(s);istr>>v;return v;}
template<class T> inline string to_string(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;

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

ll ceil(ll n)
{
	return (n / 10) * 10 + 10;
}

int main()
{
	vector<int> r(5);
	ll ans = INF, time = 0;

	rep(i, 5) cin >> r[i];
	SORT(r);

	do{
		time = 0;
		rep(i, 5) {
			time += r[i];
			if (time % 10 != 0 && i != 4) {
				time = ceil(time);
			}
		}
		ans = min(ans, time);
	}while(next_permutation(r.begin(), r.end()));

	cout << ans << endl;

	return 0;
}


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

using namespace std;

// typedef long long ll;
int main()
{
   int n;
   cin>>n;
   long double x[n],y[n];
   for(int i=0;i<n;i++)
      cin>>x[i]>>y[i];
   long double sum=0;
   for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
      {
         sum+=sqrt(
            (x[i]-x[j])*(x[i]-x[j])+
            (y[i]-y[j])*(y[i]-y[j]));
      }
   long double ans;
   ans=(sum * 2.0)/n;
   std::cout << std::fixed << std::setprecision(8) << ans;
   
   return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	vi a;
	int i, j, sum;

	a.resize(3);

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

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

	sum = 0;
	rep(2) {
		sum += abs(a[i] - a[i + 1]);
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int maxf = 3;
int f[maxf];

int main()
{
    int mini = 0 , ans;
    for (int i = 0 ; i < 3 ; i++){
        cin >> f[i];
        if (mini <= f[i]){
            mini = f[i];
        }
    }
    if (mini == f[0]){
        ans = f[1] + f[2];
    }else if (mini == f[1]){
        ans = f[0] + f[2];
    }else if (mini == f[2]){
        ans = f[0] + f[1];
    }
    cout << ans;
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using PL = pair<ll,ll>;

const ll INF = 1e15;
vector<vector<ll>> to, ot;
vector<ll> ok;

void dfs0(ll v) {
	if(ok[v] & 1)return;
	ok[v]++;
	for(auto i : to[v]) {
		dfs0(i);
	}
}

void dfs1(ll v) {
	if(ok[v] & 2)return;
	ok[v] += 2;
	for(auto i : ot[v]) {
		dfs1(i);
	}
}

int main()
{
	ll n, m, p;
	cin >> n >> m >> p;
	vector<tuple<ll,ll,ll>> edge;
	to.resize(n), ot.resize(n), ok.resize(n);

	for(ll i = 0; i < m; i++) {
		ll a, b, c; cin >> a >> b >> c; a--, b--;
		c -= p; c = -c;
		edge.emplace_back(a, b, c);
		to[a].push_back(b);//辺
		ot[b].push_back(a);//逆辺
	}
	dfs0(0), dfs1(n - 1);

	{//Bellman -ford
		vector<ll> dist(n, INF);
		dist[0] = 0;
		bool res = 1;
		ll step = 0;
		while(res) {

			res = false;
			for(auto i : edge) {
				ll a, b, c; tie(a, b, c) = i;
				if(ok[a] != 3 || ok[b]!= 3)continue;
				ll nxt = c + dist[a];
				if(nxt < dist[b]) {
					res = true;
					dist[b] = nxt;
				}
			}
			step++;
			if(step > n) {
				cout << -1 << endl;
				return 0;
			}
		}
		cout << max(0LL, -dist[n - 1]) << endl;
	}

}

Measured memory_bytes: 768
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    s = input()
    ans = INF
    n = len(s)
    for i in range(n - 2):
        ans = min(ans,abs(int(s[i:i + 3]) - 753))
    print(ans)
if __name__ =='__main__':
    main()  

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[100],m,n;
  int sm;
  string s[100],t[1000];
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      cin>>s[i]>>a[i];
    for(i=0;i<m;i++)
      cin>>t[i];
    sm=0;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	for(k=0;k<8;k++){
	  if(s[i][k]!='*'&&s[i][k]!=t[j][k])
	    break;
	}
	if(k==8)
	  sm+=a[i];
      }
    }
    cout<<sm<<endl;
  }
  return 0;
}

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

int main() {
    unsigned int X;
    bool resolved = false;

    std::cin >> X;
    for (int A = 0;; A++) {
        for (int B = A; B >= 0; B--) {
            if (std::pow(A, 5) - std::pow(B, 5) == X) {
                std::cout << A << " " << B << std::endl;
                resolved = true;
                break;
            } else if (std::pow(-A, 5) - std::pow(B, 5) == X) {
                std::cout << -A << " " << B << std::endl;
                resolved = true;
                break;
            } else if (std::pow(A, 5) - std::pow(-B, 5) == X) {
                std::cout << A << " " << -B << std::endl;
                resolved = true;
                break;
            } else if (std::pow(-A, 5) - std::pow(-B, 5) == X) {
                std::cout << -A << " " << -B << std::endl;
                resolved = true;
                break;
            }
        }
        if (resolved) {
            break;
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3576
//printf
#include <stdio.h>
//atoi
#include <stdlib.h>
//strtok
#include <string.h>

int main(){
  int i,h,w;
  char s[15];
  char *p;
  //scanf is not valid!
  //for(;~scanf("%s",s);){
  while(fgets(s, 15, stdin) != NULL){
    //printf("%s",s);
    p = strtok(s, " ");
    //printf("%s\n",p);
    int h_max = atoi(p);
    p = strtok(NULL, " ");
    int w_max = atoi(p);
    //printf("H:%d,W:%d\n",h_max,w_max);
    if(w_max == 0 && h_max == 0) return 0;
    for(h=0;h<h_max;h++){
      for(w=0;w<w_max;w++){
	(w == 0 || w == (w_max - 1) || h == 0 || h == (h_max-1)) ? putchar('#') : putchar('.');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 524
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

[<EntryPoint>]
let main _ =
    let s = read string

    if s.Length = 2 then s
    else Util.strRev s
    |> printfn "%s"
    0 // return an integer exit code


Measured memory_bytes: 12240
#include<iostream>
#include<math.h>
#include<algorithm>
typedef long long ll;

using namespace std;

ll n, a, b;
ll dp[2005];

int main() {
	cin >> n;
	for (int i = 3; i < 10; i++) {
		dp[n - i] = 1;
	}
	dp[n] = 1;
	for (int i = n-3; i >= 0; i--){
		for (int j = 3; j < 10; j++){
			dp[i - j] = (dp[i - j + 1] + dp[i])%1000000007;
		}
	}
	cout << dp[0];
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '1')
            ++count;
    }
    cout << count << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  for(int i = 1; k >= i; i++){
    for(int j = 0; n-1 > j; j++){
      if(a[j]%i > a[j+1]%i){
        swap(a[j],a[j+1]);
      }
    }
  }
  for(int i = 0; n > i; i++){
    cout << a[i] << endl;
  }
}


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


int main(){
    
    string str, command, p;
    int q, a, b;
    
    cin >> str >> q;
    
    for(int i=0; i< q; i++){
        cin >> command >> a >> b;
        
        if(command == "print"){
            
            string str1 = str.substr(a, b-a+1);
            cout << str1 << endl;
        }else if(command == "reverse"){
            string s = str.substr(a,b-a+1);
            int n = s.size();
            for(int j=0; j<n; j++){
                str[j+a] = s[n-j-1];
                
            }
        }else if(command == "replace"){
            cin >> p;
            str = str.replace(a, b-a+1, p);
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3220
n=int(input())
L=list(map(int,input().split()))
newL = sorted(L, reverse=True)

alice=0
bob=0

for i in range(n):
    if i%2==0:
        alice+=newL[i]
    elif i%2==1:
        bob+=newL[i]
print(alice-bob)

    

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

 
/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
 

int main(){
    string S;
    cin>>S;
    int tmp=0;
    if(S.at(0)!=S.at(1)){
        tmp=1;
        //cout<<"a";
    }
    if(S.at(0)!=S.at(2)){
        tmp=1;
    }
    if(S.at(1)!=S.at(2)){
        tmp=1;
    }

    if(tmp==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    int n,k; cin>>n>>k;
    ll ans=k;
    ans*=pow(k-1,n-1);
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    
    int[][] val = new int[N][2];
    for(int i = 0; i < N; i++){
      String[] t = sc.nextLine().split(" ");
      val[i][0] = Integer.parseInt(t[0]);
      val[i][1] = Integer.parseInt(t[1]);
    }
    Arrays.sort(val, (a, b) -> Integer.compare(a[0], b[0]));
    
    Queue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
    int ans = 0;
    int A = 0;
    for(int i = 1; i <= M; i++){
      while(A < N && val[A][0] <= i){
        pq.offer(val[A][1]);
        A++;
      }
      if(!pq.isEmpty()){
      	ans += pq.poll();
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 122412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    string s; cin >> s;
    int k; cin >> k;
    char first = s[0];
    if(first!='1'){
        cout << first << endl;
    }else{
        bool flag = true;
        for(int i = 0; i < k; i++){
            if(s[i]!='1') {
                flag = false;
                first = s[i];
                break;
            }
        }
        if(flag) cout << 1 << endl;
        else cout << first << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = 
#define REVERSE(x) reverse(ALL(x))
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<>())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SIZE(x) ll((x).size())
#define gcd __gcd
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
template <typename T = int> inline T in(){
  T x; cin >> x; return x;}
template <typename T> inline void print(const T& x){
  cout << x << "\n";}
inline int lcm(int a, int b){
  return a / gcd(a, b) * b;}
bool is_prime(int n){
  if (n < 2) return false;
  FOR(i, 2, (int)(sqrt(n) + 1)){
    if (n % i == 0) return false;
  }
  return true;
}


signed main(){
  int N = in();
  vector<int> vec(N);
  for (int& x: vec) x = in();
  vector<int> vec2(N);
  REP(i, N) vec2.at(vec.at(i) - 1) = i + 1;
  for (int x: vec2) cout << x << " ";
  cout << "\n";
}

Measured memory_bytes: 2432
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    set<char> s;
    rep(i,3){
        char a;
        cin >> a;
        s.insert(a);
        }
    if(s.size() == 2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, i, x;
  char op;
  scanf("%d%s%d", &a, &op, &b);
  for(i = 0; i > -1; i++)
  if(op != '?')
    {
      switch (op){
      case '+':
	x = a + b;
        break;
      case '-':
	x = a - b;
	break;
      case '*':
	x = a * b;
	break;
      case '/':
	x = a / b;
	break;
      }
	printf("%d\n", x);
	scanf("%d%s%d", &a, &op, &b);
      
    }
  else
    {
      break;
    }
   return 0;
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
namespace __gnu_pbds {
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
}
using namespace __gnu_pbds;

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}


ll n,k;
int cur=0;
int x[2*MAX];


int vis[2*MAX];

ll play(){

   ll need=0;
   int here=0;
   int visnum=2;
   vis[0]=1;
   while(1){
    if(!vis[x[here]-1]){
        vis[x[here]-1]=visnum;
        visnum++;
        here=x[here]-1;
    }
    else{
        cur=vis[x[here]-1];
        return (vis[here]-vis[x[here]-1]+1);

    }
   }

}


int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("digits.in" , "r" , stdin);
//freopen("digits.out" , "w" , stdout);



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

    ll how=play();

    k-=cur;
    if(k>how){
        k%=how;
    }

    k+=cur;








    int ans=1;
    int pos=0;
    while(k>0){

        ans=x[pos]-1;
        pos=x[pos]-1;
        k--;

    }

    cout<<ans+1;






     return 0;

}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n,m;
    cin>>n>>m;
    vin s(n),c(n);
    rep(i,m)cin>>s[i]>>c[i];
    int ans=-1;
    rep(i,999){
        string t=to_string(i);
        if(t.size()==n){
            bool can=true;
            rep(j,m){
                char d='0'+c[j];
                if(t[s[j]-1]!=d){
                    can=false;
                    break;
                }
            }
            if(can){
                ans=i;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding=utf-8


def partial_reverse(origin, begin, end):
    return origin[:begin] + origin[begin:end][::-1] + origin[end:]


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

    for i in range(Q):
        b, e = map(int, input().split())
        A = partial_reverse(A, b, e)

    print(' '.join(map(str, A)))



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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(void){
    //前半は最大化,後半は最小化
    //N個のものを除去する前から数列は(前半部分)|(後半部分)に二分される,ここから前半部分と後半部分の要素がそれぞれN個となるように取り除く
    //前後半の境目となる仕切りをA[i]|A[i+1]からA[i+1]|A[i+2]にスライドさせることを考える
    //A[i+1]が新しく前半のメンバーとして残るのは,A[0]~A[i+1]の最小値がA[i+1]でないとき

    int N; cin >> N;
    int sz = 3*N;
    ll A[sz];
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll sum_pr[N+1] = {}; //sum_pr[i]: A[0]~A[N-1 + i]までを候補として選択した時に最大化されたN個の和
    rep(i, sz){
        cin >> A[i];
        if(i < N){pq.push(A[i]); sum_pr[0] += A[i];}
    }
    for(int i = 1; i <= N; i++){
        //sum_pr[i]を求める
        //A[N-1 + i]が新たに候補として加わる
        ll cmp = pq.top();
        if(A[N-1 + i] > cmp){
            pq.pop();
            pq.push(A[N-1 + i]);
            sum_pr[i] = sum_pr[i-1] + A[N-1 + i] - cmp;
        }
        else sum_pr[i] = sum_pr[i-1];
    }

    priority_queue<ll> pq_lat;
    ll sum_lat[N+1] = {}; //sum_lat[i]: A[i+N]からA[3N-1]までが候補;
    rep(i, N){
        pq_lat.push(A[3*N-1 - i]);
        sum_lat[N] += A[3*N-1 - i];
    }
    for(int i = N-1; i >= 0; i--){
        //A[2N-1], A[2N-2],...,A[N]を候補に追加していく
        ll cmp = pq_lat.top();
        if(A[N+i] < cmp){
            pq_lat.pop();
            pq_lat.push(A[N+i]);
            sum_lat[i] = sum_lat[i+1] + A[N+i] - cmp;
        }
        else sum_lat[i] = sum_lat[i+1];
    }
    ll ans = -100100100100100100ll;
    rep(i, N+1) ans = max(ans, sum_pr[i]-sum_lat[i]);
    cout << ans << endl;
    //rep(i, N+1) cout << "pr: " << sum_pr[i] << ", lat: " << sum_lat[i] << endl;

    return 0;
}

Measured memory_bytes: 6516
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = f.read_int_list()

    return 1.0 / sum([1.0/ai for ai in a])


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast

    ll n;
    cin >> n;
    cout << 1-n << endl;    

}


//    cout << fixed << setprecision(12);


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
typedef pair<char, ll> P;

ll partition(P A[], ll p, ll r){
    ll x = A[r].second;
    ll i = p-1;
    rep(j,p,r){
        if(A[j].second <= x){
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

void quicksort(P A[], ll p, ll r) {
    if(p < r){
        ll q = partition(A, p, r);
        quicksort(A, p, q-1);
        quicksort(A, q+1, r);
    }
}

void merge(P A[], ll lv, ll mid, ll rv){
    ll n1 = mid - lv;
    ll n2 = rv - mid;
    vector<P> L(n1+1), R(n2+1);
    rep(i,0,n1) L[i] = A[lv+i];
    rep(i,0,n2) R[i] = A[mid+i];
    L[n1] = make_pair('a', INF);
    R[n2] = make_pair('a', INF);
    ll i = 0, j = 0;
    rep(k, lv, rv){
        if(L[i].second <= R[j].second){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(P A[], ll lv, ll rv){
    if(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        mergeSort(A, lv, mid);
        mergeSort(A, mid, rv);
        merge(A, lv, mid, rv);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    P A[100010], prev[100010];
    cin >> N;
    rep(i,0,N){
        char c;
        ll a;
        cin >> c >> a;
        A[i] = make_pair(c, a);
        prev[i] = make_pair(c, a);
    }

    quicksort(A, 0, N-1);
    mergeSort(prev, 0, N);
    bool is_stable = true;
    rep(i,0,N){
        if(A[i] != prev[i]) is_stable = false;
    }
    if(is_stable){
        print("Stable");
    }else{
        print("Not stable");
    }
    rep(i,0,N){
        print2(A[i].first, A[i].second);
    }



    
}


Measured memory_bytes: 7476
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const long double INF = 1e18;




int main(){
	long double h,ma=0.0,mi=INF;
	while(cin>>h){
		ma=max(ma,h);
		mi=min(mi,h);
	}
	cout<<fixed<<setprecision(3)<<ma-mi<<endl;
	return 0;
}
/*

*/

Measured memory_bytes: 1288
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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


  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 20002
#define POOL_SIZE 20002

typedef enum {
  BACK_SLASH,
  POOL,
} Type;

typedef struct {
  Type type;
  int value; // backslash=>index, area=>area
} Item;

int count_pool(Item* stack, int stack_top)
{
  int cnt = 0;
  for(int i = 0; i < stack_top; i++) {
    if(stack[i].type == POOL) {
      cnt++;
    }
  }
  return cnt;
}

void print_stack(Item* stack, int stack_top)
{
  int num_pool = count_pool(stack, stack_top);
  printf("%d", num_pool);
  if(num_pool == 0) {
    putchar('\n');
    return;
  } else {
    putchar(' ');
  }

  int pool_cnt = 0;
  for(int stack_index = 0; stack_index < stack_top; stack_index++) {
    switch(stack[stack_index].type) {
      case POOL:
        pool_cnt++;
        printf("%d", stack[stack_index].value);
        if(pool_cnt == num_pool) {
          putchar('\n');
        } else {
          putchar(' ');
        }
        break;
      case BACK_SLASH:
        break;
      default:
        fputs("Unknown token found in print_stack()\n", stderr);
        exit(1);
    }
  }
}

void print_total_area(Item* stack, int stack_top)
{
  int total_area = 0;
  for(int i = 0; i < stack_top; i++) {
    switch(stack[i].type) {
      case POOL:
        total_area += stack[i].value;
        break;
      case BACK_SLASH:
        break;
      default:
        fprintf(stderr, "Unknown token found: %d\n", stack[i].type);
        exit(1);
    }
  }
  printf("%d\n", total_area);
}

int main()
{
  char buf[BUF_SIZE];
  fgets(buf, sizeof(buf), stdin);
  char* lf_addr = strchr(buf, '\n');
  if(lf_addr) {
    *lf_addr = '\0';
  } else {
    fputs("Error: LF not found\n", stderr);
    exit(1);
  }

  Item stack[POOL_SIZE];
  int stack_top = 0;
  for(size_t i = 0; i < strlen(buf); i++) {
    switch(buf[i]) {
      case '\\':
        stack[stack_top].type = BACK_SLASH;
        stack[stack_top].value = i;
        stack_top++;
        break;
      case '/':;
        int total_area = 0;
        for(int k = stack_top-1; 0 <= k; k--) {
          if(stack[k].type == BACK_SLASH) {
            total_area += i - stack[k].value;
            stack[k].type = POOL;
            stack[k].value = total_area;
            stack_top = k + 1;
            break;
          } else if(stack[k].type == POOL) {
            total_area += stack[k].value;
          } else {
            fputs("Unknown item found\n", stderr);
            exit(1);
          }
        }
        break;
      case '_':
        break;
      default:
        fprintf(stderr, "Unknown token found: %c\n", buf[i]);
        exit(1);
    }
  }

  print_total_area(stack, stack_top);
  print_stack(stack, stack_top);
  return 0;
}



Measured memory_bytes: 2108
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize
    }
    println!("{}", (n - 1) * n / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};
 
int n, m;
 
int main(){
	cin >> n >> m;
	cout <<  m + 100 * (10 - min(n, 10) ) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;

int main()
{
    ll n,m;
    cin>>n>>m;
    unordered_map<int,vector<string>>f;
    for(int i = 0; i < m; i++){
        int p; string c;
        cin>>p>>c;
        f[p].push_back(c);
    }

    int ans = 0,p = 0;

    for(auto i: f){
        int ni = i.second.size();
        bool ok = false;
        int cnt = 0;
        for(int j = 0; j < ni; j++){
            if(i.second[j] == "AC"){
                ans++;
                ok = true;
                break;
            }
            else
                cnt++;
        }
        if(ok)
            p+=cnt;
    }

    cout<<ans<<" "<<p<<"\n";
    return 0;
}


Measured memory_bytes: 13732
N = int(input())
S = input()
s0,s1,s2 = int(S[0]),int(S[1]),int(S[2])
C = [0 for i in range(10)]
D = [0 for i in range(100)]
E = [0 for i in range(1000)]
C[s0] += 1
C[s1] += 1
C[s2] += 1
D[s0*10+s1] += 1
D[s0*10+s2] += 1
D[s1*10+s2] += 1
E[s0*100+s1*10+s2] += 1
for i in range(3,N):
    s = int(S[i])
    for i in range(100):
        E[10*i+s] =  E[10*i+s]+D[i]
    for i in range(10):
        D[10*i+s] = D[10*i+s]+C[i]
    C[s] += 1
ans = 0
for i in range(1000):
    if E[i] > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3188
import math
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import product
from collections import defaultdict
from collections import deque
from collections import Counter
import heapq


def input_li():
    return list(map(int, input().split()))


N = int(input())
A_LI = input_li()
Q = int(input())
cnt = Counter(A_LI)
ans = sum(A_LI)
BC_LI = []
for _ in range(Q):
    BC_LI.append(input_li())
for b, c in BC_LI:
    ans -= b * cnt[b]
    ans += c * cnt[b]
    print(ans)
    if c in cnt:
        cnt[c] += cnt[b]
    else:
        cnt[c] = cnt[b]
    cnt[b] = 0


Measured memory_bytes: 108448
n,k = map(int,input().split())
mod = 10**9 + 7


def pow_mod(x, n, mod):
    if n > 1:
        return pow_mod(pow(x,2) % mod, n//2, mod) * pow(x, n%2) % mod
    else:
        return x


pow_n = [-1] * (k+1)
for i in range(1,k+1):
    if pow_n[k//i] == -1:
        pow_n[k//i] = pow_mod(k//i, n, mod)

ans = 0
c = [0] * (k+1)
for i in range(k, 0, -1):
    count = pow_n[k//i]
    for j in range(2, k//i+1):
        count -= c[i*j]
        count %= mod
    c[i] = count
    ans += count * i
    ans %= mod
print(ans)


Measured memory_bytes: 11948
n, m = [int(i) for i in input().split(" ")]
ab = []

for i in range(0, n):
    ab.append([int(i) for i in input().split(" ")])
    
ab = sorted(ab, key=lambda k: k[0])

c = 0
ac = 0
for i in range(0, n):
    if m == 0:
        break
    if ab[i][1] <= m:
        m -= ab[i][1]
        c += ab[i][0] * ab[i][1]
    else:
        c += ab[i][0] * m
        m = 0
print(c)

Measured memory_bytes: 23520
from collections import Counter

# 入力 (各文字列をソートしておく)
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]

# Counter でヒストグラムに
num = Counter(S)

# 各文字列ごとに個数 x を扱う
result = sum(x * (x - 1) // 2 for x in num.values())
print(result)

Measured memory_bytes: 23808
/**
 *   
 *   Date: 30 March 2020
 *   Time: 12:46:34
**/
#pragma GCC optimize("O3")
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;
ll dp[100100][4];
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n,a,b,c,d;
	cin>>n;
	matrix v1(n+1,vector<ll>(3));
	for(ll i=1;i<=n;i++)
	{
		cin>>v1[i][0]>>v1[i][1]>>v1[i][2];
	}
	dp[1][0]=v1[1][0];
	dp[1][1]=v1[1][1];
	dp[1][2]=v1[1][2];
	for(ll i=2;i<=n;i++)
	{
		a=v1[i][0],b=v1[i][1],c=v1[i][2];
		dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	d=max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout<<d<<endl;

return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<uint64_t> L(n+1);
  L[0]=2;
  L[1]=1;
  for (int i=2; i<=n; i++) {
    L[i]= L[i-1]+L[i-2];
  }
  cout << L[n] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; ; i++){
            int x = sc.nextInt();
            if(x == 0)
            break;
            else{
                System.out.println("Case " + i + ": "+ x );
            }
        } 
    }
}


Measured memory_bytes: 42720