akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  string L;
  cin >> L;
  auto dp = vector<vector<ll>>(100002, vector<ll>(2, 0));
  dp[0][0] = 1;  // a+b <= L が確定していない
  REP(i, L.size()) {
    char b = L[i];
    if(b == '1') {
      dp[i + 1][0] += dp[i][0] * 2;
      dp[i + 1][1] += dp[i][0];
      dp[i + 1][1] %= MOD;
    } else {
      dp[i + 1][0] += dp[i][0];
    }
    dp[i + 1][1] += dp[i][1] * 3;
    dp[i + 1][1] %= MOD;
    dp[i + 1][0] %= MOD;
    dump(i, b, dp[i + 1]);
  }
  ll ans = (dp[L.size()][0] + dp[L.size()][1]) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 5760
S = int(input())

mod = 10**9 + 7


fact = [0] * 4000
fact[0] = 1
for i in range(1, 4000):
    fact[i] = fact[i - 1] * i % mod

invfact = [0] * 4000
# フェルマーの小定理とモジュラ逆数
invfact[4000 - 1] = pow(fact[4000 - 1], mod - 2, mod)
for i in range(4000 - 1, 0, -1):
    invfact[i - 1] = invfact[i] * i % mod
# print(invfact)


def nCk(n, k):
    return fact[n] * invfact[k] * invfact[n - k] % mod


ans = 0
for n in range(1, S):
    if 3 * n > S:
        break
    ans += nCk(S - 3 * n + (n - 1), n - 1)
    ans %= mod

print(ans)


Measured memory_bytes: 9180
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
char c[yuzu|10];
int main() {
  scanf("%s",c+1);
  int i,n=strlen(c+1);
  if (c[1]^'1'||c[n]^'0') return puts("-1")&0;
  for (i=1;i<=n/2;++i) if (c[i]^c[n-i]) return puts("-1")&0;
  int last=n;
  for (i=n-1;i;--i) {
    printf("%d %d\n",last,i);
    if (c[i]=='1') last=i;
  }
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  ll N=1<<n;
  ll INF=1001001001;
  vector<ll> s(N);
  rep(i,N) cin>>s[i];
  sort(s.rbegin(),s.rend());
  vector<ll> p,q;
  // initialize
  p.push_back(s[0]);
  s[0]=INF;
  rep(i,n){
    sort(p.rbegin(),p.rend());
    q=p;
    auto it=s.begin();
    for(auto itq=q.begin();itq!=q.end();++itq){
      while(it!=s.end()){
        if(*itq<=*it){
          ++it;
        } else {
          p.push_back(*it);
          *it=INF;
          ++it;
          break;
        }
      }
    }
  }
  cout<<(p.size()==N?"Yes":"No")<<"\n";
}

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

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

  bool flag = true;
  
  for(char i = 'a';i<='z';i++){
    int count = 0;
    for(int j = 0;j<w.size();j++){
      if(w[j] == i) count++;
    }

    if(count%2 == 1){
      flag = false;
      break;
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;
char str1[1000000],str2[1000000];

int main(){


cin >> str1 >> str2;
int count = 0;
for(int i=0;str1[i];i++){
	if(str1[i]!=str2[i])count++;
}
printf("%d\n",count);

	return 0;
}

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

class C
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;
		var k = int.Parse(Console.ReadLine());

		foreach (var g in s.Select((c, i) => new { c, i }).GroupBy(_ => _.c).OrderBy(g => g.Key))
		{
			var l = new List<string>();
			foreach (var _ in g)
				for (int j = 1; j <= k && _.i + j <= n; j++)
				{
					var ss = s.Substring(_.i, j);
					var bi = l.BinarySearch(ss);
					if (bi < 0) l.Insert(~bi, ss);
				}
			if (k <= l.Count) { Console.WriteLine(l[k - 1]); Environment.Exit(0); }
			k -= l.Count;
		}
	}
}



Measured memory_bytes: 14036
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
map<string, int>mp;
int n;
int main() {
	n = read();
	string s;
	for_int(i, 1, n) {
		cin >> s;
		mp[s]++;
	}
	printf("AC x %d\n", mp["AC"]);
	printf("WA x %d\n", mp["WA"]);
	printf("TLE x %d\n", mp["TLE"]);
	printf("RE x %d\n", mp["RE"]);
	return 0;
}

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

void ABC087A() {
	int X = 0;
	int A = 0;
	int B = 0;

	scanf("%d%d%d", &X, &A, &B);

	printf("%d\n", (X - A) % B);
}

int main(){
	ABC087A();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    REP(i, 26) {
        vi v;
        REP(j, n) {
            if (s[j] - 'a' == i) {
                v.emplace_back(j);
            }
        }
        char x = '*';
        for (int u : v) {
            if (x != '*' and t[u] != x) {
                cout << "No" << endl;
                return;
            }
            x = t[u];
        }
    }
    REP(i, 26) {
        vi v;
        REP(j, n) {
            if (t[j] - 'a' == i) {
                v.emplace_back(j);
            }
        }
        char x = '*';
        for (int u : v) {
            if (x != '*' and s[u] != x) {
                cout << "No" << endl;
                return;
            }
            x = s[u];
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1544
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

def ins(bit,ind,pl)
  while ind < bit.size
    bit[ind] += pl
    ind += ind & -ind
  end
end

def pop(bit,c)
  pl = bit.size - 1
  ind = pl
  pl >>= 1
  return false if(bit[-1] < c)
  while pl > 0
    return false if ind >= bit.size
    if(bit[ind] < c)
      c -= bit[ind]
      ind += pl
    else
      ind -= pl
    end
    pl >>= 1
  end
  if(bit[ind] < c)
    ind += 1
  end
  return ind
end


def b_sum (bit, ind)
  sum = 0
  while ind > 0
    sum += bit[ind]
    ind -= ind & -ind
  end
  return sum
end

bit = na(2**20+1)
n = inp[0]
pt = inp
d=[]
pt.size.times do |i|
  d << [i+2,pt[i]]
end
d.sort_by!{|u|u[1]*-1}
ins(bit,1,2)
ins(bit,n+2,2)
ans = 0
d.each.with_index do |a,i|
  ins(bit,a[0],1)
  my = b_sum(bit, a[0])
  x1 = pop(bit,my-2)
  x2 = pop(bit,my-1)
  x3 = pop(bit,my+1)
  x4 = pop(bit,my+2)
  ans += ((x2-x1)*(x3-a[0]) + (x4-x3)*(a[0] -x2) )* a[1]
end
p ans

Measured memory_bytes: 25272
#include<stdio.h>
int main()
{
    int A,B,sum=0,mul=0,add=0;
    scanf("%d %d",&A,&B);
    sum= A+B;
    add= A-B;
    mul= A*B;
     if(sum>=add && sum>=mul)
    {
        printf("%d\n",sum);
    }
    else if(add>=sum && add>=mul)
    {
        printf("%d\n",add);
    }
    else if(mul>=sum && mul>=add)
    {
        printf("%d\n",mul);
    }
    return 0;
}


Measured memory_bytes: 128
from collections import deque

INF = float("inf")

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

Si, Sj = (0, 0)
for i, a in enumerate(A):
    if "S" in a:
        Si, Sj = (i, a.index("S"))
        A[Si][Sj] = "c"
        break

distance = INF

Q = deque([(0, Si, Sj)])
while Q:
    cnt, i, j = Q.popleft()

    distance = min(distance, i, j, H - i - 1, W - j - 1)

    if cnt >= K:
        continue

    for ni, nj in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)):
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == ".":
            A[ni][nj] = "c"
            Q.append((cnt + 1, ni, nj))

print(-(-distance // K) + 1)


Measured memory_bytes: 11252
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  sort(all(vec));
  while(vec[n-1]>=k) n--;

  vector<vector<bool>> dpl(n+1, vector<bool>(k+1, false));
  vector<vector<bool>> dpr(n+1, vector<bool>(k+1, false));
  dpl[0][0] = true;
  rep(i,n) rep(j,k) if(dpl[i][j]){
    dpl[i+1][j] = true;
    if(j+vec[i]<=k) dpl[i+1][j+vec[i]] = true;
  }
  dpr[n][0] = true;
  for(int i=n; i>0; i--) rep(j,k) if(dpr[i][j]){
    dpr[i-1][j] = true;
    if(j+vec[i-1]<=k) dpr[i-1][j+vec[i-1]] = true;
  }

  auto isneed = [&](int i){
    vector<int> cntr(k+1,0);
    rep(j,k) cntr[j+1] = cntr[j] + dpr[i+1][j+1]; // trueの個数の累積和
//    dbg(i); dbg(cntr);
    rep(j,k) if(dpl[i][j]){
      // 和が k-vec[i] ~ k-1 の中に値があるとtrue
      // つまりcntrでk-vec[i]-j ~ k-1-j
      if(k-vec[i]<=j && j<=k-1) return true;
      if(cntr[max(k-1-j,0)] - cntr[max(k-vec[i]-j-1,0)]>0) return true;
    }
    return false;
  };

  int ans=0;
  rep(i,n){
    if(!isneed(i)) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#endif

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

    int n; cin >> n;
    int x; cin >> x;

    int ans = 0;
    fo1(i, n) {
        int k; cin >> k;
        if (k >= x) ans++; 
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){string s="";while(n)s+=((n%10)+'0'),n/=10;reverse(s.begin(),s.end());return s;}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}

struct can{
    ll tk,mxi;
};

bool cmp(can a, can b)
{
    return a.tk<b.tk;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    faster_io;
    ll n,m,ans=0,k;
    cin>>n>>m>>k;

    for(ll i=m; i>0; i--){
        if(n%i==0 && m%i==0)k--;
        if(k==0)cout<<i<<endl,exit(0);
    }

    return 0;
}




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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, m; cin >> n >> m;
	vvi g(n);
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		g[u].push_back(v); g[v].push_back(u);
	}
	int timer = 0;
	vi stTime(n, INF), enTime(n, INF);
	vi low(n);
	vi ans(n);
	function<void(int, int)> dfs = [&] (int u, int p) {
		stTime[u] = timer++;
		low[u] = stTime[u];
		int jai = 0;
		for (int v : g[u]) {
			if (v == p) continue;
			if (stTime[v] >= INF) {
				// tree edge
				dfs(v, u);
				low[u] = min(low[u], low[v]);
				if (low[v] >= stTime[u] && p != -1) ans[u] = 1;
				jai++;
			} else if (enTime[v] >= INF) {
				// back edge
				low[u] = min(low[u], stTime[v]);
			}
		}
		enTime[u] = timer;
		if (p == -1 && jai > 1) ans[u] = 1;
	};
	dfs(0, -1);
	for (int i = 0; i < n; i++) if (ans[i]) cout << i << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker



Measured memory_bytes: 4928
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int Q;
    cin >> Q;

    while (Q--) {

        long long p, q;
        cin >> p >> q;

        int ans = 0;
        for (long long i = -200; i < 200; i++) {
            for (long long j = -200; j < 200; j++) {
                if (i == 0 && j == 0) continue;
                long long d = (i * i) + (j * j);
                if ((i * p + j * q + 1000000 * d) % d == 0 && (i * q - j * p + 1000000 * d) % d == 0) ans++;
            }
        }

        if (ans == 8) cout << "P" << endl;
        else cout << "C" << endl;

    }

}














































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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(k >= s.size()){
        cout << s << endl;
        return 0;
    }
    s = s.substr(0, k);
    s += "...";
    cout << s << endl;
}

Measured memory_bytes: 3628
import numpy as np
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

#めぐる式二分探索
def is_ok(i):
    su = 0
    for a in A:
        su += math.ceil(a / i) - 1
    if su <= K:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(meguru_bisect(0, max(A) + 1))

Measured memory_bytes: 49320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
const int maxn=1e5+5;
const int mod=1e9+7;
int main(){
    fastio;
    int n,m;
    cin>>n>>m;
    string s;
    cin >>s;
    stack<int> st;
    int i=n;
    while(i>0){
        bool ok = false;
        for(int j=m;j>=1;--j){
            if(i-j>=0 && s[i-j]=='0'){
                ok = true;
                st.push(j);
                i-=j;
                break;
            }
        }
        if(ok==false){
            cout<<-1<<endl;
            return 0;
        }
    }
    while(!st.empty()){
        int tp = st.top();
        st.pop();
        cout<<tp<<" ";
    }
    cout<<endl;
    return 0;
}    


Measured memory_bytes: 924
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    vec v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>N;
    cout<<v[N - 1]<<endl;
}

Measured memory_bytes: 256
def divisor_list(n):
    i=1
    l=[]
    while i<=n:
        if n%i == 0:
            l.append(i)
        i = i+1
    return l


a, b, k = map(int,input().split())


s1 = set(divisor_list(a))
s2 = set(divisor_list(b))
s3 = list(s1 & s2)
s3.sort(reverse=True)
print(s3[k-1])

Measured memory_bytes: 3064
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

@r = 10**9+7
s = gets.chomp
nk = 1
dp = na2(2,13,0)
dp[0][0] = 1
s.reverse.each_char.with_index do |c, i|
  now_i = (i+1) % 2
  mae_i = (i)% 2
  if(c != "?")
    d = (c.to_i * nk) % 13
    (0...13).each do |j|
      dp[now_i][j] = dp[mae_i][j - d]
    end
  else
    t = nk
    tail = 0
    sum = 0
    head = 0
    10.times do |j|
      sum += dp[mae_i][head]
      head = (head + t) % 13
    end
    13.times do |j|
      sum -= dp[mae_i][tail]
      sum += dp[mae_i][head]
      dp[now_i][head] = sum % @r
      tail += t
      tail %= 13
      head += t
      head %= 13
    end
  end
  nk *= 10
  nk %= 13
end
p dp[s.size%2][5] %@r


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct DSU {
    int par[SZ], sz[SZ];
    DSU() {
        F0R(i,SZ) par[i] = i, sz[i] = 1;
    }
    
    int get(int x) { // path compression
    	if (par[x] != x) par[x] = get(par[x]);
    	return par[x];
    }
    
    bool unite(int x, int y) { // union-by-rank
    	x = get(x), y = get(y);
    	if (x == y) return 0;
    	if (sz[x] < sz[y]) swap(x,y);
    	sz[x] += sz[y], par[y] = x;
    	return 1;
    }
};

string S;
int N;
vpi al;

pi getLeft(pi p) {
    p.s = min(p.s,N/2-1);
    // cout << "OH " << p.f << " " << p.s << "\n";
    if (p.f > p.s) return {-1,-1};
    return p;
}

pi getRight(pi p) {
    p.f = max(p.f,(N+1)/2);
    if (p.f > p.s) return {-1,-1};
    return {N-1-p.s,N-1-p.f};
}

DSU<MX> D;
int sum[MX];
    
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> S; N = sz(S);
    int t; cin >> t;
    F0R(i,t) {
        pi p; cin >> p.f >> p.s; p.f --, p.s --;
        pi x = getLeft(p), y = getRight(p);
        // cout << p.f << " " << p.s << " " << x.f << " " << x.s << " " << y.f << " " << y.s << "\n";
        if (x == mp(-1,-1) && y == mp(-1,-1)) continue;
        if (x == mp(-1,-1)) al.pb(y);
        else if (y == mp(-1,-1)) al.pb(x);
        else if (x.f != y.f) al.pb({min(x.f,y.f),max(x.f,y.f)-1});
    }
    vi dif; 
    dif.pb(0);
    for (int i = 0; i < sz(S)-1-i; ++i) dif.pb((S[sz(S)-1-i]-S[i]+26)%26);
    dif.pb(0);
    vi DIF; F0R(i,sz(dif)-1) DIF.pb((dif[i+1]-dif[i]+26)%26);
    
    for (auto a: al) D.unite(a.f,a.s+1);
    F0R(i,sz(DIF)) sum[D.get(i)] += DIF[i];
    F0R(i,sz(DIF)) if (sum[i] % 26 != 0) {
        cout << "NO";
        exit(0);
    }
    cout << "YES";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

//7368791

int main()
{
	int m, n;
	while(cin >> m >> n && m!=0){
	int a[7368792]={};
	int cnt=0, ans;
	for(int i=m; i<7368792; i++)
	{
	
		if(a[i]==0)
		{
			if(cnt==n)
			{
				ans=i;
				break;
			}
			else
			{
				cnt++;
				int tmp=1;
				while(tmp*i<7368792)
				{
					a[tmp*i]=1;
					tmp++;
				}
			}
		}
	}
	cout << ans << endl;
}
	return 0;
}

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

int main()
{
    long long A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (T * (V - W) >= abs(A - B))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3672
N,W = map(int, input().split())

weight = []
value = []

for _ in range(N):
    x, y = map(int, input().split())
    value.append(x)
    weight.append(y)

T = [[0]*(W+1) for _ in range(N+1)]
T[:][0] = 0
T[0][:] = [0]*(W+1)

for i in range(1,N+1):
    for j in range(1,W+1):
        if j >= weight[i-1]:
            T[i][j] = max(T[i-1][j-weight[i-1]] + value[i-1], T[i-1][j])
        else:
            T[i][j] = T[i-1][j]
print(T[N][W])




Measured memory_bytes: 42104
def make_dict(s):
    res = {}
    for v in s:
        if v in res:
            res[v] += 1
        else:
            res[v] = 1
    return res

n = int(input())
s = []
for i in range(n):
    s.append(input())

w_dict = make_dict(s[0])

for i in range(1, n):
    tmp_dict = make_dict(s[i])
    keys = list(w_dict.keys())
    for k in keys:
        if k in tmp_dict:
            w_dict[k] = min(w_dict[k], tmp_dict[k])
        else:
            w_dict.pop(k)

if w_dict:
    ans = ''
    for k in sorted(w_dict.keys()):
        ans += k * w_dict[k]
    print(ans)
else:
    print('')

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int n, m, a, b;
	cin >> n >> m;
	vector<vector<int>> work(m + 1);
	rep(i, 0, n) {
		cin >> a >> b;
		if (a > m)continue;
		work[a].push_back(b);
	}
	priority_queue<int> temp;
	ll ans = 0;
	rep(i, 0, m) {
		rep2(v, work[i + 1])temp.push(v);
		if (temp.size()) {
			ans += (ll)temp.top();
			temp.pop();
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8408
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define ll long long
#define chushi(a, b) memset(a, b, sizeof(a))
const double eps = 1e-8;
const ll INF = 1e18 + 5;
const ll mod = 998244353;
const int maxn = 1e5+5;
using namespace std;

int n, m, x;
int book[20][20] = {0};
int val[20] = {0};
ll tot = INF;

void solve(){
	ll len = 1 << n;
	for(int i = 0; i <= len; i++){
		chushi(val, 0);
		int ind = i; ll sum = 0;
		for(int j = 1; j <= n; j++, ind >>= 1){
			if(ind & 1){
				sum += book[j][0];
				for(int k = 1; k <= m; k++){
					val[k] += book[j][k];
				}
			}
		}
		int flag = 0;
		for(int j = 1; j <= m; j++){
			if(val[j] < x) flag = 1; 
		}
		if(flag) continue;
		tot = min(tot, sum);
	}
}

int main(){
	
	cin >> n >> m >> x;
	for(int i = 1; i <= n; i++){
		cin >> book[i][0];
		for(int j = 1; j <= m; j++){
			cin >> book[i][j];
		}
	}
    
    solve();
    
    if(tot == INF) cout << -1 << endl;
    else cout << tot << endl;
    
    return 0;
}





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

int h[100010];
int dp[100010];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++){
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    B = [[] for _ in range(N)]
    for i in range(N):
        k = int(readline())
        for _ in range(k):
            x, y = map(int, readline().split())
            B[i].append((x - 1, y))

    ans = 0
    for bit in range(1 << N):
        ok = True
        for i in range(N):
            if not (bit & (1 << i)):
                continue
            for x, y in B[i]:
                if bool(bit & (1 << x)) != bool(y):
                    ok = False
                    break
            if not ok:
                break

        if ok:
            ans = max(ans, str(bin(bit)).count('1'))

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74492
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;
lli res = 0;
void fun(string s, lli upto, lli n){
    if(s.length()==n) {cout<<s<<'\n'; ++res; return;}
    for(lli i=0; i<upto+1; ++i){
        if(i==upto) fun(s+(char)('a'+i), upto+1, n);
        else fun(s+(char)('a'+i), upto, n);
    }
    return;
}
void solve(){
    lli n; cin>>n;
    string s="";
    fun(s, 0, n);
    // cout<<res;
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}

Measured memory_bytes: 1536
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int n, bool[][] adj) {
    auto refs = new int[](n + 1);

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (adj[i][j])
                refs[j]++;
        }
    }

    int ans = 0;
    bool update = true;
    while (update) {
        update = false;

        for (int i = 1; i <= n; i++) {
            if (refs[i] == 1) {
                ans++;
                update = true;
                refs[i] = 0;

                for (int j = 1; j <= n; j++) {
                    if (adj[i][j]) {
                        refs[j]--;
                    }
                }
            }
        }
    }
    return ans;
}

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    auto adj = new bool[][](n + 1, n + 1);
    for (int i = 0; i < m; i++) {
        auto ab = readints;
        int a = ab[0], b = ab[1];

        adj[a][b] = adj[b][a] = true;
    }

    writeln(calc(n, adj));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
   
  int a[20], b[50], c[50];
  for (int i=0; i<n; i++){
    cin >>a[i];
  } 
  for (int i=0; i<n; i++){
    cin >>b[i];
  }
  for (int i=0; i<n; i++){
    cin >>c[i];
  }
  
  
  
  int ans = 0;
  int tmp = a[0];

  for (int i=0; i<n; i++){

    ans += b[a[i]-1];
    
    if(tmp+1 == a[i]){
      ans += c[tmp-1];
    }
       
    tmp = a[i];

  }

  cout << ans;


  return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *D = map(int, read().split())

    csum = accumulate(D)
    ans = sum(s * d for s, d in zip(csum, D[1:]))
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
const int maxN = 4005;
int c[maxN][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int S;
    cin >> S;
    c[0][0] = 1;
    for (int i = 1; i < maxN; i++) {
        c[i][0] = 1;
        for (int j = 1; j <= i; j++) c[i][j] = sum(c[i - 1][j - 1], c[i - 1][j]);
    }
    int ans = 0;
    for (int cnt = 1; cnt * 3 <= S; cnt++) {
        ans = sum(ans, c[S - 3 * cnt + cnt - 1][cnt - 1]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 48944
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define CANCER ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;


int main()
{
	CANCER;
	int x,a;
	cin>>x>>a;
	if(x<a)
		cout<<0<<"\n";
	else
		cout<<10<<"\n";
	return 0;
}


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

char **data;
int w,h;

int r(int,int);

int main(){
	int i,j;
	int num;
	int x,y;
	while(cin>>w>>h){
		if(w==0 && h==0) break;
		data=new char*[h];
		for(i=0;i<h;i++){
			data[i]=new char[w+1];
			cin>>data[i];
			for(j=0;j<w;j++){
				if(data[i][j]=='@'){
					data[i][j]='.';
					x=j;
					y=i;
				}
			}
		}
		num=r(x,y);
		cout<<num<<endl;
	}
	return 0;
}

int r(int x,int y){
	int count=0;
	if(x>=w || x<0) return 0;
	if(y>=h || y<0) return 0;

	if(data[y][x]=='.'){
		data[y][x]='@';
		count++;
	}
	else return 0;
	count+=r(x+1,y);
	count+=r(x-1,y);
	count+=r(x,y+1);
	count+=r(x,y-1);
	return count;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
std::vector<int> w(1e6),ww(1e6),wa(1e6);
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
int nCk(int n,int k){
  int res=1;
  res*=w[n];
  res*=ww[n-k];res%=MOD;
  res*=ww[k];res%=MOD;
  return res;
}
//main
//解説AC
signed main(){
  int N,M,K;cin>>N>>M>>K;
  w[0]=1;for(int i=1;i<1e6;i++)w[i]=w[i-1]*i%MOD;
  for(int i=0;i<1e6;i++)ww[i]=pw(w[i],MOD-2);
  for(int i=0;i<1e6;i++)wa[i]=pw(i,MOD-2);
  int res=0;
  res+=N*(N+1)%MOD*(((2*N+1)*wa[3]-1)%MOD)%MOD;
  res%=MOD;
  res*=M;res%=MOD;res*=M;res%=MOD;
  int tmp=res;
  res=0;
  swap(N,M);
  res+=N*(N+1)%MOD*(((2*N+1)*wa[3]-1)%MOD)%MOD;
  res%=MOD;
  res*=M;res%=MOD;res*=M;res%=MOD;
  res+=tmp;res%=MOD;
  res*=wa[4];res%=MOD;
  res*=nCk(N*M-2,K-2);res%=MOD;
  cout<<res<<endl;
}


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


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}


int main(){
	ll n,memo = 0,mid = 0,ans = 0;
	cin >> n;
	ll a[n],b[n] = {0};
	
	rep(i,0,n){
		cin >> a[i];
		b[i] = a[i]-i-1;
	}
	sort(b,b+n);
	
	
	if(n % 2)mid = b[n/2];
	else mid = (b[n/2]+b[n/2-1])/2;
	//cout << mid << endl;
	
	rep(i,0,n){
		ans += abs(a[i] - (mid + (i+1)));
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();

		int cnt = 0;
		for(int i=1;i<=N;i++) {
			 if(String.valueOf(i).length()%2==1) {
				 cnt++;
			 }
		}
		out.println(cnt);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i, h) cin >> c[i];
    
    int nPatW = 1;
    int nPatH = 1;
    rep(i,h) nPatH *= 2;
    rep(i,w) nPatW *= 2;

    int ans = 0;
    rep(py, nPatH) {
        rep(px, nPatW) {
            vector<string> t = c;
            rep(i, h) {
                if (py & (1 << i)) {
                    rep(z, w) t[i][z] = 'r'; 
                }
            }
            rep(j, w) {
                if (px & (1 << j)) {
                    rep(z, h) t[z][j] = 'r'; 
                }
            }
            int cnt = 0;
            rep(y, h) rep(x, w) if (t[y][x] == '#') cnt++;
            if (cnt == k) ans++;
        }
    }

    put(ans);
    
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define eps 1e-7
#define pw(x) ((x)*(x))
const double pi=acos(-1.0);
int sgn(double x)
{
    return x<-eps?-1:x>eps;
}
struct P
{
    double x,y;
    P () {}
    P(double x,double y):x(x),y(y){}
    P operator - (const P & b){return P (x-b.x,y-b.y);}
    double operator * (const P & b) { return x*b.y-y*b.x;}
    double dorm() { return sqrt(pw(x)+pw(y));}
};
double R;
P rot(P s,double ang)
{
   return P(s.x*cos(ang)-s.y*sin(ang),s.y*cos(ang)+s.x*sin(ang));
}
void CCI(P c1,double r1,P c2,double r2,P & ret1)
{
    P v=c2-c1;
    double n=v.dorm();
    double ang=acos((pw(r1)-pw(r2)+pw(n))/2/r1/n);
    P v1=rot(v,ang);
    ret1=P(r1/n*v1.x+c1.x,r1/n*v1.y+c1.y);
}
struct splay
{
    P m[100];
    int id,n;
    void find()
    {
       for(int i=0;i<n;i++)
            if(sgn(m[i].dorm()-R)==0) { id=i ;break;}
    }
    P nxt()
    {
        int x=-1;
        double ang=-1;
        for(int i=0;i<n;i++){
            if(i==id) continue;
            P a;
            CCI(m[id],(m[id]-m[i]).dorm(),P(0,0),R,a);
            double ang1=atan2(a.y-m[id].y,a.x-m[id].x)-atan2(m[i].y-m[id].y,m[i].x-m[id].x);
            if(sgn(ang1)<0) ang1+=2*pi;
            if(ang<-0.5||sgn(ang-ang1)>0) {
                ang=ang1 , x=i;
            }
            else if(sgn(ang-ang1)==0){
                if(sgn((m[i]-m[id])*(m[x]-m[id]))>0) {
                    ang=ang1 , x=i;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(i==id) continue;
            m[i]=rot(m[i]-m[id],ang);
            m[i]=P(m[i].x+m[id].x,m[i].y+m[id].y);
        }
        id=x;
        return m[x];
    }
}ans;
int main()
{
    int q;
    while(scanf("%d%lf%d",&ans.n,&R,&q)&&ans.n){
        for(int i=0;i<ans.n;i++) scanf("%lf%lf",&ans.m[i].x,&ans.m[i].y);
        ans.find();
        while(q--){
            P w=ans.nxt();
          //  printf("%d\n",ans.id);
            printf("%.10f %.10f\n",w.x,w.y);
        }
    }
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>
#include <iomanip>
#include <limits>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	vector<double>a(n);
	vector<double>b(n);
	rep(i, n)cin >> a[i] >> b[i];

	vector<pair<double, double>>vec(n);

	rep(i, n) {
		vec[i].first = a[i];
		vec[i].second = b[i];
	}

	
	vector<int>town(n);
	for (int i = 0; i < n; i++) {
		town[i] = i;
	}
	

	double dis = 0;

	int cnt = 0;

	int p = 1;
	for (int i = 1; i <= n; i++) {
		p *= i;
	}

	do {
		for (int i = 0; i < n - 1; i++) {
			dis += sqrt(((vec[town[i]].first - vec[town[i + 1]].first) * (vec[town[i]].first - vec[town[i + 1]].first)) + ((vec[town[i]].second - vec[town[i + 1]].second) * (vec[town[i]].second - vec[town[i + 1]].second)));

		}
	} while (next_permutation(town.begin(), town.end()));

	

	double ans = dis / p;

	cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M;
  cin >> N >> M;
  vector<int> d(N, -1);
  for (int i = 0; i < M; i++){
    int s, c;
    cin >> s >> c;
    s--;
    if (d[s] != -1 && d[s] != c || s == 0 && c == 0 && N > 1){
      cout << -1;
      return 0;
    }
    d[s] = c;
  }
  if (d[0] == -1){
    if (N > 1){
      d[0] = 1;
    } else {
      d[0] = 0;
    }
  }
  for (int i = 1; i < N; i++){
    if (d[i] == -1){
      d[i] = 0;
    }
  }
  if (N == 1){
    cout << d[0];
  } else if (N == 2){
    cout << d[0] * 10 + d[1];
  } else {
    cout << d[0] * 100 + d[1] * 10 + d[2];
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int MAX=0;
    int MIN=1e9;
    for(int i=1;i<=m;i++)
    {
        int temp1,temp2;
        scanf("%d%d",&temp1,&temp2);
        MAX=max(MAX,temp1);
        MIN=min(MIN,temp2);
    }
    int ans=max(0,MIN-MAX+1);
    printf("%d\n",ans);
}


Measured memory_bytes: 256