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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;i++){
    cin >> s[i];
  }
  vector<vector<int>> l(h,vector<int>(w));
  vector<vector<int>> r(h,vector<int>(w));
  vector<vector<int>> u(h,vector<int>(w));
  vector<vector<int>> d(h,vector<int>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        l[i][j]=-1;
        u[i][j]=-1;
      }else{
        if(j>0){
          l[i][j]=l[i][j-1]+1;
        }
        if(i>0){
          u[i][j]=u[i-1][j]+1;
        }
      }
    }
  }
  for(int i=h-1;i>=0;i--){
    for(int j=w-1;j>=0;j--){
      if(s[i][j]=='#'){
        r[i][j]=-1;
        d[i][j]=-1;
      }else{
        if(j<w-1){
          r[i][j]=r[i][j+1]+1;
        }
        if(i<h-1){
          d[i][j]=d[i+1][j]+1;
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 67200
#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 reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    cout << a << endl;
  } else {
    cout << a-1 << endl;
  }
  return 0;
}

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

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

  int x, y;
  cin >> x >> y;
  
  cout << abs(x - y) << endl;

}


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

int main(){
    int dish[5];
    int min10;
    int minN10;
    int ans = 0;

    //input
    for(int i = 0; i < 5; i++){
        cin >> dish[i];
    }
    min10 = (dish[0] - 1) % 10;
    minN10 = 0;
    for(int i = 1; i < 5; i++){
        if(min10 > (dish[i] - 1) % 10){
            min10 = (dish[i] - 1) % 10;
            minN10 = i;
        }
    }

    for(int i = 0; i < 5; i++){
        if(minN10 == i){
            ans += dish[i];
        }else{
            if(dish[i] % 10 == 0){
                ans += (dish[i] / 10) * 10;
            }else{
                ans += (dish[i] / 10 + 1) * 10;
            }
        }
    }

    //output
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;
using Graph = vector<vector<ll>>; // グラフ型 // グラフ


int main()
{
    ll k;
    cin >> k;
    if(k>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int* inputArray(int num){
    int* ans;
    ans = new int[num];
    for(int i = 0; i < num; i++){
        scanf("%d", &ans[i]);
    }
    return ans;
}

int sum(int* input, int num){
    int ans = 0;
    for(int i = 0; i < num; i++) ans += input[i];
    return ans;
}

int main(){
    int h, n;
    cin >> h >> n;
    int ans = sum(inputArray(n), n);
    if(ans < h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  map<string,int> d;
  cin >> N;
  REP(i,N){
  	string s;
  	cin >> s;
  	d[s]++;
  }
  int maxv = 0;
  FORE(p,d){
  	chmax(maxv,p.second);
  }

  FORE(p,d){
  	if(p.second == maxv){
  		cout << p.first << endl;
  	}
  }

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vll;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 4e2+5;

ll n, t, a[N], s[N];
ll memo[N][N];

ll sum (int l, int r) {
    return s[r] - s[l-1];
}

ll cost (int l, int r) {
    if (memo[l][r]) return memo[l][r];
    if (l == r) return memo[l][r] = 0;
    ll ans = LINF;
    for (int i = l; i < r; i++) {
        ans = min(ans, sum(l, i) + sum(i+1, r) + cost(l, i) + cost(i+1, r));
    }
    return memo[l][r] = ans;
}

int main () {
    scanf("%lld", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        s[i] = a[i];
        s[i] += s[i-1];
    }

    printf("%lld\n", cost(1, n));

    return 0;
}

Measured memory_bytes: 1536
N = int(input())

k = 0
T = False

while N-(k*7)>0:
    if (N-(k*7))%4 == 0:
        T = True
        break
    k += 1

if N-(k*7)==0:
    T = True

if T:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
/*
14.4.20
*/
#include "bits/stdc++.h"
#define int long long
using namespace std;

int32_t main() {
	int n, W;
	cin >> n >> W;

	int wt[n], val[n];
	for(int i = 0; i < n; ++i) {
		cin >> wt[i] >> val[i];
	}

	int dp[100005];
	for(int i = 0; i <= 100000; ++i) dp[i] = 10000 * 100000 + 7;

	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 1000 * 100; j >= val[i];--j) {
			dp[j] = min(dp[j], dp[j-val[i]] + wt[i]);
		}
	}

	int mxm = -1e9;
	for(int i = 0; i <= 1000 * 100; ++i) {
		if(dp[i] <= W) {
			mxm = max(mxm, i);
		}
	}

	cout << mxm << endl;
}
/*
If for(int j = val[i]; j >= 100000; ++j) is used 
the for
3 8
3 30
4 50
5 60

dp[100] = 8;
Each wt will be used multiple times

Therefore, reverse order is followed
*/

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 1000000000;
    for(int i = 0; i<= int(s.size()) - int(t.size()); i++) {
        int curr = 0;
        for(int j = i; j<i+int(t.size()); j++) {
            if(s[j] != t[j-i]) curr ++;
        }
        ans = min(ans, curr);
    }
    cout << ans << '\n';
}

int main() {_
    int t = 1;
//    cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
inf = float('inf')
from scipy.optimize import fmin
from collections import defaultdict
dir = {'R', 'L', 'U', 'D'}
N = int(input())
dic = defaultdict(list)
for _ in range(N):
    x, y, d = input().split()
    x, y = int(x), int(y)
    dic[d].append((x, y))
x_max = defaultdict(lambda : -inf)
x_min = defaultdict(lambda : inf)
y_max = defaultdict(lambda : -inf)
y_min = defaultdict(lambda : inf)
for d in dir:
    if dic[d]:
        dic[d].sort()
        x_max[d] = dic[d][-1][0]
        x_min[d] = dic[d][0][0]
        dic[d].sort(key = lambda x:x[1])
        y_max[d] = dic[d][-1][1]
        y_min[d] = dic[d][0][1]
def dx(t):
    return max(x_max['U'], x_max['D'], x_max['R']+t, x_max['L']-t)-min(x_min['U'], x_min['D'], x_min['R']+t, x_min['L']-t)
def dy(t):
    return max(y_max['U']+t, y_max['D']-t, y_max['R'], y_max['L'])-min(y_min['U']+t, y_min['D']-t, y_min['R'], y_min['L'])
def f(t):
    if t<0:
        return inf
    return dx(t)*dy(t)

xopt = fmin(f, x0 = 10**8, ftol = 10**-9, disp = False)
print(f(xopt[0]))













Measured memory_bytes: 31228
program main
character(3000) s,t
integer,allocatable,dimension(:,:)::DP
character(3000) ans
read*,s,t
allocate( DP(0:len_trim(s),0:len_trim(t)) )

!DP(i,j)にはSのi文字目までの部分とTのj文字目までの部分のLCSの長さが格納されています
!初期条件としてDP(0,:)=0及びDP(:,0)=0が既知です。
!一番左上に(0,0)を据えて右下に展開していくとします。
!このときある(i,j)について
!一つ上でかつ一つ左の値と一つ上の値と一つ左の値を知っていたらば(i,j)を求めることが可能です。

DP=0
do i= 1, len_trim(s)
  do j= 1, len_trim(t)
    if(s(i:i)==t(j:j))then
      DP(i,j)=DP(i-1,j-1)+1
    else
      DP(i,j)=max(DP(i-1,j),DP(i,j-1))
    endif
  end do
end do

!一番DPの値が高いところ(DP(len_trim(s),len_trim(t)))から1段ずつ降っていきます
ans=""
i = len_trim(s)
j = len_trim(t)
do
  if( DP(i,j)==DP(i-1,j) )then
    i=i-1
  else if( DP(i,j)==DP(i,j-1) )then
    j=j-1
  else
    ans = s(i:i)// trim(ans)
    i=i-1
    j=j-1
  end if
  if(DP(i,j)==0)exit
end do

print"(A)",trim(ans)
end program main

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010,mod=998244353;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
struct item{
	string s;
	int p,id;
	bool operator<(const item& i)const{
		if(s!=i.s) return s<i.s;
		return p>i.p;
	}
}it[maxn];
int n;
int main(){
	cin>>n;
	FOR(i,1,n) cin>>it[i].s>>it[i].p,it[i].id=i;
	sort(it+1,it+n+1);
	FOR(i,1,n) printf("%d\n",it[i].id);
}

Measured memory_bytes: 1792
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double norm(point a){
  return sqrt(dot(a,a));
}

int isOnSegment(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
    (dot(b-a, c-a) > -EPS) &&
    (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return isOnSegment(a1,a2,b1) || isOnSegment(a1,a2,b2)
      || isOnSegment(b1,b2,a1) || isOnSegment(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
      ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}
double distance_ls_p(point a, point b, point c) {
  if ( dot(b-a, c-a) < EPS ) return norm(c-a);
  if ( dot(a-b, c-b) < EPS ) return norm(c-b);
  return abs(cross(b-a, c-a)) / norm(b-a);
}

double dist(point a,point b,point c,point d){
  if(is_intersected_ls(a,b,c,d))return 0.0;
  double A=distance_ls_p(a,b,c);
  double B=distance_ls_p(a,b,d);
  double C=distance_ls_p(c,d,a);
  double D=distance_ls_p(c,d,b);
  return min(min(A,B),min(C,D));
}

int main(void){

  int q;
  cin >> q;
  while(q--){
    point a,b,c,d;
    cin >> a.x >> a.y >> b.x >> b.y;
    cin >> c.x >> c.y >> d.x >> d.y;

    printf("%.10f\n",dist(a,b,c,d));
  }
  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
        n=n%10;
        if(n==3)
        {
            cout<<"bon";
            return 0;
        }
        else if(n==2 || n==4 || n==5 || n==7 || n==9)
        {
            cout<<"hon";
            return 0;
        }
        else
        {
            cout<<"pon";
            return 0;
        }
}

Measured memory_bytes: 3580
n = int(input())

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

    divisors.sort()
    return divisors

#nは必ず含まれる
ans = 1

ans += len(make_divisors(n-1)) - 1

l = make_divisors(n)

for num in l[1:]:
	if num**2 > n:
		break
	else:
		tmp = n
		while True:
			tmp = tmp // num
			if tmp % num != 0:
				break
		if tmp % num == 1:
			ans += 1

print(ans)


Measured memory_bytes: 3188
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
#define sz 1000002
int cnt[sz];
int primes[sz + 1];
//ADVANTAGES OF THIS TECHNIQUE IS WHEN THERE ARE MANY QUERIES THEN SQRT(N) TRICK MIGHT NOT WORK INSTEAD WE CAN DO BIG OF LOGN PER QUERY PRIME_FACTORIZATION USING SIEVE METHOD
//SO IT IS ALSO A VERY USEFUL TECHNIQUE
//prime factorization using sieve
void sieve(){
    int i,j;
    for(i = 1;i<=sz;i++) primes[i] = -1;
    for(i = 2;i<=sz;i++){
        if(primes[i] == -1)
        {for(j = i; j <= sz;j += i){
               if(primes[j] == -1){
                   primes[j] = i;
               }
        }
        }
    }
}
int get_prime_factor(int n){
    int fl = 0;
    int temp = -1;
    while(n != 1){
        if(temp != primes[n]){
            temp = primes[n];
            cnt[primes[n]]++;
            if(cnt[primes[n]] > 1) {
                fl = 1;
                break;
            }
        }
        n = n / primes[n];
    }
      return fl;
}
int main(){
   int q,n,fl,i,j;
   sieve();
   cin >> n;
   int a[n];
   for(i = 0;i<n;i++) cin >> a[i];
   int gg =  a[0];
   for(i = 1;i<n;i++) gg = __gcd(gg,a[i]);
   for(i = 0;i<n;i++){
       fl = get_prime_factor(a[i]);
       if(fl == 1) break;
   }
     if(fl == 0) cout << "pairwise coprime" << endl;
     else if(fl == 1 && gg == 1) cout << "setwise coprime" << endl;
     else cout << "not coprime" << endl;
    return 0;
}



Measured memory_bytes: 11704
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string o,e;
    cin >> o >> e;
    int n = min(o.size(), e.size());

    for (int i=0; i<n; i++) cout << o[i] << e[i];
    if (o.size() > e.size()) cout << o.back();
    if (e.size() > o.size()) cout << e.back();
    cout << endl;
}

Measured memory_bytes: 512
import sys
# from math import gcd
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')


a,b,c,d = map(int,input().split())
g = gcd(c, d)
l = c * d // g

def f(p, q):
    return p // q

res = b - a + 1
res -= f(b, c) - f(a - 1, c)
res -= f(b, d) - f(a - 1, d)
res += f(b, l) - f(a - 1, l)

print(res)

Measured memory_bytes: 5556
// Problem C

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

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

ll N, K;

int main() {
  cin >> N >> K;
  cout << min(N%K, K - (N%K)) << endl;
  
  return 0;
}


Measured memory_bytes: 3588
import math

N, K = map(int, input().split())
ans_base = []

for i in range(1, N+1):
    ans_base.append(max(math.ceil(math.log(K / i, 2)), 0))

base_min = min(ans_base)
ans = 0
for j in range(N):
    ans += (1 / 2) ** (ans_base[j] - base_min)

ans *= (1 / N) * (1 / 2) ** base_min
print(ans)

Measured memory_bytes: 3864
#include <cstdio>

int n;

int main() {
    scanf("%d", &n);
    int x = n % 10;
    if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) printf("hon");
    else if (x == 0 || x == 1 || x == 6 || x == 8) printf("pon");
    else printf("bon");
}


Measured memory_bytes: 1732
n = int(input())
a = input().split()
t = [int(m) for m in a]
m = int(input())
#行列
c = []
for i in range(m):#h:高さ
    c.append([int(m) for m in input().split()])
k = sum(t)
for i in range(m):
    print(k - t[c[i][0] - 1] + c[i][1])

Measured memory_bytes: 3064
U = 3000
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def perm(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[n-k]
    z %= MOD
    return z

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z *= fact_inv[n-k]
    z %= MOD
    return z

ans = 0
s = int(input())
for k in range(1, s+1):
    if s-3*k < 0:
        break
    a = s-3*k
    ans += comb(a+k-1, k-1)
    ans %= MOD
print(ans)

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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int N,res=0,l,r;
    cin >> N;
    vector<bool> v(10000,true);

    v[1]=false;

    for (int i=2;i<v.size();i++){
        if(v[i]){
            for(int j=2*i;j<v.size();j+=i){
                v[j] = false;
            }
        }
    }

    
    for (int i=11;i<v.size();i+=10){
        if(v[i]) {
            N--;
            cout << i << " ";
            }
        if (N==0){
            cout << endl;
            break;
        }
    }
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

A, B, C, D, E, F = MAP()

water = set()

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

sugar = [0]*(F+1)
sugar[0] = 1
for i in range(1, F+1):
	sugar[i] = 0<(sugar[i-C]*(0<i) + sugar[i-D]*(0<i))

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp

#print(water)
#print(sugar_acc)

ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	t = min(E*water_tmp//100, F-water_tmp)
	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue
	den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)


Measured memory_bytes: 10596
using System;

class Program
{
    static void Main(string[] args)
    {
        var xy = Console.ReadLine().Split(' ');
        var x = long.Parse(xy[0]);
        var y = long.Parse(xy[1]);

        var ans = 0;
        while (x <= y)
        {
            ans++;
            x *= 2;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
    a[i] = v[i];
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (a[i] < v[n / 2]) {
      cout << v[n / 2] << endl;
    } else {
      cout << v[n / 2 - 1] << endl;
    }
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 122;
 
int n, k;
int a[N];
int b[N];
int neg[N], pos[N];
int s;
vector <int> d;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	cin >> n >> k;                                                                                 
	for(int i = 1; i <= n; i++) cin >> a[i], s += a[i], b[i] = a[i];
	for(int i = 1; i * i <= s; i++)                                                                	
	{
		if(s % i == 0)
		{
			d.pb(i);
			d.pb(s / i);
		}
	}
	sort(all(d));
	resize(d);
	reverse(all(d));
	for(int it : d)
	{
		for(int i = 1; i <= n; i++) b[i] = a[i] % it, neg[i] = 0, pos[i] = 0;
		sort(b + 1, b + n + 1);
		for(int i = 1; i <= n; i++)
		{
			neg[i] = neg[i - 1] + b[i];
			pos[i] = pos[i - 1] + (it - b[i]) % it; 
		}
		for(int i = 1; i <= n; i++)
		{
			int cnt1 = neg[i];
			int cnt2 = pos[n] - pos[i];
			if(cnt1 == cnt2 && cnt2 <= k) cout << it, exit(0);
		}
	}
}                                

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define endl "\n"
#define int long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
const int nmax = 1e5 + 7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(2);
    map <string, int> m;
    m["AC"] = 0; m["WA"] = 0; m["TLE"] = 0; m["RE"] = 0;
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        string x; cin >> x;
        m[x]++;
    }
    for (int i = 0; i < 4; ++i) {
        for (auto x : m) {
            if (i == 0 and x.first == "AC") {
                cout << x.first << " x " << x.second << endl;
                break;
            }
            if (i == 1 and x.first == "WA") {
                cout << x.first << " x " << x.second << endl;
                break;
            }
            if (i == 2 and x.first == "TLE") {
                cout << x.first << " x " << x.second << endl;
                break;
            }
            if (i == 3 and x.first == "RE") {
                cout << x.first << " x " << x.second << endl;
                break;
            }
        }
    }


}

Measured memory_bytes: 3668
#include<stdio.h>

int main(){
    int a,b;
    char buf[10] = "";
    scanf("%d%d",&a,&b);
    if(a < b){
        a^=b;
        b^=a;
        a^=b;
    }
    int i;
    for(i = 0; i < a; i++){
        buf[i] = '0' + b;
    }
    buf[i] = 0;
    puts(buf);

    return 0;
}

Measured memory_bytes: 128
inf=100000000

def calc(uth,dis,c):
    fare=0
    if dis>=inf:
        return inf
    if unchin[c]==1:
        return uth[c][1][0]*dis
    ddis=uth[c][0]
    dcost=uth[c][1]
    i=1
    while(i<unchin[c] and dis>ddis[i]):
        fare+=(ddis[i]-ddis[i-1])*dcost[i-1]
        i+=1
    fare+=(dis-ddis[i-1])*dcost[i-1]
    return fare

def floyd(bigmap,n):
    res=bigmap
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                if res[i][j]>res[i][k]+res[k][j]:
                    res[i][j]=res[i][k]+res[k][j]
    return res

def init2d(bigmap,n):
    for i in range(n+1):
        bigmap.append([])
    for map1 in bigmap:
        for j in range(n+1):
            map1.append(inf)
    for i in range(1,n+1):
        bigmap[i][i]=0
    return bigmap

while(1):
    n,m,c,s,g=map(int,raw_input().split())
    if(n==m==0): break
    rosen=[]
    for i in range(c+1):
        map0=[]
        rosen.append(init2d(map0,n))

    for i in range(m):
        x,y,d,c0=map(int,raw_input().split())
        rosen[c0][x][y]=min(rosen[c0][x][y],d)
        rosen[c0][y][x]=min(rosen[c0][x][y],d)

    unchin=list(map(int,raw_input().split()))
    unchin.insert(0,0)
    uth=[]
    uth.append([])
    for i in range(1,c+1):
        ddis=list(map(int,raw_input().split()))
        ddis.insert(0,0)
        dcost=list(map(int,raw_input().split()))
        uth.append([ddis,dcost])

    bigmap=[]
    bigmap=init2d(bigmap,n)


    for c0,cmap in enumerate(rosen[1:]):
        tmp=floyd(cmap,n)
        for i in range(1,n+1):
            for j in range(1,n+1):
                bigmap[i][j]=min(bigmap[i][j],calc(uth,tmp[i][j],c0+1))

    bigmap=floyd(bigmap,n)

    ans=bigmap[s][g]
    if ans < inf:
        print(ans)
    else:
        print(-1)

  

Measured memory_bytes: 11480
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 300100;
char s[maxn];
int sum[maxn];
int main(void) {
    int n; scanf("%d%s",&n,s+1);
    for (int i=1;i<=n;i++) if (s[i] == 'E') sum[i]=sum[i-1]+1; else sum[i]=sum[i-1];
    int mx = n;
    for (int i=1;i<=n;i++) {
        mx=min(mx,(i-1-sum[i-1])+(sum[n]-sum[i]));
    }
    printf("%d\n",mx);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;


void solve(){
   int l, r, d;
   cin >> l >> r >> d;
   int s , c = 0;
   for(int i = 1; i <= r; i++){
       s = i * d;
       if(s >= l && s <= r){
           c++;
       }
   }
   cout << c << endl;

}



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


    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ll A, B, N;
  scanf("%lld%lld%lld", &A, &B, &N);
  ll x = B - 1;
  if (N < B) x = N;
//  cerr << x << endl;
  printf("%lld\n", (ll) floor(1.0 * A * x / B) - 1ll * A * (ll) floor(1.0 * x / B));
  return 0;
}


Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long; 

int main() {
    ll a,b,c,count=0;
    ll na,nb,nc;
    cin >> a >> b >> c;

    if (a%2==1 or b%2==1 or c%2==1) {
        cout << 0 << endl;
    }
    else if (a==b and b==c) cout << -1 << endl;
    else {
        while (true) {
            if (a%2==1 or b%2==1 or c%2==1) {
                cout << count << endl;
                break;
            }
            else {
                na=(b+c)/2;nb=(a+c)/2;nc=(a+b)/2;
                a=na;b=nb;c=nc;
                ++count;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut m:usize = read!();
    let mut v:usize = 0;
    for i in 0..m {
        let a:usize = read!();
        v += a;
    }
    if n < v {
        println!("-1");
        exit(0);
    }
    println!("{}",n-v);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K,C;
    string S;
    cin >> N >> K >> C >> S;
    vector<int>cnt;
    vector<int>res;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'o') {
            cnt.push_back(i);
            if(res.size() == 0) {
                res.push_back(i);
            }
            else if(res.back()+C < i) {
                res.push_back(i);
            }
        }
    }
    if(res.size() > K) {
        return 0;
    }
    vector<int>res2;
    for(int i = N-1; i >= 0; i--) {
        if(S[i] == 'o') {
            if(res2.size() == 0) {
                res2.push_back(i);
            }
            else if(res2.back()-C > i) {
                res2.push_back(i);
            }
        }
    }
    for(int i = 0; i < K; i++) {
        if(i+1 != K) {
            if(cnt[lower_bound(cnt.begin(),cnt.end(),res[i]+1)-cnt.begin()]+C < res2[K-i-2]) {
                continue;
            }
            cout << res[i]+1 << endl;
        }
        else if(res[i] == res2[K-i-1]){
            cout << res[i]+1 << endl;
        }
    }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    vector<int> goal {0, 1, 2, 3, 4, 5, 6, 7};
    queue<vector<int>> que;
    que.push(goal);

    map<vector<int>, int> mp;
    mp[goal] = 0;

    while(que.size()){
        vector<int> s = que.front(); que.pop();
        int cost = mp[s];
        int zi = -1;
        for(int i=0;i<8;i++){
            if(s[i] == 0){
                zi = i;
                break;
            }
        }
        if(zi % 4 < 3){
            vector<int> next = s;
            assert(zi + 1 < 8);
            swap(next[zi], next[zi+1]);
            if(mp.find(next) == mp.end()){
                mp[next] = cost + 1;
                que.push(next);
            }
        }
        if(zi % 4 > 0){
            vector<int> next = s;
            swap(next[zi], next[zi-1]);
            assert(zi - 1 >= 0);
            if(mp.find(next) == mp.end()){
                mp[next] = cost + 1;
                que.push(next);
            }
        }

        vector<int> next = s;
        assert((zi+4)%8 >= 0);
        swap(next[zi], next[(zi+4)%8]);
        if(mp.find(next) == mp.end()){
            mp[next] = cost + 1;
            que.push(next);
        }
    }

    int temp;
    while(cin >> temp){
        vector<int> query(8);
        query[0] = temp;
        for(int i=1;i<8;i++){
            cin >> query[i];
        }
        assert(mp.find(query) != mp.end());
        cout << mp[query] << endl;
    }

    return 0;
}

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

vector<int> a[4];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for (int i = 0; i < 3; ++i) {
		int u, v;
		cin >> u >> v;
		a[--u].push_back(--v);
		a[v].push_back(u);
	}
	int cnt = 0;
	for (int i = 0; i < 4; ++i)
		if (a[i].size() & 1)
			++cnt;
	if (cnt == 0 || cnt == 2)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	//cin.tie(0);	ios::sync_with_stdio(false);

  int i,j;
  int D; cin >> D;
  int C[26]; rep(i,26){cin >> C[i];}
  int S[D][26]; 
  rep(i,D){rep(j,26){cin >> S[i][j];}}
  int last[26]; rep(i,26){last[i]=0;}
  
  ll ans = 0;
  rep(i,D){
      /*int max=0,idx=0;
      rep(j,26){
          if(max<S[i][j]){max=S[i][j];idx=j+1;}
      }*/
      cout << rand() % 26 + 1 << endl; //last[idx-1]=i+1;
  }

  /*for(i=0;i<D;i++){
      ans += S[i][T[i]]; last[T[i]]=i+1;
      rep(j,26){
          ans -= C[j] * (i+1 - last[j]);
      }
      cout << ans << endl;
  }*/

  return 0;

}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
//using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define REP(countName, end) for (ll countName = 0; countName < end; countName++)
#define rev(countName, right, left, down) for (ll countName = right; countName >= left; countName -= down)
#define REV(countName, end) for (ll countName = end; countName >= 0; countName--)


auto solve1(int n, std::vector<int> &&p)
{
    auto ans = 0, min = n;
    REP(i, n)
    {
        min = std::min(min, p[i]);
        if (p[i] <= min)
        {
            ans++;
        }
    }
    return ans;
}

int main(void)
{
    int n;
    cin >> n;
    std::vector<int> p(n);
    REP(i, n) { cin >> p[i]; }
    cout << solve1(n, std::move(p)) << endl;
    return 0;
}

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

int parr[220000],part[220000];

typedef struct{
    int r;
    int t;
    int i;
    int count;
} pair_t;

int sort1(const void *a, const void *b){
    if ( ((pair_t*)a)->r - ((pair_t*)b)->r >0 ) {
        return 1;
    }
    if ( ((pair_t*)a)->r - ((pair_t*)b)->r <0 ) {
        return -1;
    }
    if ( ((pair_t*)a)->r - ((pair_t*)b)->r ==0 ) {
        if ( ((pair_t*)a)->t - ((pair_t*)b)->t >0 ) {
            return 1;
        }
        if ( ((pair_t*)a)->t - ((pair_t*)b)->t <0 ) {
            return -1;
        }
    }
    return 0;
}

int sort2(const void *a, const void *b){
    if ( ((pair_t*)a)->i - ((pair_t*)b)->i >0 ) {
        return 1;
    }
    if ( ((pair_t*)a)->i - ((pair_t*)b)->i <0 ) {
        return -1;
    }
    return 0;
}

int findr(int x){
    if (parr[x]==x){
        return x;
    } else {
        return parr[x]=findr(parr[x]);
    }
}

void uniter(int x, int y){
    x=findr(x);
    y=findr(y);
    if(x==y){
        return ;
    }
    parr[y]=x;
}

int findt(int x){
    if (part[x]==x){
        return x;
    } else {
        return part[x]=findt(part[x]);
    }
}

void unitet(int x, int y){
    x=findt(x);
    y=findt(y);
    if(x==y){
        return ;
    }
    part[y]=x;
}

int main(void){
    int n,k,l,p,q,r,s;
    scanf("%d%d%d",&n,&k,&l);
    
    for (int i=0; i<n; i++){
        parr[i]=i;
        part[i]=i;
    }
    
    for (int i=0; i<k; i++){
        scanf("%d%d",&p,&q);
        p--;
        q--;
        uniter(p,q);
    }
    
    for (int i=0; i<l; i++){
        scanf("%d%d",&r,&s);
        r--;
        s--;
        unitet(r,s);
    }
    
    pair_t pair[n];
    for (int i=0; i<n; i++){
        pair[i].r=findr(i);
        pair[i].t=findt(i);
        pair[i].i=i;
        pair[i].count=1;
    }
    qsort (pair,n,sizeof(pair_t),sort1);
    for (int i=1; i<n; i++){
        if (pair[i].r==pair[i-1].r && pair[i].t==pair[i-1].t){
            pair[i].count+=pair[i-1].count;
        }
    }
    for (int i=n-1; i>=0; i--){
        if (pair[i].r==pair[i+1].r && pair[i].t==pair[i+1].t){
            pair[i].count=pair[i+1].count;
        }
    }
    qsort (pair,n,sizeof(pair_t),sort2);
    for (int i=0; i<n; i++){
        printf("%d ",pair[i].count);
    }
    printf("\n");
	return 0 ;
}

Measured memory_bytes: 8332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int c, a, b;
    cin >> c;
    if (c == 1) {
        cout << "Hello World\n";
    } else {
        cin >> a >> b;
        cout << a + b << "\n";
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define INF 1e9
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>cost(n,0);
    for(int i=0;i<n;i++){
        cin>>cost[i];
    }
    vector <int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(cost[i]-cost[j]));
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4044
N=int(input())
S=input()
A=["SS","SW","WS","WW"]

X=""
for a in A:
    T=a
    for i in range(1,N-1):
        if T[-1]=="S":
            if S[i]=="o":
                T+=T[-2]
            else:
                if T[-2]=="S":
                    T+="W"
                else:
                    T+="S"
        else:
            if S[i]=="o":
                if T[-2]=="S":
                    T+="W"
                else:
                    T+="S"
            else:
                T+=T[-2]

    F=True
    if (T[0]=="S") and not((S[0]=="o")^(T[1]==T[-1])):
        pass
    elif (T[0]=="W") and not((S[0]=="x")^(T[1]==T[-1])):
        pass
    else:
        F=False

    if (T[-1]=="S") and not((S[-1]=="o")^(T[0]==T[-2])):
        pass
    elif (T[-1]=="W") and not((S[-1]=="x")^(T[0]==T[-2])):
        pass
    else:
        F=False

    if F:
        X=T

if X:
    print(X)
else:
    print(-1)


Measured memory_bytes: 213072
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

int main() {
    int n, wmax;
    std::cin >> n >> wmax;

    std::vector<int> ws(n);
    for (auto& w : ws) std::cin >> w;
    std::sort(ws.rbegin(), ws.rend());

    std::vector<mint> dp(wmax + 1, 0);
    dp[0] = 1;

    mint ans = 0;
    for (int i = 0; i < n; ++i) {
        // i番目が選ばない最小のもの
        // i+1番目以降は全部選ぶ
        int rem = std::accumulate(ws.begin() + i + 1, ws.end(), 0);
        // wmax - ws[i] < w + rem <= wmax
        int l = std::max(0, (wmax - rem - ws[i] + 1));
        int r = std::max(0, (wmax - rem + 1));
        ans += std::accumulate(dp.begin() + l, dp.begin() + r, mint(0));

        for (int w = wmax; w >= ws[i]; --w) {
            dp[w] += dp[w - ws[i]];
        }
    }

    if (std::accumulate(ws.begin(), ws.end(), 0) <= wmax) ans += 1;
    std::cout << ans << std::endl;
    return 0;
}



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

int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<"Hello World"<<endl;
    return 0;
  }else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<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++)

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    bool C[H][W] = {};
    int R[H][W] = {};
    queue<pair<int,int>> que;
    string S;
    rep(i,H){
        cin >> S;
        rep(j,W){
            if(S[j] == '#'){
                C[i][j] = true;
                que.push(make_pair(i,j));
            }
        }
    }
    int count = 1;
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        int x = p.second,y = p.first;
        R[y][x] = count;
        int x1 = x,x2=x;
        while(0<x1){
            x1--;
            if(C[y][x1]){x1++;break;}
            C[y][x1] = true;
            R[y][x1] = count;
        }
        while(x2<W-1){
            x2++;
            if(C[y][x2]){x2--;break;}
            C[y][x2] = true;
            R[y][x2] = count;
        }
        int y1 = y,y2=y;
        while(0<y1){
            y1--;
            bool flag = false;
            for(int i=x1;i<=x2;i++){
                if(C[y1][i]){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
            for(int i=x1;i<=x2;i++){
                C[y1][i] = true;
                R[y1][i] = count;
            }
        }
        while(y2<H-1){
            y2++;
            bool flag = false;
            for(int i=x1;i<=x2;i++){
                if(C[y2][i]){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
            for(int i=x1;i<=x2;i++){
                C[y2][i] = true;
                R[y2][i] = count;
            }
        }
        count++;
    }
    rep(i,H){
        rep(j,W){
            cout << R[i][j] << " ";
        }
        cout << endl;
    }
    /*
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        cout << p.first << " " << p.second << endl;
    }
    */
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;


int main(void){

    int N;
    int P[200002]={0};
    int f[200001]={0};
    int ans=1;
    cin>>N;
    int m=1e9;
    cin>>P[0];
    m=P[0];
    
    for(int i=1;i<N;i++){
        cin>>P[i];
        if(m>P[i])ans++;
        m=min(m,P[i]);
    }
    /*
    for(int i=1;i<=N;i++){
        if(f[i]==0){
            ans++;
            continue;
        }
        for(int j=0;j<f[i];j++){
            if(P[j]<i){
                break;
            }
            else if(j==f[i]-1)ans++;
        }
        
    }
    */
    
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1024
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

K, N = input_int()

A = many_int()

b_list=[]
n_list=[]
for i,a in enumerate(A):
    nexts = 0 if i+1==N else i+1
    back  = N-1 if i==0 else i-1
    
    if A[back] > a:
        back = (a+K)-A[back]
    else:
        back = a-A[back]
    
    if A[nexts] < a:
        nexts = (A[nexts]+K)-a
    else:
        nexts = A[nexts]-a
    
    
    b_list.append(back)
    n_list.append(nexts)

print(sum(b_list)-max(b_list))

Measured memory_bytes: 91468
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) == 2:
        print(s)
    else:
        s = list(s)
        s.reverse()
        print("".join(s))


if __name__ == '__main__':
    solve()


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

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var a = Math.Clamp(K, 0, S.Length);

            Console.Write(S.Substring(0, a));

            if(S.Length > K) {
                Console.Write("...");
            }
        }
    }
}

Measured memory_bytes: 27484