akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  // cin>>t;
  t=1;
  while(t--){
    string s;
    cin>>s;
    ll maxcnt=0;
    ll n=s.size();
    forn(i,0,n){
      ll j=i, cnt=0;
      if(s[i]=='S')
        continue;
      while(j<n && s[j]=='R'){
        j++;
      }
      cnt = j-i;
      maxcnt=max(maxcnt,cnt);
      i=j-1;
    }
    cout<<maxcnt<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
vi g[N];
int u[N];

void dfs(int x, int p, int d){
	DEBUG("%d->%d: %d\n", p+1, x, d);
	u[x]=d;
	for(int &i : g[x]){
		if(i==p) continue;
		dfs(i, x, d+1);
	}
}

int main(){
	int n; scanf("%d", &n);
	REP(i, n-1){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		g[a].EB(b);
		g[b].EB(a);
	}
	dfs(0, -1, 0);
	int mx=0;
	REP(i, n) if(u[i]>u[mx]) mx=i;
	DEBUG("\n");
	dfs(mx, -1, 0);
	REP(i, n) if(u[i]>u[mx]) mx=i;
	DEBUG("diam=%d\n", u[mx]);
	if(u[mx]%3==1){
		printf("Second\n");
	}else{
		printf("First\n");
	}
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=100001;
bool is_prime[max_n];
int prime[max_n];
int sieve(int n){
    int p=0;
    rep(i,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    FOR(i,2,n+1){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int cnt[100001];
int main(){
    sieve(100001);
    int sum=0;
    for(int i=3;i<=100000;++i){
        if(i%2==1&&is_prime[i]&&is_prime[(i+1)/2]) ++sum;
        cnt[i]=sum;
    }
    int q,l,r;
    cin>>q;
    rep(i,q){
        cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root, NIL;
Node treeSearch(Node a, int b);
void insert(int);
void inorder(Node);
void preorder(Node);
int main(){
  int n, i, m;
  char c[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf("%d", &m);
      Node t = treeSearch(root, m);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( c[0] == 'i' ){
      scanf("%d", &m);
      insert(m);
    } else if ( c[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
Node treeSearch(Node a, int b){
  while( a != NIL && b != a->key ){
    if ( b < a->key ) a = a->left;
    else a = a->right;
  }
  return a;
}
void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}
void inorder(Node a){
  if ( a == NIL ) return;
  inorder(a->left);
  printf(" %d", a->key);
  inorder(a->right);
}
void preorder(Node a){
  if ( a == NIL ) return;
  printf(" %d", a->key);
  preorder(a->left);
  preorder(a->right);
}



Measured memory_bytes: 20472
import sys
input=sys.stdin.readline

def main():
    mod=1000000007
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    if k==1:
        return 0
    A.sort(reverse=True)
    
    Fact=[1] #階乗
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=pow(Fact[-1],mod-2,mod)
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod
    
    ans=0
    for i,a in enumerate(A):
        if i==0:
            ans+=a*comb(n-i-1,k-1)
        elif i==n-1:
            ans-=a*comb(i,k-1)
        else:
            #print(a*comb(n-i-1,k-1),a*comb(i,k-1))
            ans+=a*comb(n-i-1,k-1)
            ans-=a*comb(i,k-1)
        ans%=mod
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 62376
def main():
    h, w = map(int, raw_input().split())
    aa = [map(int, raw_input().split()) for _ in xrange(h)]
    bb = [map(int, raw_input().split()) for _ in xrange(h)]
    dp = [{aa[0][0] - bb[0][0]}]
    for x in xrange(1, w):
        a = aa[0][x] - bb[0][x]
        ab = set()
        for c in dp[-1]:
            ab.add(abs(c + a))
            ab.add(abs(c - a))
        dp.append(ab)
    dp = [dp]
    for y in xrange(1, h):
        a = aa[y][0] - bb[y][0]
        ab = set()
        for c in dp[y - 1][0]:
            ab.add(abs(c + a))
            ab.add(abs(c - a))
        dp.append([ab])
        for x in xrange(1, w):
            a = aa[y][x] - bb[y][x]
            ab = set()
            for c in dp[y - 1][x]:
                ab.add(abs(c + a))
                ab.add(abs(c - a))
            for c in dp[y][x - 1]:
                ab.add(abs(c + a))
                ab.add(abs(c - a))
            dp[-1].append(ab)
    print min(abs(c) for c in dp[-1][-1])


main()


Measured memory_bytes: 505500
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  ll h[n];
  fo(i,n)
  cin>>h[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=2;i<n;i++)
  {
    dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    for(ll j=2;j<=k;j++)
    {
      if(i-j<0)
        break;
      dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
  }
  cout<<dp[n-1];
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, T;
    cin >> N >> T;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    sort(items.begin(), items.end());
    vector<vector<ll>> dp(N + 1, vector<ll>(T + 3005, 0));
    rep(i, N) {
        P p = items[i];
        ll a = p.first;
        ll b = p.second;
        rep(j, T + 3005) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j < T) {
                dp[i + 1][j + a] = max(dp[i + 1][j + a], dp[i][j] + b);
            }
        }
    }
    ll ans = 0;
    rep(i, T + 3005) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 141184
from collections import deque

K = int(input())
que = deque(range(1, 10))

for _ in range(K - 1):
    x = que.popleft()
    if x % 10 != 0:
        que.append(10 * x + x % 10 - 1)
    que.append(10 * x + x % 10)
    if x % 10 != 9:
        que.append(10 * x + x % 10 + 1)

print(que.popleft())


Measured memory_bytes: 11912
S = list(input())

res = True
for i, s in enumerate(S, 1):
    if i % 2 == 0:
        if s not in ['L', 'U', 'D']:
            res = False
    else:
        if s not in ['R', 'U', 'D']:
            res = False

print("Yes" if res else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename V> typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V> typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int N,Q;
string S;
vector<pair<char, char>> E;

int check(int i){ // O(N)
  rep(q, Q){
    if (S[i]!=E[q].first) continue;
    if (E[q].second=='L') i--;
    if (E[q].second=='R') i++;
    if (i==-1) return -1;
    if (i==N) return 1;
  }
  return 0;
}

int solve(){
  cin>>N>>Q;
  cin>>S;
  rep(q, Q){
    char c, d;cin>>c>>d;
    dump(c, d);
    E.pb(mp(c, d));
  }
  // rep(i, N){
  //   dump(check(i));
  // }

  int left = -1;
  int right = N;
  while (right-left>1){
    int mid = (right+left)/2;
    if (check(mid)!=-1) { right = mid;}
    else{ left = mid; }
  }

  int l = right;

  left = -1;
  right = N;
  while (right-left>1){
    int mid = (right+left)/2;
    if (check(mid)==1) { right = mid;}
    else{ left = mid; }
  }
  int r = right;
  dump(l, r);

  cout << r-l << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1100
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e5+1;
  ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
  //
  //	
  	ll solve(){
  		vector<float> vec;
  		cout<<fixed<<setprecision(16);
  		rep(i,0,18)
  			vec.pb(pow(2,i));
  		sort(all(vec));
  		double n,k;
  		cin>>n>>k;
  		double ans=0;
  		rep(i,1,n+1){
  			if(i<k)	{
	  			float  t=1.0*k/i;
	  			ans+=1.0/(*lb(all(vec),t)*n);
	  			// cout<<(*lb(all(vec),t))<<" ";
  			}
  			else
  				ans+=1.0/n;
  		}
  		// ans/=n;
  		cout<<ans;
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 256
#coding:utf-8
  
import sys
import copy
  
def main():
    line = sys.stdin.readline()
    #case
    while line.split() != ["0","0"]:
        analy(line)
        line = sys.stdin.readline()
    return
  
def analy(line):
    #????
    field = [int(n) for n in line.split()]
    # ???A?c
    num = int(sys.stdin.readline())
    data = []
    for i in range(num):
        a = sys.stdin.readline()
        b = [int(n) for n in a.split()]
        #???A?c
        data.append(b)
    print (compute(field, data))
  
def compute(field, ng):
    list = []
    for i in range(field[1]):
        for j in range(field[0]):
            #???¨?c???????????¢??
                if i == 0 :
                    #??????
                    if [j+1,i+1] in ng:
                        list.append(0)
                    elif j == 0:
                        #?¶?????¢
                        list.append(1)
                    else:
                        list.append(list[j-1])
                else:
                    if [j+1,i+1] in ng:
                        list[j] = 0
                    elif j != 0:
                    #no left >> the same.
                        list[j] = list[j-1] + list[j]
    return list[len(list)-1]
  
if __name__ == "__main__":
    main()

Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
const ll mod=1e9+7;
ll dp[3100000];
main(){
  int n=in();
  ll ans=0;
  dp[1]=1;
  dp[2]=mod-1;
  rep2(i,1,n){
  dp[i]=(dp[i]%mod+mod)%mod;
  dp[i]=(dp[i]+dp[i-1])%mod;
  ans+=(n-1)*dp[i]%mod;
  if(i==n){ans+=dp[i];break;}
  ans+=dp[i]*(n-1)%mod*(n-2)%mod;
  ans%=mod;
  dp[i+1]+=dp[i];
  dp[i+2]-=dp[i];
  dp[i+3]+=dp[i];
  dp[i+n+2]-=dp[i];
  }
  rep2(i,n+1,n*3){
  dp[i]=(dp[i]%mod+dp[i-1]+mod)%mod;
  ans=(ans+dp[i])%mod;}
  cout<<ans<<endl;
}


Measured memory_bytes: 23680
s = gets.chomp
t = gets.chomp
tlength = t.length

min = tlength
(s.length - tlength + 1).times{|i|
  diff = tlength
  ss = s[i .. i + tlength - 1]
  tlength.times{|j|
    # p [s, t, ss, i, j, ss[j], t[j]]
    diff -= 1 if ss[j] == t[j]
  }

  min = diff if min > diff
}

puts min


Measured memory_bytes: 14264
n = int(input())
MOD = 10**9+7
# dp[i][j][k][l]:文字列長iで,後ろから3文字目がj,2文字目がk,1文字目がlの文字列の個数
#                ただしA:0,C:1,G:2,T:3とする。
dp= [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(101)]
# 文字列長0の文字列Sは、333+Sと考えてよい。
dp[0][3][3][3] = 1
for i in range(100):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        #if dp[i][j][k][l] == 0:
        #  continue
        for m in range(4):
          # 条件を満たさないパターンを除外する。
          # 条件を満たさないのは、文字列の末尾が下記の場合。
          # 021,201,021,0?21,02?1
          if k == 0 and l == 2 and m == 1:
            continue
          if k == 2 and l == 0 and m == 1:
            continue
          if k == 0 and l == 1 and m == 2:
            continue
          if j == 0 and l == 2 and m == 1:
            continue
          if j == 0 and k == 2 and m == 1:
            continue
          dp[i+1][k][l][m] += dp[i][j][k][l]
          dp[i+1][k][l][m] %= MOD
ans = 0
for j in range(4):
  for k in range(4):
    for l in range(4):
      ans += dp[n][j][k][l]
      ans %= MOD
print(ans)            

Measured memory_bytes: 48932
#include<stdio.h>
 
int main(){
  int n,m,i;
  int day=0,aday=0;
  scanf("%d",&n);
  scanf("%d",&m);
  int a[m];
  
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    day=day+a[i];
  }
  
  aday=n-day;
  if(aday<0){
    printf("-1");
  }
  
  else{
    printf("%d",aday);
  }
  
  return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n>=30)
     cout<<"Yes";
    else
     cout<<"No";
}   
    

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

int main () {
  int N , M ;
  cin >> N >> M ;
  int A[N] , B[N] , C[M] , D[M] ;
  for(int i = 0 ; i < N ; i++ ){
    int a , b ;
    cin >> a >> b ;
    A[i] = a ; B[i] = b ;
  }
  for(int i = 0 ; i < M ; i++ ){
    int c , d ;
    cin >> c >> d ;
    C[i] = c ; D[i] = d ;
  }
  for(int i = 0 ; i < N ; i++ ){
  int ans = -1 ;
  long long pre = 1000000000000 ;
  for(int j = 0 ; j < M ; j++ ){
    long long d = abs(C[j]-A[i]) + abs(D[j]-B[i]) ;
    if(d < pre) {
      ans = j ;
      pre = d ;
    }
  }
  cout << ans + 1 << endl ;
}
}

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

int main(){
    string a, b; cin>>a>>b;
    long long int counter = 0;
    for(int i=0; i<min(a.length(), b.length()); ++i){
        if(a[i]!=b[i]) counter++;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

// #define DEBUG

using namespace std;

int h, w, c;
int p[9][9];

void Coloring(int y, int x, int c, bool checked[9][9]) {
  if (checked[y][x]) {
    return;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      Coloring(ny, nx, c, checked);
    }
  }
  p[y][x] = c;
  checked[y][x] = false;
}

int Count(int y, int x, bool checked[9][9]) {
  if (checked[y][x]) {
    return 0;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      ret += Count(ny, nx, checked);
    }
  }

  return ret + 1; 
}

int dfs(int limit, int c, int* pv = nullptr) {
  if (limit == 0) {
    bool checked[9][9] = { false };
    return Count(0, 0, checked);
  }
  int ret = 0;
  for (int i = 1; i <= 6; i++) {
    if (limit == 1 && i != c) {
      continue;
    }
    // ?????????
    if (p[0][0] == i) {
      continue;
    }
    int tmp[9][9];
    memcpy(tmp, p, sizeof(p));
    bool checked[9][9] = { false };
    Coloring(0, 0, i, checked);
    int tpv[10] = { 0 };
    int d = dfs(limit - 1, c, tpv);
    memcpy(p, tmp, sizeof(p)); // UNDO
    if (d > ret) {
      ret = d;
      if (pv != nullptr) {
        pv[limit] = i;
        for (int j = 0; j < limit; j++) {
          pv[j] = tpv[j];
        }
      }
    }
  }

  return ret;
}

int main() {
  while (true) {
    cin >> h >> w >> c;
    if (h + w + c == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> p[i][j];
      }
    }
    int pv[10] = { 0 };
    cout << dfs(5, c) << endl;
   
#ifdef DEBUG
    for (int i = 0; i < 10; i++) {
      cout << pv[i] << " \n"[i == 9];
    }
#endif
  }

  return 0;
}

Measured memory_bytes: 3020
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int string_compare(const void *a, const void *b)
{
    return(strcmp((char *)a, (char *)b));
}

int main(void){

    int N, L;

    scanf("%d%d", &N, &L);

    char S[N][L+1];

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

    qsort((void *)S, N, L+1, string_compare);

    for(int i = 0; i < N; i++){
        for(int j = 0; j < L; j++){
            printf("%c", S[i][j]);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1620
#include<stdio.h>
int main(){
  int H,W;
  int i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0 && W==0)break;
    else{
      for(i=1;i<=H;i++){
	for(j=1;j<=W;j++){
	  if((j+i)%2==0)printf("#"); 
	  else printf(".");
	}
	printf("\n");
      }
      printf("\n");
    }
    
}
  return 0;
}

Measured memory_bytes: 572
N = int(input())
a = list(map(int, input().split()))

if N == 1:
  print("Yes")
  
else:
  flag = True
  for i in range(N-1):
    if a[len(a)-1-i]-a[len(a)-2-i] < -1:
      flag=False
      break
    if a[len(a)-1-i]-a[len(a)-2-i] == -1:
      a[len(a)-2-i]-=1

  print("Yes") if flag else print("No")

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S;
    cin >> S;
    bool flg = false;
    for(auto x: S){
        if(x == '7'){
            flg = true;
            break;
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
from heapq import heappush, heappop
H, W = map(int, input().split())
s = [input() for _ in range(H)]
black = sum(x == '#' for row in s for x in row)
INF = 10 ** 9
sp = [[INF] * W for _ in range(H)]
sp[0][0] = 0
q = [(0, 0, 0)]
while q:
    dist, prev_x, prev_y = heappop(q)
    for dx, dy in zip([1, 0, -1, 0], [0, -1, 0, 1]):
        x = prev_x + dx
        y = prev_y + dy
        if (0 <= x < W and 0 <= y < H
                and s[y][x] == '.' and dist + 1 < sp[y][x]):
            sp[y][x] = dist + 1
            heappush(q, (dist + 1, x, y))

if sp[H - 1][W - 1] == INF:
    print(-1)
else:
    print(H * W - black - sp[H - 1][W - 1] - 1)

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


import sys
import math

# 1整数
# n = int(input())

# 空白区切り2整数
n, m = list(map(int, input().split()))

ll = []

for i in range(n):
    ll.append(list(map(int, input().split())))
ll = sorted(ll)

sum = 0
nokori = m
for i in range(n):
    if nokori <= ll[i][1]:
        sum += nokori*ll[i][0]
        break
    nokori -= ll[i][1]
    sum += ll[i][0]*ll[i][1]

print(sum)


Measured memory_bytes: 28632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  int64_t x;
  mint(int64_t x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(int64_t t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  //for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

#define N 200010

//head

int n;
int a[N];
mint sum;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> a[i];
  sum = accumulate(a, a+n, mint());
  sum = sum*sum;
  rep(i, n) {
    sum -= mint(a[i])*a[i];
  }
  cout << sum/2 << endl;
}

Measured memory_bytes: 4436
def Main(K, A, B):
    for i in range(A, B+1):
        if i%K == 0:
            return 'OK'
    return 'NG'

def main():
    K = int(input())
    A, B = map(int, input().split())
    print(Main(K, A, B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] d = new Integer[n];
        for(int i=0;i<n;i++){
            d[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(d, Collections.reverseOrder());
        int prev = d[0];
        int cnt =1;
        for(int i=1;i<n;i++){
            if(prev!=d[i]){
                cnt++;
                prev = d[i];
            }else{
                continue;
            }
        }
        System.out.println(cnt);

    }
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <stdlib.h>   

int main()
{
int sum,i=0;
 char str[1000];
  while(1){
        scanf("%s",str);
        if (str[0]=='0')break;
        for (sum=0,i=0;str[i]!='\0'; i++) {
            sum+=(str[i]-'0');
        }
        printf("%d\n",sum);
        }
 return 0;
}

Measured memory_bytes: 536
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    A = list(map(int,input().split()))
    for e in A:
        if e%2 == 0:
            if e%3 != 0 and e%5 != 0:
                print("DENIED")
                exit(0)
    print("APPROVED")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = gets.to_i
s = gets.chomp.chars
 
r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r * g * b
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[i+t] && s[i] != s[i+2*t] && s[i+t] != s[i+2*t]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14328
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

ii arr[200003];
int ans[200003];

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &arr[i].fi);
		arr[i].se = i;
	}
	sort(arr+1, arr+n+1);
	for(int i = 1; i <= n; i++)
	{
		int idx = arr[i].se;
		if(i <= n/2) ans[idx] = arr[n/2+1].fi;
		else ans[idx] = arr[n/2].fi;
	}
	for(int i = 1; i <= n; i++)
	{
		printf("%d\n", ans[i]);
	}
}





Measured memory_bytes: 4480
n, a, b = map(int, input().split())
sum = 0

for i in range(1, n+1):
    sum_i = i%10 + (i//10)%10 +(i//100)%10 + (i//1000)%10 + (i//10000)%10
    if a <= sum_i <= b:
        sum += i

print(sum)

Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn f(m: usize, k: usize) -> usize {
    (m+(k-1-1))/(k-1)
}

fn main() {
    let (n,k) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let xs = read_vec_i64();
    let inf = 1usize << 50;
    let min_i = {
        let mut res = inf;
        let mut res_i = 0;
        for (i,&x) in xs.iter().enumerate() {
            if res > x as usize {
                res = x as usize;
                res_i = i;
            }
        }
        res_i
    };
    let mut res = inf;
    for i in 0..n-k+1 {
        //eprintln!("{}", i+k);
        if i <= min_i && min_i < i+k {
            res = min(res, 1 + f(i,k) + f(n-(i+k-1)-1,k));
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	for(int i=0; i<n; i++){
		if(arr[i]%2==0){
			if(arr[i]%3==0 || arr[i]%5==0) continue;
			else{
				cout<<"DENIED";
				return 0;
			}
		}	
	}
	cout<<"APPROVED";
}

Measured memory_bytes: 3648
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int h;
    while(cin>>h,h){
        vvi v(h,vi(5));
        rep(i,h)rep(j,5)cin>>v[i][j];
        vector<pair<pii,int>>del;
        ll ans=0;
        bool flag=true;
         vector<vector<bool>>used(h,vb(5,true));
        while(flag){
            del.clear();
            for(int i=0; i<h;i++){
                for(int j=0; j<4;j++){
                    if(!used[i][j])continue;
                    bool foo=true;
                    int cnt=1;
                    int k=j+1;
                    while (foo&&k<5) {
                        if(!used[i][k])break;
                        if(v[i][j]==v[i][k]){cnt++;k++;}
                        else foo=false;
                    }
                    if(cnt<3)continue;
                    del.push_back(make_pair(pii(i,j),cnt));
                    rep(_,cnt-1)used[i][j+_]=false;
                   // cout<<v[i][j]<<" "<<cnt<<endl;
                    ans+=cnt*v[i][j];
                }
            }
            if(del.empty())break;
            vector<vector<int>>temp(h,vi(5));
            rep(i,h){
                rep(j,5){
                    rep(k,del.size()){
                        if(del[k].first==pii(i,j)){
                            rep(_,del[k].second)
                            used[del[k].first.first][del[k].first.second+_]=false;
                        }
                    }
                }
            }
            int last[10000]={0};
            for(int i=h-1; i>=0;i--){
                rep(j,5){
                    if(!used[i][j])continue;
                    {temp[(h-1-last[j])][j]=v[i][j];used[h-1-last[j]][j]=true;last[j]++;}
                }
            }
            v=temp;
            //rep(i,h){rep(j,5)cout<<v[i][j];cout<<endl;}
            //cout<<endl;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


WG<int> es;

void dfs(int x,int r,int b[]){

  for(auto e:es[x]){
    if(e.to==r) continue;
    if(e.cost%2){
      b[e.to]=-1*b[x];
    }else{
      b[e.to]=b[x];
    }
    dfs(e.to,x,b);
  }
 
}


main(){
  int n;
  cin>>n;
  es.resize(n);
  int b[110000]={};

  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    es[a].PB(edge<int>(b,c));
    es[b].PB(edge<int>(a,c));
  }

  b[0]=1;
  dfs(0,-1,b);


  rep(i,n){
    cout<<max(b[i],0LL)<<endl;
  }
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi H(n);
  for(auto &a:H){
    cin>>a;
  }
  if(n==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  vi H2;
  for(int i=0;i<n-1;i++){
    while(i<n-1&&H[i]==H[i+1]){
      i++;
    }
    H2.pb(H[i]);
  }
  H2.pb(H[n-1]);
  for(int i=0;i<H2.size()-1;i++){
    if(H2[i]>H2[i+1]){
      H2[i]--;
    }
  }
  bool ans=true;
  for(int i=0;i<H2.size()-1;i++){
    if(H2[i]>H2[i+1])ans=false;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

//		run();

		Scanner scanner=new Scanner(System.in);

		long n=scanner.nextLong();

		int a=(int)Math.sqrt(n);//切り捨て。

		int b=0;

		for(int i=a; i > 0;i--) {

			if(n%i==0) {
				a=i;
				b=(int)(n/a);
				break;
			}

		}

		int result=Math.max(String.valueOf(a).length(), String.valueOf(b).length());

		System.out.println(result);

		scanner.close();

	}

//	public static void run() {
//
//		for(int i=0;i<100000;i++) {
//			System.out.println("n= "+i+"sqrt(n)= "+Math.sqrt(i)+"(int) "+(int)Math.sqrt(i));
//		}
//	}
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int a,b;

signed main()
{
    cin>>a>>b;

    if(a<=5){
        cout <<0<<endl;
    }
    else if(a>=13){
        cout << b<<endl;
    }
    else{
        cout <<b/2<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b && b<c || a==b && b<c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<c && c<b || a==c && c<b){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<a&&a<c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<c&&c<<a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<a&&a<b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else {
		cout<<c<<" "<<b<<" "<<a<<endl;
	}
	return 0;
}

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

def cmb_fnct(MOD):
    #MOD:素数
    fact_mod = [1,1]
    inv_mod = [0,1]
    inv_fact_mod = [1,1]
    i = len(fact_mod)
    i_ = len(inv_fact_mod)

    def cmb(n,r):
        nonlocal i, i_
        r = min(r, n-r)
        if r<0: 
            return 0
        if r==0:
            return 1
        if r==1: 
            return n%MOD

        while n >= i:
            fact_mod[i:i] = [(fact_mod[i-1]*i)%MOD]
            i += 1

        while n-r >= i_:
            inv_mod[i_:i_] = [(-inv_mod[MOD%i_]*(MOD//i_))%MOD]
            inv_fact_mod[i_:i_] = [(inv_fact_mod[i_-1]*inv_mod[i_])%MOD]
            i_ += 1

        return fact_mod[n] * inv_fact_mod[r] * inv_fact_mod[n-r] % MOD
    return cmb

def solve():
    S = int(input())
    M = 10**9+7
    cmb = cmb_fnct(M)
    return str(sum(cmb(S-2*N-1,N-1) for N in range(1,S//3+1))%M)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 9340
import sys
from collections import deque
from collections import defaultdict
import math
#input = sys.stdin.readline
sys.setrecursionlimit(20000000)
mod = 10**9 + 7
l = [int(i) for i in input()]
ko = [[0,0] for i in range(len(l)+1)]
ko[0][0] = 1
for i in range(len(l)):
        if l[i] == 1:
                ko[i+1][0] = ko[i][0]*2
                ko[i+1][1] = ko[i][1]*3+ko[i][0]
        elif l[i] == 0:
                ko[i+1][1] = ko[i][1]*3
                ko[i+1][0] = ko[i][0]
        ko[i+1][1]%=mod
        ko[i+1][0]%=mod
print(sum(ko[len(l)])%mod)

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B)
    {
        cout << C << endl;
    }
    else if (B == C)
    {
        cout << A << endl;
    }
    else
    {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll k; cin >> k;
    ll a, b; cin >> a>> b;
    bool flag = false;
    for(ll i=a; i<=b; i++){
        if(i%k==0) flag = true;
    }
    if(flag) cout << "OK" << endl;
    else cout << "NG" << endl;
}

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

Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        var P = new List<int>();
        eratos(P, 1000);
        var A = new long[1001];//素因数分解
        for (int i = 1; i <= N; i++)
        {
            int j = i;
            foreach (var item in P)
            {
                while (j % item  == 0)
                {
                    A[item]++;
                    j /= item;
                }
            }
        }
        long ans = 1;
        foreach (var item in A)
        {
            ans *= (item + 1);
            ans %= mod;
        }
        WriteLine(ans);
    }
    //2～nまでの素数のリスト(n>=2)
    void eratos(List<int> P, int n)
    {
        var a = new bool[n + 1];
        a[0] = a[1] = true;
        int i;
        for (i = 2; i * i <= n; i++)
        {
            if (!a[i])
            {
                P.Add(i);
                int j = i << 1;
                while (j <= n)
                {
                    a[j] = true;
                    j = j + i;
                }
            }
        }
        for (; i <= n; i++) if (!a[i]) P.Add(i);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  map<string, int> mp;
  mp[s] = a;
  mp[t] = b;
  mp[u]--;

  printf("%d %d\n", mp[s], mp[t]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25
#define LIM 1000000

using namespace std;

int n,sum,out;
bool prm[1000000];

void eucprime()
{
	FOR(i, 2, LIM)
	{
		if(prm[i] == 0)
		{
			for( int j = 2; j*i < LIM; j++)
			{
				prm[i*j] = 1;
			}
		}
	}
}
	

int main()
{
	while( cin >> n, !cin.eof())
	{
		CLR(prm);
		prm[0] = 1; prm[1] = 1;
		eucprime();
		
		int cnt=0;
		
		FOR(i, 0, n+1)
		{
			if(prm[i] == 0)
				cnt++;
		}
		
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0