akhauriyash/Code-Regression huggingface dataset:
using System;

public class ChangingaCharacter
    {
        static void Main(string[] args)
        {
            string[] line1 = Console.ReadLine().Trim().Split(' ');
            var lengs = int.Parse(line1[0]);
            var target = int.Parse(line1[1]);
            string str = Console.ReadLine().Trim();
            string ans = null;

            for (int i = 0; i < lengs; i++)
            {
                if (i == target - 1)
                {
                    ans = ans + str[i].ToString().ToLower();
                }
                else
                {
                    ans = ans + str[i];
                }
            }
            Console.WriteLine(ans);
        }
    }

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

int main(){
  	string s;
	
  	cin>>s;
  
  	if(s=="Sunny")
      cout<<"Cloudy";
    else if(s=="Cloudy")
      cout<<"Rainy";
    else if(s=="Rainy")
      cout<<"Sunny";
      
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >>n;
  vector<int>v(n);
  for(int i=0;i<n;++i)
    cin >>v[i];
  sort(v.begin(),v.end());
    double ans = v[0];
  for(int i=1;i<n;++i)
    ans=(ans+v[i])/2;
  printf("%.8f",ans);
}


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

int main() {

  int k,s;
  cin>>k>>s;
  int ans=0;
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      int z=s-x-y;
      if(z>=0&&z<=k) ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            StringBuilder sb = new StringBuilder(br.readLine());
            System.out.println(sb.reverse().toString());

        } catch (Exception e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24112
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  string S; cin >> S;
  if(S == "Sunny") cout << "Cloudy" << endl;
  else if(S == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    string ans="No";

    string S,T;

    cin >> S >> T;

    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<char>());
    if(S<T) ans = "Yes";

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
N = int(input())
def Div(i):
    if i == 1 or i == 2 or i==3 or i==5 or i==6:
        return False
    elif i == 4 or i == 7:
        return True
    else:
        if Div(i-4) or Div(i-7):
            return True
        else:
            return False
print("Yes" if Div(N) else "No")

Measured memory_bytes: 3060
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;

signed main(){
    ll x[5];
    rep(i,5) cin>>x[i];
    rep(i,5){
        if(!x[i]) cout<<i+1<<endl;
    }
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);




int main()
{
    int64 n, k;
    cin >> n >> k;
    vint64 s(n + 1);
    Rep(i, n)
    {
        int ai;
        cin >> ai;
        s[i + 1] = (s[i] + ai + k - 1) % k;
    }
    map<int64, int64> mp;
    int64 count = 0;
    queue<int64> que;
    Rep(i, n + 1)
    {
        count += mp[s[i]];
        ++mp[s[i]];
        que.push(s[i]);
        if (que.size() == k)
        {
            mp[que.front()]--;
            que.pop();
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b,c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	if (a==b && b==c) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if(n == 1 && m == 1){
            System.out.println(1);
        }else if(n == 1 || m == 1){
            System.out.println(n*m-2);
        }else{
            System.out.println(n*m-(2*n+2*m-4));
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
    #ifdef DGC
        //freopen("a.txt", "r", stdin);
        //freopen("b.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b-a+1 - (b/c-(a-1)/c + b/d-(a-1)/d - (b/(c*d/__gcd(c, d))-(a-1)/(c*d/__gcd(c, d)))) << "\n";

    return 0;
}


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

void set_right(vector<vector<int>>& P, uint xBase) {
    if (xBase >= P[0].size()) return;
    for (uint x=xBase; x<P[0].size(); ++x) {
        for (uint y=0; y<P.size(); ++y) {
            P[y][x] = 0;
        }
    }
};

void set_left(vector<vector<int>>& P, uint xBase) {
    for (uint x=0; x<xBase; ++x) {
        for (uint y=0; y<P.size(); ++y) {
            P[y][x] = 0;
        }
    }
};

void set_bottom(vector<vector<int>>& P, uint yBase) {
    for (uint y=0; y<yBase; ++y) {
        for (uint x=0; x<P[y].size(); ++x) {
            P[y][x] = 0;
        }
    }
};

void set_top(vector<vector<int>>& P, uint yBase) {
    if (yBase >= P.size()) return;
    for (uint y=yBase; y<P.size(); ++y) {
        for (uint x=0; x<P[y].size(); ++x) {
            P[y][x] = 0;
        }
    }
};

int main() {
    uint W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> P(H, vector<int>(W, 1));

    for (size_t i=0; i<N; ++i) {
        uint x, y, a;
        cin >> x >> y >> a;

        if (a == 1) {
            set_left(P, x);
        }
        else if (a == 2) {
            set_right(P, x);
        }
        else if (a == 3) {
            set_bottom(P, y);
        }
        else if (a == 4) {
            set_top(P, y);
        }
    }

    int area = 0;
    for (uint y=0; y<P.size(); ++y) {
        for (uint x=0; x<P[0].size(); ++x) {
            area += P[y][x];
        }
    }
    cout << area << endl;
}

Measured memory_bytes: 3672
<?php

$str = trim(fgets(STDIN));
$substr1 = substr($str, 0, (strlen($str)-1)/2);
$substr2 = substr($str, (strlen($str)+3)/2-1, (strlen($str)-1)/2);
print (isKaibun($str) && isKaibun($substr1) && isKaibun($substr2)) ? "Yes" : "No";

function isKaibun($str) {
    $char = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
    $count = count($char);
    for ($i=0; $i < floor($count / 2) ; $i++) { 
        if ($char[$i] != $char[$count-1-$i]) return false;
    }
    return true;
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int a, b;
    cin >> a >> b;
    if(b == 1){
        cout << 0;
        return 0;
    }
    b -= a;
    if(b <= 0){
        cout << 1;
        return 0;
    }
    ll ans = 1 + b/(a-1);
    if(b%(a-1) != 0)ans++;
    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int N,M; cin >> N >> M;
    vector<ll> x(N), y(N), z(N);
    for(int i=0; i<N; ++i) cin >> x[i] >> y[i] >> z[i];

    ll ans = -(1LL<<60);

    for(int bit=0; bit<1<<3; ++bit){
        vector<ll> cake(N);
        for(int i=0; i<N; ++i){
            ll tmp = 0;
            if(bit&1<<0) tmp += x[i];
            else tmp -= x[i];

            if(bit&1<<1) tmp += y[i];
            else tmp -= y[i];

            if(bit&1<<2) tmp += z[i];
            else tmp -= z[i];

            cake[i] = tmp;
        }
        sort(cake.rbegin(), cake.rend());
        chmax(ans, accumulate(cake.begin(), cake.begin()+M, 0LL));
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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(b < a){
        a = b;
        return true;
    }
    return false;
}

const int m[4][2][11] = {
    {
        { 0,  1,  2, 14, 15, 18, 19, 20, 27, 28, 29},
        {27, 28, 29, 15, 14, 20, 19, 18,  0,  1,  2}
    },
    {
        { 6,  7,  8,  9, 10, 11, 12, 17, 21, 22, 23},
        {21, 22, 23, 11, 10,  9, 17, 12,  6,  7,  8}
    },
    {
        { 0,  3,  6,  9, 20, 15, 16, 17, 23, 26, 29},
        {23, 26, 29, 20,  9, 17, 16, 15,  0,  3,  6}
    },
    {
        { 2,  5,  8, 11, 18, 12, 13, 14, 21, 24, 27},
        {21, 24, 27, 18, 11, 14, 13, 12,  2,  5,  8}
    }
};

bool check(const vector<int> &p){
    const int c[] = {0, 9, 12, 15, 18, 21, 30};
    rep(i, 6){
        REP(j, c[i], c[i + 1]){
            if(p[j] != p[c[i]]){
                return false;
            }
        }
    }

    return true;
}

vector<int> move(vector<int> p, int i){
    vector<int> res = p;

    rep(j, 11){
        res[m[i][1][j]] = p[m[i][0][j]];
    }

    return res;
}

int dfs(int depth, vector<int> p){
    if(check(p)){
        return 0;
    }else if(depth >= 8){
        return IINF;
    }

    int res = IINF;
    rep(i, 4){
        chmin(res, 1 + dfs(depth + 1, move(p, i)));
    }

    return res;
}

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

    int n;
    cin >> n;

    while(n--){
        vector<int> p(30);
        rep(i, 30){
            cin >> p[i];
        }

        int ans = dfs(0, p);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3180
def found_min(x, y):
    if x == -1 and y == -1:
        return -1
    elif x == -1:
        return y
    elif y == -1:
        return x
    else:
        if x >= y:
            return y
        else:
            return x
n = int(input())
Stamp = input()

OXStamp = 0
index = 0

while True:
    
    i = found_min(Stamp[index:].find("OX"), Stamp[index:].find("XO"))
    if i == -1:
        break
    else:
        OXStamp += 1
        index += i + 2
print(OXStamp)


Measured memory_bytes: 5792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;

long long power(long long x, long long y, long long p)
{
long long res = 1;


x = x % p;


while (y > 0)
{
if (y & 1)
res = (res*x) % p;


y = y>>1;
x = (x*x) % p;
}
return res;
}

void solve()
{
    ll n,x,m;
    cin>>n>>x>>m;
    ll res=0;
    vll pat;
    pat.pb(x);
    ll vis[m];
    vis[x]=0;
    clr(vis);
    ll patlen=-1;
    ll pats=-1,paten=-1;
    ll i;
    for(i=0;i<2*m;i++)
    {
        ll no = pat.back();
        ll now = power(no,2,m);
        if(vis[now])
        {
            patlen = sz(pat)-vis[now];
            pats = vis[now];
            paten = sz(pat);
        }
        else{
            vis[now]=sz(pat);
            pat.pb(now);
        }
    }
    vll fpat;
    for(i=pats;i<paten;i++)
    {
        fpat.pb(pat[i]);
    }
    ll nn = 0;
    for(i=0;i<min(n,pats);i++)
    {
        res+=pat[i];
        nn++;
    }
    ll fulrem = n-nn;
    ll sip = sz(fpat);
    ll nor = fulrem/sip;
    ll rem2 = fulrem%sip;
    ll sum=0;
    for(auto it:fpat)
    {
        sum+=it;
    } 
    res+=(nor)*sum;
    for(i=0;i<rem2;i++)
    {
        res+=fpat[i];
    }
    cout<<res<<"\n";



}



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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 5036
n = int(input())
Adj = [[0]]
for _ in range(n):
    Adj.append(list(map(int, input().split()))[2:])

visited = [False]*(n+1)
s = [0]*(n+1)
f = [0]*(n+1)
time = 0

def dfs(i):
    global time
    time += 1
    s[i] = time
    visited[i] = True
    for j in Adj[i]:
        if not visited[j]:
            dfs(j)
    time += 1
    f[i] = time

while not all(visited[1:]):
    i = visited[1:].index(False) + 1
    dfs(i)

for i in range(1, n+1):
    print(i,s[i], f[i])


Measured memory_bytes: 5652
def main():
    n = int(input())
    dp = [list(map(int, input().split())) for _ in range(n)]
    for i in range(1, n):
        dp[i][0] += max(dp[i-1][1], dp[i-1][2])
        dp[i][1] += max(dp[i-1][0], dp[i-1][2])
        dp[i][2] += max(dp[i-1][0], dp[i-1][1])
    print(max(dp[n-1]))

if __name__ == "__main__":
    main()


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

const int PRM = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int c = 1;
    
    for (int i = 1; i <= n; i++) {
        c = 1ll * c * i % PRM;
    }
    
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
a = int(S[:2])
b = int(S[2:])
is_a_Y = is_b_Y = False

if 1 <= a <= 12:
    is_a_Y = True
if 1 <= b <= 12:
    is_b_Y = True

if is_a_Y and is_b_Y:
    print('AMBIGUOUS')
elif is_a_Y and not is_b_Y:
    print('MMYY')
elif not is_a_Y and is_b_Y:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
/**
*    created: 16.07.2020 01:46:22
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    map<int,int> mp;
    vector<int> v;
    int sum = 0;
    rep(i,n) {
        int a; cin >> a;
        mp[a]++;
        v.push_back(a);
        sum += a;
    }
    if (mp.size() == 1) {cout << 0 << endl; return 0;}
    int m1 = sum/n;
    int m2 = m1+1;
    int t1 = 0;
    int t2 = 0;
    rep(i,n) t1 += (v[i]-m1) * (v[i]-m1);
    rep(i,n) t2 += (v[i]-m2) * (v[i]-m2);
    cout << min(t1,t2) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long X; cin >> X;
    long long ans = 0;
    ans += X/11*2;
    X %= 11;
    if(X > 6) cout << ans + 2 << endl;
    else if(X != 0) cout << ans + 1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 8/3/2019

*/

#include <bits/stdc++.h>
using namespace std;
#define time cout << "\ntime: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;

    




int main(void){
	int n;
	cin >>n;
	int M[n][3];
	for(int i=0 ;i<n ;i++)
		for(int j=0 ; j<3 ;j++)
			cin >>M[i][j];

    for(int i=n-2 ; i>=0 ;i--){
    	for(int j=0;j<3 ;j++){
    		int x=M[i][j];
    		for(int k=0 ;k<3 ;k++){
    			if(k==j)
    				continue;
    			M[i][j]=max(M[i+1][k]+x,M[i][j]);
    		}
    	}
    }


    cout<< max({M[0][0],M[0][1],M[0][2]});
   return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define REP(a) for(i = 0; i <= a; i++)
int main(void) {
    long long int a[90],n,i;
    a[0] = 2;
    a[1] = 1;
    scanf("%lld",&n);
    REP(n) {
        if (i < 2) {
            continue;
        }
        a[i] = a[i - 1] + a[i - 2];
    }
    printf("%lld\n",a[n]);
    return 0;
}

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

int main(void){
	int a[5];
	int min = 0;
	for(int i = 0; i < 5; i++){
		scanf("%d", a + i);
		if(a[i] % 10 != 0 && a[i] % 10 < a[min] % 10)min = i;
	}
	int sum = 0;
	for(int i = 0; i < 5; i++){
		if(i == min)continue;
		sum += (a[i] + 9) / 10;
	}
	sum = sum * 10 + a[min];
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split(' '))
i = 0
while pow(2,i) < k:
    i += 1 #k=5~8ではi=3
q = 1;rate = 0;j = 0
while q <= n:
    while q*pow(2,(i-j)) >= k:
        j += 1
    j -= 1
    rate += min(1/pow(2,(i-j)),1)
    q += 1
print(rate/n)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long H = sc.nextInt();
        long W = sc.nextInt();

        if (H == 1 || W == 1) {
            System.out.println(1);
        } else {
            System.out.println((long) Math.ceil((double) (H * W) / 2));
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(){
  int N;
  vector<int> P;
  vector<int> Q;
  cin >> N;
  P.resize(N);
  Q.resize(N);
  for(int i=0; i<N; ++i){
    cin >> P[i];
    P[i]--;
    Q[P[i]] = i;
  }

  int count_max = 0;
  int count = 1;
  for(int i=0; i<N-1; ++i){
    if(Q[i+1] > Q[i]){
      count++;
    }else{
      if(count_max < count){
        count_max = count;
      }
      count = 1;
    }
  }
  if(count_max < count){
    count_max = count;
  }

  cout << N - count_max << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100010
int n,T,num,ans,a[N];
int main(){
//	freopen("a.in","r",stdin);
	scanf("%d%d",&n,&T);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	int mn=a[1];
	for(int i=2;i<=n;++i){
		if(mn<a[i]) ans=max(ans,a[i]-mn);
		mn=min(mn,a[i]); 
	}
	mn=a[1];
	for(int i=2;i<=n;++i){
		if(a[i]-mn==ans) num++;
		mn=min(a[i],mn);
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>

//using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

string S;

int main()
{
	cin >> S;

	int A = stoi(S.substr(0, 2));
	int B = stoi(S.substr(2));

	string ans = "NA";

	if (1 <= A && A <= 12 && 1 <= B && B <= 12)ans = "AMBIGUOUS";
	else if (1 <= A && A <= 12)ans = "MMYY";
	else if (1 <= B && B <= 12)ans = "YYMM";

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 100010
using namespace std;
int n,A[10000010];
bool pri[10000010];
void init(int N){
	for(int i=2;i<=N;i++)
	if(!pri[i])
	for(int j=i+i;j<=N;j+=i)pri[j]=1;
	pri[1]=pri[2]=1;
}
int q1[3010],q2[3010],t1,t2,S,T;
int k,cnt,h,t;
int F[M],L[M],N[M],a[M],c[M],dis[M],q[M];
void add(int x,int y,int z){
	a[++k]=y;c[k]=z;
	N[k]=F[x];F[x]=k;
}
bool BFS(int x,int y){
	q[t=1]=x;h=0;
	for(int i=1;i<=n;i++)dis[i]=1000000000;
	dis[x]=0;
	while(h<t){
		x=q[++h];
		for(int i=F[x];i;i=N[i])if(c[i]&&dis[a[i]]>n){
			dis[a[i]]=dis[x]+1;
			if(a[i]==y)return 1;
			q[++t]=a[i];
		}
	}
	return dis[y]<=n;
}
int dfs(int x,int T,int flow){
	if(x==T)return flow;
	int used=0;
	for(int i=F[x];i;i=N[i])if(c[i]&&dis[a[i]]==dis[x]+1){
		const int v=dfs(a[i],T,min(flow-used,c[i]));
		if(!v)continue;c[i]-=v;c[i^1]+=v;used+=v;
		if(used>=flow)return used;
	}
	return used;
}
int dinic(int S,int T){
	int ans=0;
	while(BFS(S,T))ans+=dfs(S,T,1000000000);
	return ans;
}
int main(){
	scanf("%d",&n);init(10000000);k=1;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		A[x]^=1;
	}
	for(int i=1;i<=10000001;i++)if(A[i]!=A[i-1]){
		if(i&1)q1[++t1]=i;
		else q2[++t2]=i;
	}
	for(int i=1;i<=t1;i++)
	for(int j=1;j<=t2;j++)if(!pri[abs(q1[i]-q2[j])]){
		add(i,j+t1,1),add(j+t1,i,0);
	}
	
	S=t1+t2+1;T=n=t1+t2+2;
	for(int i=1;i<=t1;i++)add(S,i,1),add(i,S,0);
	for(int i=1;i<=t2;i++)add(i+t1,T,1),add(T,i+t1,0);
	int v=dinic(S,T);
	cout<<(t1-v)/2*2+(t2-v)/2*2+((t1-v)&1)*3+v;
	return 0;
}


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

int N;
vector<long long> A;

void solve() {
    vector<long long> plus, minus;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<long long>());
    sort(minus.begin(), minus.end());
    if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();

    vector<pair<long long, long long> > res;
    long long cur = minus[0];
    for (int i = 0; i+1 < plus.size(); ++i) {
        res.push_back({cur, plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(), cur});
    cur = plus.back() - cur;

    for (int i = 1; i < minus.size(); ++i) {
        res.push_back({cur, minus[i]});
        cur -= minus[i];
    }

    cout << cur << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
}

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

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0;
    rep(i, n+1){
        string s = to_string(i);
        int tmp = 0;
        rep(j, s.size()){
            tmp += (s[j] - '0');
        }
        if(tmp>= a && tmp <= b){
            sum+= i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
D = list(map(int, input().split()))

VALUES = []
for l in range(k + 1):
    for r in range(k - l + 1):
        if l + r > n:
            continue
        JEWELS = D[:l] + D[n - r:]
        JEWELS.sort()
        
        back = k - (l + r)
        for _ in range(back):
            if not JEWELS:
                break
            if JEWELS[0] >= 0:
                break
            JEWELS.pop(0)
        
        VALUES.append(sum(JEWELS))

print(max(VALUES))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, vector<vector<int>>> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 25;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int w, h;
int board[MAX_N][MAX_N];
int ans;
bool isOK(int y, int x)
{
    if(y >= 0 and x >= 0 and y < h and x < w) return true;
    return false;
}
void dfs(int sy, int sx, int cnt)
{
    if(cnt > 10) return;
    if(board[sy][sx] == 3)
    {
        ans = min(ans, cnt);
        return;
    }
    for(int i = 0; i < 4; i++)
    {
        int y = sy, x = sx;
        if(isOK(y + dy[i], x + dx[i]) && board[y + dy[i]][x + dx[i]] == 1) continue;
        while(true)
        {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(not isOK(ny, nx)) break;
            if(board[ny][nx] == 1)
            {
                board[ny][nx] = 0;
                dfs(y, x, cnt + 1);
                board[ny][nx] = 1;
                break;
            }
            if(board[ny][nx] == 3)
            {
                dfs(ny, nx, cnt + 1);
                break;
            }
            y = ny;
            x = nx;
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> w >> h, w | h)
    {
        int sy, sx;
        ans = INF;
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                cin >> board[i][j];
                if(board[i][j] == 2) sy = i, sx = j;
            }
        }
        dfs(sy, sx, 0);
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}




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

int main() {
  
  int N;
  string S;
  
  
  cin >> N;
  
  
  for(int i=0; i<N; i++){
    
    
    cin >> S;
    
    if(S=="Y"){
      
      cout << "Four" << endl;
      break;
    }
    
    if(i==N-1)
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a, b;
    cin >> a >> b;
    
    if(a == "H")
    {
        if(b == "H")
        {
            cout << "H" << endl;
        }
        else
        {
            cout << "D" << endl;
        }
    }
    else
    {
        if(b == "H")
        {
            cout <<"D" << endl;
        }
        else
        {
            cout << "H" << endl;
        }
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;
static const int MOD = (1000000000 + 7);

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

    string s;
    cin >> s;
    int w;
    cin >> w;

    for( int i = 0; i < s.size(); ++i ) {
        if( !( i % w ) ) cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
# B - AcCepted

S = list(str(input()))
ans = 'AC'
if S[0] != 'A':
    ans = 'WA'
else:
    S[0] = 'a'

cnt = 0
for i in range(2, len(S)-1):
    if S[i] == 'C':
        cnt += 1
        S[i] = 'c'
if cnt != 1:
    ans = 'WA'

for s in S:
    if s.islower() == False:
        ans = 'WA'
        break

print(ans)


Measured memory_bytes: 9124
import sys
from collections import Counter
n, p = [int(i) for i in sys.stdin.readline().split()]
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


facs = factorization(p)
res = 1
for k, v in facs:
    res *= k ** (v // n)
print(res)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 3e3 + 5;
int dp[N][N];
int n,m;
string s,t;
int solve(int i,int j){
    if(i == n || j == m){
        return 0;
    }

    int &ans = dp[i][j];
    if(ans != -1) return ans;

    int res = 0;
    res = max(res,solve(i+1,j));
    res = max(res,solve(i,j+1));
    if(s[i] == t[j]){
        res = max(res,1 + solve(i+1,j+1));
    }
    return ans = res;
}
string res = "";
void trace(int i,int j){
    if(i == n || j == m){
        return;
    }
    if(s[i] == t[j]){
        res += s[i];
        trace(i+1,j+1);
        return;
    }
    if(solve(i,j) == solve(i+1,j)){
        trace(i+1,j);
        return;
    }
    if(solve(i,j) == solve(i,j+1)){
        trace(i,j+1);
        return;
    }
    return;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>s>>t;
    n = s.length();
    m = t.length();
    int ans = solve(0,0);
    trace(0,0);
    // cout<<ans<<endl;
    cout<<res<<endl;
    return 0;
    
}



Measured memory_bytes: 71168
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;
  A--;
  B--;
  print((int)ceil(B * 1.0 / A));
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

vector<vector<char> > vec;
vector<char> stv;
char st[110];
int n,l,i,j;

int main(){
    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++){
        scanf("%s",st);
        stv.clear();
        for(j=0;j<l;j++)stv.push_back(st[j]);
        vec.push_back(stv);
    }
    sort(vec.begin(),vec.end());
    for(i=0;i<n;i++){
        for(j=0;j<l;j++)printf("%c",vec[i][j]);
    }
    printf("\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int minimum = inf9;
    for(int i = 0; i < N; i++){
        int P;
        cin >> P;
        ans += (minimum > P);
        minimum = min(minimum, P);
    }
    cout << ans << endl;
}





Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int main(){
	int n,s=0;
	cin>>n;
	while(n){
		s+=(n%10==2);
		n/=10;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
import math
MOD=10**9+7
N=int(input())
li=[]
zcnt=0
az,bz=0,0
for i in range(N):
    A,B=map(int,input().split())
    if A==0 and B==0:
        zcnt+=1
        continue
    if A!=0 and B==0:
        bz+=1
        continue
    elif A==0 and B!=0:
        az+=1
        continue
    g=math.gcd(A,B)
    if A<0 and B<0:
        li.append((-(A//g),-(B//g)))
    elif A<0 and B>0:
        li.append((-(A//g),-(B//g)))
    else:
        li.append((A//g,B//g))
c=Counter(li)
dic={}
ans=(pow(2,az,MOD)+pow(2,bz,MOD)-1+MOD)%MOD
for a,b in c.keys():
    if (a,b) in dic:
        continue
    l,r=(-b,a),(b,-a)
    s=c.get(l,0)+c.get(r,0)
    dic[l],dic[r]=1,1
    res=(pow(2,c[(a,b)],MOD)+pow(2,s,MOD)-1+MOD)%MOD
    ans=(ans*res)%MOD
print((ans-1+zcnt)%MOD)

Measured memory_bytes: 120616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define INF 1e15
int main()
{
	
ll n,g;cin>>n>>g;
ll f[n+1],c[n+1];
for(ll i=0;i<n;i++)
cin>>f[i]>>c[i];


// we should try every permutation in this problem

vector<ll> perm(n);
iota(perm.begin(), perm.end(), 0);
ll mi=1000000009;

do
{
    ll sum=0;
     ll count=0;
	for(int i=0;i<n;i++)
	{
		ll idx=perm[i];
		ll times=f[idx];
		ll need=g-sum;
		ll p=(idx+1)*100;
		
		ll check=need/p+(need%p>0);/// jine v chaide a bro
		
		if(check<=f[idx])
		{
					count+=check;
					sum+=(check*p);
					sum+=c[idx];
					break;
					

		}
		else if(check>f[idx]){
		count+=f[idx],sum+=(f[idx]*p),sum+=c[idx];}
		
		if(sum>=g)break;
	
	}
	
	
	mi=min(count,mi);
	
}while (next_permutation(perm.begin(), perm.end()));


cout<<mi<<endl;





}

Measured memory_bytes: 256
N = int(input())
S = map(int, input().split())

result = 0

prev = 0

now_count = 0
for c in S:
  if c <= prev:
    now_count += 1
  else:
    if now_count > result:
      result = now_count
    now_count = 0
  
  prev = c

if now_count > result:
  result = now_count
print(result)

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

int main(void){
   
    int N;
    cin >> N;
    map<string,int>mp{};
    
    char b;
    string w_i;
    cin >> w_i;
    mp[w_i] = 1;
    b = w_i[w_i.size()-1];
    
    for(int i=1;i<N;i++){
        cin >> w_i;
        if(w_i[0] == b && mp.count(w_i) == 0){
            mp[w_i] = 1;
            b = w_i[w_i.size()-1];
        }
        else{
            cout << "No" <<endl;
            return 0;
        }
    }
    
    cout << "Yes" <<endl;
}


Measured memory_bytes: 3556
a = [input() for i in range(2)]
b = a[1].split(" ")
ans = 0

num = int(a[0])
if num>2:
  for i in range (0,num-2):
    for j in range (i+1,num-1):
      for k in range (j+1, num):
        if int(b[i])!=int(b[j]):
          if int(b[j])!=int(b[k]):
            if int(b[k])!=int(b[i]):
              if int(b[i])+int(b[j])>int(b[k]):
                if int(b[j])+int(b[k])>int(b[i]):
                  if int(b[k])+int(b[i])>int(b[j]):
                    ans=ans+1
print(ans)

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

int main() {
    int N,x;
    cin>>N>>x;
    int sum=0;
    int a[110];
    for(int i=0;i<N;++i)cin>>a[i];
    sort(a,a+N);
    for(int i=0;i<N;++i){
        if(sum+a[i]<=x){
            sum+=a[i];
        }else{
            cout<<i<<endl;
            return 0;
        }
    }
    if(sum==x){
        cout<<N<<endl;
    }else{
        cout<<N-1<<endl;
    }
}


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

signed main(){
  lint H, W; cin >> H >> W;
  vector<vector<char> > field(H, vector<char> (W));
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++) cin >> field[i][j];
  }
  vector<vector<lint> > dp(H, vector<lint> (W, 0));
  for(lint i = 1; i < H; i++){
    dp[i][0] = dp[i - 1][0] + (field[i][0] != field[i - 1][0]);
  }
  for(lint j = 1; j < W; j++){
    dp[0][j] = dp[0][j - 1] + (field[0][j - 1] != field[0][j]);
  }
  for(lint i = 1; i < H; i++){
    for(lint j = 1; j < W; j++){
      lint x = dp[i][j - 1] + (field[i][j - 1] != field[i][j]);
      lint y = dp[i - 1][j] + (field[i - 1][j] != field[i][j]);
      dp[i][j] = min(x, y);
    }
  }
  lint ans = dp[H - 1][W - 1];
  if(field[0][0] == '.' && field[H - 1][W - 1] == '.') ans /= 2;
  if(field[0][0] == '#' && field[H - 1][W - 1] == '#') ans = ans/2 + 1;
  if(field[0][0] != field[H - 1][W - 1]) ans = (ans + 1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 384
from math import ceil
from collections import deque

N, D, A = map(int, input().split())
monsters = []
for i in range(N):
    x, h = map(int, input().split())
    monsters.append((x, h))
monsters.sort()

damege_sum = 0
ans = 0
q = deque([])
for i in range(N):
    x, h = monsters[i]
    while q and q[0][0] < x:
        damege_sum -= q[0][1]
        q.popleft()
    h -= damege_sum
    if h > 0:
        hit = ceil(h / A)
        ans += hit
        damage = hit * A
        damege_sum += damage
        q.append((x + 2 * D, damage))

print(ans)




Measured memory_bytes: 44540
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
	unsigned short *A,*B;
	
	int C[VMAX+1];
	int n,i,j;
	scanf("%d",&n);
	
	A=malloc(sizeof(short)*n+1);
	B=malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++)C[i]=0;
	
	for(i=0;i<n;i++){
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
	
	for(j=1;j<=n;j++){
	B[C[A[j]]]=A[j];
	C[A[j]]--;
	}
	
	for(i=1;i<=n;i++){
	if(i>1)printf(" ");
	printf("%d",B[i]);
	}
	
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 9588
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	string S;
	string T;
	cin >> T;
	for (int i = 0; i < T.size(); i++)
	{
		if (T[i] == '1')S.push_back('1');
		if (T[i] == '0')S.push_back('0');
		if (T[i] == 'B'&&S.size()>0)S.pop_back();
	}
	cout << S;
}


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

long long fgcd (long long a, long long b) {
    if (a > b) {
        long long d = a; a = b; b = d;
    }
    if (b%a == 0) return a;
    else return fgcd(a, b%a);
}

int main() {
    int n; cin >> n;
    vector<long long> a(n), lg(n), rg(n);
    for (int i=0; i<n; i++) cin >> a[i];
    lg[0] = a[0]; rg[n-1] = a[n-1];
    for (int i=1; i<n; i++) {
        lg[i] = fgcd(a[i-1], lg[i-1]);
    }
    for (int i=n-2; i>=0; i--) {
        rg[i] = fgcd(a[i+1], rg[i+1]);
    }
    long long ans = 0;
    for (int i=1; i<n-1; i++) {
        ans = max(ans, fgcd(lg[i], rg[i]));
    }
    ans = max(ans, max(rg[0], lg[n-1]));
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
#define mod 1000000007

int N, M, T1[100][100], T2[100][100], A[100][100];
bool dp[82][82][12808];

int main() {
// freopen("input.in","r",stdin);
 //freopen("output.out","w",stdout);
  cin >> N >> M;
  for(int i = 0;i < N;i++) {
    for(int j = 0;j < M;j++) {
      cin >> T1[i][j];
    }
  }
  for(int i = 0;i < N;i++) {
    for(int j = 0;j < M;j++) {
      cin >> T2[i][j];
      A[i][j] = abs(T1[i][j] - T2[i][j]);
      // debug(A[i][j]);
    }
  }

  for(int i = 0;i < N;i++) {
    for(int j = 0;j < M;j++) {
      if(i == 0 and j == 0) {
        dp[i][j][A[i][j]] = true;
        continue;
      }
      for(int k = 0;k <= (N+M-1)*80;k++) {
        bool possible = false;
        int x = abs(A[i][j]+k);
        int y = abs(A[i][j]-k);
        if(i != 0) {
            possible |= dp[i-1][j][x] | dp[i-1][j][y];
        }
        if(j != 0) {
            possible |= dp[i][j-1][x] | dp[i][j-1][y];
        }

        dp[i][j][k] = possible;
      }
    }
  }

  for(int k = 0;k <= (N+M-1)*80;k++) {
    if(dp[N-1][M-1][k]) {
      cout << k << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 84224
#include<stdio.h>
#include <math.h>

typedef long long ll;
ll INF = 1100000000; // 1e9

int main() {
	/* 数値を格納する配列 */
	ll n, l[100];
	
	/* 数値の総数を入力 */
	scanf("%lld", &n);
	
	/* 配列に格納する数値を入力 */
	for (ll i = 0; i < n; ++i)
		scanf("%lld", &l[i]);
	
	ll count = 0;
	for (ll i = 0; i < n - 2; i++)
	{
		for (ll j = i + 1; j < n - 1; j++)
		{
			for (ll k = j + 1; k < n; k++)
			{
				ll x = l[i], y = l[j], z = l[k];
				if (x == y || y == z || z == x) continue;
				
				ll tmp;
				if (x > y) {
					tmp = y;
					y = x;
					x = tmp;
				}
				if (x > z) {
					tmp = z;
					z = x;
					x = tmp;
				}
				if (y > z) {
					tmp = z;
					z = y;
					y = tmp;
				}
				// x < y < z になった
				if (x + y > z) count++;
				
				
			}
			
		}
		
	}
	
	printf("%lld", count);
	
	return 0;
}

Measured memory_bytes: 1732
n = int(input())
al, xyl = [], []
for _ in range(n):
    a = int(input())
    xy = [list(map(int, input().split())) for _ in range(a)]
    xyl.append(xy)

ans = 0
for i in range(2**n):
    cnt = 0
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            cnt += 1
            for x, y in xyl[j]:
                x -= 1
                if (i >> x) & 1 != y:
                    flag = False
    if flag:
        ans = max(ans, cnt)
print(ans)

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

#define fo(i, x, y) for (int i = x; i <= y; ++i)
#define fd(i, x, y) for (int i = x; i >= y; --i)

const int maxn = 1e6 + 5;

int n, lim;
int a[maxn], pri[maxn];
bool f[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

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

int main()
{
	n = getint();
	fo(i, 1, n) a[i] = getint(), lim = max(lim, a[i]);
	fo(i, 2, lim)
		if (!pri[i])
		{
			pri[i] = i;
			fo(j, i, lim / i)
				if (!pri[i * j]) pri[i * j] = i;
		}
	bool flag = true;
	fd(i, n, 1)
	{
		int x = a[i];
		while (x > 1)
		{
			if (f[pri[x]]) {flag = false; goto sig;}
			x /= pri[x];
		}
		x = a[i];
		while (x > 1)
		{
			f[pri[x]] = true;
			x /= pri[x];
		}
	}
	sig:
	if (flag) {printf("pairwise coprime\n"); return 0;}
	int x = a[1];
	fo(i, 2, n) x = gcd(x, a[i]);
	printf(x == 1? "setwise coprime\n" : "not coprime\n");
	return 0;
}


Measured memory_bytes: 11472