akhauriyash/Code-Regression huggingface dataset:
//Be Name Khoda
//man az biganegan  hargez  nanalam
//ke harche kard ba man ashena kard
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(15) << x; exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;

ll n;

int main()
{
    GEL(n);
    ll lx=0,ly=0,lt=0;
    For(i,0,n)
    {
        ll x,y,t;
        GEL(t);
        GEL(x);GEL(y);
        
        if (abs(x-lx)+abs(y-ly)>t-lt) RET("No");
        if ((abs(x-lx)+abs(y-ly))%2!=(t-lt)%2) RET("No");
        lx=x;
        ly=y;
        lt=t;
    }     
    RET("Yes");
}

Measured memory_bytes: 256
n, m = map(int, input().split())
aa = [[]*n for i in range(n)]
ans = "IMPOSSIBLE"
for i in range(m):
  k = list(map(int, input().split()))
  aa[k[0]-1].append(k[1]-1)
  aa[k[1]-1].append(k[0]-1)
tmp = aa[0]
for j in range(len(tmp)):
  if n-1 in aa[tmp[j]]:
    ans = "POSSIBLE"
print(ans)

Measured memory_bytes: 50136
#include <stdio.h>

int main(void) {
	int b, f, r, v;
	int count[4][3][10] = {};
	int i, j, k;
	int n;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		count[b - 1][f - 1][r - 1] += v;
	}
	for(i = 0; i < 4 ;i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				printf(" %d",count[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3) printf("####################\n");
	}

	return 0;
}



Measured memory_bytes: 2060
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

long long x[100000];
long long y[100000];
long long MOD = 1000000007;
long long cum_sum_x[100000];
long long cum_sum_y[100000];
int main(){
    int n;
    int m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < m; i++){
        cin >> y[i];
    }

   long long x_ans = 0;
   for(int i = 0; i < n; i++){
       x_ans = (x_ans + x[n - 1 - i] * (n - 1 - i)) % MOD;
       x_ans = ((x_ans - x[n - 1 - i] * i) % MOD + MOD) % MOD;
   }
   long long y_ans = 0;
    for(int i = 0; i < m; i++){
       y_ans = (y_ans + y[m - 1 - i] * (m - 1 - i)) % MOD;
       y_ans = ((y_ans - y[m - 1 - i] * i) % MOD + MOD) % MOD;
   }
   cout << (x_ans * y_ans) % MOD << endl;

    return 0;
}


Measured memory_bytes: 1792
#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() {
        ll n, d;
        cin >> n >> d;
        vector<ll> x(n), y(n);
        int ans = 0;
        rep(i, n){
                cin >> x[i] >> y[i];
                if(sqrt(x[i]*x[i]+y[i]*y[i])<=d){
                        ans++;
                }
        }
        cout << ans << endl;

}

Measured memory_bytes: 6488
//#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
//#include <math.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

ld mysqrt(ld s)
{
    ld x = s / 2.0;
    ld last_x = 0.0;

    while (x != last_x)
    {
        last_x = x;
        x = (x + s / x) / 2.0;
    }

    return x;
}

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

    ull H, W; cin >> H >> W;

    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    ull tmp = (W / 2) * (H / 2);

    ull a = (W / 2) + (W % 2 != 0 ? 1 : 0);
    ull b = (H / 2) + (H % 2 != 0 ? 1 : 0);

    cout << tmp + a * b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
  
  bool a[31] = {};
  
  for(int i=0;i<28;i++) {
    int n;
    scanf("%d", &n);
    a[n] = true;
  }
  
  for(int i=1;i<31;i++) {
    if(!a[i])printf("%d\n", i);
  }
  
  return 0;
}

Measured memory_bytes: 1024
import sys
import os
import math
a,b,x = map(int,input().split())
if x >= (a**2)*b/2:
    ｙ = 2*(a*a*b-x)/(a*a)
    print((math.degrees(math.atan2(y,a))))
else:
    y = 2*x/(a*b)
    print((math.degrees(math.atan2(b,y))))


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

using namespace std;

typedef long long LL;

int n, k;
LL ans;

int main(){
	scanf("%d%d", &n, &k);
	LL t = n / k;
	ans = t * t * t;
	if(!(k&1)){
		if(n % k >= k / 2)	t++;
		ans += t * t * t;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

const ll MOD = 1000000007;
int N;
int dp[105][4][4][4];

int dfs(int now,int a,int b, int c){
    if(dp[now][a][b][c]) return dp[now][a][b][c];
    if(now == N) {
        dp[now][a][b][c] = 1;
        return 1;
    }
    int tmp = 0;
    for(int d=0;d<=3;++d){
        if(a==0&&b==2&&c==1) continue; //AGC?;
        if(a==0&&b==1&&c==2) continue; //ACG?;
        if(a==2&&b==0&&c==1) continue; //GAC?;

        if(b==0&&c==2&&d==1) continue; //?AGC;
        if(b==0&&c==1&&d==2) continue; //?ACG;
        if(b==2&&c==0&&d==1) continue; //?GAC;

        if(a==0&&b==2&&d==1) continue; //AG?C;
        if(a==0&&c==2&&d==1) continue; //A?GC;

        tmp += dfs(now+1,b,c,d);
        tmp %=MOD;
    }
    dp[now][a][b][c] = tmp;
    return tmp;
}

int main() {
    cin >> N;
    cout << dfs(0,3,3,3) << endl;
}

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

int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  string ans = "IMPOSSIBLE";
  int GCD = a.at(0);
  for (int i = 1; i < n; i ++) {
    GCD= gcd(GCD, a.at(i));
  }
  if (k <= a.back() && k % GCD == 0) ans = "POSSIBLE";

  cout << ans << endl;
}


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


int main() {

 string S;
 int K;
 cin >> S >> K;
 int num = K;
 int N = S.size();

 set<string> str;
 for(int i = 0;i < N;i++) {
   string s;
   s.push_back(S.at(i));
   for(int j = i + 1;j < min(i + 1 + K,N);j++) {
    str.insert(s);
    s += S.at(j);
   }
   str.insert(s);
  }

 set<string>::iterator it = str.begin();
 
 for(int i = 0;i < num - 1;i++) {
   it++;
 }

 cout << *(it) << endl;

}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define nn 200008
#define ll long long 
#define mod 1000000007
ll qpow(ll x,ll y=mod-2){
	ll res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
int X,Y,n;int wi[nn],col[nn];
vector<int> have[nn];
int cmp(int x,int y){
	return wi[x]<wi[y];
}
ll f[nn],rf[nn];
int can(int x,int y){
	if(col[x]==col[y]) return wi[x]+wi[y]<=X;return wi[x]+wi[y]<=Y;
}

int pa[nn];
int find(int x){
	if(pa[x]==x) return x;
	return pa[x]=find(pa[x]);
}
void link(int x,int y){
	pa[find(x)]=find(y);
}

int cnt[nn];
signed main(){
	f[0]=rf[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod,rf[i]=qpow(f[i]);
	scanf("%d%d%d",&n,&X,&Y);
	for(int i=1;i<=n;i++) scanf("%d%d",&col[i],&wi[i]),have[col[i]].push_back(i),pa[i]=i;
	
	#define pii pair<int,int>
	#define mp make_pair 
	vector<pii> s;
	for(int i=1;i<=n;i++) if(have[i].size()){
		sort(have[i].begin(),have[i].end(),cmp);
		s.push_back(mp(wi[have[i][0]],have[i][0]));
		for(int j=1;j<have[i].size();j++) if(can(have[i][j],have[i][0])) link(have[i][j],have[i][0]);
	}
	
	sort(s.begin(),s.end());
	for(int i=1;i<=n;i++) if(have[i].size())
		for(int j=0;j<have[i].size();j++) 
			for(int k=0;k<4 and k<s.size();k++) if(can(s[k].second,have[i][j])) 
			 	link(have[i][j],s[k].second);
	
	for(int i=1;i<=n;i++) have[i].clear();
	for(int i=1;i<=n;i++) have[find(i)].push_back(i);
	
	ll ans=1;
	for(int i=1;i<=n;i++) if(have[i].size()){
		for(int j=0;j<have[i].size();j++) cnt[col[have[i][j]]]++;
		ans=ans*f[have[i].size()]%mod;
		for(int j=0;j<have[i].size();j++) ans=ans*rf[cnt[col[have[i][j]]]]%mod,cnt[col[have[i][j]]]=0;
	}
	cout<<ans<<"\n";	
	return 0;
}

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

int solve(int N, int K, int X, int Y)
{
    if (N <= K) return N*X;
    else return K*X + Y*(N-K);
}

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    cout << solve(N, K, X, Y) << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	char b; cin >> b;
	char ans;
	if (b == 'A')ans = 'T';
	if (b == 'T')ans = 'A';
	if (b == 'C')ans = 'G';
	if (b == 'G')ans = 'C';
	Cout(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>


struct Subject {
	int point{ 0 }, need{ 0 };
};

int main() {
	std::vector<std::vector<int>> by_digit(21);
	for (auto i = 0; i < (1 << 20); ++i) {
		int count = 0;
		for (auto j = i; j > 0; j >>= 1) {
			count += j % 2;
		}
		by_digit[count].push_back(i);
	}
	while (true) {
		int n, u; std::cin >> n >> u; if (n == 0) break;
		std::vector<Subject> subjects(n);
		for (auto &s: subjects) {
			int prev;
			std::cin >> s.point >> prev;
			for (auto i = 0; i < prev; ++i) {
				int a; std::cin >> a;
				s.need |= (1 << a);
			}
		}
		int min_count = -1;
		for (auto d = 1; min_count == -1; ++d) {
			for (const auto p : by_digit[d]) {
				int point = 0;
				for (auto i = 0; i < subjects.size(); ++i) if ((p & (1 << i)) != 0) {
					if ((p & (subjects[i].need)) != subjects[i].need) {
						point = 0;
						break;
					}
					else {
						point += subjects[i].point;
					}
				}
				if (point >= u) {
					min_count = d;
					break;
				}
			}
		}
		std::cout << min_count << '\n';
	}
}


Measured memory_bytes: 7572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int n, m;

ll fact (int x) {
    ll ret = 1;
    REP1 (i, x) {
        ret = ret * i % MOD;
    }
    return ret;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    if (abs(n-m) > 1) {
        cout << 0 << endl;
    } else {
        cout << ((n == m) + 1) * fact(n) * fact(m) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf

main :: IO ()
main = loop 1

loop :: Int -> IO()
loop i = do
  {[x] <- getInts
  ; if x == 0 then return ()
    else do
    { putStr $ printf "Case %d: %d\n" i x
      ; loop (i+1)
     }
  }

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInt :: [Int] -> IO()
putInt = putStrLn . unwords. map show



Measured memory_bytes: 4252
def main():
    n,m = map(int,input().split())
    a,b = [],[]
    for i in range(n):
        a.append(list(input()))
    for j in range(m):
        b.append(list(input()))
    flag = 0
    for i in range((n-m)+1):
        for j in range((n-m)+1):
            counter = 0
            for k in range(m):
                for l in range(m):
                    if a[k+i][l+j] == b[k][l]:
                        counter += 1
            if counter == m**2:
                flag = 1
    print("Yes" if flag else "No")
main()

Measured memory_bytes: 9140
S=list(input())
K=int(input())
N=len(S)

for i in range(N):
    if S[i]=="a":
        continue
    sa=ord("z")-ord(S[i])+1
    if sa<=K:
        K-=sa
        S[i]="a"

if K!=0:
    K%=26
    S[i]=chr(ord(S[i])+K)

print("".join(S))

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

int main()
{
	int n,k,type,i,ans=1000000,c,tmp;
	for(scanf("%d%d",&n,&k),i=1,type=(1<<n)-1;type>=0;type--,i=1)
	{
		for(c=n,tmp=type;c--;tmp/=2)
			if(tmp&1) i*=2;
			else i+=k;
		ans=min(i,ans); 
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define ll 		int
#define int 		long long
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define vpi 		vector<pii>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}


signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	
    int n;
    cin>>n;
    ld A[n];
    for(int i=0;i<n;i++)cin>>A[i];

    ld dp[n+1][n+1];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        dp[i][j]=0.0;
    }
    dp[0][0]=1.0;
    for(int i=0;i<n;i++)
    {
        dp[i+1][0]=dp[i][0]*A[i];
        for(int j=0;j<=i;j++)
        {
            dp[i+1][j+1]=dp[i][j]*(1-A[i])+dp[i][j+1]*A[i];

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

        cout<<endl;
    }*/

    ld ans=0;
    for(int i=0;i<=n;i++)
    {
        int head=(n-i);
        int tail=i;
        if(tail<head)
        ans+=dp[n][i];
    }
    coud(ans,13);

    
return 0;
}

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

int main(){
    int a;
    int b;
    int c;
    cin >> a >>b >>c;
    if(a<=b && b<=c && a<=c) cout << a << " "<< b <<" " << c <<endl;
    else if(a<=b && c<=b && a<=c ) cout << a << " " <<c << " " << b << endl;
    else if(b<=a && a<=c && b<=c) cout << b<<" " << a<<" "<< c <<endl;
    else if(b<=a && c<=a && b<=c) cout << b<< " " << c << " " << a <<endl;
    else if(c<=a && a<=b &&c<=b)  cout << c <<" " << a <<" "<< b << endl;
    else if(c<=a && b<=a &&c<=b)  cout << c <<" " << b <<" "<< a <<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
using namespace std;
int main(){
    int H, W;
    cin >> H >> W;

    string a[H+2]={"#"};
    for(int i=1; i<W; i++) a[0] += "#";
    for(int i=1; i<=H; i++) cin >> a[i];
    a[H+1] = a[0];

    for(int i=0; i<H+2; i++)
        cout << '#' << a[i] << "#\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;


int main(){
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> hs(N, 0);
    rep(i, N){
        cin >> hs[i];
    }
    int l = 0;
    int r = 1e9;
    int ans = 1;
    while(l <= r){
        ll t = 0;
        int mid = (l + r) / 2;
        double de = A - B;
        rep(i, N){
            // midの必要性を検証.
            double tmp = hs[i] - 1.0 * B * mid;
            if(tmp > 0){
                t += ceil((double)(tmp) / (de));
            }
        }
        if(t > mid){
            // mdではng
            l = mid + 1;
        }else{
            // mdでもok.
            r = mid - 1;
            ans = mid;
        }
    }

    cout  << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

int main() {
  int H, W;
  cin >> H >> W;
  GraphC g(H + 2, vector<char>(W + 2, '#'));
  repe(y, 1, H) repe(x, 1, W) cin >> g[y][x];

  rep(y, 0, H + 2) {
    rep(x, 0, W + 2) cout << g[y][x];
    cout << endl;
  }

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int64_t> l(n + 1);
    l.at(0) = 2ll;
    l.at(1) = 1ll;
    for (int i = 2; i <= n; i++) {
        l.at(i) = l.at(i - 1) + l.at(i - 2);
    }
    printf("%lld", l.at(n));
}


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

int main() {
  int a1, a2, a3, a4;
  cin >> a1;
  a2 = a1/100;
  a3 = a1 - a2*100;
  a3 = a3/10;
  a4 = a1 - a2*100 - a3*10;
  a4 = a2 + a3 + a4;
  cout << a4;
}

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s; cin >> s;
    if (s[s.size()-1] == 's') s += "es";
    else s += 's';

    cout << s << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	REP(i,5)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
h,w = map(int,input().split())
s = []
def calc(i,j,k,l):
    if k==0 and l==0:
        return 0
    elif i+k==-1 or j+l==-1 or i+k==h or j+l==w:
        return 0
    elif s[i+k][j+l] == '#':
        count[i][j] = count[i][j] + 1
for i in range(h):
    s += [input()]
count = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        for k in range(3):
            for l in range(3):
                calc(i,j,k-1,l-1)
for i in range(h):
    s_tmp=''
    for j in range(w):
        if s[i][j]=='#':
            s_tmp += '#'
        else:
            s_tmp += str(count[i][j])
    s[i]=s_tmp
for i in range(h):
    print(s[i])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vi a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(int i=0;i<n;i++){ // bの値について全探索
        auto itr1 = lower_bound(a.begin(),a.end(),b[i]); // itr1 =b[i]
        int aitr = itr1 - a.begin();
        auto itr2 = upper_bound(c.begin(),c.end(),b[i]);
        int citr = c.end() - itr2;
        //cout << "a= " << aitr << " c= " << citr << endl;
        ans += (ll)aitr * (ll)citr;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split()))
odd = 0
even = 0
even4 = 0

for num in A:
    if num % 2 == 1:
        odd += 1
    else:
        even += 1
    if num % 2 == 0 and num % 4 != 0:
        even4 += 1
even4 = even - even4
    
if odd == 0 or odd <= even4 or (odd + even4 == N and odd == even4 + 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20040
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    int n, q;
    string s;
    cin>>n>>q>>s;
    int pre[n];
    pre[0] = 0;
    rep(i, 1, sz(s)) {
        pre[i] = pre[i-1];
        if(s[i] == 'C' && s[i-1] == 'A') {
            pre[i]++;
        }
    }
    while(q--) {
        int l, r;
        cin>>l>>r;
        l--; r--;
        int ans = pre[r] - pre[l];
        cout<<ans<<endl;
    }
    
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

typedef complex<double> P;

void solve(long long N, std::vector<long long> x, std::vector<long long> y) {
    vector<P> ps;
    for (int i = 0; i < N; i++) ps.push_back(P(x[i], y[i]));

    P t;
    double eps = 0.999;
    double c = 1.0;
    for (int i = 0; i < 100000; i++) {
        double mx = -1e9;
        P tt;
        for (auto p : ps) {
            if (mx < abs(p - t)) {
                mx = abs(p - t);
                tt = p;
            }
        }
        t += (tt - t) * c;

        c *= eps;
    }

    {
        double mx = -1e9;
        P tt;
        for (auto p : ps) {
            if (mx < abs(p - t)) {
                mx = abs(p - t);
                tt = p;
            }
        }
        printf("%.10lf\n", mx);
    }


}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	map<string,int> mp;
	while(n--)
	{
		string s;cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if(a==c){
    }
    else{
      cout<<"Yes";
      return 0;
    }
  }
    if(a==c){
    if(a==b){
    }
    else{
      cout<<"Yes";
      return 0;
    }
  }
    if(c==b){
    if(a==c){
    }
    else{
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[79]:


N = int(input())


# In[80]:


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# In[82]:


if N < 3:
    print(0)
else:
    mylist = make_divisors(N)
    idx = len(mylist)//2
    ans = 0
    for x in mylist[idx:]:
        if N//(x-1) == N%(x-1):
            ans += x-1
    print(ans)


# In[ ]:






Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] rate = new int[8];
		int red = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(3200 <= a) {
				red++;
			} else {
				rate[(a/400)]++;
			}
		}
		int min = 0;
		int max = 0;
		int count = 0;
		for(int i = 0; i < 8; i++) {
			if(rate[i] >= 1) {
				count++;
			}
		}
		min = Math.max(count, 1);
		max = count+red;
		System.out.println(min+" "+max);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){
	static int x,f; static char ch; x = 0,f = 1,ch = getchar();
	while (!isdigit(ch)){  if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - '0',ch = getchar();
	return x * f;
}
const int N = 1000050,P = 998244353;
int n,a[N];

int p[N/10],cntp,mu[N],vis[N],inv[N];
int F[N],G[N];
inline void sieve(int n){
	register int i,j;
	mu[1] = 1; inv[1] = 1;
	for (i = 2; i <= n; ++i){
		inv[i] = (LL)(P-P/i) * inv[P%i] % P;
		if (!vis[i]) mu[i] = -1,p[++cntp] = i;
		for (j = 1; i * p[j] <= n; ++j){
			vis[i*p[j]] = 1;
			if (i % p[j] == 0){ mu[i*p[j]] = 0; break; }
			else mu[i*p[j]] = -mu[i];
		}
	}
//	for (i = 1; i <= 20 && i <= n; ++i) cout<<i<<' '<<mu[i]<<'\n';
	for (i = 1; i <= n; ++i) if (mu[i])
	for (j = 1; j * i <= n; ++j) F[i*j] = (F[i*j] + mu[i] * inv[j]) % P;
	for (i = 1; i <= n; ++i) F[i] = (F[i]+P)%P;
}

int main(){
	register int i,j;
	n = read(); while (n--) i = read(),++a[i];
	for (n = 1,i = 1000000; i ; --i) if (a[i]){ n = i; break; }
	for (i = 1; i <= n; ++i) a[i] = (LL)a[i] * i % P;
	for (i = 1; i <= n; ++i){
		for (j = i; j <= n; j += i) G[i] = (G[i] + a[j]) % P;
		G[i] = (LL)G[i] * G[i] % P;
	}
	sieve(n);
	int ans = 0;
	for (i = 1; i <= n; ++i) ans = (ans + (LL)F[i] * G[i]) % P;
	for (i = 1; i <= n; ++i) ans = (ans - a[i] + P) % P;
	ans = (LL)ans * (P+1>>1) % P;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 24064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A =sc.nextInt();
      int B =sc.nextInt();
      
     
      if(A==1&&B==2||B==1&&A==2){
      System.out.println(3);
      }
      else if(A==2&&B==3||A==3&&B==2){
      System.out.println(1);
      }
      else if(A==3&&B==1||A==1&&B==3){
      System.out.println(2);
      }
    }
}

Measured memory_bytes: 21972
import java.util.*;
 
class Main{
    public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int cnt = 0;
		int taro = 0;
		int hanako = 0;
		while(cnt < n){
			String card1 = scan.next();
			String card2 = scan.next();

			if(card1.compareTo(card2) > 0){
				taro += 3;
			}
			else if(card1.compareTo(card2) < 0){
				hanako += 3;
			}
			else{
				taro += 1;
				hanako += 1;
			}
			cnt++;
		}
		System.out.println(taro + " " + hanako);
    }
}

Measured memory_bytes: 30000
def main():
  num = int(input())
  
  dchar = 'abcdefghijklmnopqrstuvwxyz'
  result = []
  num = num - 1
  while num >= 0:
    result.append(dchar[num % 26])
    num = num // 26 - 1
  print(''.join(reversed(result)))
  
main()


Measured memory_bytes: 9164
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pa pair<int,int>
#define pb push_back
using namespace std;

int u,d,r,l;
vector<pa> p;
void addnum(int x,int y){
  if(y==0){
    p.pb(pa(p[x].first-1,p[x].second));
    l=min(l,p[x].first-1);
  }
  else if(y==1){
    p.pb(pa(p[x].first,p[x].second-1));
    d=min(d,p[x].second-1);
  }
  else if(y==2){
    p.pb(pa(p[x].first+1,p[x].second));
    r=max(r,p[x].first+1);
  }
  else if(y==3){
    p.pb(pa(p[x].first,p[x].second+1));
    u=max(u,p[x].second+1);
  }
}
int main(void){
  int n,i;
  int x,y;
  while(scanf("%d",&n),n){
    p.clear();
    u=d=r=l=0;
    p.pb(pa(0,0));
    for(i=0;i<n-1;i++){
      scanf("%d %d",&x,&y);
      addnum(x,y);
    }
    printf("%d %d\n",r-l+1,u-d+1);
  }
  return 0;
}

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

int main(){
	
	long long a=0,b,n,cnt=0;
		cin>>a >>b;
	
	for(int i=1; i<=b; i++){
		cin>>n;
			cnt +=n;
	}	
	a -=cnt;
	
	if(a<0)
		cout<<"-1";
	else
		cout<<a;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =1e5+100;

int main()
{
    ll n,x;
    while(~scanf("%lld%lld",&n,&x))
    {
        ll t =x*2+1;
        ll sum =n/t;
        if(n%t)
            sum++;
        printf("%lld\n",sum);
    }
    return 0;
}


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

int main(){

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

    vector<int> player(N, K-Q);
    rep(i, Q){
        player[A[i]-1] += 1;
    }

    rep(i,N){
        if(player[i] > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))

if N == 1:
    print(0)
    exit()

ans = 0

for i in range(1,N):
    if A[i] < A[i-1]:
        ans += A[i-1] - A[i]
        A[i] = A[i-1]

print(ans)

Measured memory_bytes: 32240
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll dp[100005];
int h[100005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    rep1(i, n) cin >> h[i];
    memset(dp, 0x3f, sizeof dp);
    dp[1] = 0;
    rep1(i, n)
        iter(j, i+1, min(i+k, n)+1)
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    cout << dp[n] << endl;
}



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

int main(){
  long long ans = 1;
  int n;
  cin >> n;
  vector<int> b(0),c(168);
  int a[1001]={};
  for(int i=2;i<1001;i++){
    int k=0;
    while(i*k<1001){
      a[i*k]++;
      k++;
    }
  }
  for(int i=1;i<1001;i++){
    if(a[i]==1)
      b.push_back(i);
  }
  for(int i=2;i<=n;i++){
    int d=i;
    for(int k=0;k<168;k++){
      while(d%b.at(k)==0){
        c.at(k)++;
        d/=b.at(k);
      }
    }
  }
  for(int i=0;i<168;i++)
    ans =(ans%(1000000007)*(c.at(i)+1))%1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 256
#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() {
  long double pi= 3.141592653589;
  long double A,B,M;int H; cin>>A>>B>>H>>M;
  long double sii = abs(M*pi/30.0 - ((H%12)*60.0+M)*pi/360.0);
  long double ans = A*A+B*B-2*A*B*cos(sii);
  
  if(sii==0) cout << abs(A-B) << endl;
  else if(sii == pi) cout << A+B << endl;
  else cout << setprecision(20) << sqrt(ans) << endl;
}

Measured memory_bytes: 4172
X = int(input())
if 400 <= X <= 599: print(8)
elif 600 <= X <= 799: print(7)
elif 800 <= X <= 999: print(6)
elif 1000 <= X <= 1199: print(5)
elif 1200 <= X <= 1399: print(4)
elif 1400 <= X <= 1599: print(3)
elif 1600 <= X <= 1799: print(2)
else: print(1)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b)){
        cout<<"B"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
x=range(int(input()))
P=[]
Q=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:Q+=[P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]]
print(sum(Q)*0.5)

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

using namespace std;

#define ll long long

int main(){
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<ll> d(40, 0);
  ll ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 40; j++){
      if(a[i] & ((ll)1 << (ll)j)){
        d[j]++;
      }
    }
  }
  bool flag = false;
  for(int j = 39; j >= 0; j--){
    if(flag){
      ans = ans * 2 + max(d[j], (ll)n - d[j]);
    }else{
      if(k & ((ll)1 << (ll)j)){
        ans = ans * 2 + max(d[j], (ll)n - d[j]);
        if(d[j] >= (ll)n - d[j]){
          flag = true;
        }
      }else{
        ans = ans * 2 + d[j];
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s>>t;
//    cout << s << endl;
//    cout << s << endl;
    if (s == t.substr(0,t.size()-1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }




    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
vii dp;
vec<vec<PII>> restore;
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    string s,t,ans; cin >> s >> t;
    dp.resize(s.size()+1, vi(t.size()+1));
    restore.resize(s.size() + 1, vec<PII>(t.size() + 1));
    restore[0][0] = make_pair(-1, -1);
    for(int i = 0; i < s.size(); ++i) {
        for(int j = 0; j < t.size(); ++j) {
            if(s[i] == t[j]) {
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
    }


    // 同じ値が並んでいる箇所の左端ではほしい遷移が起きるので、という実装
    int i = (int)s.size()-1;
    int j = (int)t.size()-1;
    while(i >= 0 && j >= 0) {
        if(dp[i+1][j+1] == dp[i+1][j]) {
            --j;
        }
        else if(dp[i+1][j+1] == dp[i][j+1]) {
            --i;
        }
        else if(dp[i+1][j+1] == dp[i][j] + 1) {
            ans = s[i] + ans;
            --i;
            --j;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 105984
from sys import exit, setrecursionlimit, stderr, stdin
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect
import functools

def input():
  return stdin.readline().strip()

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

s = input()
s = s.replace("BC", "X")
N = len(s)

ans = 0

x = 0
for i in range(N-1, -1, -1):
  if s[i] == "X":
    x += 1
  elif s[i] == "A":
    ans += x
  else:
    x = 0
print(ans)

Measured memory_bytes: 42480
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 998244353
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge &operator=(const int &x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	string s;
	int w;

	cin >> s >> w;

	rep(i, s.size())
	{
		if (i % w == 0)
		{
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		LinkedList<Integer> ll = new LinkedList<>();
		
		int H = 999;
		int W = 999;
		
		int cnt = 0;
		
		//?????????????´?
		while(H != 0 || W != 0) {
			H = sc.nextInt();
			W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			} else {
				ll.add(H);
				ll.add(W);
				cnt+=2;
			}
		}
		
		int k = 0;
		while(k < cnt) {
			int j = 0;
			while(j < ll.get(k)) {
				int i = 0;
				while(i < ll.get(k+1)) {
					if(j == 0 || j == ll.get(k) - 1
					 ||i == 0 || i == ll.get(k+1) - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
					i++;
				}
				System.out.println();
				j++;
			}
			System.out.println();
			k+=2;
		}
		
	}
}

Measured memory_bytes: 34024
#include <iostream>
#include <vector>
using namespace std;
int group[20];
int n;
int m,k;
string mt[20];
int rsglobal = 1e9;
 
 
void check(int j, int i, vector <int> &white, int &rs)
{
    if (mt[j][i] == '1')
        white[group[j]]++;
    if (white[group[j]] > k){
        for (int l = 1; l <=n; l++)
            white[l] = 0;
        for (int l = 1; l <=j; l++)
            if (mt[l][i] == '1')
                white[group[l]]++;
        rs++;
    }
}
 
void backtrack(int step,int lastgroup)
{
    if (step == n+1){
        int rs = group[n] - 1;
        vector <int> white (20, 0);
        for (int i = 1; i <= m ;i++){
            for (int j = 1; j <=n; j++){
                check(j,i, white, rs);
            }
        }
       /* for (int i = 1; i <= n; i++)
            cout << group[i] << " ";
        cout << "\n";
        for (int i = 1; i <=n; i++)
            cout << white[i] << "\n";
        cout << rs << "\n\n";*/
        rsglobal = min(rsglobal, rs);
        return;
    }
    group[step] = lastgroup;
    backtrack(step+1, lastgroup);
    if (step != 1){
        group[step] = lastgroup + 1;
        backtrack(step+1, lastgroup + 1);
    }
    return;
 
}
 
int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n ;i++){
        cin >> mt[i];
        mt[i] = "5" + mt[i];
    }
    backtrack(1,1);
    cout << rsglobal;
 
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> minus;
	vector<ll> plus;
	for (int i = 0;i < N;i++) {
		ll x;
		cin >> x;
		if (x >= 0)
			plus.push_back(x);
		else
			minus.push_back(abs(x));
	}
	ll ans = INF;
	for (int i = 0;i < minus.size();i++) {
		if (i + K - 1 < minus.size())
			ans = minus[i];
		else if(K - ((int)minus.size() - i) <= plus.size()) {
			ll r = plus[K - ((int)minus.size() - i) - 1];
			ll l = minus[i];
			ans = min({ ans, r * 2 + l, l * 2 + r });
		}
	}
	if (plus.size() >= K)
		ans = min(ans, plus[K-1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1656