akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.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(){int A, B;
cin >> A >> B;
// vector<int> a(N); vector<int> b(N);
// rep(i, N) cin >> a.at(i) >> b.at(i);
string S;
cin >> S;
rep(i, A){
    if(!(S.at(i) >= '0' && S.at(i) <= '9')){
        cout << "No" << endl;
        return 0;
    }
}
if(S.at(A) != '-'){
        cout << "No" << endl;
        return 0;
}
for(int i = A + 1; i < A + B + 1; i++){
    if(!(S.at(i) >= '0' && S.at(i) <= '9')){
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    For(i, k, n){
        if(a[i-k] < a[i])
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }

return 0;
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/


int main()
{
    char c;
    cin >> c;
    if(c== 'A') cout << "T";
    else if(c== 'T') cout << "A";
    else if(c== 'C') cout << "G";
    else cout << "C";
}


Measured memory_bytes: 3640
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void kek(){
    cout << "No";
    exit(0);
}
void solve()
{
    int x,  y;
    cin >> x >> y;
    int t = 4 * x - y; 
    if(t < 0 || t % 2) kek();
    int a = t / 2; 
    int b = x - a;
    if(a < 0 || b < 0) kek();
    cout << "Yes";
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 3636
/*

????????????????????????????????????????????????????????????????????????????????? ??? ??? ??? ??? ??? ??? ??? ??? 
??????????????????????????????????????????????????????????????????????????????????????????????????????????????? { 
??????????????????????????????????????????????????????????????????????????????,.-?????¬?????¬??§???l 
???????????????????????£?????????????????? l::::::::}????????????????????????l???l???-?????????_l_;:='?????? ', 
????????????????????????????????????????????°??´???'"?´????????????????????? l???l??????????????????????????????i 
?????????????????????????????????????????????????????????????????????????????? l???l???????????? ??? ??? ??? ??? l 
?????????????????????????????????????????????????????????????????????????????????l???l???????????????????????? ??? } 
????????????????????????????????????????????????????????????????????????????????? l???l???????????????????????? ??? l 
????????????????????????????????????????????????????????????????????????????????????l???l???????????????????????????,' 
?????????????????????????????????????????????????????? ??????????????????????????? ??? ????????????????????????,' 
???????????????????????????????????????????????? .???{??????????????????????????? ??? }???} ??? ??? ??? ??? ,' 
?????????????????????????????????????????????????????? ?????????????????????????????? ?????????????????????/ 
???????????????????????????????????????????????????????????????????¨?¨?¨???????????? ?´?????????????????? / 
????????????????????????????????????????????????????????????????????????/?????? l????????????????????????/ 
?????????????????????????????????????????????????????????????????????????????????j??? ??? ??? ??? ??? / 
?????????????????????????????????????????????????????? ??? ,. -???'"????????£???????????? ??? ??? /???????????? 
?????????????????????????????? ??? ??? ??? ???,.-???'" -?????¬?????¬?????¬?????????,,??? ??? /???????????????????????? ??????-??? 
???????????????????????? ??? ??? ??? ??? ??? ??? ??£ ????????´?????´??????'"?????£????????? /??????????????????????????????????????? ??£??????-??? 
??????????????????????????????????????????????????????????????????????????? ??? ??? ?????????/???????????????????????????????????????????????????????????????-???



*/
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000
 
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A<B && B<C) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3092
import sys
readline = sys.stdin.readline

def solve():
    N, M, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    cum_a = [0] * N
    cum_b = [0] * M
    for i in range(N):
        cum_a[i] = A[i] if i == 0 else A[i] + cum_a[i - 1]
    
    for i in range(M):
        cum_b[i] = B[i] if i == 0 else B[i] + cum_b[i - 1]

    d = 0
    for i in range(N):
        if cum_a[i] <= K:
            d = i + 1
        else:
            break
    

    ans = 0
    e = 0
    while d >= 0:
        rem = K - (cum_a[d - 1] if d != 0 else 0)
        while e < M and cum_b[e] <= rem:
            e += 1
        ans = max(ans, d + e)
        d -= 1
    
    print(ans)

solve()

Measured memory_bytes: 109020
# coding: utf-8
# Your code here!
N, M = map(int,input().split())
C = [0] * (N+1)

for i in range(M):
    a, b = map(int,input().split())
    C[a] += 1
    C[b] += 1
    
for i in range(N):
    print(C[i+1])

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, L) = Slice2<long>();
            var u = new long[N];
            var minA = long.MaxValue;
            var min = long.MaxValue;
            for (var i = 0; i < N; ++i)
            {
                u[i] = L + i + 1 - 1;
                if (Abs(u[i]) < minA)
                {
                    minA = Abs(u[i]);
                    min = u[i];
                }
            }
            WriteLine(u.Sum() - min);
        }
        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27924
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

int cl[MAXN], cr[MAXN];

ll ans;

int n;

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d %d", &cl[i], &cr[i]);
    }

    /*
    cl[n + 1] = cr[n + 1] = 0;
    ++n;
    */

    sort(cl + 1, cl + n + 1);
    sort(cr + 1, cr + n + 1);
    reverse(cl + 1, cl + n + 1);

    ll sum = 0;       

    /*
    5 3 1 0
    0 2 4 6
    */

    for (int i = 1; i <= n; ++i) {
    	ans = max(ans, sum + cl[i]);
    	ans = max(ans, sum - cr[i]);
    	ans = max(ans, sum + cl[i] - cr[i]);
    	sum += (cl[i] - cr[i]);
    } 

    printf("%lld\n", ans * 2);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int[] l=new int[n];
		for(int i=0;i<n;i++){
			l[i]=sc.nextInt();
		}
		int dis=0;
		int count=1;
		for(int i=0;i<n;i++){
			dis=dis+l[i];
			if(dis<=x){
				count++;
				
			}
		}
			System.out.println(count);
	}
		
}

Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main()
{
int h,m,c=0,f=0;

cin>>h>>m;
int x[m];
int i;
for(i=0;i<m;i++)
{
    cin>>x[i];
    c=c+x[i];
}
if(c<h)
{
    cout<<"No";
}
else{
        cout<<"Yes"
;}

//cout<<c;
return 0;
}

Measured memory_bytes: 640
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
#import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    n,m,d = mapline()
    alpha = 2
    if d == 0:
        alpha = 1
    print(alpha * (n - d) * (m-1) / n / n)


if __name__ == "__main__":
    run()


Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    map<string, ll> mp;
    ll n;
    cin >> n;
    rep(i, 0, n){
        string s;
        cin >> s;
        mp[s]++;
    }
    ll mx = 0;
    vector<string> ans;
    for(auto e : mp){
        if(e.second > mx) {
            ans.clear();
            ans.push_back(e.first);
            mx = e.second;
        }else if(e.second == mx) {
            ans.push_back(e.first);
        }
    }
    sort(ALL(ans));
    for(auto e : ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 27200
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  int n, a[10000007] = {};
  ll z = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) for (int j = i; j <= n; j += i) a[j]++;
  for (int i = 1; i <= n; i++) z += 1ll * i * a[i];
  cout << z << '\n';
}


Measured memory_bytes: 42260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

// Nを与えると素因数分解をし、{素数:個数}のmapを返す
map<long long, long long> prime_factorize(long long n) {
    map<long long, long long> mp;
    for (long long a = 2; a * a <= n; a++) {
        if (n % a != 0) continue;
        long long exp = 0;  // 指数

        // 割れる限り割り続ける
        while (n % a == 0) {
            exp++;
            n /= a;
        }

        mp[a] = exp;
    }

    // 最後に残った数が1でないのならN自身が素数
    if (n != 1) mp[n] = 1;
    return mp;
}

// prime_factorize を使用してNの約数の個数を返す
long long factor_num(long long n) {
    long long num = 1;
    map<long long, long long> mp = prime_factorize(n);
    for (auto p : mp) num *= p.second + 1;
    return num;
}

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

    // 正整数jに対し、jの倍数であってN以下であるものの総和をg(j)としたとき
    // sum_{j = 1}^{N} g(j)が解答となる
    // y = floor(N/x)とおくと g(x) = xy(y+1)/2 であるためO(N)で解ける

    long long sum = 0;

    rep(i, n) {
        long long j = i + 1;
        long long y = n / j;
        sum += j * y * (y + 1) / 2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s,a="CF";
int n;
int main()
{
	cin>>s;
	n=s.size();
	int flag=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]==a[flag])
		{
			flag++;
		}
		if(flag==2)
		break;
	}
	if(flag==2)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

namespace AtCoder {
	class Program {
		public static void Main() {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			int n = int.Parse(Console.ReadLine());
			int i; int tri = 0;
			for (i = 0; tri < n; i++) tri += i;
			for(int j = 1; j < i; j++) {
				if (j == tri - n) continue;
				Console.WriteLine(j);
			}
			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(){
int a,b,c,d,kazu=0;
	scanf("%d %d %d",&a,&b,&c);
	for(d = a;d<=b;d++){
		if((c%d)==0){
			kazu++;
		}
	}
	printf("%d\n",kazu);
	return 0;
}

Measured memory_bytes: 2756
N=int(input())
mod=10**9+7
if N==1:
  print(0)
  exit()
dp=[[0,0,0]for i in range(N-1)]
dp[0]=[64,34,2]
for i in range(N-2):
  dp[i+1][2]=dp[i][1]+dp[i][2]*10
  dp[i+1][1]=dp[i][0]*2+dp[i][1]*9
  dp[i+1][0]=dp[i][0]*8
  dp[i+1][2]%=mod
  dp[i+1][1]%=mod
  dp[i+1][0]%=mod
print(dp[-1][-1])

Measured memory_bytes: 207312
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-c) <= d || abs(a-b) <= d && abs(b-c) <= d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}


Measured memory_bytes: 512
/* In the name of Anton */

/*
* Motto :)
*
*
*
*
*
*/

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(x,a) for(auto &x: a)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define vt vector
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

template<class A> void read(vt<A>& v);
template<class T> void read(T& x){
  cin>>x;
}

void read(double &d){
  string t;
  read(t);
  d=stod(t);
}
void read(long double &d){
  string t;
  read(t);
  d=stold(t);
}

template<class H, class... T> void read(H &h, T&...t){
  read(h);
  read(t...);
}

template <class A> void read(vt<A> &x){
  trav(a,x)
    read(a);
}

string to_string(char c){
  return string(1,c);
}

string to_string(bool b){
  return b?"true":"false";
}

string to_string(const char* s){
  return string(s);
}

string to_string(string s){
  return string(s);
}

string to_string(vt<bool> v){
  string res;
  rep(i,sz(v)){
    res+=char('0'+v[i]);
  }
  return res;
}

template<class T> string to_string(T v){
  bool f=1;
  string res;
  trav(x,v){
    if(!f)
      res+=' ';
    f=0;
    res+=to_string(x);
  }
  return res;
}

template<class A> void write(A x){
  cout<<to_string(x);
}

template<class H, class...T> void write(const H& h, const T&...t){
  write(h);
  write(t...);
}

void print(){
  write("\n");
}

template<class H, class...T> void print(const H& h, const T&...t){
  write(h);
  if(sizeof...(t))
    write(' ');
  print(t...);
}

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

const int mxN=2005;
const ll mod=1e9+7;
ll dp[mxN];

void pre(){
  rep(i,mxN){
    dp[i]=1;
  }

  dp[0]=0;
  dp[1]=0;
  dp[2]=0;

  for(int i=3;i<mxN;i++){
    for(int j=3;j<mxN;j++){
      if(i+j<mxN){
        dp[i+j]=(dp[i+j]+dp[i])%mod;
      }
    }

  }
}

void solve(){
  int s; read(s);
  print(dp[s]);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t=1;
  // read(t);
  rep(i,t) solve();
  return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAXN = 1e2+2;
const int MAX = 1e5+5;
int N, W, w[MAXN], b[MAXN];
ll pd[MAX];

ll solve() {
	REP(i, 1, N) PER(j, W, 1)
		if(w[i] <= j) pd[j] = max(pd[j], pd[j-w[i]]+b[i]);
	return pd[W];
}

int main(int argc, char ** argv) {
	scanf("%d%d", &N, &W);
	REP(i, 1, N) scanf("%d%d", &w[i], &b[i]);
	printf("%lld\n", solve());
	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>
 
//#define int long long
 
#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define endl '\n'
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
mt19937 mrand(random_device{}());
 
double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
 
void solve();
void scan();
 
signed main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed; cout.precision(15);
    solve();
    return 0;
}

void solve() {
	int h, w; cin >> h >> w;
	vector<vector<int>> dp(h, vector<int>(w, inf0));
	vector<string> f(h);
	for (int i = 0; i < h; i++)
		cin >> f[i];
	if (f[0][0] == '#') dp[0][0] = 1;
	else dp[0][0] = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!i && !j) continue;
			int m1 = inf0;
			int m2 = inf0;
			if (i) {
				if (f[i][j] == '.' || f[i - 1][j] == '#') m1 = dp[i - 1][j];
				else {
					m1 = dp[i - 1][j] + 1;
				}
			}
			if (j) {
				if (f[i][j] == '.' || f[i][j - 1] == '#') m2 = dp[i][j - 1];
				else m2 = dp[i][j - 1] + 1;
			}
			dp[i][j] = min(m1, m2);
		}
	}
	cout << dp[h - 1][w - 1] << endl;
    return;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>

long long l;
int n;
long long x[200005], x2[200005];
long long sum[200005], sum2[200005];
int main() {
	std::cin >> l >> n;
	for (int i = 1; i <= n; ++i) {
		std::cin >> x[i];
		sum[i] = sum[i - 1] + x[i];
	}

	for (int i = 1; i <= n; ++i) {
		x2[i] = l - x[n - i + 1];
		sum2[i] = sum2[i - 1] + x2[i];
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		long long tmp;
		tmp = (n - i - 1) * l + 2 * (sum[i + 1 + (n - i - 1) / 2] - sum[i + 1 - 1]) - x[i + (n - i + 1 + 1) / 2]
			- 2 * (sum[n] - sum[i + 1 + (n - i - 1 + 1) / 2]);
		ans = std::max(ans, tmp);
		tmp = (n - i - 1) * l + 2 * (sum2[i + 1 + (n - i - 1) / 2] - sum2[i + 1 - 1]) - x2[i + (n - i + 1 + 1) / 2]
			- 2 * (sum2[n] - sum2[i + 1 + (n - i - 1 + 1) / 2]);
		ans = std::max(ans, tmp);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 6528
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long[] a = { sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong() };
		long N = 4 * sc.nextLong();
		class State implements Comparable<State> {
			double volume;
			long value;

			public State(double volume_, long value_) {
				volume = volume_;
				value = value_;
			}

			public int compareTo(State o) {
				return Double.compare(value / volume, o.value / o.volume);
			};
		}
		PriorityQueue<State> pq = new PriorityQueue<>();
		pq.add(new State(1, a[0]));
		pq.add(new State(2, a[1]));
		pq.add(new State(4, a[2]));
		pq.add(new State(8, a[3]));
		long cost = 0;
		long cur = 0;
		while (Math.abs(N - cur) > 0) {
			State s = pq.poll();
			long num = (long) ((N - cur) / (long) s.volume);
			cost += (long) s.value * num;
			cur += (long) s.volume * num;
		}
		System.out.println(cost);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 22996
# -*- coding: utf-8 -*-

N,K = list(map(int, input().rstrip().split()))
#-----

def check(n,k):
    sum_min = (k-1)*k/2
    sum_max = n*(n+1)/2 - (n-k)*(n-k+1)/2
    
    sum_pattern = sum_max - sum_min + 1
    return sum_pattern


cnt = 0
for i in range(K,N+1):
    c = check(N,i)
    cnt = (cnt + c) % (10**9+7)
    
print(int(cnt+1))


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9 + 7;

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;
  int cnt = 0;
  
  sort(a.begin(), a.end(), greater<int>());
  
  int prev = a[0];
  map<int,int> mp;
  mp[a[0]] = 2;
  for (int i = 1; i < n; i++) {
    mp[a[i]] += 2;
    mp[prev]--;
    if (mp[prev] == 0) {
      mp.erase(prev);
      auto itr = *(mp.rbegin());
      prev = itr.first;
    }
    res += prev;
  }

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

Measured memory_bytes: 8788
#include<stdio.h>
int main()
{
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	int sum=0;
	for(int i=1;i<=x;i++)
	{
		int w=i;
		int anc=0;
		while(w)
		{
			anc=anc+w%10;
			w=w/10;
		}
		if(anc>=y&&anc<=z)
			sum=sum+i;
	}
	printf("%d\n",sum);
	return 0;
 } 

Measured memory_bytes: 128
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

ll memo[200][200];
ll combi(ll a, ll b) {
  if (memo[a][b]) return memo[a][b];
  if (b == 1) return a;
  if (a == b) return 1;
  return memo[a][b] = combi(a-1, b-1)+combi(a-1, b);
}

int main() {
  bool notPrime[1121];
  memset(notPrime, false, sizeof(notPrime));
  for (int i = 2; i*i <= 1120; i++) {
    for (int j = i+i; j <= 1120; j+=i) {
      notPrime[j] = true;
    }
  }
  vector <int> prime;
  for (int i = 2; i <= 1120; i++) {
    if (!notPrime[i]) prime.push_back(i);
  }
  int m = prime.size();
  while (true) {
    int n, k;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    // cout << 1121 << " " << m << " " << k+1 << " " << ((1LL<<31)-1) << endl;
    ll dp[1121][m][2];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < m; i++) {
      dp[prime[i]][i][1] = 1;
    }

    // for (int p = 0; prime[p] < n; p++) {	
    //   cout << prime[p] << " ";
    // }
    // cout << endl;
    for (int i = 2; i <= k; i++) {
      for (int t1 = 0; t1 <= n; t1++) {
	for (int t2 = 0; t2 < m; t2++) {
	  dp[t1][t2][i%2] = 0;
	}
      }
      for (int p1 = 0; p1 < m; p1++) {
	for (int num = 2; num < n; num++) {
	  if (dp[num][p1][(i+1)%2] == 0) continue;
	  for (int p2 = p1+1; p2 < m; p2++) {
	    if (num+prime[p2] > n) break;

	    dp[num+prime[p2]][p2][i%2] += dp[num][p1][(i+1)%2];
	  }
	}
      }
      // for (int p = 0; prime[p] < n; p++) {
      // 	cout << dp[n][p][i%2] << " ";
      // }
      // cout << endl;
      // for (int t1 = 0; t1 <= n; t1++) {
      // 	cout << setw(2) << t1 << ":";
      // 	for (int t2 = 0; t2 < m && prime[t2] <= n; t2++) {
      // 	  cout << dp[t1][t2][i%2] << " ";
      // 	}
      // 	cout << endl;
      // }
      // cout << endl;
    }
    ll ans = 0;
    for (int i = 0; i < m; i++) ans += dp[n][i][k%2];
    cout << ans << endl;
  }
}

Measured memory_bytes: 4492
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vi face_W(n, 0);
  vi face_E(n, 0);
	Loop(i, n) {
		if (i == 0) {
			if (s[i] == 'W') face_W[i] = 1;
			else face_E[i] = 1;
		}
		else {
			face_W[i] = face_W[i - 1];
			face_E[i] = face_E[i - 1];
			if (s[i] == 'W') face_W[i]++;
			else face_E[i]++;
		}
	}
	int ans = INT_MAX;
	Loop(i, n) {
		int val1 = (i - 1 >= 0) ? face_W[i - 1] : 0;
		int val2 = face_E[n - 1] - face_E[i];
		int buf = val1 + val2;
		ans = min(ans, buf);
	}
	cout << ans << endl;
}

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

#define MAXN 1005
#define MAXK 10
typedef long long lint;

using namespace std;

const int mod = 1e9 + 7;
int n, m; 
lint sum, basec, bases, basev, baseh, hori, vert, addh, addv, conn, ish, isv, k;
char s[MAXN][MAXN];

struct matrix {
	lint a[MAXK][MAXK];
	int n;

	matrix(int n = 0):n(n) {
		memset(a, 0, sizeof(a));
	}

	void init() {
		for (int i = 1; i <= n; ++i)
			a[i][i] = 1;
	}

	matrix operator * (const matrix b) const {
		matrix c(n);	
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				for (int k = 1; k <= n; ++k)
					c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j] % mod) % mod;
		return c;
	}
}base, trans;

matrix power(matrix a, lint b) {
	matrix res(a.n);
	res.init();
	while (b) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	} 
	return res;
}

void build() {
	/*for (int i = 1; i <= k; ++i) {
		conn = (sum * basec % mod - hori * ish - vert * isv % mod + mod) % mod;
		hori = (baseh * sum % mod + hori * addh % mod) % mod;
		vert = (basev * sum % mod + vert * addv % mod) % mod;
		sum = sum * bases % mod;	
	}*/
	base = trans = matrix(4);
	base.a[1][1] = conn;
	base.a[1][2] = hori;
	base.a[1][3] = vert;
	base.a[1][4] = sum;
	trans.a[2][1] = -ish;
	trans.a[3][1] = -isv;
	trans.a[4][1] = basec;
	trans.a[2][2] = addh;
	trans.a[4][2] = baseh;
	trans.a[3][3] = addv;
	trans.a[4][3] = basev;
	trans.a[4][4] = bases;
}

int main() {
	scanf("%d%d%lld", &n, &m, &k);
	--k;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			if (j != 1)
				hori += s[i][j] == '#' && s[i][j - 1] == '#';
			if (i != 1)
				vert += s[i][j] == '#' && s[i - 1][j] == '#';
			sum += s[i][j] == '#';
		}
	basec = conn = 1;
	bases = sum;
	baseh = hori;
	basev = vert;
	for (int i = 1; i <= n; ++i)
		if (s[i][1] == s[i][m] && s[i][1] == '#')
			++addh;
	for (int i = 1; i <= m; ++i)
		if (s[1][i] == s[n][i] && s[1][i] == '#')
			++addv;
	ish = addh != 0;
	isv = addv != 0;
	if (ish && isv) {
		puts("1");
		return 0;
	}
	build();
	base = base * power(trans, k);
	/*for (int i = 1; i <= k; ++i) {
		conn = (sum * basec % mod - hori * ish - vert * isv % mod + mod) % mod;
		hori = (baseh * sum % mod + hori * addh % mod) % mod;
		vert = (basev * sum % mod + vert * addv % mod) % mod;
		sum = sum * bases % mod;	
	}*/
	printf("%lld\n", (base.a[1][1] + mod) % mod);
}



/*
4 4 5
.#..
##..
#.#.
###.

3 3 2
###
#.#
###
*/

Measured memory_bytes: 1280
#include<vector>
#include<iostream>
#include<cmath>
int main(){
    int N;
    std::cin>>N;
    std::vector<int>A=std::vector<int>(N);
    long long money=1000;
    long long kabu;
    int index;
    bool isBuy=1;
    for(int i=0;i<N;++i){
        std::cin>>A[i];
    }
    for(int i=0;i<N;++i){
        if(isBuy){
            if(i+1<N){
                index=1;
                while(i+index+1<N && A[i]==A[i+index]){
                    index++;
                }
                if(A[i]<A[i+index]){
                    kabu=money/A[i];
                    money-=kabu*A[i];
                    isBuy=0;
                }else{
                    continue;
                }
            }
        }else{//sell kabu
            if(i+1<N){
                index=1;
                while(i+index+1<N && A[i]==A[i+index]){
                    index++;
                }
                if(A[i]>A[i+index]){
                    money+=kabu*A[i];
                    kabu=0;
                    isBuy=1;
                }else{
                    continue;
                }
            }else{
                money+=kabu*A[i];
                kabu=0;
            }
        }
    }
    std::cout<<money;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ref(i,n) for(long long i=0;i<n;i++)
using namespace std;
#define mo 1000000007

typedef pair<long long,long long> P;
set<P> v;
map<P,long long> mp;

long long gcd(long long m,long long n){
    if(m==0) return n;
    if(n==0) return m;
    if(n>m) return gcd(m,n%m);
    else return gcd(n,m%n);

    }

int main()
{
    int n;
    cin>>n;
    long long a0=0,aa=0,a1=0,yy;

    ref(i,n){
        long long x,y;
        cin>>x>>y;
        if(!x&&!y){aa++;continue;}
        if(y==0) {a0++;continue;}
        if(x==0) {a1++;continue;}
        if(x<0){ x=-x;y=-y;}

        if(y>0) yy=y; else yy=-y;

        P p=P(x/gcd(x,yy),y/gcd(x,yy));

        if(v.find(p)!=v.end()) mp[p]++;
        else {mp[p]=1;v.insert(p);}
    }
    long long ans=1;


    auto j=v.begin();

    ref(i,v.size()){

        P t=*j,p;
        if(t.second<0) {
            p=P(-t.second,t.first);
        }
        else p=P(t.second,-t.first);

        if(v.find(p)!=v.end()){

            long long y1=1,y2=1;

            ref(k,mp[t]) y1=y1*2%mo;
            ref(k,mp[p]) y2=y2*2%mo;

            long long yy=(y1+y2-1)%mo;

            ans=ans*yy%mo;
            mp[t]=0;mp[p]=0;

        }
    j++;
    }


    auto i=mp.begin();

    ref(k,mp.size()){
        long long xx=1;
        ref(k,i->second) xx=xx*2%mo;
        ans=ans*xx%mo;
        i++;
    }



        long long y1=1,y2=1;

        ref(k,a0) y1=y1*2%mo;
        ref(k,a1) y2=y2*2%mo;

        long long ye=(y1+y2-1)%mo;

        ans=ans*ye%mo;



    ans+=aa;
    ans%=mo;
    if(ans==0) ans+=mo;
    cout<<ans-1;
    return 0;

}


Measured memory_bytes: 28580
#include <cstdio>


#define gc getchar
#define pc putchar
#define sp pc(' ')
#define lnn pc('\n')
template <class t>
inline void read(t &num) {
    register bool flag = 0;
    register char c = gc();
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') flag = 1, c = gc();
    num = 0;
    while (c >= '0' && c <= '9') num = (num << 1) + (num << 3) + c - '0', c = gc();
    flag && (num = ~(num - 1));
}
template <class t>
inline void print(t num) {
    if (num < 0) pc('-'), num = ~(num - 1);
    if (num >= 10) print(num / 10);
    pc(num % 10 + '0');
}
int min(int a, int b) {
    return a > b ? b : a;
}

typedef long long ll;

int n;
int ans;
bool flag;
int main() {
    read(n);
    flag = true;
    for (int i = 1; i <= n; i++) {
        if (flag) ans++;
        int x = i;
        while (x % 10 == 9) x /= 10;
        if (x == 0) flag ^= 1;
    }
    print(ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int> > dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      for (int k = 0; k < 1 << (W - 1); ++k) {
        // Check if two horizontal lines are connecting
        // 2 つの横線がつながっていないか調べる
        bool ok = true;
        for (int l = 0; l < W - 2; ++l) {
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
            ok = false;
          }
        }
        if (ok) {
          if (j >= 1 && ((k >> (j - 1)) & 1)) {
            // The case which goes left
            // 左方向に横線をたどるケース
            dp[i + 1][j - 1] += dp[i][j];
            dp[i + 1][j - 1] %= mod;
          } else if (j <= W - 2 && ((k >> j) & 1)) {
            // The case which goes right
            // 右方向に横線をたどるケース
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] %= mod;
          } else {
            // The case which goes straight
            // 横線をたどらないケース
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K - 1] << endl;
  return 0;
}


Measured memory_bytes: 3608
import Control.Monad
import Control.Monad.State

data BaseBallState = BBS { first :: Int
                         , second :: Int
                         , third :: Int
                         , outCount :: Int
                         , point :: Int
                         } deriving Show

main = do
    n <- readLn
    commandSet <- replicateM n $ getUntil3Out 0 []
    mapM_ print $ map (\commands -> evalState (moveGame commands) (BBS 0 0 0 0 0)) commandSet

getUntil3Out :: Int -> [String] -> IO [String]
getUntil3Out n cs = do
    if n == 3 then return cs
              else do
                  c <- getLine
                  if c == "OUT" then getUntil3Out (n+1) cs
                                else getUntil3Out n (cs ++ [c])

moveGame :: [String] -> State BaseBallState Int
moveGame []     = do
    bbs <- get
    return $ point bbs
moveGame (c:cs) = do
    bbs <- get
    doEvent c
    moveGame cs

doEvent :: String -> State BaseBallState Int
doEvent command = case command of
                    "HIT" -> hit
                    "HOMERUN" -> homerun

hit :: State BaseBallState Int
hit = do
    bbs <- get
    put $ BBS { first = 1
              , second = first bbs
              , third = second bbs
              , outCount = outCount bbs
              , point = point bbs + third bbs
              }
    return $ point bbs + third bbs

homerun :: State BaseBallState Int
homerun = do
    bbs <- get
    put $ BBS { first = 0
              , second = 0
              , third = 0
              , outCount = outCount bbs
              , point = point bbs + third bbs + second bbs + first bbs + 1
              }
    return $ point bbs + third bbs + second bbs + first bbs + 1

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

int main(void){
  string s,t;
  int f;

  cin >> s >> t;
  f=1;
  for (int i=0; i<s.size(); i++){
    f &= (s[i]==t[i]);
  }
  cout << (f?"Yes":"No") << endl;
  return 0;
}

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




namespace ConsoleApplication1 {

    class ClassMain {

        public static string revstr(string str){
            char[] ss=str.ToCharArray();
            Array.Reverse(ss);
            return new string(ss);

        }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }

                for (int i = 0; i < n; i++) {
                    HashSet<string> hashs = new HashSet<string>();
                    string str = Console.ReadLine();
                    for (int j = 1; j <= str.Length - 1; j++) {
                        string spl1 = str.Substring(0, j);
                        string spl2 = str.Substring(j);
                        //Console.WriteLine(spl1+"-"+spl2);
                        
                        string newstr = spl1 + spl2;
                        hashs.Add(newstr);
                        newstr = spl2 + spl1;
                        hashs.Add(newstr);

                        newstr = revstr(spl1) + spl2;
                        hashs.Add(newstr);
                        newstr = spl2 + revstr(spl1) ;
                        hashs.Add(newstr);
                    
                        newstr = spl1 + revstr(spl2);
                        hashs.Add(newstr);
                        newstr = revstr(spl2) + spl1;
                        hashs.Add(newstr);

                        newstr = revstr(spl1) + revstr(spl2);
                        hashs.Add(newstr);
                        newstr = revstr(spl2) + revstr(spl1);
                        hashs.Add(newstr);


                    }
                    
                    Console.WriteLine(hashs.Count);
                    
                }



            }
        }
    }
}

Measured memory_bytes: 6276
v,e=map(int,input().split())
dis=[[10**15 for _ in range(v)]for _ in range(v)]
for i in range(e):
	a,b,c=map(int,input().split())
	dis[a][b]=c
for i in range(v):
	dis[i][i]=0
for k in range(v):
	for i in range(v):
		for j in range(v):
			dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])
for i in range(v):
	if dis[i][i]<0:
		print("NEGATIVE CYCLE")
		exit()
for i in range(v):
	ans=[]
	for j in range(v):
		if dis[i][j]>=10**14:
			ans.append("INF")
		else:
			ans.append(dis[i][j])
	print(*ans)


Measured memory_bytes: 6444
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
        signed main() {
    COMinit();
    int k,q;
    cin>>k>>q;
    int d[k];
    for(int i=0;i<k;i++)cin>>d[i];
    int z[k]={},sa[k]={};
    if(d[0]==0){z[0]=1;}
    sa[0]=d[0];
    for(int i=1;i<k;i++){
            z[i]=z[i-1];
            if(d[i]==0)z[i]++;
            sa[i]=sa[i-1]+d[i];
    }
    int n,x,m,n0,zeros,zx,al,ans,t[k];
    for(int i=0;i<q;i++){
            cin>>n>>x>>m;
            n--;
            if(d[0]==0)t[0]=0;
                else t[0]=(d[0]-1)/m;
                for(int i=1;i<k;i++)t[i]=t[i-1]+max(d[i]-1,0ll)/m;
                if(n%k){
                        zeros=z[n%k-1]+(n/k)*(z[k-1]);
                        cerr<<zeros<<endl;
                        zeros+=(sa[n%k-1]+(n/k)*sa[k-1]+x)/m;
                        cerr<<zeros<<endl;
                        zeros-=t[n%k-1]+(n/k)*t[k-1];
                        cerr<<zeros<<endl;

                }else {
                        zeros=(n/k)*(z[k-1]);
                        zeros+=(x+(n/k)*sa[k-1])/m;
                        zeros-=(n/k)*t[k-1];
                }
                zeros-=x/m;
                cout<<n-zeros<<endl;
                

           


    }
    
      }

        


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){

    int h,w;
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0)break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;

    }

}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    int n;
    cin >> n;
    vector<int> arr(n + 1), toBe(n + 1);
    for(int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        toBe[i] = i;
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        if(arr[i] != toBe[i])
            cnt++;
    }
    if(cnt > 2)
        cout << "NO";
    else
        cout << "YES";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    int n,a; cin >> n >> a;
    vector<int> x(n);
    for (int i = 0; i < n; i ++) cin >> x[i];

    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(n + 1,vector<ll>(a * n + 1, 0)));
    for (int i = 0; i  < n + 1; i ++ ) dp[i][0][0] = 1;

    for (int i = 0; i < n; i ++ ) {
        int num = x[i];
        for (int j = 1; j < n + 1; j ++) {
            for (int s = 0; s < n * a + 1; s ++) {
                if (s - num >= 0) dp[i + 1][j][s] = dp[i][j][s] + dp[i][j - 1][s - num];
                else dp[i + 1][j][s] = dp[i][j][s];
            }
        }
    }

    ll ans = 0;
    for (ll i = 1; i < n + 1; i ++) {
        ans += dp[n][i][i * a];
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 52224