akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>

#define forn(i, n) for (int i = (int)(0); i < (int)(n); ++i)

#define fi first
#define se second
#define eb emplace_back

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;

constexpr int power(int x, int n) {
  return n > 0 ? power(x, n - 1) * x : 1;
}

void solve_b() {
  int n;
  cin >> n;
  int x = 30000;
  if (n == 3) {
    cout << "2 5 63\n";
    return ;
  } else if (n == 4) {
    cout << "2 5 20 63\n";
    return ;
  }
  int gs = 0;
  int s = 0;
  forn(i, n - 3) {
    while (__gcd(x, 6) == 1) --x;
    cout << x << ' ';
    gs = __gcd(gs, x);
    s += x; s %= 6;
    --x;
  }
  bool ok = false;
  forn(k, x + 1) if (k > 0 && __gcd(k, 6) != 1) {
      forn(j, k) if (j > 0 && __gcd(j, 6) != 1) {
          forn(i, j) if (i > 0 && __gcd(i, 6) != 1) {
              if ((i + j + k + s) % 6 == 0 && __gcd(gs, __gcd(i, __gcd(j, k))) == 1) {
                cout << k << ' ' << j << ' ' << i;
                ok = true;
                break;
              }
            }
          if (ok) break;
        }
      if (ok) break;
    }
  assert(ok);
  cout << endl;
}

void solve_a() {
  string s;
  cin >> s;
  if (s.length() < 26) {
    for (char c = 'a'; c <= 'z'; ++c) {
      if (find(s.begin(), s.end(), c) == s.end()) {
        s += c;
        break;
      }
    }
  } else {
    string t = s;
    if (!next_permutation(s.begin(), s.end())) {
      s = "-1";
    } else {
      int i = 0;
      while (s[i] == t[i]) ++i;
      s = s.substr(0, i + 1);
    }
  }
  cout << s << endl;
}

int main() {
#ifndef HOME
  // freopen("input.txt", "rt", stdin);
#endif
  solve_b();
  return 0;
}


Measured memory_bytes: 384
def main():
  n = int(input())
  m = int(input())
  ans = m
  for i in range(n):
    a, b = map(int,input().split())
    m += (a - b)
    if m < 0:
      ans = 0
      break
    elif m > ans:
      ans = m
  print(ans)
main()


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


int main(){
int p,q,r;
cin>>p>>q>>r;
if(p>q){
if(p<r){
cout<<p+q;
return 0;
}else{
cout<<r+q;
return 0;
}

}else{
if(q<r){
cout<<p+q;
return 0;
}else{
  cout<<p+r;
return 0;  
}
}



}

Measured memory_bytes: 3564
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

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

  int n;cin>>n;
  int m=n*(n+1)/2;
  int p=0;
  for(int d=2;d*d<=m;d++) {
    if (m%d==0) {
      p=d;
      break;
    }
  }
  int r[111]{};
  int s[111]{};
  vector<int> comps[111];
  int z = m/p;
  for (int i=0;i<p;i++) {
    for (int k=n;k>=1;k--) {
      if (r[k]) continue;
      if (s[i]+k > z) continue;
      s[i]+=k,comps[i].pb(k);
      r[k] = 1;
    }
  }
  vector<pii> edges;
  for (int i=0;i<p;i++){
    for(int j=i+1;j<p;j++){
      for(int u:comps[i]) for(int v:comps[j]) edges.pb({u,v});
    }
  }
  cout<<edges.size()<<endl;
  for(auto pr:edges) cout<<pr.fst<<" "<<pr.snd<<endl;
  return 0;
}


Measured memory_bytes: 384
n,a,b = list(map(int,input().split()))
to, ans = 0 , 0
 
if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n < a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
if n - ((a + b) * to) < a:
  ans += n - ((a + b) * to)
else:
  ans += a
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#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 P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int N; cin>>N;
    int ans = 0;
    FOR(i,1,N){
        int b = (N-1) / i;
        ans += b;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	int A,B;
	char op;
	cin>>A>>op>>B;
	if(op=='+')
		cout<<A+B<<endl;
	else
		cout<<A-B<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);
  long double n;
    cin>>n;
  lli ans;
  ans=ceil(n/1000);
  cout<<abs(ans*1000-n);
 

}

Measured memory_bytes: 3788
#include <cstdio>
#include <cstdlib>
using namespace std;
int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n >= 400 && n <= 599)
			printf("8\n");
		else if (n >= 600 && n <= 799)
			printf("7\n");
		else if (n >= 800 && n <= 999)
			printf("6\n");
		else if (n >= 1000 && n <= 1199)
			printf("5\n");
		else if (n >= 1200 && n <= 1399)
			printf("4\n");
		else if (n >= 1400 && n <= 1599)
			printf("3\n");
		else if (n >= 1600 && n <= 1799)
			printf("2\n");
		else if (n >= 1800 && n <= 1999)
			printf("1\n");
	}
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
    io
double l;
cin>>l;
 cout << fixed << setprecision(10) <<pow(l/3,3)<<endl;

}

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
before = 0.5
for i in range(N):
    now = A[i] - 1
    ans += B[now]
    if now == before + 1:
        ans += C[before]
    before = now

print(ans)

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

int main(){
  int X,N;
  int i,res,d;
  bool p[102];
  cin >> X >> N;
  int t;
  for(i=0;i<102;i++)
    p[i] = true;
  for(i=0;i<N;i++){
    cin >> t;
    p[t] = false;
  }

  d = 200;
  res = 0;
    
  for(i=0;i<102;i++){
    if (p[i])
      if (abs(X-i) < d){
        d = abs(X-i);
        res = i;
      }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b;
    cin>>a>>b;
    if(a>9 || b>9)
        cout<<-1<<endl;
    else
        cout<<a*b<<endl;
    return 0;
}


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

int main() {
    ll x;
    cin>>x;
    ll f = 100;
    int conuter = 0;
    while (f<x)
    {
        f += f/100;
        conuter++;
    }
    cout<<conuter<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main()
{
	int month[12];

	month[0]=31;
	month[1]=29;
	month[2]=31;
	month[3]=30;
	month[4]=31;
	month[5]=30;
	month[6]=31;
	month[7]=31;
	month[8]=30;
	month[9]=31;
	month[10]=30;
	month[11]=31;

	int hoge,fuga;

	hoge = 1;

	int i;
	int count=0;

	while(hoge!=0)
	{
		count = 0;
		cin >> hoge >> fuga;
		//cout << count << endl;
		for(i=0;i<hoge-1;i++)
		{
			count+=month[i];
		}	
		//cout << count << endl;

		count+=fuga;

		//cout << count << endl;

		int flag = 0;
	
		flag = count % 7;

		if(flag==0 & hoge!=0)
		{
			cout << "Wednesday" <<endl;
		}
		if(flag==1 & hoge!=0)
		{
			cout << "Thursday" <<endl;
		}
		if(flag==2 & hoge!=0)
		{
			cout << "Friday" <<endl;
		}
		if(flag==3 & hoge!=0)
		{
			cout << "Saturday" <<endl;
		}
		if(flag==4 & hoge!=0)
		{
			cout << "Sunday" <<endl;
		}
		if(flag==5 & hoge!=0)
		{
			cout << "Monday" <<endl;
		}
		if(flag==6 & hoge!=0)
		{
			cout << "Tuesday" <<endl;
		}
	}
}

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

int main(int argc, char** argv) {
	int n;
	cin >> n;
	vector<int> vec;
	for(int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		vec.push_back(tmp);
	}
	for(vector<int>::reverse_iterator rit = vec.rbegin();
			rit != vec.rend();
			++rit)
		cout << *rit << ((rit != vec.rend()-1)?" ":"");
	cout << endl;

	return 0;
}

Measured memory_bytes: 1220
def judge():
    if m == -1 or f == -1:
        return 'F'
    elif m + f >= 80:
        return 'A'
    elif m + f >= 65:
        return 'B'
    elif m + f >= 50:
        return 'C'
    elif m + f >= 30:
        if r >= 50:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'


while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break

    print(judge())



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) clog << #x << ": " << x << endl;
#endif

const LL MOD = 998244353;

LL fastexp(LL b, int e) {
    LL ans = 1;
    while(e) {
        if(e & 1) {
            ans = (ans * b) % MOD;
        }
        b = (b * b) % MOD;
        e >>= 1;
    }
    return ans;
}

LL N, K;
LL fac[1000000], invfac[1000000];

LL binom(int n, int k) {
    if(k > n) {
        return 0;
    }
    return (((fac[n] * invfac[k]) % MOD) * invfac[n - k]) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    fac[0] = invfac[0] = 1;
    for(int n = 1; n < 1000000; ++n) {
        fac[n] = (fac[n - 1] * n) % MOD;
        invfac[n] = fastexp(fac[n], MOD - 2);
    }
    
    cin >> N >> K;
    LL ans = 0;
    for(int R = 1; R <= K; ++R) {
        int B = K - R;
        int D = R - B;
        if(D < 0 || R < N) {
            continue;
        } else if(D == 0) {
            ans += binom(K - 1, R) - binom(K - 1, N - 2);
        } else if(D < N) {
            ans += binom(K, R) - binom(K, N - D - 1);
        } else {
            ans += binom(K, R);
        }
        /*dbg_var(R);
        dbg_var(ans);*/
    }
    ans = ((ans % MOD) + MOD) % MOD;
    cout << ans << '\n';
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, T, A;
    ll t, a;
    cin >> N >> t >> a;
    rep(i, N - 1) {
        cin >> T >> A;
        ll t0 = (t + T - 1) / T * T, a0 = t0 / T * A;
        ll a1 = (a + A - 1) / A * A, t1 = a1 / A * T;
        if (a0 < a) {
            t = t1;
            a = a1;
        } else if (t1 < t) {
            t = t0;
            a = a0;
        } else {
            t = min(t0, t1);
            a = t / T * A;
        }
    }
    cout << a + t << endl;
}

Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int& a , int b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
string s , t ; 
cin>>s>>t ; 
int n = s.length()  , m = t.length() ; 
vector<vector<int>>dp(n+1 , vector<int>(m+1));
for(int i = 0 ; i<=n ; i++)dp[i][0] = 0 ;
for(int j = 0 ; j<=m ; j++)dp[0][j] = 0 ;

for(int i = 1 ; i <= n ; i++){
	for(int j = 1 ; j<= m ; j++){

		if(s[i-1] == t[j-1]){
			dp[i][j] = dp[i-1][j-1] + 1;
		}
		else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);


	}
}

// for(int i = 0 ; i <= n ; i++){
// 	for(int j = 0 ; j<= m ; j++){cout<<dp[i][j]<<" ";}cout<<endl;}


// cout<<dp[n][m];

string ans = ""  ;
int i = n , j = m ;
while(i>0&&j>0){

	if(dp[i-1][j-1]+1==dp[i][j]&&(dp[i-1][j] == dp[i][j-1])){
		ans+=s[i-1];
		i--;
		j--;
	}
	else if(dp[i-1][j]>dp[i][j-1])i--;
	else j--;


}

reverse(all(ans));
cout<<ans;







	
}

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

int n, m;
vector<int> x, v;

int solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    x.push_back(a);
  }
  sort(x.begin(), x.end());
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = x[m - 1] - x[0];
  if(n >= m) return 0;
  for(int i = 0; i < m - 1; ++i)
    v.push_back(x[1 + i] - x[i]);
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < n - 1; ++i) ans -= v[i];
  return ans;
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 2e5 + 5;
int n , m , c;
int dp[N] , a[N];

struct line
{
    int a , b;
    void operator -= (line const &o)
    {
        a -= o.a;
        b -= o.b;
    }
};

deque < line > dq;
line l;

int CCW(line l1 , line l2 , line l3)
{
    l3 -= l2;
    l2 -= l1;
    return l2.a * l3.b - l2.b * l3.a;
}

void push(line l)
{
    while(dq.size() >= 2 && CCW(dq[dq.size() - 2] , dq[dq.size() - 1] , l) >= 0) dq.pop_back();
    dq.pb(l);
}

int val(line l , int x)
{
    return l.a * x + l.b;
}

int get(int x)
{
    int l = 0 , r = dq.size() - 1 , mid = 0;
    while(l <= r)
    {
        mid = (l + r) / 2;
        //cerr << l << " " << r << " " << mid << endl;
        if(mid != 0 && val(dq[mid - 1] , x) < val(dq[mid] , x)) r = mid - 1;
        else if(mid != dq.size() - 1 && val(dq[mid + 1] , x) < val(dq[mid] , x)) l = mid + 1;
        else break;
    }
    //cerr << mid << endl;
    return val(dq[mid] , x);
}

main()
{
    //freopen("Z.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> c;
    FOR(i , 1 , n)
        cin >> a[i];
    l.a = -2 * a[1];
    l.b = a[1] * a[1];
    push(l);
    FOR(i , 2 , n)
    {
        dp[i] = get(a[i]) + a[i] * a[i] + c;
        l.a = -2 * a[i];
        l.b = a[i] * a[i] + dp[i];
        push(l);
    }
    cout << dp[n];
}


Measured memory_bytes: 6656
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N) {
  ll a = N % 10;
  if (a == 3) {
    cout << "bon" << endl;
  } else if (a == 0 || a == 1 || a == 6 || a == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3780
s = gets
l = s.length - 1
c1 = 0
c2 = 0

for i in 0 .. l - 1
  if i % 2 == 0
    if s[i] == "1"
      c1 += 1
    else
      c2 += 1
    end
  else
    if s[i] == "1"
      c2 += 1
    else
      c1 += 1
    end
  end
end

puts [c1,c2].min


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  char t[q],d[q];
  rep(i,q){
    cin>>t[i]>>d[i];
  }
  s="!"+s;
  s=s+"!";
  int ll,rr;
  int l=0,r=n+1;
  int mid=(l+r)/2;
  while(l!=r){
    int now=mid+1;
    bool flag=true;
    rep(i,q){
      if(s[now]==t[i]){
	if(d[i]=='L') now--;
	else now++;
      }
      if(now==0){
	flag=false;
	break;
      }
    }
    if(flag) r=mid;
    else l=mid+1;
    mid=(l+r)/2;
  }
  ll=mid;
  l=0;r=n+1;mid=(l+r)/2;
  while(l!=r){
    int now=mid;
    bool flag=true;
    rep(i,q){
      if(s[now]==t[i]){
	if(d[i]=='L') now--;
	else now++;
      }
      if(now==n+1){
	flag=false;
	break;
      }
    }
    if(flag) l=mid+1;
    else r=mid;
    mid=(l+r)/2;
  }
  rr=mid;
  //cout<<ll<<" "<<rr<<endl;
  cout<<max((int)0,rr-ll-1)<<endl;

  return 0;
}


Measured memory_bytes: 4324
#include <iostream>

using namespace std;

long count(long a ,long b){
    int i,n,ans;
    if(a<=b){
        i=100*a/8;
        n=10*b+10;
    }
    else{
        i=10*b;
        n=100*a/8+10;
    }
    for(;i<=n;i++){
        if((i*2/25)==a && (i/10)==b)
        return i;
    }
    return -1;
}

int main()
{
    long a,b;
    cin >> a >> b;
    cout << count(a,b) ;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
    int h1, m1, h2, m2, k, de;
    scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
    m1 += h1*60;
    m2 += h2*60;
    de = m2 - m1;
    printf("%d\n", de-k);
    return 0;
}

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

int main() {
  while(true) {
    int n,x,ans = 0;
    cin >> n >> x;
    if(n==0&&x==0) break;
    for(int i = 1; i <= n-2; ++i) {
      for(int j = i+1; j <= n-1; ++j) {
        for(int k = j+1; k <= n; ++k) {
          if(i + j + k == x) {
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
from collections import deque
import sys
input = sys.stdin.buffer.readline


n = int(input())
A = [int(i) for i in input().strip().split()]

b = deque()

flag = True

if n % 2 == 1:
    flag = False
for a in A:
    if flag:
        b.append(a)
    else:
        b.appendleft(a)
    flag = not flag

print(" ".join((str(s) for s in b)))


Measured memory_bytes: 117968
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int s, c, result = 0;
  cin >> s >> c;
  if (s > c) {
    result += c / 2;
  } else {
    c = c / 2;
    if (c <= s) {
      result = c;
    } else if (c > s) {
      result = s;
      c = c - s;
      result = result + c / 2; 
    }
  }
  cout << result << endl;
}

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

using namespace std;

ll C[55][55];
void CombTable(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if ((j == 0) || (j == i)) {
				C[i][j] = 1;
			} else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

int main() {
	ll N, P;
	cin >> N >> P;
	ll even = 0, odd = 0;
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		if (a%2 == 0) {
			even++;
		} else {
			odd++;
		}
	}

	CombTable(N);

	ll cnt_e = 0;
	for (int i = 0; i <= even; i++) {
		cnt_e += C[even][i];
	}

	ll cnt_o = 0;
	if (P == 0) {
		for (int i = 0; i <= odd; i++) {
			if (i%2 == 1) continue;
			cnt_o += C[odd][i];
		}
	} else {
		for (int i = 0; i <= odd; i++) {
			if (i%2 == 0) continue;
			cnt_o += C[odd][i];
		}
	}

	ll res = cnt_e * cnt_o;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) std::cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define MAX 1000003

struct SieveOfEratosthenes {
    vector<Int> table;

    SieveOfEratosthenes(Int n) {
        CreateTable(n);
    }

    // n以下の数について、最小素因数を記録した表を生成する
    void CreateTable(Int n) {
        rep(i, n + 1) {
            table.push_back(i);
        }

        if (n <= 3) return;
        // 2の倍数の最小素因数は2
        for (Int i = 2; i <= n; i += 2) {
            table[i] = 2;
        }
        // 3以上の奇数について最小素因数を記録する
        for (Int p = 3; p * p <= n; p += 2) {
            // 奇数pがp未満の数の倍数である場合は無視
            if (table[p] < p) continue;
            // 素数pの倍数を記録
            for (Int x = p; x <= n; x += p) {
                table[x] = p;
            }
        }
    }

    // 素数判定
    bool IsPrime(Int n) {
        return table[n] == n;
    }

    // 最小素因数表を使って素因数分解を行う
    vector<Int> primeFactors(Int n) {
        auto result = vector<Int>();
        while (table[n] != 1) {
            result.push_back(table[n]);
            n /= table[n];
        }
        return result;
    }

    set<Int> primeFactorSet(Int n) {
        auto result = set<Int>();
        while (table[n] != 1) {
            result.insert(table[n]);
            n /= table[n];
        }
        return result;
    }
};

int main() {
    Int n;
    cin >> n;
    auto sieve = SieveOfEratosthenes(MAX);
    bool flags[MAX] = {false};

    auto pairwise = true;
    Int g;
    rep(i, n) {
        Int a;
        cin >> a;
        if (pairwise) {
            auto t = sieve.primeFactorSet(a);
            for (auto &p : t) {
                if (flags[p] == true) {
                    pairwise = false;
                    break;
                }
                flags[p] = true;
            }
        }

        if (i == 0) {
            g = a;
        } else {
            g = gcd(g, a);
        }
    }
    if (g > 1) {
        PUTS("not coprime")
    } else if (pairwise) {
        PUTS("pairwise coprime")
    } else {
        PUTS("setwise coprime")
    }
}


Measured memory_bytes: 12136
/* ABC143-A
   Takatan */

#include<stdio.h>
#include<math.h>
int main(void){
    int window, curtain;

    scanf( "%d %d" , &window, &curtain);
    window = window - 2 * curtain;
    if(window<0){
        window = 0;
    }
    printf( "%d\n" , window);
    return 0;
}

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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll ans = a[0];

    for (ll i = 1; i < n; i++){
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3964
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int A[3], B[3];
int deg[4];

int main()
{
	for (int i = 0; i < 3; ++i) {
		scanf("%d%d", A + i, B + i);
		--A[i]; --B[i];
		++deg[A[i]];
		++deg[B[i]];
	}
	int n1 = 0, n2 = 0;
	for (int i = 0; i < 4; ++i) {
		if (deg[i] == 1) ++n1;
		else if (deg[i] == 2) ++n2;
	}
	if (n1 == 2 && n2 == 2) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int i,n,a,d,e;
        long long f;
        scanf("%d",&n);
        scanf("%d",&d);
        e=d;
        f=d;
        for(i=2;i<=n;i++){
         scanf("%d",&a);
         if(a<d){
          d=a;
         }
         if(a>e){
          e=a;
         }
         f=f+a;
        }
        printf("%d %d %lld\n",d,e,f);
    return 0;
}

Measured memory_bytes: 1860
#include <iostream>

using namespace std;

int main() {
  string s;
  cin>>s;
  int i = 0;
  int num = s.length()-1;
  int counter =0;
  //if(s.length() % 2 == 0){
    //for(int i = 0; i <)
    while (i < num) {
            if (s[i] == s[num]) {
                num--;
                i++;
            } else {
                s[num] = s[i];
                num--;
                i++;
counter++;
            }
  }
  //cout<<s<<endl;
  cout<<counter;
//}
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2==0:
                    print('#', end='')
                else:
                    print('.', end='')
            print()
        print("\n", end="")


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    int INF = 1e9 + 7;
    vector<int> dp(1e5 + K, INF);
    dp[0] = 0;
    rep(i, N)
    {
        reps(k, K + 1, 1)
        {
            int j = i + k;
            if (j < N)
            {
                dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
            }
        }
    }
    cout << dp[N - 1] << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 1024
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
   int n,i,j,k,l;
   cin>>n>>k;
   if(k==1)
    cout<<"0";
   else if(k<=n)
    cout<<"1";
   else
   {
     k=k-n;
     l=(k+n-2)/(n-1);
     cout<<l+1;
   }
  }

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

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

struct edge { int to, cost; };

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

signed main()
{
   string s; cin >> s;

   map<char,int> cnt;
   for (int i = 0; i < s.size(); i++) {
      cnt[s[i]]++;
   }

   if (cnt['N'] == 0 && cnt['S'] != 0 ||
       cnt['S'] == 0 && cnt['N'] != 0 ||
       cnt['E'] == 0 && cnt['W'] != 0 ||
       cnt['W'] == 0 && cnt['E'] != 0) {
      cout << "No" << endl;
   } else {
      cout << "Yes" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = sum(a)

ad = collections.Counter(a)

for i in range(q):
    b, c = map(int, input().split())
    s += ad.get(b, 0) * (c - b) 
    print(s)
    ad[c] += ad.get(b, 0)
    ad[b] = 0

Measured memory_bytes: 24068
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using namespace atcoder;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

using S = int;
S op(S a,S b) {return max(a,b);}
S e() {return -1;}
S target;
bool f(S a) {return a < target;}

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

    int N,Q; cin >> N >> Q;
    vector<S> A(N);
    rep(i,N) cin >> A[i];

    segtree<S,op,e> st(A);
    rep(i,Q) {
        int t; cin >> t;
        if (t == 1) {
            int x; S v;cin >> x >> v;
            --x;
            st.set(x,v);
        } else if (t == 2) {
            int l,r; cin >> l >> r;
            --l;
            cout << st.prod(l,r) << '\n';
        } else {
            int x; cin >> x >> target;
            --x;
            cout << st.max_right<f>(x) + 1 << '\n';
        }
    }
    return 0;
}

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

int main() {
	
	int n, l;
	cin >> n >> l;
	
	int ans = 0;
	int min = 1000;
	
	for(int i=1; i<=n; i++){
		int aji = l+i-1;
		if(abs(aji) < abs(min)) min = aji;
		ans += aji;
	}
	ans -= min;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
import bisect
n, c = [int(i) for i in sys.stdin.readline().split()]
x_ls = []
inv_x_ls = []
v_ls = []
for i in range(n):
    x, v = [int(i) for i in sys.stdin.readline().split()]
    x_ls.append(x)
    inv_x_ls.append(c - x)
    v_ls.append(v)
inv_v_ls = v_ls[::-1]
inv_x_ls = inv_x_ls[::-1]
v_ls = [0] + [v - x for v, x in zip(accumulate(v_ls), x_ls)]
inv_v_ls = [0] + [v - x for v, x in zip(accumulate(inv_v_ls), inv_x_ls)]
x_ls = [0] + x_ls
inv_x_ls = [0] + inv_x_ls
best_v = 0
best_inv_v = 0
for i in range(n + 1):
    best_v = max(best_v, v_ls[i])
    best_inv_v = max(best_inv_v, inv_v_ls[i])
    v_ls[i] = best_v
    inv_v_ls[i] = best_inv_v

best = 0
for tokei in range(n+1):
    tokei_dis = x_ls[tokei]
    hantokei = max(0, inv_v_ls[n - tokei] - tokei_dis)
    res = v_ls[tokei] + hantokei
    best = max(best, res)
for hantokei in range(n+1):
    hantokei_dis = inv_x_ls[hantokei]
    tokei = max(0, v_ls[n - hantokei] - hantokei_dis)
    res = inv_v_ls[hantokei] + tokei
    best = max(best, res)
print(best)

Measured memory_bytes: 72668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> ans(h, vector<int>(w));
    int now = 0, cnt = 0;
    rep(row, h) rep(col, w){
        ans[row][col] = now+1;
        cnt++;
        if (a[now] == cnt){
            now++;
            cnt = 0;
        }
    }
    for(int i = 1; i < h; i+=2){
        reverse(all(ans[i]));
    }
    rep(row, h){
        rep(col, w){
            cout << ans[row][col] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,cou;
    std::cin >> a>>b;
    for (int i = a; i <= b; i++) {
        string s;
        s=std::to_string(i);
        if(s[0]==s[4] && s[1]==s[3]){
            cou++;
        }
    }
    std::cout << cou << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N,K; cin>>N>>K;
  ll a[N]; CINA(a,N);
  sort(a,a+N);
  bool r=false;
  if(a[N-1]>=K){
    ll x = a[0];
    for(int i=1;i<N;i++){
      x = gcd(a[i],x);
    }
    if(K%x==0){ r = true; }
  }
  cout << (r?"POSSIBLE":"IMPOSSIBLE");
}

Measured memory_bytes: 1024
console.log((args=>{
  const [N,A,B] = args.trim().split` `.map(BigInt);
  if ( A > B || ( N == 1 && A !== B ) ) return '0';
  return `${(B-A) * (N-2n) + 1n}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 3e5;
const double PI = 3.141592653589 , eps = 1e-9;


void solve(){
    vector <int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
     cout << a[k - 1];
}


int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i = 1, j, k, n, ans = 10e18, t, l, m, c;
  scanf("%lld%lld", &n, &c);
  ll d[c][c], co[3][c];
  for(i = 0; i < 3; ++i) for(j = 0; j < c; ++j) co[i][j] = 0;
  for(i = 0; i < c; ++i) for(j = 0; j < c; ++j) scanf("%lld", &d[i][j]);
  for(i = 1; i <= n; ++i) for(j = 1; j <= n; ++j) {
    scanf("%lld", &t);
    t--;
    co[(i + j) % 3][t]++;
  }
  for(i = 0; i < c; ++i) for(j = 0; j < c; ++j) for(k = 0; k < c; ++k) if(i != j && j != k && k != i) {
     ll tmp = 0;
     for(l = 0; l < c; ++l) {
       tmp += co[0][l] * d[l][i] + co[1][l] * d[l][j] + co[2][l] * d[l][k];
     }
     if(tmp < ans) ans = tmp;
  }
  printf("%lld", ans);
  return 0;
}

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

using lint = int64_t;
#define bit(n) (lint(1) << n)
const int INF = 1e9;
const lint LINF = 1e18;

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

class IoSetup {
    public:
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);

        cout << fixed << setprecision(12);
    }
} iosetup;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h + 1);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        s[i] += '#';
    }
    for (int i = 0; i <= w; i++) {
        s[h][i] = '#';
    }

    vector<vector<int>> tate(h, vector<int>(w + 1)), yoko(h, vector<int>(w + 1));
    for (int i = 0; i < h; i++) {
        int last = -1;
        for (int j = 0; j < w + 1; j++) {
            if (last == -1 and s[i][j] == '.') {
                last = j;
            } else if (last >= 0 and s[i][j] == '#') {
                for (int k = last; k < j; k++) {
                    yoko[i][k] = j - last;
                }
                last = -1;
            }
        }
    }
    for (int i = 0; i < w; i++) {
        int last = -1;
        for (int j = 0; j < h + 1; j++) {
            if (last == -1 and s[j][i] == '.') {
                last = j;
            } else if (last >= 0 and s[j][i] == '#') {
                for (int k = last; k < j; k++) {
                    tate[k][i] = j - last;
                }
                last = -1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(ans, tate[i][j] + yoko[i][j] - 1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 39424
data_list = []
while True:
    H, W = map(int, input().split())
    if not H and not W:
        break
    data_list.append([H, W])

for data in data_list:
    for x in range(data[0]):
        if x == 0 or x == data[0] - 1:
            print('#' * data[1])
        else:
            for y in range(data[1]):
                if y == 0:
                    print('#', end='')
                elif y == data[1] - 1:
                    print('#')
                else:
                    print('.', end='')
    print('')


Measured memory_bytes: 7004
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	int y = x/d;
	if(y<k){
		k-=y;
		int ans = x-y*d;		
		if(k&1){
			ans = abs(ans-d);
		}		
		cout << ans << endl;
	}
	else{
		cout << x-d*k << endl;
	}
 
	return 0;
}  

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

int main() {
  int n, m;
  int a, b;
  cin >> n >> m;
  vector<int> data(n, 0);
  for (int i=0; i<m; i++) {
    cin >> a >> b;
    data.at(a-1)++;
    data.at(b-1)++;
  }
  for (int i=0; i<n; i++) {
    cout << data.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
int main()
{
    int r;
  cin>>r;
    cout << 2 * r * M_PI;
}


Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;
typedef long long ll;

ll n, k, ans, M=1e9+7, a[N];
ll fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};
ll c(ll p, ll q) {return fac[p] * fiv[q] % M * fiv[p-q] % M;}

int main() {
	ll i, t;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	sort(a, a+n);
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	for(i=k-1; i<n; i++) {
		(ans += a[i] * c(i, k-1)) %= M;
		(ans -= a[n-i-1] * c(i, k-1)) %= M;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

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

const int MOD = 1000000007;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s; cin >> s;
	if (s.length() >= 4 && s.substr(0,4) == "YAKI") cout << "Yes";
	else cout << "No";
}

// read!
// ll vs. int!

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
	int n,  P[100], tmp, N[100], ntmp;
	char S[100][11], tmps[11];
	cin >> n;
	for(int i=0; i < n; i++){
		cin >> S[i] >> P[i];
		N[i] = i;
	}

	for(int i = 0; i < n; i++){
		for(int k=n-1; k > i; k--){
			if(strcmp(S[i], S[k]) > 0){
				strcpy(tmps, S[i]);
				tmp = P[i];
				ntmp = N[i];
				strcpy(S[i], S[k]);
				P[i] = P[k];
				N[i] = N[k];
				strcpy(S[k], tmps);
				P[k] = tmp;
				N[k] = ntmp;
			}
			else if (strcmp(S[i], S[k]) == 0 && P[i] < P[k]){
				strcpy(tmps, S[i]);
				tmp = P[i];
				ntmp = N[i];
				strcpy(S[i], S[k]);
				P[i] = P[k];
				N[i] = N[k];
				strcpy(S[k], tmps);
				P[k] = tmp;
				N[k] = ntmp;
			}
		}
	}

	for(int i = 0; i < n; i++){
		printf("%d\n", N[i] + 1);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
   string s;
   while(cin>>s)
   {
       long l;
       l=s.size();
       fr(i,l)
       {
           if(isalpha(s[i]))
           {
               while(isalpha(s[i])&&i<l)
               {
                   cout<<s[i];
                   i++;
               }
               cout<<" ";
           }
       }
   }
    return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


def lcm(x, y):
    return x//gcd(x, y)*y


n = int(input())
ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)

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

int main() {
  int N, M;
  scanf("%d%d", &N, &M);

  int ans = 0;
  int L_MAX = 0;
  int R_MIN = 1e5 + 1;
  for (int i = 0; i < M; ++i) {
    int L, R;
    scanf("%d%d", &L, &R);
    L_MAX = max(L_MAX, L);
    R_MIN = min(R_MIN, R);
  }

  if (R_MIN - L_MAX + 1 > 0) {
    ans = R_MIN - L_MAX + 1;
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := nextString()
	var out string
	for _, r := range n {
		switch r {
		case '1':
			out += string('9')
		case '9':
			out += string('1')
		}
	}

	fmt.Println(out)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int i,num,n,num_th;
	num=100000;
	num_th=100;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		num=num*1.05;
		num_th=(int)(num/1000);
		if(num%1000!=0)num=(num_th+1)*1000;
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 0