akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int x;cin>>x;
  int ans=0;
  int shake=x/500;
  x-=shake*500;
  ans+=shake*1000;
  shake=x/5;
  ans+=shake*5;
  cout<<ans<<endl;
}


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

int main() {
  string S; cin >> S;
  S = '0' + S + '0';
  int N = S.size();
  long long ans = 0;
  for(int i = N-1; i >= 0; i--) {
    int num = S[i] - '0';
    if(S[i+1] >= '6' || (S[i+1] == '5' && S[i] >= '5')) num++;
    ans += S[i] < '5' ? num : 10 - num;
    S[i] = num + '0';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2308
N = int(input())
ret = 0
if N <= 105:
    if N == 105:
        print(1)
    else:
        print(0)
    exit()

ans = 1
for i in range(106, N+1):
    ret = 0
    for j in range(1, i+1):
        if i % j == 0:
            ret += 1
    if ret == 8 and i % 2 == 1:
        ans += 1
print(ans)

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

using namespace std;
int sum(int a,int b,int c,int d){
    return a*c + b*d;
}
int judge(int max,int min){
    if(max < min)   return min;
    else    return max;
    return 0;
}
int main(void)
{
    int x,y,b,p,N,max,jud,hikaku = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x >> y >> b >> p;
        max = sum(x,y,b,p);
        if(b >= 5 && p >= 2){
            max *= 0.8;
            cout << max << endl;
        }else if(b >= 5 && p <= 2){
            jud = x * b + y * 2;
            hikaku = judge(jud,max) * 0.8;
            if(hikaku < max)    cout << hikaku << endl;
            else cout << max << endl;
        }else if(b <= 5 && p >= 2){
            jud = x * 5 + y * p;
            hikaku = judge(jud,max) * 0.8;
            if(hikaku < max)    cout << hikaku << endl;
            else cout << max << endl;
        }else{
            cout << max << endl;
        }
    }
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
        
        DecimalFormat df = new DecimalFormat("0.00000");
        while (true)
        {
        	int n = Integer.parseInt(br.readLine());
        	if (n == 0)
        		break;
        	String[] tensu = br.readLine().split(" ");
        	
        	double sum = 0;
        	double asum = 0;
        	double average = 0;
        	double hensa = 0;
        	for (int i = 0; i < n; i++)
        	{
        		sum += Double.parseDouble(tensu[i]);
        	}
        	average = sum / n;
        	for (int i = 0; i < n; i++)
        	{
        		asum += Math.pow(Double.parseDouble(tensu[i]) - average, 2);
        	}
        	
        	hensa = Math.sqrt(asum / n);
        	System.out.println(df.format(hensa));
        }
    	
	}
}

Measured memory_bytes: 27872
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, d: "List[int]"):
    print(len(set(d)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == '__main__':
    main()


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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const int N = 100;
const int M = 100;
int n, m;
int t[N], h[M];

int main() {
  while (1) {
    scanf("%d%d ", &n, &m);
    if (!n && !m) break;
    int tt = 0, th = 0;
    REP(i,n) {
      scanf("%d ", t+i);
      tt += t[i];
    }
    REP(i,m) {
      scanf("%d ", h+i);
      th += h[i];
    }
    int a = -1, b = -1, sum = 1000000;
    REP(i,n) REP(j,m) {
      int diff = h[j] - t[i];
      int tmp = h[j] + t[i];
      if (tt + diff == th - diff && tmp <= sum) {
        a = i, b = j;
        sum = tmp;
      }
    }
    if (a == -1)
      puts("-1");
    else {
      printf("%d %d\n", t[a], h[b]);
    }
  }
  return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint x[200005], v[200005];
llint pos[200005], p[200005];
llint l[200005], r[200005];
vector<P> vecx, vecv;
llint dp[200005], suma[200005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> v[i];
	
	for(int i = 1; i <= n; i++) vecx.push_back(make_pair(x[i], i));
	for(int i = 1; i <= n; i++) vecv.push_back(make_pair(v[i], i));
	sort(vecx.begin(), vecx.end());
	sort(vecv.begin(), vecv.end());
	
	for(int i = 0; i < vecv.size(); i++) pos[vecv[i].second] = i+1;
	for(int i = 0; i < vecx.size(); i++) p[i+1] = pos[vecx[i].second];
	
	r[0] = 0;
	for(int i = 1; i <= n; i++) r[i] = max(r[i-1], p[i]);
	l[n+1] = n+1;
	for(int i = n; i >= 1; i--) l[i] = min(l[i+1], p[i]);
	
	llint* sum = suma+1;
	dp[0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = r[i-1]; j <= r[i]; j++) sum[j] = (sum[j-1] + dp[j]) % mod;
		llint tmp = (sum[r[i]] - sum[l[i]-2] + mod) % mod;
		dp[r[i]] += tmp, dp[r[i]] %= mod;
	}
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 20588
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	vector<pair<string, pair<ll, string> > > hoge;
	vector<pair<string, pair<ll, string> > > a(8);
	vector<pair<string, pair<ll, string> > > b(8);
	vector<pair<string, pair<ll, string> > > c(8);
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		a[i].second.first = p;
		a[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		a[i].first = tn;
	}
	sort(ALL(a));
	cout<<a[0].second.first<<" "<<a[0].second.second<<endl;
	cout<<a[1].second.first<<" "<<a[1].second.second<<endl;
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		b[i].second.first = p;
		b[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		b[i].first = tn;
	}
	sort(ALL(b));
	cout<<b[0].second.first<<" "<<b[0].second.second<<endl;
	cout<<b[1].second.first<<" "<<b[1].second.second<<endl;
	REP(i, 8) {
		int p;
		string t;
		cin>>p>>t;
		string tn;
		c[i].second.first = p;
		c[i].second.second = t;
		REP(i, t.size()) {
			if(t[i] == '.') {
				t.erase(t.begin() + i);
			}
		}
		tn = t;
		c[i].first = tn;
	}
	sort(ALL(c));
	cout<<c[0].second.first<<" "<<c[0].second.second<<endl;
	cout<<c[1].second.first<<" "<<c[1].second.second<<endl;
	REP(i, 6) {
		hoge.pb(a[2 + i]);
	}
	REP(i, 6) {
		hoge.pb(b[2 + i]);
	}
	REP(i, 6) {
		hoge.pb(c[2 + i]);
	}
	sort(ALL(hoge));
	cout<<hoge[0].second.first<<" "<<hoge[0].second.second<<endl;
	cout<<hoge[1].second.first<<" "<<hoge[1].second.second<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  int i, j, k;
  for (i = 0; i < n; i++) {
    cin >> w.at(i);
  }

  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (w.at(i) == w.at(j)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for (i = 0; i < n - 1; i++) {
    if (w.at(i).at(w.at(i).length() - 1) != w.at(i + 1).at(0)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> c(n);
    for (int i=0; i<n; ++i){
        cin >> c[i];
    }
    int ans=1;
    int k=0;
    for (int i=0; i<n; ++i){
        k+=c[i];
        if(k <= x) ++ans;
    }
    cout << ans << endl;
}

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

    # divisors.sort()
    return divisors

n = int(input())
a_list = list(map(int, input().split()))

a_list.reverse()

cnt_list = [0] * (2 * (10 ** 5) + 1)
ret = [0] * (2 * (10 ** 5) + 1)

for i in range(len(a_list)):
    if (a_list[i] == 1 and cnt_list[n-i] % 2 == 0) or (a_list[i] == 0 and cnt_list[n-i] % 2 == 1):
        ret[n-i] = 1
        div_list = make_divisors(n-i)
        for div in div_list:
            if cnt_list[div] == 0:
                cnt_list[div] = 1
            else:
                cnt_list[div] = 0

m = ret.count(1)
print(m)
for i in range(n+1):
    if ret[i] == 1:
        print(i)


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

int main()
{
	int n;
	while (cin >> n, n) {
		n = 1000 - n;
		cout << (n / 500 + n % 500 / 100 + n % 100 / 50 + n % 50 / 10 + n % 10 / 5 + n % 5) << endl;
	}
	return 0;
}



Measured memory_bytes: 3080
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

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

    static class EDividingChocolate {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();
            int k = in.nextInt();
            int res = Integer.MAX_VALUE;
            char[][] c = new char[h][w];
            int[][] acc = new int[h + 1][w + 1];

            for (int i = 0; i < h; i++) {
                c[i] = in.next().toCharArray();
            }

            for (int j = 0; j <= w; j++) {
                for (int i = 0; i <= h; i++) {
                    if (i > 0 && j > 0) {
                        if (c[i - 1][j - 1] == '1') {
                            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1] + 1;
                        } else {
                            acc[i][j] = acc[i - 1][j] + acc[i][j - 1] - acc[i - 1][j - 1];
                        }
                    } else {
                        acc[i][j] = 0;
                    }
                }
            }

            for (int i = 0; i < Math.pow(2, h - 1); i++) {
                // 必要な情報はc, k, i
                int cmp = func(acc, k, i);
                res = Math.min(res, cmp);
                // System.out.println(cmp);
            }

            out.println(res);

        }

        int func(int[][] acc, int k, int x) {
            ArrayList<Integer> al = new ArrayList<>();
            al.add(0);
            int cnt = 1;
            while (x > 0) {
                if (x % 2 == 1) {
                    al.add(cnt);
                }
                cnt++;
                x /= 2;
            }
            al.add(acc.length - 1);

            // System.out.println(al.toString());

            int res = al.size() - 2;
            int last = 0;

            for (int i = 0; i < acc[0].length; i++) {
                for (int j = 1; j < al.size(); j++) {

                    // System.out.println(al.get(j));
                    // System.out.println(acc[al.get(j)][i]);

                    if ((acc[al.get(j)][i] - acc[al.get(j)][last])
                            - (acc[al.get(j - 1)][i] - acc[al.get(j - 1)][last]) > k) {
                        if (last == i - 1) {
                            return 114514;
                        }
                        res++;
                        last = i - 1;
                        // System.out.println("cut: " + last);
                    }
                }
            }
            return res;
        }

    }
}



Measured memory_bytes: 23812
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
lst=[0]*(n+1)
for i in range(n+1):
    lst[i]=abs(a[i+1]-a[i])
s=sum(lst)
for i in range(1,n+1):
    print(s-lst[i-1]-lst[i]+abs(a[i+1]-a[i-1]))

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

template<ll mod=MOD>
ll modpow(ll x,ll n){
  if(n==0)return 1;
  if(n%2)return ((x%mod)*(modpow(x,n-1)%mod))%mod;
  else {
    ll half=modpow(x,n/2)%mod;
    return (half*half)%mod;
  }
}

#define int ull

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

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

  vector<ll>B=A;
  vector<map<int,ll>>vec(N);
  for(int i=0;i<N;i++){
    for(int j=2;j*j<=A[i];j++){
      while(A[i]%j==0)A[i]/=j,vec[i][j]=(vec[i][j]+1)%MOD;
    }
    if(A[i]!=1)vec[i][A[i]]=1;
  }

  map<int,ll>LCM;
  for(int i=0;i<N;i++){
    for(auto it:vec[i]){
      LCM[it.first]=max(LCM[it.first],it.second);
    }
  }

  ll lcm=1;
  for(auto it:LCM)lcm=((lcm%MOD)*modpow(it.first,it.second))%MOD;
  lcm%=MOD;

  for(int i=0;i<N;i++)B[i]%=MOD;
  ll ans=0;
  lcm%=MOD;
  for(int i=0;i<N;i++){
    ans=(((modpow(B[i],MOD-2)*lcm)%MOD)+ans%MOD)%MOD;
  }
  cout<<ans%MOD<<endl;

  return 0;
}


Measured memory_bytes: 3968
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] values = new int[3];
        for (int i = 0; i < 3; i++) {
            values[i] = sc.nextInt();
        }
        Arrays.sort(values);

        if ((3 * values[2] % 2) == ((values[0] + values[1] + values[2]) % 2)) {
            int ans = ((3 * values[2]) - (values[0] + values[1] + values[2])) / 2;
            System.out.println(ans);
        } else {
            int ans = ((3 * (values[2] + 1)) - (values[0] + values[1] + values[2])) / 2;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 22868
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := ReadInt()
	fmt.Println(3 * r * r)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int a[N<<1];
int main() {
    //freopen("in.txt","r",stdin);
	int k,n;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		a[i+n]=a[i]+k;
	}
	int ans=1e9;
	for(int i=0;i<n;i++) {
		ans=min(ans,a[i+n-1]-a[i]);
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a1 = sc.nextInt();
    int a2 = sc.nextInt();
    int a3 = sc.nextInt();
    
    if(a1 <= 13 && a1 >= 1  && a2 <= 13 && a2 >= 1 && a3 <= 13 && a3 >= 1){
      if(a1 + a2 + a3 >= 22){
      System.out.println("bust");
      }else {
      System.out.println("win");
      }
    }else{
      System.out.println("入力条件を満たしていません");
    }
  }
}

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

using ll = long long;
const int maxn = 3e3 + 3;
const ll mo = 998244353;

ll mpow(ll u, ll k) {
    ll ans = 1;
    for(; k > 0; k >>= 1, u = u * u % mo) {
        if(k & 1)
            ans = ans * u % mo;
    }
    return ans;
}

ll tp;

int n, s, a[maxn];
ll dp[maxn];

int main() {
    tp = mpow(2, mo - 2);
    scanf("%d%d", &n, &s);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    dp[0] = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = s; j >= a[i]; --j) {
            dp[j] = (dp[j] + dp[j - a[i]] * tp) % mo;
        }
    }
    ll ans = dp[s] * mpow(2ll, n) % mo;
    printf("%lld\n", (ans + mo) % mo);
    return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  vector<bool> ab(8001, true);
  vector<bool> bc(8001, true);
  vector<bool> ca(8001, true);
  REP(i, 4001) {
    REP(j, b.size()) {
      if(i+j >= a.size()) break;
      if(a[i+j] != '?' && b[j] != '?' && a[i+j] != b[j]) ab[4000+i] = false;
    }
    REP(j, c.size()) {
      if(i+j >= b.size()) break;
      if(b[i+j] != '?' && c[j] != '?' && b[i+j] != c[j]) bc[4000+i] = false;
    }
    REP(j, a.size()) {
      if(i+j >= c.size()) break;
      if(c[i+j] != '?' && a[j] != '?' && c[i+j] != a[j]) ca[4000+i] = false;
    }
    REP(j, a.size()) {
      if(i+j >= b.size()) break;
      if(b[i+j] != '?' && a[j] != '?' && b[i+j] != a[j]) ab[4000-i] = false;
    }
    REP(j, b.size()) {
      if(i+j >= c.size()) break;
      if(c[i+j] != '?' && b[j] != '?' && c[i+j] != b[j]) bc[4000-i] = false;
    }
    REP(j, c.size()) {
      if(i+j >= a.size()) break;
      if(a[i+j] != '?' && c[j] != '?' && a[i+j] != c[j]) ca[4000-i] = false;
    }
  }
  int ans = 1e9;
  REP(bx, 8000) REP(cx, 8000) {
    if(ab[bx] && bc[min(8000, max(0, cx-bx+4000))] && ca[8000-cx]) {
      int l = min(cx, min(4000, bx));
      int r = max(cx+c.size(), max(4000+a.size(), bx+b.size()));
      chmin(ans, r-l);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d;cin>>n>>d;
  cout<<(n-1)/(d*2+1)+1<<endl;
  return 0;

}


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

typedef long long ll;
const int maxn = 1e5 + 5;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n;

int main()
{
	double d, x;
	n = gi();
	scanf("%lf%lf", &d, &x);
	double ans = 0;
	++n;
	while ((n--) > 1) {
		ans += d + (n - 0.5) * x;
		d = (5 * x + (2 * n + 2) * d) / (2 * n);
		x = (2 * n + 4) * x / 2 / n;
	}
	printf("%.10lf\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int r;
    cin >> r;
    double pi = 3.14159265358979;
    cout << 2*r*pi << endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <complex>
#include <cmath>
#include <algorithm>
#include <valarray>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

template<ll MD>
struct SMatrix {
    typedef ll D;
    vector<valarray<D>> d;
    SMatrix() {}
    int N, M;
    SMatrix(int n, int m) {
        N = n; M = m;
        d.resize(n);
        for (int i = 0; i < N; i++) {
            d[i] = valarray<D>(D(0), m);
        }
    }
    valarray<D>& operator[](int p) {
        return d[p];
    }
    const valarray<D>& operator[](int p) const {
        return d[p];
    }

    SMatrix operator*(const SMatrix &right) {
        assert(M == right.N);
        SMatrix res(N, right.M), r(right.M, right.N);
        for (int i = 0; i < right.M; i++) {
            for (int j = 0; j < right.N; j++) {
                r[i][j] = right[j][i];
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < right.M; j++) {
                res[i][j] = (d[i]*r[j]%MD).sum()%MD;
            }
        }
        return res;
    }

    SMatrix pow(ll p) {
        assert(N == M);
        SMatrix res(N, M), buf = *this;
        for (int i = 0; i < N; i++) {
            res[i][i] = D(1);
        }
        while (p != 0) {
            if (p % 2) {
                res = res*buf;
            }
            p /= 2;
            buf = buf*buf;
        }
        return res;
    }
};

const ll MD = 1e9+9;

SMatrix<MD> res;

ll w;
void mul(ll x) {
    SMatrix<MD> p(w, w);

    for (int i = 0; i < w; i++) {
        for (int j = -1; j <= 1; j++) {
            if (i+j < 0) continue;
            if (w <= i+j) continue;
            p[i][i+j] = 1;
        }
    }
    p = p.pow(x);

    res = p * res;
}

bool solve(int ca) {
    ll h, n;
    cin >> w >> h >> n;
    if (!w) return false;
    res = SMatrix<MD>(w, 1);
    vector<P> v;
    vector<ll> u;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y; x--; y--;
        v.push_back(P(x, y));
        u.push_back(y);
    }
    u.push_back(0);
    u.push_back(h-1);
    sort(u.begin(), u.end());
    res[0][0] = 1;
    for (int i = 1; i < (int)u.size(); i++) {
        mul(u[i]-u[i-1]);
        for (P p: v) {
            if (p.second != u[i]) continue;
            res[p.first] = 0;
        }
    }
    printf("Case %d: %lld\n", ca, res[w-1][0]);
    return true;
}

int main() {
    int ca = 1;
    while (true) {
        if (!solve(ca)) break;
        ca++;
    }
    return 0;
}

Measured memory_bytes: 1452
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    long ans=0,anstmp=0;
    if (((M-1)/N != Q/N)) {
        cout<<"OK"<<endl;
    } else {
        cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, p;
	cin >> n >> p;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<vector<ll>> dp(n+1, vector<ll>(5005, 0));
	dp[0][0] = 1;
	rep(i,n)rep(j,5001){
		dp[i+1][j] += dp[i][j];
		if(j+a[i] <= 5000) dp[i+1][j+a[i]] += dp[i][j];
	}
	ll ans = 0;
	rep(j,5001){
		if(j%2 == p) ans += dp[n][j];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct P{
	int a,b;
	bool operator < (const P&t)const{
		return a<t.a;
	}
}x[100005];
long long ans;
priority_queue<int>Q;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d %d",&x[i].a,&x[i].b);
		x[i].a=m-x[i].a+1;
	}
	sort(x+1,x+n+1);
	int z=n;
	for(int i=m;i;--i){
		while(x[z].a==i){
			Q.push(x[z].b);
			z--;
		}
		if(!Q.empty()){
			ans+=Q.top();
			Q.pop();
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1660
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k,a,b[262144]={0},p,x[262144],r=0;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){scanf("%d",&a);
        //if(b[a]==0){kind++;}
        b[a]++;
    }
    p=0;
    for(i=1;i<=n;i++){
        if(b[i]!=0){x[p]=b[i];p++;}
    }
    qsort(x,p,sizeof(int),sortfncsj);
    for(i=0;i<(p-k);i++){r+=x[i];}
    printf("%d\n",r);
    return 0;
}

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

int main(){
  string strA,strB;
  bool chk = true;
  
  cin >> strA >> strB;
  
  if(strA.size() > strB.size()) cout << "GREATER";
  else if(strA.size() < strB.size()) cout << "LESS";
  else{
    while(chk == true){
      if(stoi(strA.substr(0,1)) > stoi(strB.substr(0,1))){
        cout << "GREATER";
        chk = false;
      }else if(stoi(strA.substr(0,1)) < stoi(strB.substr(0,1))){
        cout << "LESS";
        chk = false;
      }else{
        if(strA.size() == 1){
          cout << "EQUAL";
          chk = false;
        }else{
          strA.erase(0,1);
          strB.erase(0,1); 
        }
      }
    }
  }
}

Measured memory_bytes: 256
import math

L = int(input())
n = int(math.log2(L))
N = n + 1

edges = []
for i in range(1, N):
    edges.append((i, i + 1, 0))
    edges.append((i, i + 1, 2 ** (n - i)))

res = L - 2 ** n
bits = format(res, '0' + str(n) + 'b')
weight = 2 ** n
for i, bit in enumerate(bits):
    if int(bit):
        edges.append((1, i + 2, weight))
        weight += 2 ** (n - i - 1)

print(N, len(edges))
for row in edges:
    print(*row)


Measured memory_bytes: 3064
N = int(input())
p = dict()
for i in range(N):
    s = input()
    if not s in p:
        p[s] = 0
    p[s] += 1
m = max(p.values())
ans = [k for k in p.keys() if p[k] == m]
ans = sorted(ans)
for j in range(len(ans)):
    print(ans[j])

Measured memory_bytes: 35468
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (n, m): (usize, usize) = (sc.read(), sc.read());

    let mut dp: Vec<Vec<i64>> = vec![vec![0; n + 1]; n + 1];
    dp[1][n - 1] = 1 as i64;
    for _i in 0..m {
        let mut nxt: Vec<Vec<i64>> = vec![vec![0; n + 1]; n + 1];
        for j in 0..n + 1 {
            for k in 0..n + 1 {
                nxt[n - k][k] += dp[j][k] * j as i64;
                nxt[n - k][k] %= MODLL;
                if k != 0 {
                    nxt[j][k - 1] += dp[j][k] * k as i64;
                    nxt[j][k - 1] %= MODLL;
                }
                nxt[j][k] += dp[j][k] * (n - k - j) as i64;
                nxt[j][k] %= MODLL;
            }
        }
        dp = nxt;
    }

    let ans = dp[n].iter().fold(0, |sum, a| sum + a) % MODLL;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 100006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

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

ll dp[3005];

int main()
{
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  vi v;
  for(ll i=1;i*i<=n;i++)
  {
     if(n%i==0)
     {
        v.pb(i);
        if((n/i)!=i)
           v.pb(n/i);

     } 
  }

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

  for(int i=0;i<v.size();i++)
  {
    dp[i]=pow(k,(v[i]+1)/2,mod);
    //dp[i] stores all possible palindrome of length v[i];
    for(int j=0;j<i;j++)
    {
       if(v[i]%v[j]==0)
         {
           dp[i]-=dp[j];
           dp[i]+=mod;
           dp[i]%=mod;
         }
      //subtracts all its divisors since it is alredy counted
    }
    //if length is odd then all the cycles would produce a distinct seq;
    //else it would repeat after length/2
    //for ex 123321 ->321123 after 3 moves
    if(v[i]&1)
     {
        ans=(ans+(dp[i]*v[i])%mod);
        ans%=mod;
     }
     else
     {
       ans=(ans+(dp[i]*(v[i]/2))%mod);
       ans%=mod;
     }

  }

  cout << ans;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    priority_queue<int> que;
    rep(i, N) que.push(A[i]);

    rep(i, M) {
        int value = que.top(); que.pop();
        value /= 2;
        que.push(value);
    }

    ll ans = 0;
    rep(i, N) {
        ans += que.top(); que.pop();
    }

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

Measured memory_bytes: 4296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    //  cout << x << " ";
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}
int h, n;
vector<pair<int, int>> v(10001);
int dp[10001][10001];
int solve(int in, int sum)
{
   // cout << sum << " ";
    if (in >= n && sum > 0)
    {
        return 1e15;
    }
    if (sum <= 0)
    {
        return 0;
    }
    int ze = 0;
    if(dp[in][max(ze,sum)]!=-1){
        return dp[in][max(ze, sum)];
    }
    int ans = 1e15;
    int s = sum - v[in].F;
    ans = min(ans, solve(in + 1, sum));
    ans = min(ans, v[in].S + solve(in, s));
    return dp[in][max(ze,sum)]=ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;
    memset(dp, -1, sizeof(dp));
    while (tc--)
    {
       
        cin >> h >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> v[i].F >> v[i].S;
        }
        int ans = solve(0, h);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 782336
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxm=2e3+5;
const int mod=1e9+7;
int d[maxm];
int n;
signed main(){
    cin>>n;
    d[0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i-3;j++)
		{
            d[i]+=d[j];
            d[i]%=mod;
        }
    }
    cout<<d[n]<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  bool possible = true;
  map<char,int>reps;
  int a=0,b=0,c=0;
  for(int i=0;i<s.length();i++){
  	if(s[i]=='a'){
  		a++;
  	}else if(s[i]=='b'){
  		b++;
  	}else{
  		c++;
  	}
  }

  if(c-b>1||c-a>1||b-c>1||b-a>1||a-c>1||a-b>1){
  	cout<<"NO"<<endl;
  }else{
  	cout<<"YES"<<endl;
  }
}  



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

int main() {
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    sort(a,a+n);
    int sum = 0;
    rep(i,n-1)sum+=a[i];
    if(a[n-1]>=sum)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	return 0;
}

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

#define loop(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
typedef long long ll;


bool solve(int l1, int r1, int l2, int r2, bool isFirst){
    bool res = false;

    //cout << l1 << ' ' << r1 << ' ' << isFirst << endl;

    if(isFirst && l1 >= 5 && r1 >= 5){
        return false;
    }
    if(!isFirst && l2 >= 5 && r2 >= 5){
        return true;
    }

    if(isFirst){
        if(l1 < 5) {
            if(l2 < 5) res |= solve(l1, r1, l2+l1, r2, !isFirst);
            if(r2 < 5) res |= solve(l1, r1, l2, r2+l1, !isFirst);
        }
        if(r1 < 5){
            if(l2 < 5) res |= solve(l1, r1, l2+r1, r2, !isFirst);
            if(r2 < 5) res |= solve(l1, r1, l2, r2+r1, !isFirst);
        }
    } else {
        if(l2 < 5) {
            if(l1 < 5) res |= !solve(l1+l2, r1, l2, r2, !isFirst);
            if(r1 < 5) res |= !solve(l1, r1+l2, l2, r2, !isFirst);
        }
        if(r2 < 5){
            if(l1 < 5) res |= !solve(l1+r2, r1, l2, r2, !isFirst);
            if(r1 < 5) res |= !solve(l1, r1+r2, l2, r2, !isFirst);
        }
        res = !res;
    }

    return res;
}

int main(){
    int l1, r1, l2, r2;
    while(cin >> l1 >> r1 >> l2 >> r2){
        cout << (solve(l1,r1,l2,r2,true) ? "ISONO" : "NAKAJIMA") << endl;
    }
}

Measured memory_bytes: 1156
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

getTuple3 :: IO (Int, Int, Int)
getTuple3 = (\[a,b,c] -> (a, b, c)) . map read . words <$> getLine

f (a, b, c) (a', b', c') = (a' + max b c, b' + max c a, c' + max a b)

main = readLn >>= flip replicateM getTuple3 >>= print . (\(a,b,c) -> max a (max b c)) . foldl1 f

Measured memory_bytes: 159100
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
        
    while(true){
        cin >> x;
        cin >> y;
        if(x==0 && y==0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
}


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

using namespace std;

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

// 46786 - 106

vector<int> fin;
vector<int> fup;
vector<vector<int>> edges;

int br = 0;
int ttime = 0;


void dfs(int node, int parent=-1) {
    fin[node] = ttime;
    ++ttime;
    fup[node] = ttime;
    for (auto out : edges[node]) {
        if (out == parent) {
            continue;
        }
        if (fin[out] != -1) {
            fup[node] = min(fup[node], fin[out]);
        } else {
            dfs(out, node);
            fup[node] = min(fup[node], fup[out]);
            if (fup[out] > fin[node]) {
                ++br;
            }
        }
    }
}



void oneCase() {
   int n, m;
   cin >> n >> m;
   edges.resize(n);
   for (int i = 0; i < m; ++i) {
       int a, b;
       cin >> a >> b;
       --a;
       --b;
       edges[a].pb(b);
       edges[b].pb(a);
   }
   fin.assign(n, -1);
   fup.assign(n, -1);
   dfs(0);

   cout << br << "\n";


}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define NEXT_NONE			0
#define NEXT_CHECK_NUM		1
#define NEXT_INCLUDE3		2
#define NEXT_END_CHECK_NUM	3

void call(int n){
	int next;
	int i,x;
	
	i = 1;
	next = NEXT_CHECK_NUM;
	for(;;){
		if( next == NEXT_CHECK_NUM ){
			x = i;
			if( x % 3 == 0 ){
				printf(" %d",i);
				next = NEXT_END_CHECK_NUM;
			} else {
				next = NEXT_INCLUDE3;
			}
		} else if(next == NEXT_INCLUDE3 ){
			if( x % 10 == 3 ){
				printf(" %d",i);
				next = NEXT_END_CHECK_NUM;
			} else {
				x /= 10;
				if( x ){
					next = NEXT_INCLUDE3;
				} else {
					next = NEXT_END_CHECK_NUM;
				}
			}
		} else if(next == NEXT_END_CHECK_NUM ){
			if( ++i <= n ){
				next = NEXT_CHECK_NUM;
			} else {
				printf("\n");
				next = NEXT_NONE;
			}
		} else {
			break;
		}
	}
}

int main(int argc, char **argv){
	int n;

	// Input
	scanf("%d",&n);

	// Call
	call(n);
	
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k= sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int cnt =0;

        for(int i =a;i<=b;i++){
            if(i%k==0){
                cnt++;
            }
        }
        if(cnt>0){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
    }
}

Measured memory_bytes: 35880
n=int(input())
a=[int(input()) for _ in range(n)]

q=[]

def bisect_desc(a,x):
    r = len(a)
    if r == 0:
        return 0
    l = 0
    while l != r:
        f = (l+r)//2
        if a[f] >= x:
            l = f+1
        else:
            r = f
    return l

for sa in a:
    t = bisect_desc(q,sa)
    if t ==len(q):
        q.append(sa)
    else:
        q[t] = sa

print(len(q))

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    vector<int> v(3);
    int t = 0;
    REP(i,3){
        cin >> v[i];
    }
    int ans = 0;
    sort(ALL(v));
    IREP(i, 3)v[i] -= v[0];
    REP(i, 3)t += (v[i] % 2==0);
    REP(i, 3)
    {
        if (t == 1 && (v[i] % 2) == 1)
        {
            v[i]++;
            ans++;
        }
        if (t == 2 && (v[i] % 2) == 0)
        {
            v[i]++;
            ans++;
        }
    }
    ans += v[2] - v[1] + v[2] - v[0];
    ans /= 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
a = y2 - y1
b = x2 - x1

x3 = x2 - a
y3 = y2 + b
x4 = x1 - a
y4 = y1 + b
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
N=int(input())
a=[]
for i in range(4):
  a.append(N%10)
  N//=10
if (a[0]==a[1] and a[1]==a[2]) or (a[2]==a[1] and a[1]==a[3]) :
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 3316
mod=10**9+7
N,M=map(int,input().split())
alist = [True]*(N+1)
for i in range(M):
  alist[int(input())] = False

#print(alist)
reslist = [0]*(N+1)
reslist[0] = 1
if alist[1]:
  reslist[1] = 1

for i in range(2,N+1):
  if alist[i]:
    reslist[i] = (reslist[i-2]+reslist[i-1])%mod
  else:
    reslist[i] = 0
    
#print(reslist)
print(reslist[N])

Measured memory_bytes: 7668