akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int max=1e9+100;
const ll  MAX=1e18+500;
const int sz=2e5+100;
int mark[sz];
vector<int> test;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        test.clear();
        memset(mark,0,sizeof mark);
        int ara[n+2];
        for(i=1;i<=n;i++) cin>>ara[i];

        int ct=0;
        for(i=n;i>=1;i--){
            p=mark[i];
            x=0;
            if(p%2 != ara[i]) ++x,++ct,test.pb(i);
            if(x>0){
                int sq=sqrt(i);
                for(j=1;j<=sq;j++){
                    if(i%j==0){
                        ++mark[j];
                        if(j*j != i) ++mark[i/j];
                    }
                }
            }
        }
        reverse(test.begin(),test.end());
        cout<<ct<<endl;
        if(test.size()>0){
        for(auto xx: test) cout<<xx<<" ";
        cout<<endl;
        }
      
        
    }





}

Measured memory_bytes: 3192
n, Y = [int(s) for s in input().split(' ')]
 
for x in range(n, -1, -1):
    if Y < x*10000 or n < x:
        continue
    
    for y in range(n-x, -1, -1):
        if Y < x*10000+y*5000 or n < x+y:
            continue
            
        z = int((Y-x*10000-y*5000)/1000)
        if (Y-x*10000-y*5000) % 1000 == 0 and n == x+y+z:
            print('{} {} {}'.format(x, y, z))
            exit()
            
print('-1 -1 -1')

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

# def can_reach(x, default_pos, x_moves):
#     for tries in range(2**len(x_moves)):  # x_moves は最大 4000, 2**100 で既に 10**30 なのでぜんぜん間に合わない。
#         result = default_pos
#         for digit in range(len(x_moves)):
#             result += (x_moves[digit] if tries & (1<<digit) else -x_moves[digit])
#         if result == x:
#             return True
#     return False

# def can_reach(x_aim, default_pos, x_moves):  # ソートして貪欲？
#     for i in sorted(x_moves, reverse=True):
#         if x_aim > default_pos:
#             default_pos += i
#         else:
#             default_pos -= i
#     if default_pos == x_aim:
#         return True
#     else:
#         return False

# def can_reach(x_aim, default_pos, x_moves):  # dp → TLE
#     def dp(i, pos):
#         if i == 0:
#             if pos == default_pos: return True
#             else: return False
#         else:
#             return dp(i-1, pos - x_moves[i-1])  or dp(i-1, pos + x_moves[i-1])

#     return dp(len(x_moves), x_aim)

# def can_reach(x_aim, default_pos, x_moves):  # dp with table
#     dp = [[False for _ in range(20000)] for _ in range(len(x_moves)+1)]  # 20000 * 8000 = O(10**8) ぐらい
#     def read_dp(i, j):
#         return dp[i][j+10000]
#     def write_dp(i, j, k):
#         dp[i][j+10000] = k
#     write_dp(0, default_pos, True)
#     for i in range(len(x_moves)):
#         for j in range(20000):
#             if dp[i][j] == True:
#                 dp[i+1][j+x_moves[i]] = True
#                 dp[i+1][j-x_moves[i]] = True
#     return read_dp(len(x_moves), x_aim)
    

def can_reach(x_aim, default_pos, x_moves):  # dp with dict
    dp = set([default_pos])
    for i in x_moves:
        new_dp = []
        for j in dp:
            new_dp.append(j+i)
            new_dp.append(j-i)
        dp = set(new_dp)
    return x_aim in dp


def main(): 
    s = SI()
    x, y = LI()

    x_moves = []
    y_moves = []
    moving_x = True
    for i in s.split('T'):
        if moving_x:
            x_moves.append(len(i))
        else:
            y_moves.append(len(i))
        moving_x = not moving_x

    if can_reach(x, x_moves[0], x_moves[1:]) and can_reach(y, 0, y_moves):
        print('Yes')
    else:
        print('No')

main()

Measured memory_bytes: 3884
from itertools import accumulate

n = int(input())
a = [[0] * 1001 for _ in range(1001)]
for x1, y1, x2, y2 in (map(int, input().split()) for _ in range(n)):
    a[x1][y1] += 1
    a[x1][y2] -= 1
    a[x2][y1] -= 1
    a[x2][y2] += 1
print(max(map(max, map(accumulate, zip(*map(accumulate, a))))))

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll X, Y;

int main() {
    cin >> X >> Y;
    ll cnt = 0;
    while(X <= Y) {
        cnt++;
        X *= 2;
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
from heapq import*
h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=[]
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=[]
    for my,mx in stack:
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if len(tmp)==0:
        print(i)
        break

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

int main() {
    int N;
    cin >> N;
    vi S(N);
    rep(i, N) {
        cin >> S[i];
    }

    int sum = 0;
    rep(i, N) {
        sum += S[i];
    }
    
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }

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

    bool ok = false;
    for (int i = 0; i < N; i++) {
        if (S[i] % 10 != 0) {
            ok = true;
            sum -= S[i];
            break;
        }
    }

    if (ok) {
        cout << sum << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const int inf = 0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans;
}
ll mul(ll a,ll b){//大数取模乘法防止溢出
    ll ans=0;
    a%=mod,b%=mod;
    while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }
    return ans;
}
//(b/a)%p=b*a^(p-2)%p
int pr(ll num){//判断素数
     if(num == 1) return 0;
     if(num ==2|| num==3 ) return 1 ;
     if(num %6!= 1&&num %6!= 5) return 0 ;
     int tmp =sqrt( num);
     for(int i= 5;i <=tmp; i+=6 )
          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
     return 1 ;
}
int Day(int y,int m, int d){
    if(m==1||m==2) { m+=12; y--; }
    int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
    return w+1;
}
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}

//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec

//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址

const int maxn=1e5+5;
int d,v[maxn]={0};
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;++i){
        int temp;
        cin>>d;
        for(int j=1;j<=d;++j){
            cin>>temp;
            v[temp]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        if(v[i]==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3560
<?php
    $n = trim(fgets(STDIN));
    $arr = explode(" ", trim(fgets(STDIN)));
    sort($arr);
    $min = 0;
    $total = 0;
    for($i = $arr[0]; $i <= $arr[$n - 1]; $i++){
        for($j = 0; $j < $n; $j++){
            $total += ($arr[$j] - $i) * ($arr[$j] - $i);
        }
        if($i == $arr[0]){
            $min = $total;
        }
        elseif($min > $total){
            $min = $total;
        }
        $total = 0;
    }
    echo $min;
?>

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

#define ii pair<int, int>
#define LL long long int 
#define x first
#define y second
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define INF int(1e9)

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    string ABC = "ABC";
    int k = 0;
    string str;
    int n;
    cin >> n;
    cin >> str;

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

        if(str[i]==ABC[k])
            k++;
        else
        {
            if(str[i]=='A')
                k = 1;
            else
                k = 0;
        }
        if(k==3){
            ans++;
            k = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#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() {
    cin>>N;
    vec a(N), num(N, 0);
    rep(i,N){
        cin>>a[i];
        --a[i];
        ++num[a[i]];
    }
    ll ans = 0;
    rep(i,N){
        ans += num[i] * (num[i] - 1) / 2;
    }
    rep(i,N){
        ll temp = ans;
        A = a[i];
        temp -= (num[A] * (num[A] - 1)) / 2;
        temp += ((num[A] - 2) * (num[A] - 1)) / 2;
        cout<<temp<<endl;
    }
}

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

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

   if(S[5] == '0') {
    if(S[6] == '4' || S[6] == '3' || S[6] == '2' || S[6] == '1') {
        cout << "Heisei";
        return 0;
    }
   }

   cout << "TBD";    
   return 0;
}

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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	string s[55];
	for (int i = 0; i < h; i++)
		cin >> s[i];
	int a[] = { 0,1,0,-1,0 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.')
				continue;
			for (int k = 0; k < 4; k++) {
				if (i + a[k] < 0 || i + a[k] >= h || j + a[k + 1] < 0 || j + a[k + 1] >= w)
					continue;
				if (s[i + a[k]][j + a[k + 1]] == '#')
					goto pnz;
			}
			cout << "No" << endl;
			return 0;
		pnz:;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, h;
    cin >> n >> h;
    vll a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    ll ma = *max_element(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    ll ans = (h+ma-1)/ma;
    dump(ans);
    rep(i, n){
        h -= b[i];
        if(h < 0) h = 0;
        chmin(ans, (h+ma-1)/ma+i+1);
        dump(ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s, t;
	cin >> s >> t;
	bool f = false;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s == t) {
			f = true;
			break;
		}
		s = s.back() + s.substr(0, s.size() - 1);
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  ll n;
  scanf("%lld", &n) ;
  printf("%lld", ((n/11)<<1LL) + ((n%11)>6?2:(n%11==0)?0:1)) ;
	
  return 0 ;
}



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

struct po{
  int x,y,t;
};

int main(){
  int tu,n;
  while(1){
    cin>>tu>>n;
    if(tu==0 && n==0) break;
    queue<po> Q;
    set< pair<int,int> > co;
      for(int i=0;i<n;i++){
	int nx,ny;
	cin>>nx>>ny;
	co.insert(make_pair(nx,ny));
      }
    int sx,sy;
    cin >>sx>>sy;
    Q.push((po){sx,sy,0});
    co.insert(make_pair(sx,sy));
    int dx[6]={1,0,-1,-1,0,1},dy[6]={0,-1,-1,0,1,1};
    while(Q.empty()==false){
      po u = Q.front();
      Q.pop();
      if(u.t<tu){
	for(int i=0;i<6;i++){
	  int nx=u.x+dx[i];
	  int ny=u.y+dy[i];
	  if(co.count(make_pair(nx,ny))==0){
	    co.insert(make_pair(nx,ny));
	    Q.push((po){nx,ny,u.t+1});
	  }
	}
      }
    }
    cout<<co.size()-n<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 1360
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
ll A[50], B[50];

int main() {
    fastio();
    cin >> N;
    REP(i, N) cin >> A[i];
    ll ans = 0, tmp;
    while (true) {
        tmp = 0;
        REP(i, N) {
           B[i] = A[i] / N;
           tmp += B[i];
        }
        if(tmp == 0) break;
        ans += tmp;
        REP(i, N) {
            A[i] -= B[i] * N;
            A[i] += (tmp - B[i]);
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, k; cin >> n >> k;
	int a[5000];
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	n = lower_bound(a, a + n, k) - a;
	if (n == 0)cout << 0 << endl;
	else if (n == 1)cout << 1 << endl;
	else if (n == 2) {
		if (a[0] + a[1] < k)cout << 2 << endl;
		else cout << 0 << endl;
	}
	else {
		int le = 0; int ri = n;
		while (ri - le > 1) {
			int mid = (ri + le) / 2;
			bitset<5001> exi; exi[0] = 1;
			rep(i, n) {
				if (i == mid)continue;
				exi |= exi << a[i];
			}
			int chk;
			per(j, k) {
				if (exi[j]) {
					chk = j; break;
				}
			}
			if (chk + a[mid] >= k)ri = mid;
			else le = mid;
		}
		if (le == 0) {
			bitset<5001>exi; exi[0] = 1;
			Rep(i, 1, n) {
				exi |= exi << a[i];
			}
			int chk;
			per(j, k) {
				if (exi[j]) {
					chk = j; break;
				}
			}
			if (chk + a[0] >= k)cout << 0 << endl;
			else cout << 1 << endl;
		}
		else {
			cout << le + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


N = int(input())

ans = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i

print(ans)


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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	for {
	    var (
		a, b int
		s    string
	    )
		fmt.Scan(&a, &s, &b)
		if s == "?" {
			break
		}
		var ans int
		switch s {
		case "+":
			ans = a + b
		case "-":
			ans = a - b
		case "/":
			ans = a / b
		case "*":
			ans = a * b
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 1132
N,X=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(abs(X-x[i]))
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

ll=[0]*(N+1)
for i in range(N):
    ll[i+1]=gcd(ll[i],l[i])
print(ll[N])


Measured memory_bytes: 64408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[100][100];

int main(){
	int n;
	scanf("%d",&n);
	rep(_,0,n){
		char s[20]={};
		scanf("%s",s);
		int p=-1;
		for(int i=0;i<20;i++)if(s[i]=='.')p=i;
		ll x;
		sscanf(s,"%lld",&x);
		rep(i,0,9)x*=10;
		if(p==-1){
		}else{
			ll d;
			sscanf(s+p+1,"%lld",&d);
			int z=9-strlen(s+p+1);
			rep(i,0,z)d*=10;
			x+=d;
		}
		//printf("%lld\n",x);
		int p2=0,p5=0;
		while(x%2==0)x/=2,p2++;
		while(x%5==0)x/=5,p5++;
		a[p2][p5]++;
		//printf("%lld %lld\n",p2,p5);
	}
	
	ll ans=0;
	rep(i,0,50)rep(j,0,50)rep(ii,0,50)rep(jj,0,50){
		if(i+ii>=18&&j+jj>=18){
			ans+=a[i][j]*a[ii][jj];
			if(i==ii&&j==jj)ans-=a[i][j];
		}
	}
	printf("%lld\n",ans/2);
	
}

Measured memory_bytes: 1756
N,K = map(int, input().split())
h = list(map(int, input().split()))

DP=[0]*(N)
DP[0]=0
DP[1]=abs(h[1]-h[0])
#print(DP)
for i in range(2,N):
    DP[i]=DP[i-1]+abs(h[i]-h[i-1])
    for u in range(1,K+1):
        if i-u>=0:
            DP[i]=min(DP[i],DP[i-u]+abs(h[i]-h[i-u]))
        else:
            break
    #print(DP)
print(DP[N-1])

Measured memory_bytes: 84200
N = int(input())
ans = len(str(N)) # Fの値は高々この値
for A in range(1, int(N**0.5) + 1):
  if N % A != 0: # AはNの約数でない
    continue
  B = N // A
  f = len(str(max(A,B)))
  ans = min(ans, f)
print(ans)

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

int main(){
  int a, b, c ,d; cin >> a >> b >> c >> d;
  int tak, aoki;
  tak = (a - 1) / d;
  aoki = (c - 1) / b;
  if (tak >= aoki) cout << "Yes" <<endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
long long n;
long long k;
long long a[200005];
bool vis[200005];
long long Node;
long long Loop[200005];
void DetectLoop(long long u) {
	if(vis[u]){
		Node=u;
		return;
	}
	vis[u]=1;
	DetectLoop(a[u]);
}

long long GetBStep(long long u,long long step) {
	if(u==Node) {
		return step;
	}
	return GetBStep(a[u],step+1);
}

long long GetLoopLen(long long u,long long step) {
	if(vis[u]==1) {
		return step;
	}
	vis[u]=1;
	Loop[step]=u;
	return GetLoopLen(a[u],step+1);
}

int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
	}
	DetectLoop(1);
	memset(vis,0,sizeof(vis));
	//cout<<Node<<' '<<GetBStep(1,0)<<' '<<GetLoopLen(Node,0);
	long long r=GetBStep(1,0);
	long long mod=GetLoopLen(Node,0);
	if(k<=r) {
		int u=1;
		while(k!=0) {
			u=a[u];
			k--;
		}
		cout<<u;
		return 0;
	}
	cout<<Loop[(k-r)%mod];
	return 0;
}

Measured memory_bytes: 6772
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	bool f = false;
	if(a == b && b == c) f = true;
	cout << (f?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
#define mod 998244353
#define EPS 1e-9
#define tc int t; cin >> t; while(t--)
using namespace std;

int main() {
    FIO;
    int n,m; cin >> n >> m;
    vi h(n + 1), chk(n + 1, 1);
    FOR(i,1,n) cin >> h[i];
    while(m--){
        int a, b; cin >> a >> b;
        if(h[a] < h[b]) chk[a] = 0;
        if(h[a] > h[b]) chk[b] = 0;
        if(h[a] == h[b]) chk[a] = chk[b] = 0;
    }
    int ans = 0;
    FOR(i,1,n) ans += chk[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
    private static StringBuilder sb;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sb = new StringBuilder(s.length() * 3);
        int rc = 0;
        int lc = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R') {
                if (lc == 0) {
                    rc++;
                } else {
                    exec(rc, lc);
                    rc = 1;
                    lc = 0;
                }
            } else {
                lc++;
            }
        }
        exec(rc, lc);
        System.out.println(sb.substring(0, sb.length() -1));
    }
    private static void exec(int rc, int lc) {
        int sum = rc + lc;
        int half = sum / 2;
        if (sum % 2 == 0) {
            for(int i = 0; i < rc - 1; i++) {
                sb.append('0').append(' ');
            }
            sb.append(half).append(' ').append(half).append(' ');
            for(int i = 0; i < lc - 1; i++) {
                sb.append('0').append(' ');
            }
        } else {
            int rh = half;
            int lh = half;
            if (rc % 2 == 0) {
                lh += 1;
            } else {
                rh += 1;
            }
            for(int i = 0; i < rc - 1; i++) {
                sb.append('0').append(' ');
            }
            sb.append(rh).append(' ').append(lh).append(' ');
            for(int i = 0; i < lc - 1; i++) {
                sb.append('0').append(' ');
            }
        }
    }
}


Measured memory_bytes: 28196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,s;
int solve(int se,int no,int sum){
  if(no>=n){
    if(sum==s) return 1;
    else return 0;
  } 
  if(se>=10) return 0;
  return solve(se+1,no,sum)+solve(se+1,no+1,sum+se);
}
main(){
  while(1){
    int res;
    scanf("%d %d",&n,&s);
    if(n==0 && s==0) break;
    res=solve(0,0,0);
    printf("%d\n",res);
  }
}

Measured memory_bytes: 0
(N,),r,*L=$<.map{|l|l.split.map &:to_i};l=(n=*0..N).map{[1e9]*$.};L.map{|a,b,c|l[a][b]=l[b][a]=c};n.map{|k|n.map{|i|n.map{|j|(l[i][j]>t=l[i][k]+l[k][j])&&l[i][j]=t}}};p r.permutation.map{|b,*a|s=0;a.map{|c|s+=l[b][b=c]};s}.min

Measured memory_bytes: 102852
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;

int main(void) {
  long long N, D, A;
  cin >> N >> D >> A;
  map<P, long long> m;
  for (int i = 0; i < N; i++) {
    long long X, H;
    cin >> X >> H;
    m[P(X, 2)] = H;
  }
  long long ans = 0;
  long long current = 0;
  for (auto e : m) {
    if (e.first.second == 1) {
      current += e.second;
    } else {
      if (e.second <= current) continue;
      long long cnt = (e.second - current + A - 1) / A;
      ans += cnt;
      m[P(e.first.first + 2 * D + 1, 1)] = -cnt * A;
      current += cnt * A;
    }
  }

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

Measured memory_bytes: 25216
#include<cstdio>

int main() {
    int x,y;
    for(int i = 1; i <= 3000; i++){
        scanf("%d %d",&x,&y);
        if(x == 0 && y == 0){
            break;
        }
        if(x >= y){
            printf("%d %d\n",y,x);
        }
        else{
            printf("%d %d\n",x,y);
        }
    }
return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int,int>;
constexpr ll mod = 1000000007;
void pPRINTl(ostream& ost) { ost << endl; }
template <class T>void pPRINTL(ostream& ost,T t){ost<<t<<endl;}
template <class T, class... U>void pPRINTl(ostream& ost, T t, U... u) {ost << t << " ";pPRINTl(ost, u...);}
//template <class... T>void PRINTl(T... t) { pPRINTl(cout, t...); }
#define PRINTl //
void pPRINT(ostream& ost) {}
template <class T>void pPRINT(ostream& ost, T t){ost<<t;}
template <class T, class... U>void pPRINT(ostream& ost, T t, U... u) {ost << t << " ";pPRINT(ost, u...);}
template <class... T>void PRINT(T... t) { pPRINT(cout, t...); }
 
 
 
int main(){
  
  ll n,d;
  cin>>n>>d;
  PRINT(n/(d*2+1)+(n%(d*2+1)==0?0:1));
  
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int a, b, c;
    string ans = "win";
    cin >> a >> b >> c;
    if ((a + b + c) >= 22)ans = "bust";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int L,R,d;
  cin >> L >> R >>d;
  cout << R/d - (L-1)/d << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
 
int main() {
  string s; cin>>s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n<=999){
		n=n%100;
		n=n%10;
	}
	if(n==2||n==4||n==5||n==7||n==9) printf("hon\n");
	if(n==0||n==1||n==6||n==8) printf("pon\n");
	if(n==3) printf("bon\n");
	return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, a;

int main(){
	cin >> n >> a;
	n %= 500;
	if(n > a){
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A,B;
    cin >> A >>B;


    cout << A+B/2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int N,Ma,Mb;
int a[45],b[45],c[45];
int dp[450][450][45];

int main(){

cin>>N>>Ma>>Mb;

for(int i=0; i<N; i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);

for(int i=0; i<=400; i++){
    for(int j=0; j<=400; j++){
        for(int k=0; k<N; k++){
            dp[i][j][k]=INF;
        }
    }
}

for(int k=0; k<N; k++) dp[0][0][k]=0;
dp[a[0]][b[0]][0]=c[0];

for(int i=0; i<=400; i++){
    for(int j=0; j<=400; j++){
        for(int k=1; k<N; k++){
            dp[i][j][k]=min(dp[i][j][k],dp[i][j][k-1]);
            dp[i+a[k]][j+b[k]][k]=min(dp[i+a[k]][j+b[k]][k],dp[i][j][k-1]+c[k]);
        }
    }
}

int ans=INF;
for(int i=1; i<=400; i++){
    for(int j=1; j<=400; j++){
        for(int k=0; k<N; k++){
            if(i*Mb==j*Ma) ans=min(ans,dp[i][j][k]);
        }
    }
}

if(ans<INF) cout<<ans<<endl;
else cout<<-1<<endl;

}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, M=0, sum=0, A;
	cin>>N;
	for(int i=0;i<N;i++) {
		cin>>A;
		M=max(M,A);
		sum+=A;
	}
	cout<<(M<sum-M ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
 int a, b, c;
 int id = 0;
 cin >> a >> b >> c;
 for(int i = a; i<=b; ++i)
   if(c%i == 0)
     ++id;
 cout << id << endl;
 return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
queue<int> q[3];
int main()
{
	for(int i=0;i<3;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<s.size();j++)
		{
			q[i].push(s[j]-'a');
		}
	}
	int id=0;
	int num;
	while(1)
	{
		if(q[id].empty())  break;
		num=q[id].front();
		q[id].pop();
		id=num;
	}
	cout<<char(id+'A')<<endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int a,b,m;
  cin >> a >> b >> m;
  vector<int> ar(a);
  vector<int> br(b);

  forn(i,a) cin >> ar[i];
  forn(i,b) cin >> br[i];
  int ans = (*min_element(all(ar))) + (*min_element(all(br)));
  forn(i,m){
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    setmin(ans, ar[x]+br[y]-c);
  }

  cout << max(0, ans) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 1024
from collections import deque

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

buf = deque()
tmp = 0
ans = 0

for a in aaa:
    while tmp & a:
        rm = buf.popleft()
        tmp ^= rm
    buf.append(a)
    tmp ^= a
    ans += len(buf)
print(ans)


Measured memory_bytes: 24012
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long  ll;
const int mod = 1e9 + 7;
const int MAXN = 1111;

int dp[MAXN][MAXN];

int main(){
    faster
    int h, w; cin >> h >> w;
    vector<string> p(h);
    for(int i = 0;i < h;i++) cin >> p[i];
    dp[0][0] = 1;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(p[i][j] == '#')continue;
            if(j > 0) dp[i][j] += dp[i][j - 1];
            if(i > 0) dp[i][j] += dp[i - 1][j];
            dp[i][j] = dp[i][j] % mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

    



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  char tmp=N[0];
  int counter = 1;
  int max_count = 1;
  
  
  for(int i=1; i<4; i++){
    if (tmp==N[i]){
      counter++;
      if (max_count<counter){
        max_count = counter;
      }
    }
    else{
      counter = 1;
    }
    tmp = N[i];
  }
  
  if (max_count>=3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define H 250

struct Node{
  int id;
  int k;
  int pk;
  int lk;
  int rk;
};

typedef struct Node node;
int n;
node s[H];

void heep();

int main()
{
  int i;

  scanf("%d", &n);

  for(i=1;i<=n;i++){
    scanf("%d", &s[i].k);
    s[i].id = i;
  }
  
  heep();

  return 0;
}

void heep()
{
  int i;
  
  for(i=1;i<=n;i++){
    if(i!=1)s[i].pk = s[i/2].k;
    if(2*i<=n)s[i].lk = s[2*i].k;
    if(2*i+1<=n)s[i].rk = s[2*i+1].k;
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ", s[i].id, s[i].k);
    if(s[i].pk!=0)
      printf("parent key = %d, ", s[i].pk);
    if(s[i].lk!=0)
       printf("left key = %d, ", s[i].lk); 
    if(s[i].rk!=0)
      printf("right key = %d, ", s[i].rk);
    printf("\n");
  }
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
struct point{double x,y;};
void koch(int d,point p1,point p2){
	point s,u,t;
	double th=M_PI*60.0/180.0;
	if(d==0)
	return ;
	s.x=(p1.x*2.0+p2.x)/3.0;
	s.y=(p1.y*2.0+p2.y)/3.0;
	t.x=(p1.x+p2.x*2.0)/3.0;
	t.y=(p1.y+p2.y*2.0)/3.0;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	koch(d-1,p1,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(d-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
    koch(d-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(d-1,t,p2);
		}

main(){
	int n;
	point a,b;
	scanf("%d",&n);
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll f(int x) {
  int r = 0;
  while (x && (x & 1) == 0) {
    r++;
    x >>= 1;
  }
  return r;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 101010101;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans = min(ans, f(x));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = [int(i) for i in input().split(' ')]

def res():
  if N == K:
    return 0
  elif N > K:
    return N % K if K - (N % K) > (N % K) else K - (N % K)
  else :
    return abs(N - K) if abs(N - K) < abs(abs(N-K) - K) else abs(abs(N-K) - K)

print(res())

Measured memory_bytes: 3060
def dfs(u):
    for v in range(nv):
        if adj[u][v] and not visited[v]:
            visited[v] = True
            if matches[v] is None or dfs(matches[v]):
                matches[v] = u
                return True
    return False

nu, nv, ne = map(int, input().split(' '))
adj = [[False] * nv for _ in range(nu)]
matches = [None] * nv
count = 0

for _ in range(ne):
    s, t = map(int, input().split(' '))
    adj[s][t] = True

for u in range(nu):
    visited = [False] * nv
    if dfs(u): count += 1

print(count)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b;
  cin>>a>>b;
  ll ans=-1;
  for(ll i=1; i<=2000; i++){
    if(ll(i*0.08)==a && ll(i*0.1)==b){
      ans=i;
      break;
    }
  }
  

  cout<<ans<<endl;
}


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

typedef struct List {
	struct List *next;
	long long value, num;
} list;

int main()
{
	int i, N;
	long long A[200001] = {};
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	long long h;
	list *p, data[200001] = {}, *hash[100003] = {&(data[0])};
	for (i = 1; i <= N; i++) {
		data[i].value = data[i-1].value + A[i];
		for (h = llabs(data[i].value) % 100003, p = hash[h]; p != NULL; p = p->next) {
			if (data[i].value == p->value) break;
		}
		if (p != NULL) (p->num)++;
		else {
			data[i].next = hash[h];
			data[i].num = 0;
			hash[h] = &(data[i]);
		}
	}
	
	long long ans = 0;
	for (i = 0; i < 100003; i++) {
		for (p = hash[i]; p != NULL; p = p->next) ans += p->num * (p->num + 1) / 2;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>

using namespace std;

int main() {

  int candy;

  
  while(cin >> candy) {

    if(candy%39==0) cout << "3C39" << endl;

    else if(candy%39<10) cout << "3C0" << candy%39 << endl;

    else cout << "3C" << candy%39 << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
int a;
cin >> a;
if(a>=1000){cout << "ABD" ;
           
           }else {cout << "ABC" ;
                  
                 }
}

Measured memory_bytes: 256
N, K = map(int,input().split())
ls_pass = [0]+list(map(int,input().split()))
a=1
b=0

ls=["ンゴ"]+[0]+["ンゴ"]*(N-1)
ls_past=[1]
for i in range(1,N*3):
  b=a
  a=ls_pass[a]
  if ls[a]!="ンゴ":
    ls_cicle=ls_past[ls[a]:i]
    print(ls_cicle[(K-i)%len(ls_cicle)])
    break
  elif i==K:
    print(a)
    break  
  else:
    ls_past.append(a)
    ls[a]=i

Measured memory_bytes: 32388
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  ll ans=1;
  cin>>n;
  vector<ll>b(n,0);
  vector<ll>an(n,0);
  for(ll i=0;i<n;i++){
    cin>>b[i];
    if(b[i]<=(i+1)){}
    else{
      ans=0;
      break;
    }
  }
  if(ans==0){
    cout<<-1<<endl;
    return 0;
  }
  for(ll i=n-1;i>=0;i--){
    for(ll j=i;j>=0;j--){
      if(b[j]==(j+1)){
        an[i]=j+1;
        b.erase(b.begin()+j);
        break;
      }
    }
  }
  for(ll i=0;i<n;i++){
    cout<<an[i]<<endl;
  }
}


Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
N, K = [int(x) for x in input().strip().split()]
P = [int(x) for x in input().strip().split()]
q = deque([])
cur = 0
ans = 0
for i, p in enumerate(P):
    e = (1+p) / 2
    q.append(e)
    cur += e
    if i >= K-1:
        ans = max(ans, cur)
        e_ = q.popleft()
        cur -= e_
print(ans)

Measured memory_bytes: 71792
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int a[3];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a[0]>>a[1]>>a[2];
    int b=100*a[0]+10*a[1]+a[2];
    if(b%4==0)
        cout<<"YES\n";
    else cout<<"NO\n";
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    rep(j,0,s.length()){
        rep(i,0,n){
            s[j] = s[j]+1;
            if(s[j] == 'Z'+1){
                s[j] = 'A';
            }
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256