akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000

ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);


ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}

ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}

ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];

    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }

    // Sorting the pair array.
    sort(pairt, pairt + n);

    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
//ll v[500001], siz[500001];
//vector<ll>ve(0);

/*ll dp[100001][10][2];
ll solve(string s){

}

ll ret(){ll ans =0;
    REP(i, 0, s.size()-1){
        ll z = power(10, s.size()-2-i, M)%M;
        for(ll j=0; j<=9; j++){
            for(ll k=0; k<2; k++){
                if(dp[i][j][k] != -1){
                    ans = (ans%M+((dp[i][j][k]%M)*(j*z))%M)%M;
                }
            }
        }
    }
    return ans%M;
}
*/
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    string s;
    cin>>s;
    ll ans=1;
    ll k=1;
    char st = s[0];
    while(k < s.size()){
        if(s[k] == st){
            if(k == s.size()-1){
                break;
            }
            k+=2;
            ans++;
            st = '0';
        }
        else{
            st=s[k];
            k++;
            ans++;
        }
    }
    cout<<ans;
}


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

using namespace std;

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

    for (int i = 0; i < static_cast<int>(t.size()); i++) {
        cout << (t[i] == 'P' ? 'P' : 'D');
    }
    cout << endl;
}


Measured memory_bytes: 3732
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] a=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		Array.Sort(a);
		long ans=0;
		for(long i=0;i<s[0];i++){
			s[1]-=a[i];
			if(s[1]>-1){ans++;}
		}
		if(s[1]>0){ans--;}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

li pow(li x, li n) {
    if (n == 0) {
        return 1;
    }
    li sq = pow(x, n / 2);
    li ans = sq * sq % mod;
    if (n & 1) {
        ans = ans * x % mod;
    }
    return ans;
}


li inv(li x) {
    return pow(x, mod - 2);
}

struct result {
    li stripe;
    li nonstripe;

    result(li str, li nonstr) {
        stripe = str;
        nonstripe = nonstr;
    }

    li total() {
        return (stripe + nonstripe) % mod;
    }
};

result recur(vector<li> hs) {
    set<li> elements(hs.begin(), hs.end());
    li width = hs.size();

    if (elements.size() == 1) {
        li height = hs.front();
        return result(pow(2, height), (pow(2, width) - 2 + mod) % mod);
    } else {
        li height = *min_element(hs.begin(), hs.end());
        vector<vector<li>> subs;
        vector<li> sub;
        li free = 0;
        for (auto &&h : hs) {
            li newh = h - height;
            if (newh == 0) {
                free += 1;
                if (sub.size() > 0) {
                    subs.push_back(sub);
                    sub = vector<li>();
                }
            } else {
                sub.push_back(newh);
            }
        }
        if (sub.size() > 0) {
            subs.push_back(sub);
        }
        li stripe = pow(2, height);
        li nonstripe = pow(2, free);

        li negnonstripe = 2;

        for (auto &&sub : subs) {
            auto res = recur(sub);
            stripe *= res.stripe;
            stripe %= mod;

            nonstripe *= (res.nonstripe + res.stripe * 2 % mod) % mod;
            nonstripe %= mod;

            negnonstripe *= res.stripe % mod;
            negnonstripe %= mod;
        }

        nonstripe = (nonstripe + mod - negnonstripe) % mod;
        return result(stripe, nonstripe);
    }
}

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

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

    cout << recur(hs).total() << endl;
    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <set>
#include <iostream>
#define MAXX (1ll<<61)
#define MAX_CARRY 10
using namespace std;
#define ll long long

ll gcd(ll a, ll b) {
    while(b!=0) {
        ll t = b;
        b=a%b;
        a=t;
    }
    return a;
}

ll a[111111];


int main() {
    int N;
    cin>>N;
    ll M;
    cin>>M;
    ll L=1;
    for(int i=1;i<=N;i++) {
        ll A;
        cin>>A;
        A/=2;
        a[i]=A;
        // L*A[i] >= MAXX*G
        ll G = gcd(L,A);
        L = L*(A/G);
        L = min(L, M+1);
    }
    
    ll ans = ((M/L)+1)/2;
    
    for(int i=1;i<=N;i++) {
        if ((L / a[i])%2==0) {
            ans = 0;
        }
    }
    
    cout << ans << endl;

    return 0;

    
    // A[i]*(2*p+1)
    
}


Measured memory_bytes: 1024
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let sb:Vec<char> = s.trim().chars().collect();
    let mut ns = String::new();
    std::io::stdin().read_line(&mut ns).unwrap();
    let k:usize = ns.trim().parse().unwrap();
    
    let mut i:usize = 0;
    while i<k-1 && sb[i] == '1' {
        i+=1;
    }
    println!("{}", sb[i]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
#define f(p,n) for(ll i=p;i<n;i++)
ll exp(ll a,ll b,ll m);

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

 	/*#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif*/

    ll n,k;
    cin>>n>>k;
    ll a[n];
    f(0,n) cin>>a[i];

    ll c[n];
    c[0]=0;
    c[1]=abs(a[1]-a[0]);
    ll zz=0;
    f(2,n)
    {
        c[i]= mod;
    	for(ll j=max(i-k,zz);j<i;j++) c[i]=min(c[j]+abs(a[i]-a[j]) , c[i]);
    }
   // cout<<c[0]<<" "<<c[1]<<endl;
    cout<<c[n-1]<<endl;
    
return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  int count=0;
  cin>>N>>D;
int x,y;
  long long d;
  for(int i=0;i<N;i++) {
    cin>>x>>y;
    d=pow(x,2)+pow(y,2);
  if(d<=pow(D,2)) count++;
  }
  cout<<count<<endl;
  return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

const int MAX = (int)1e6;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 // 二項係数計算
 long long COM(int n, int k){  //nCkの計算をする
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }

int main(){
  ll s;
  cin>>s;
  COMinit();
  ll ans(0);
  for(int i(1);i<=s;i++){
    ll nokori = s - 3*i;
    if (nokori < 0) break;
    ll tmp = COM(nokori+i-1, i-1);
    //cout << tmp << endl;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 26984
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	ll a[100010], b[100010];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i];
	ll x=0;
	for(int i=n-1; i>=0; i--){
		x=(a[i]+x+b[i]-1)/b[i]*b[i]-a[i];
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 1792
def searchDivisors(n):
    lstDivisors = []
    t = int(n ** .5)
    for a in range(1, t + 1):
        if n % a == 0:
            lstDivisors.append(a)
            b = n // a
            if b != a:
                lstDivisors.append(b)
    lstDivisors.sort()

    return lstDivisors


N = int(input())
ans = 0
lstDivisors = searchDivisors(N)


# m で割った時の商と余りが等しい(k)場合 : N = k(m + 1)
for i in lstDivisors:
    if i == 1:
        continue
    m = i - 1
    if N // m == N % m:
        ans += m


print(ans)

Measured memory_bytes: 3264
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int N,X; cin>>N>>X;
    vector<int> m(N);
    int a=100000;
    for(int i=0;i<N;i++){
        cin>>m[i];
        X-=m[i];
        a=min(a,m[i]);
    }

    int count=0;
    while(X>=a){
        X-=a; count++;
    }
    cout<<N+count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

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

   vector<int> sum(1<<n);
   for (int s = 0; s < 1<<n; s++) {
      for (int i = 0; i < n; i++) {
         for (int j = i+1; j < n; j++) {
            if (s >> i & 1 && s >> j & 1) {
               sum[s] += a[i][j];
            }
         }
      }
   }

   vector<int> dp(1<<n);
   for (int s = 1; s < 1<<n; ++s) {
      for (int t = s; t > 0; --t) {
         t &= s;
         chmax(dp[s], dp[s & ~t] + sum[t]);
      }
   }

   COUT(dp[(1<<n)-1]);

   return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;

#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }

#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
//#define endl "\n"
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        while(n>0){
            if(n%10==7)
                {cout << "Yes";
            return 0;}
            n /= 10;
        }
        cout << "No";
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,dp[maxn][3];
int d[maxn][3],ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++)
	for (int j=0;j<3;j++) read(d[i][j]);
	for (int i=1;i<=n;i++) {
		for (int j=0;j<3;j++)
		for (int k=0;k<3;k++)
			if (j!=k) dp[i][j]=max(dp[i][j],dp[i-1][k]+d[i][j]);
	}
	for (int j=0;j<3;j++) ans=max(ans,dp[n][j]);
	printf("%d\n",ans);
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 3005;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;
const int OFF = 1 << 17;

int dp[MAXN][MAXN];
int prefix[MAXN];

int add(const int& a, const int& b) {
    if(a + b >= MOD)
        return (a + b - MOD);
    return (a + b);
}

int subt(const int& a, const int &b) {
    if(a - b < 0)
        return (a - b + MOD);
    return (a - b);
}

int main() {
    int N;
    string s;

    scanf("%d", &N);
    cin >> s;

    dp[0][1] = 1;
    for(int i = 1; i < N; i++) {
        prefix[0] = 0;
        for(int j = 1; j <= i + 1; j++)
            prefix[j] = add(prefix[j - 1], dp[i - 1][j]);

        for(int j = 1; j <= i + 1; j++) {
            if(s[i - 1] == '>')
                dp[i][j] = prefix[j - 1];
            if(s[i - 1] == '<')
                dp[i][j] = subt(prefix[i + 1], prefix[j - 1]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= N; i++)
        ans = add(ans, dp[N - 1][i]);
    printf("%d\n", ans);

    return 0;
}



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

int main(){
  ll n = 0;
  cin >> n;
  vector<int> c;
  if(n<=26){
    cout << char('a'+n-1) << endl;
    return 0;
  }
  while(1){
    --n;
    c.push_back(n%26);
    n /=26;
    if(n==0) break;
  }
  string ans = "";
  rep(i,c.size()){
    ans += char('a'+c.back());
    c.pop_back();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
}


Measured memory_bytes: 256
import java.util.*;

  public class Main{
      public static void main(String[] args){
          Scanner sc = new Scanner(System.in);
          int n = Integer.parseInt(sc.next());
          int d = Integer.parseInt(sc.next());
          double i = 0,j = 0;
          int count = 0;
          double save = 0L;
          for(int cnt = 0;cnt < n;cnt++){
              i = Double.parseDouble(sc.next());
              j = Double.parseDouble(sc.next());
              save = Math.sqrt((double)(i * i + j * j));
              if(save <= d){
                  count++;
              }
          }
          System.out.println(count);
      }
  }

Measured memory_bytes: 60420
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,x,y,d;

    in>>n>>x>>y;
    --x,--y;
    vector<int> ans(n);
    fr(i,n) fr(j,i){
        d=min({i-j,1+abs(i-x)+abs(j-y),1+abs(i-y)+abs(j-x)});
        ans[d]++;
    }
    Fr(i,n-1) cout<<ans[i]<<'\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){

  int in;
  while(cin >> in){
    if(in == -1) break;

    vector<int>V;

    while(1){
      V.push_back(in % 4);
      in /= 4;
      if(in == 0) break;
    }

    for(int i = V.size()-1; i >= 0; i--){
      cout << V[i];
    }

    cout << endl;

  }
  return 0;

}

Measured memory_bytes: 0
import sys
a1,b1 = list(map(int,input().split()))
x1 = 0
y1 = 0
d = 0
def exgcd(a,b):
    global x1,y1,d
    if b == 0:
        x1 = 1
        y1 = 0
        return a
    else:
        d = exgcd(b,a%b)
        tmp = x1
        x1 = y1
        y1 = tmp - a//b*y1
        #print(x1,y1,d)


exgcd(a1,b1)
print(x1,y1)

Measured memory_bytes: 7788
object Main extends App {
  import scala.io.StdIn._

  val Array(h, w, s, t) = readLine.trim.split(' ').map(_.toLong)
  println(if (h % 2 == 0 || w % 2 == 0) {
    "Yes"
  }else {
    if ((s + t) % 2 == 0) "Yes"
    else "No"
  })
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 44192
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector < int > VI;
typedef vector < VI > VVI;
typedef pair < int , int > PII;
 
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define MP make_pair
#define SZ(x) x.size()
#define SET(a , b) memset(a , b , sizeof(a))
#define REP(i, n) for(int i = 0 ; i < n ; i++)
#define FOR(i, a, b) for(int i = a ; i <= b ; i++)
#define FORD(i, a, b) for(int i = a ; i >= b ; i--)
#define BOOST ios_base::sync_with_stdio(0);
#define TCSOLVE() int tests; cin >> tests; REP(i, tests) solve();
 
const int N = 2e5 + 5, M = 2e5 + 5, mx = 1e9, LN = 20, mod = 998244353;

LL dp[3005][3005];

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;

	dp[a][b] = 1;
	FOR(i, a, c){
		FOR(j, b, d){
			if(i == a and j == b) continue;
			if(i == a){
				dp[i][j] = dp[i][j - 1] * a;
				dp[i][j] %= mod;
			}
			else if(j == b){
				dp[i][j] = dp[i - 1][j] * b;
				dp[i][j] %= mod;
			}
			else{
				dp[i][j] = ((dp[i - 1][j] * j)% mod) + ((dp[i][j - 1] * i)%mod) - ((dp[i - 1][j - 1] * (i - 1) * (j - 1)) % mod);
				dp[i][j] += mod;
				dp[i][j] %= mod;
			}
			// cout << i << " " <<j << " "<< dp[i][j] << " " << dp[i - 1][j - 1] << endl;
		}
	}
	cout << dp[c][d] << endl;
}

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

int main() {
 int n; cin >> n;
 vector<int> b(n-1),a(n);
  rep(i,n-1)cin >> b[i];
  a[0]=b[0];
  a[n-1]=b[n-2];
  for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
  }
  int ans=0;
  rep(i,n)ans+=a[i];

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, X;
  int ans[500];
  int tmp = 0;
  cin >> K >> X;
  for(int i = -100; i < 200; i++){
    if(X - i < K && X - i >= 0){
      ans[tmp] = i;
      tmp += 1;
    } else if (i - X < K && i - X >= 0){
      ans[tmp] = i;
      tmp += 1;
    }
  }

  rep(i, tmp){
    if (i != tmp -1){
      cout << ans[i] << " ";
    } else {
      cout << ans[i] << endl;
    }
  }



}

Measured memory_bytes: 384
p = list(map(int, input().split()))
def map_all(es):
    return all([e == es[0] for e in es[1:]]) if es else False
def has_duplicates(seq):
    return len(seq) != len(set(seq))

if map_all(p):
    print('No')
else:
    if has_duplicates(p):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long LL;
int toint(char c){
    if(isdigit(c)) return c - '0';
    if(isupper(c)) return c - 'A' + 10;
    if(islower(c)) return c - 'a' + 36;
    assert(false);
}
LL parse(){
    int p;
    cin >> p;
    string m;
    cin >> m;
    LL res = 0;
    for(char c : m){
        res = res * p + toint(c);
    }
    return res;
}

int main(){
    int n;
    while(cin >> n){
        LL sum = 0;
        for(int i = 0; i < n; i++){
            LL x = parse();
            sum = sum ^ x;
        }
        if(sum == 0){
            cout << "lose" << endl;
        }else{
            cout << "win" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}

 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

char s[500005];

void dfs(ll v,ll p,ll cnt){
	//pe(v);pe(p);p(cnt);
	ll v_count = G[v].size();
	if(p != -1){
		v_count--;
	}
	ll use = k - cnt;
	if(use < 0 || use - v_count < 0){
		ans = 0;
		return;
	}
	ans *= fact[use];
	ans %= mod;
	ans *= rfact[use - v_count];
	ans %= mod;
	//p(ans);
	for(int i=0;i<G[v].size();i++){
		ll nv = G[v][i];
		if(nv == p){
			continue;
		}
		dfs(nv, v, 2);
	}
}


int main(){
    cin >> n >> k;
    c3_init();
    ans = k;
    for(i=0;i<n-1;i++){
    	cin >> a >> b;
    	G[a].pb(b);
    	G[b].pb(a);
    }
    dfs(1,-1,1);
    p(ans); 
    return 0;
}


















Measured memory_bytes: 34304
#include<stdio.h>

int main(void){
    
    int n, i, j, day;
    int y[101], m[101], d[101];
    
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&y[i]);
        scanf("%d",&m[i]);
        scanf("%d",&d[i]);
    }
    
    for(i=1;i<=n;i++){
        day = 0;
        if(y[i]%3==0)  day += (21 - d[i]);
        else if(m[i]%2==0) day += (20 - d[i]);
        else day += (21 - d[i]);
        
        for(j=m[i]+1;j<=10;j++){
            if(y[i]%3==0) day += 20;
            else if(j%2==0) day += 19;
            else day += 20;
        }
        
        for(j=y[i]+1;j<=999;j++){
            if(j%3==0) day+= 200;
            else day += 195;
        }
        
        printf("%d\n",day);
    }
    
    return 0;
}


Measured memory_bytes: 2044
n = gets.to_i
a = gets.split.map(&:to_i)
c = 0

i = n-1

loop do

if i == 0 then
break
end

flag = false

j = i-1
loop do

if a[j]>a[j+1] then
a[j], a[j+1] = a[j+1], a[j]
c += 1
flag = true
j -= 1
else
i -= 1
break
end

if j < 0 then
break
end

end

if flag == true then
i = n-1
end

end

puts a.join(" ")
puts c


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

int main(){
    int n;string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n - 2;i++){
        if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int norm = 0;
            for (int k = 0; k < D; k++) {
                int diff = abs(X[i][k] - X[j][k]);
                norm = norm + diff * diff;
            }
            for (int l = 0; l <= norm; l++) {
                if (l * l == norm) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef vector<char> Array;
typedef vector<Array> Matrix;

struct Water {
  char x;
  char y;
  char dir;
  Water() {;}
  Water(int x, int y, int dir) : x(x), y(y), dir(dir) {;}
};

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

Matrix NextState(Matrix field, int sx, int sy) {
  if (field[sy][sx] != 4) {
    field[sy][sx]++;
  } else {
    field[sy][sx] = 0;
    vector<Water> waters;
    REP(dir, 4) {
      waters.push_back(Water(sx, sy, dir));
    }
    while (!waters.empty()) {
      vector<Water> nwaters;
      vector<char> end;
      FORIT(it, waters) {
        int nx = it->x + dx[(int)it->dir];
        int ny = it->y + dy[(int)it->dir];
        if (nx < 0 || nx >= 4 || ny < 0 || ny >= 4) { continue; }
        if (field[ny][nx] != 0) {
          field[ny][nx]++;
          if (field[ny][nx] == 5) {
            end.push_back((ny << 4) + nx);
          }
        } else {
          nwaters.push_back(Water(nx, ny, it->dir));
        }
      }
      FORIT(it, end) {
        int x = *it & 3;
        int y = *it >> 4;
        field[y][x] = 0;
        REP(dir, 4) {
          nwaters.push_back(Water(x, y, dir));
        }
      }
      waters = nwaters;
    }
  }
  return field;
}

bool OK(const Matrix &field) {
  int sum = 0;
  REP(y, 4) REP(x, 4) { sum += field[y][x]; }
  return sum == 0;
}

int main() {
  while (true) {
    Matrix field(4, Array(4, 0));
    REP(y, 4) {
      REP(x, 4) {
        int v;
        if (scanf("%d", &v) <= 0) { return 0; }
        field[y][x] = v;
      }
    }
    int ans = -1;
    set<Matrix> visit;
    queue<Matrix> que[2];
    que[0].push(field);
    REP(iter, 5) {
      if (OK(field)) { ans = 0; break; }
      int prev = iter & 1;
      int next = prev ^ 1;
      while (!que[prev].empty()) {
        Matrix matrix = que[prev].front();
        que[prev].pop();
        REP(y, 4) {
          REP(x, 4) {
            if (field[y][x] != 0) {
              Matrix nmatrix = NextState(matrix, x, y);
              if (visit.count(nmatrix)) { continue; }
              visit.insert(nmatrix);
              if (OK(nmatrix)) {
                ans = iter + 1;
                goto end;
              } else {
                que[next].push(nmatrix);
              }
            }
          }
        }
      }
    }
end:;
    printf("%d\n", ans);
  }
}

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


int main() {

  int N;
  string out = "APPROVED";

  cin >> N;

  int A[N];

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

  for (int i = 0; i < N;i++)
  {
    if(A[i] % 2 == 0)
    {
      if(A[i] % 3 == 0 || A[i] % 5 == 0)
      {

      }
      else
      {
        out = "DENIED";
        break;
      }
      
    }
  }

  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b >> u;
  if(s == u){
    a --;
  } else {
    b --;
  }
  cout << a << " " << b << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n;
vector<vi> e;
string s;

tuple<ll,ll,ll> rec(int c, int p){
	ll child = s[c] == '1';
	ll mx = 0, mn = 0;
	for(int i : e[c]) if(i != p){
		ll n, x, m; tie(n, x, m) = rec(i, c);
		n += m; x += m;
		if(mn <= x && n <= mx) mn = (mx + x) % 2;
		else{
			assert(n > mx || mn > x);
			if(n > mx) mn = n - mx;
			else mn -= x;
		}
		mx += x;
		child += m;
	}
	return tie(mn, mx, child);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n >> s;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	ll ans = 1e18;
	rep(i, n){
		auto t = rec(i, i);
		if(get<0>(t)) continue;
		ans = min(ans, get<1>(t) / 2);
	}
	cout << (ans == 1e18 ? -1 : ans) << endl;
	
	return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  ll sum = 0, keep = 1e9;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
    sum += a.at(i);
    if (a.at(i) > b.at(i)) keep = min(keep, b.at(i));
  }
  
  if (a == b) cout << 0 << '\n';
  else cout << sum - keep << '\n';
}

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    mod = [None] + read_h()

    i = n
    box = [None] * (n + 1)
    while i >= 1:
        s = sum(box[j] for j in range(i * 2, n + 1, i))
        box[i] = abs(mod[i] - (s % 2))
        i -= 1

    #  print([i for i in range(n + 1)])
    #  print(box)

    print(sum(box[1:]))
    t = [str(i) for i, b in enumerate(box) if b is not None and b > 0]
    if t:
        print(' '.join(t))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17296
#include <iostream>

using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b;
	c=(b-a)/1+1;
	if((a>0&&b>0)||(a<0&&b<0)&&(c%2==0))
	cout<<"Positive"<<endl;
	else if(a<=0&&b>=0)
	cout<<"Zero"<<endl;
	else if((a<0&&b<0)&&(c%2==1))
	cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [a, b, c, d] <- map read . words <$> getLine
    case compare (a + b) (c + d) of
        LT -> putStrLn "Right"
        GT -> putStrLn "Left"
        EQ -> putStrLn "Balanced"

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    bool flag = false;
    rep(i, N){
        ll a; cin >> a;
        if(a%2==1){
          flag = true;
        }
    }

    if(flag) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] C = new int[N];
		for(int i=0;i<N;i++) C[i] = N + 1;
		for(int i=0;i<M;i++){
			C[A[i]] = Math.Min(C[A[i]], B[i]);
		}
//Console.WriteLine(String.Join(" ",C));		
		int cnt = 0;
		int r = N;
		for(int l=0;l<N;l++){
//Console.WriteLine("l:{0}, r:{1}",l,r);
			if(l >= r){
				cnt++;
//Console.WriteLine(l);
				r = C[l];
			}
			r = Math.Min(C[l], r);
		}
		if(r <= N) cnt++;
		
		Console.WriteLine(cnt);
		
		
		
	}
	int N, M;
	int[] A, B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1; 
			B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17296
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 100005, inf = 2e9;

int n, t, mn = inf, mx, ans;

int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++) {
		scanf("%d",&t);
		mn = min(mn, t);
		if(mx < t - mn) {mx = t - mn; ans = 0;}
		if(mx == t - mn) ans++;
	}
	printf("%d\n",ans);
}


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

int main()
{
    int n,m;
    int sum = 0;
    cin >> n >> m;
    for(int i = 0; i < m; ++i)
    {
        int t;
        cin >> t;
        sum += t;
    }
    if(n < sum)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n-sum << endl;
    }
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

int main(void)
{
	while(cin >> n && n)
	{
		set<int> anses;
		int k = getInt();
		Array cards(n);
		readAll(cards, n);


		queue<IP> que;
		que.push(IP(0, P(0, k)));
		while (!que.empty())
		{
			IP ip = que.front(); que.pop();
			int bit = ip.first;
			P p = ip.second;
			int num = p.first; int rem = p.second;
			if(rem == 0) anses.insert(num);
			
			for (int i = 0; i < n; i++)
			{
				if(bit & (1 << i)) continue;
				IP nex;
				nex.first = bit | (1 << i);
				nex.second.first = num * (cards[i] >= 10 ? 100 : 10) + cards[i];
				nex.second.second = rem - 1;
				que.push(nex);
			}
		}

		cout << anses.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 46680
n = int(input())
s = [input() for _ in range(n)]

res = 0
bx = 0
xa = 0
ba = 0
for i in range(n):
    res += s[i].count('AB')
    if s[i][0] == 'B' and s[i][-1] == 'A':
        ba += 1
    elif s[i][0] == 'B':
        bx += 1
    elif s[i][-1] == 'A':
        xa += 1
if ba>0:
    res += ba-1
    if xa > 0:
        res += 1
        xa -= 1
    if bx > 0:
        res += 1
        bx -= 1
res += min(xa, bx)
print(res)

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n, ans = 0, val ;
    cin >> n ;
    val = n - 1 ;
    for (int i = 1; i <= val; i++) {
        ans += (val / i) ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 200005
using namespace std;
const ll MOD=1e9+7;

ll gcd(ll a, ll b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}
ll lcm(ll a, ll b) {
  return a*b/gcd(a,b);
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>  n(M,0);
  rep(i,N){
    ll K;
    cin >> K;
    rep(j,K){
      int a;
      cin >> a;
      n[a-1]++;
    }
  }
  int count=0;
  rep(i,M){
    if(n[i]==N){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,T;
  cin>>n>>T;
  int ans=1001;
  for(int i=0;i<n;i++){
    int c,t;
    cin>>c>>t;
    if(t<=T){
      ans=min(c,ans);
    }
  }
  if(ans==1001){
    cout<<"TLE"<<endl;
  }else{
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a*b%2==1)
cout<<"Odd";
else
cout<<"Even";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;cin>>s;
    if(s == "A") cout<<"T";
    if(s == "T") cout<<"A";
    if(s == "C") cout<<"G";
    if(s ==  "G") cout<<"C";
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL H, W;
    cin >> H >> W;

    if (H % 2 == 0)
    {
        cout << (H / 2) * W << endl;
    }
    else if (H == 1 or W == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        LL a = (H + 1) / 2;
        LL b = a - 1;
        if (W % 2 == 0)
        {
            cout << a * (W / 2) + b * (W / 2) << endl;
        }
        else
        {
            cout << a * (W + 1) / 2 + b * (W - 1) / 2 << endl;
        }
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1:
    if b == 2:
        c = 3
    else:
        c = 2
elif a == 2:
    if b == 1:
        c = 3
    else:
        c = 1
else:
    if b == 1:
        c = 2
    else:
        c = 1
print(c)

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

int main() {
    int r,D,x;
    cin>>r>>D>>x;
    int x1=r*x-D;
    cout<<x1<<endl;
    int x2=r*x1-D;
    cout<<x2<<endl;
    int x3=r*x2-D;
    cout<<x3<<endl;
    int x4=r*x3-D;
    cout<<x4<<endl;
    int x5=r*x4-D;
    cout<<x5<<endl;
    int x6=r*x5-D;
    cout<<x6<<endl;
    int x7=r*x6-D;
    cout<<x7<<endl;
    int x8=r*x7-D;
    cout<<x8<<endl;
    int x9=r*x8-D;
    cout<<x9<<endl;
    int x10=r*x9-D;
    cout<<x10<<endl;
}


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

const int MOD = 1e9 + 7;

int main() {
    string L; cin >> L;
    int n = L.length();
    vector<vector<ll> > memo(n, vector<ll>(2));
    memo[0][0] = 1;
    memo[0][1] = 2;
    for (int i = 1; i < L.length(); i++) {
        if (L[i] == '1') {
            memo[i][0] = (memo[i-1][0] * 3 + memo[i-1][1]) % MOD;
            memo[i][1] = (memo[i-1][1] * 2) % MOD;
        } else {
            memo[i][0] = (memo[i-1][0] * 3) % MOD;
            memo[i][1] = memo[i-1][1];
        }
    }
    cout << (memo[n-1][0] + memo[n-1][1]) % MOD << endl;
}


Measured memory_bytes: 5888
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let R:f64 = read();
    println!("{}", 2.00 * R * 3.1415);
}

Measured memory_bytes: 2180
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
 //   	freopen("input.txt", "r", stdin);
  //  	freopen("output.txt", "w", stdout);
//	#endif
	string x;
	cin>>x;
	rep(i,s(x)){
		cout<<"x";
	}

	return 0;
}

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

int main()
{
  int cnt['z' + 1] = {};
  string S;
  cin >> S;
  for (auto & s : S)
    ++cnt[s];
  for (int i = 'a'; i <= 'z'; ++i)
  {
    if (1 < cnt[i])
    {
      cout << "no";
      return 0;
    }
  }
  cout << "yes";
  return 0;
}


Measured memory_bytes: 256