akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int H, W;
  cin>>H>>W;

  vector<string> mp(H);
  cin>>mp;

  vector<P> newBlack;
  for(Int i=0;i<H;i++)
    for(Int j=0;j<W;j++){
      if(mp[i][j] == '.') continue;
      newBlack.push_back(P(i, j));
    }


  Int ans = 0;
  Int dx[] = {0, 0, 1, -1};
  Int dy[] = {1, -1, 0, 0};
  while(1){
    if(newBlack.empty()) break;
    vector<P> tmp;
    for(auto p:newBlack){
      Int y, x; tie(y, x) = p;
      for(Int i=0;i<4;i++){
        Int ny = y + dy[i];
        Int nx = x + dx[i];
        if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
        if(mp[ny][nx] == '.') {
          tmp.push_back(P(ny, nx));
          mp[ny][nx] = '#';
        }
      }
    }
    newBlack = tmp;
    ans++;
  }
  ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 24040
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
int n,m;
int tot;
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
{
	n=read();m=read();
	tot=n*3+m;
	printf("%d\n",tot/2);
	return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 50 + 9;

ll a[maxN];
int n;

bool isInc(){
	for(int i = 1; i + 1 <= n; i++){
		if(a[i] > a[i + 1]){
			return false;
		}
	}
	return true;
}

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

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}

	if(isInc()){
		cout << "YES\n";
		return 0;
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			swap(a[i], a[j]);
			if(isInc()){
				cout << "YES\n";
				return 0;
			}
			swap(a[i], a[j]);
		}
	}
	
	cout << "NO\n";

	return 0;
}

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

void dump(int* A, int size) {
  for (int i = 0; i < size; ++i) {
    if (i != 0) cout << ' ';
    cout << A[i];
  }
  cout << endl;
}

int main() {
  int A[110];
  int n, i, j, v;

  cin >> n;

  for (i = 0; i < n; ++i) {
    cin >> A[i];
  }

  dump(A,n);
  for (i = 1; i < n; ++i) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      --j;
    }
    A[j + 1] = v;
    dump(A, n);
  }

  return 0;
}


Measured memory_bytes: 3100
N,K =map(int,input().split())
sushi = [[int(i)for i in input().split()]for _ in range(N)]
sushi =sorted(sushi,key=lambda x:x[1],reverse=True)
neta =set()
ans = 0
daburi =[]
for i in range(K):
    if sushi[i][0] in neta:
        daburi.insert(0,i)
    neta.add(sushi[i][0])
    ans += sushi[i][1]
n = len(neta)
ans += n*n
sta = K
anslist=[ans]
s=False
while True:
    n =len(neta)
    if daburi == [] or s:
        break
    outsushi = daburi.pop(0)
    for i in range(sta,N):
        if not sushi[i][0] in neta:
            ans -= sushi[outsushi][1]
            ans += sushi[i][1]+2*n+1
            anslist.append(ans)
            neta.add(sushi[i][0])
            sta = i +1
            break
        elif i == N-1:
            s =True

print(max(anslist))

Measured memory_bytes: 24964
using System;

class Program
{
    static void Main()
    {
        int n = scan()[0];
        long ans = 0;
        for(int i = 1; i<= n; i++)
        {
        	ans+=i;
        }
        Console.WriteLine(ans);
    }
    static int[] scan()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    }
}

Measured memory_bytes: 2776
#include <stdio.h>
int Pos[100000];
int main() {
    long long N, X, M;
    scanf("%lli%lli%lli", &N, &X, &M);

    /// Precalculate f(x)
    int F[100000];
    for (int i = 0; i < M; i++) {
        F[i] = (i * 1ll * i) % M;
    }

    /// Find the cycle
    int curA = F[X];
    Pos[X] = 1;
    long long sum_cycle = X, len_cycle = 1;
    while (!Pos[curA]) { /// While the element haven't showed up before
        //printf(" %i\n", curA);

        sum_cycle += curA;
        len_cycle++;
        Pos[curA] = len_cycle;
        curA = F[curA];
    }

    int el1_ofCycle = curA;

    /// Sum and length of the sequence part before the 1st cycle
    long long sum_start = 0;
    long long len_start = (Pos[el1_ofCycle] - 1);
    len_cycle -= len_start;
    for (int i = 0, a = X; i < len_start; i++, a = F[a]) {
        sum_cycle -= a;
        sum_start += a;
    }

    if (N < len_start) {
        /// N is too small
        curA = X;
        long long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += curA;
            curA = F[curA];
        }
        printf("%lli", ans);
        return 0;
    }

    long long ans = sum_start;
    N -= len_start;
    ans += (N / len_cycle) * sum_cycle;

    curA = el1_ofCycle;
    N %= len_cycle;
    for (int i = 0; i < N; i++) {
        ans += curA;
        curA = F[curA];
    }
    printf("%lli", ans);
}


Measured memory_bytes: 2508
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	map<int, int> m;
	int s;
	cin >> s;
	m[s]++;
	int i = 2;
	while(true) {
		if(s % 2 == 0) {
			s /= 2;
			if(m[s] == 0) m[s]++;
			else {
				cout << i << endl;
				return 0;
			}
		} else {
			s = 3 * s + 1;
			if(m[s] == 0) m[s]++;
			else {
				cout << i << endl;
				return 0;
			}
		}
		i++;
	}
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    int count=0;
    int com=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==1) count++;
        else com++;
    }
    if(count%2==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;

int N;
string S;
int sn[4000];

int main()
{
  int i,j;
  long rn=0,gn=0,bn=0;
  long sum=0;

  cin >> N;
  cin >> S;

  for (i=0; i<N; i++) {
    switch(S[i]) {
    case 'R': rn++; sn[i] = 1; break;
    case 'G': gn++; sn[i] = 2; break;
    case 'B': bn++; sn[i] = 4; break;
    }
  }


  for (i=1; i<=N-2; i++) {
    for (j=i+1; j+j-i<=N; j++) {
      if ((sn[i-1]|sn[j-1]|sn[j+j-i-1])==7) sum++;
    }
  }

  printf("%ld\n", rn*gn*bn-sum);

  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(a) cerr << #a << ": " << a << endl
#define endl "\n"
#define int long long

int32_t main()
{
      IOS;

      int n , k;
      cin>>n>>k;

      n = n % k;
      int ans = min(n, k-n);
      cout<<ans;

      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

int main(){
  int H,W;
  string s;

  while(1){
    cin>>H>>W;
    s="";
    if(H==0) break;
    for(int i = 0; i<W; i++){
      s+="#";
    }

    for(int i = 0; i<H; i++){
      cout<<s<<endl;
    }

    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 
 

int main(){
	unordered_set<int> s;
	int n;
	cin>>n;
	REP(i,n){
		int a;
		cin>>a;
		s.insert(a);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n,m,a[N],ans = 0,mn = inf;

int main()
{

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(mn > a[i])
            ans++;
        mn = min(mn, a[i]);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			long m = vs[1];
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			long x = a[0], y = 0, lcm = a[0], lscm = a[0] / 2;
			bool f = true;
			for (int i = 1; i < n; i++) {
				y = a[i];

				lcm = LCM(x, y);
				lscm = LCM(x / 2, y / 2);
				if (lscm % x == 0 || lscm % y == 0 || m < lscm) {
					f = false;
					break;
				}

				x = lcm;
			}
			long ans = 0;
			if (f) {
				//System.Diagnostics.Debug.WriteLine($"{lscm} {lcm}");
				if (m >= lscm) {
					ans = 1 + (m - lscm) / lcm;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		#region 最小公倍数 long LCM(long a, long b)
		public static long LCM(long a, long b)
		{
			long gcd;
			if (b == 0) {
				gcd = a;
			} else {
				long x = a, y = b;
				long tmp = x % y;
				while (tmp != 0) {
					x = y;
					y = tmp;
					tmp = x % y;
				}
				gcd = y;
			}
			return a / gcd * b;
		}
		#endregion

	}
}


Measured memory_bytes: 31452
# B - Echo
def main():
    n = int(input())
    s = input()
    if n % 2 == 0:
        for i in range(n//2):
            if s[i] != s[i+n//2]:
                print('No')
                exit()
        else:
            print('Yes')
    else:
        print('No')
        exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N, M = list(map(int, input().split()))
results =[ input().split(" ") for i in range(M) ]

acc = [ False ] * N
pena = [ 0 ] * N 
for p, S in results:
  p = int(p) - 1
  if acc[p] is False:
    acc[p] = True if S == 'AC' else False 
    pena[p] = pena[p] + 1 if S == 'WA' else pena[p] 

wa = 0
for i in range(N):
  wa += pena[i] if acc[i] is True else 0
    
print(sum(acc), wa)



Measured memory_bytes: 33672
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n, sum1 = 0, sum2 = 0, ans = 0, l = 0;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i];
		sum1 += a[i];
	}
	if (sum1%n == 0) {
		for (ll i = 0;i < n;i++) {
			ans += (a[i] - sum1 / n)*(a[i] - sum1 / n);
		}
		cout << ans << endl;
	}
	else {
		l = sum1 / n;
		for (ll i = 0;i < n;i++) {
			ans += (a[i] - l)*(a[i] - l);
		}
		for (ll i = 0;i < n;i++) {
			sum2 += (a[i] - l - 1)*(a[i] - l - 1);
		}
		ans = min(ans, sum2);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
l=list(input())
n=len(l)
mod=10**9+7
dp1=[0]*(n+1)
dp2=[0]*(n+1)
dp2[0]=1
for i in range(n):
  if l[i]=='1':
    dp2[i+1]=dp2[i]*2%mod
    dp1[i+1]=(dp2[i]+dp1[i]*3)%mod
  else:
    dp2[i+1]=dp2[i]%mod
    dp1[i+1]=dp1[i]*3%mod
print((dp1[-1]+dp2[-1])%mod)

Measured memory_bytes: 51184
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b, c) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ld long double
const ll mod=998244353;
ll f(ll x,ll n){
    ll r=1;
    while(n){
        if(n&1)
        r=(r*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return r;
}
void solve(){
    int n,s;
    cin>>n>>s;
    int a[n];
    fr(i,0,n)
    cin>>a[i];
    ll dp[n][s+1]; // no of non empty subsets
    // dp[i][j]...subset containing elements only upto 0..i and sum=j
    memset(dp,0,sizeof(dp));
    if(a[0]<=s)
    dp[0][a[0]]=1;
    fr(i,0,n){
        dp[i][0]=f(2,i+1); // -1 is not added because whenever it is in use...its empty subset also counted since it is only counted when some a[i] needs to be attached to this
    }
    fr(i,1,n){
        fr(j,1,s+1){
            dp[i][j]=(dp[i-1][j]+dp[i-1][j])%mod; // to all those subsets....either a[i] is added or not added...giving two different subsets
            if(j-a[i]>=0)
            dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;
        }
    }
/*    fr(i,0,n){
        fr(j,0,s+1)
        cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n-1][s];

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 73976
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include<queue>

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//1

int main(void) 
{
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= a + b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main(){
  string s;
  cin >> s;
  if(
    (s.at(0) == s.at(1) && s.at(1) == s.at(2)) 
    || (s.at(3) == s.at(2) && s.at(1) == s.at(2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int K;
  cin >> K;
  char t = S.at(K-1);
  
  for(int i=0; i<S.size(); i++){
    if(S.at(i) != t){
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}

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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007

int main() 
{
    FIO;
    ll t,n,k,i,j;
    cin >> n;
    
    ll a[n+1],b[n];
    
    for(i=0;i<=n;i++)
        cin >> a[i];
    
    for(i=0;i<n;i++)
        cin >> b[i];
    
    k=0;
    
    for(i=0;i<n;i++){
        j=min(a[i],b[i]);
        
        k+=j;
        a[i]-=j;
        b[i]-=j;
        
        j=min(b[i],a[i+1]);
        
        k+=j;
        a[i+1]-=j;
        b[i]-=j;
    }
        
    t=k; 
    
    
    reverse(a,a+n+1);
    reverse(b,b+n);
    
    k=0;
    for(i=0;i<n;i++){
        j=min(a[i],b[i]);
        
        k+=j;
        a[i]-=j;
        b[i]-=j;
        
        j=min(b[i],a[i+1]);
        
        k+=j;
        a[i+1]-=j;
        b[i]-=j;
    }
    
    cout << max(k,t);
    
	return 0;
}


Measured memory_bytes: 1792
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [a,b,c,x]=t.n(4)
  let ans=0;
  for(let i=0;i*500<=x&&i<=a;i++){
    for(let j=0;i*500+j*100<=x&&j<=b;j++){
      let zan=x-(i*500+j*100)
      if(zan%50==0&&zan<=50*c)ans++;
    }
  }
  t.o(ans)
}
main()

Measured memory_bytes: 7500
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

// print a b: str の a 文字目から b 文字目までを出力する。
void print(string str){
  int a, b;
  cin >> a >> b;
  
  cout << str.substr(a, b-a+1) << endl;
}

// reverse a b: str の a 文字目から b 文字目までを逆順にする。
string reverse(string str){  
  int a, b;
  cin >> a >> b;
  
  string tmp = str.substr(a, b-a+1); // a文字からbまでの距離(b-a+1)で切り出す
  int n = tmp.size();
  for (int i = 0; i < n; i++){ // tmpの文字数分だけ回す
    str[i+a] = tmp[n-i-1]; // 逆から数えた文字を入れる
  }
  return str;
}

// replace a b p: str の a 文字目から b 文字目までを p に置き換える。
string replace(string str){
  int a, b;
  cin >> a >> b;
  string p;
  cin >> p;
  
  str = str.replace(a, b-a+1, p);
  
  return str;
}

int main(){ 
  string str;
  cin >> str;
  int n;
  cin >> n;
  
  // 指定回数 命令を処理する
  for (int i = 0; i < n; i++){
    string com;
    cin >> com;
    if(com == "print"){
      print(str);
    } else if (com == "reverse"){
      str = reverse(str);
    } else if (com == "replace"){
      str = replace(str);
    } else {
      cout << "" << endl;
    }
  }
  
  return 0;
}  


Measured memory_bytes: 3228
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long[] p1 = { sc.nextLong(), sc.nextLong() };
		long[] p2 = { sc.nextLong(), sc.nextLong() };
		if (p1[0] > p2[0]) {
			long[] tmp = p1;
			p1 = p2;
			p2=tmp;
		}
		int coe = 1;
		if (p1[1] > p2[1]) {
			coe = -1;
			p1[1] *= coe;
			p2[1] *= coe;
		}
		int n = sc.nextInt();
		long[][] p = new long[n][2];
		for (int i = 0; i < n; ++i) {
			p[i][0] = sc.nextLong();
			p[i][1] = sc.nextLong() * coe;
		}
		Arrays.sort(p, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(o1[0], o2[0]);
			}
		});
		int sz = 0;
		for (int i = 0; i < n; ++i) {
			if (p1[0] <= p[i][0] && p[i][0] <= p2[0] && p1[1] <= p[i][1] && p[i][1] <= p2[1])
				++sz;
		}
		long[] a = new long[sz];
		sz = 0;
		for (int i = 0; i < n; ++i) {
			if (p1[0] <= p[i][0] && p[i][0] <= p2[0] && p1[1] <= p[i][1] && p[i][1] <= p2[1]) {
				a[sz++] = p[i][1];
			}
		}
		long lis = LIS(a.length, a);
		double ans = (p2[0] - p1[0] + p2[1] - p1[1]) * 100 + (Math.PI * 5 - 20) * lis;
		if (lis == Math.min(p2[0] - p1[0] + 1, p2[1] - p1[1] + 1))
			ans += Math.PI * 5;
		System.out.println(String.format("%.20f", ans));
	}

	long LIS(int n, long[] a) {
		long[] f = new long[n];
		int sz = 0;
		for (int i = 0; i < n; ++i) {
			if (sz == 0) {
				f[sz] = a[0];
				++sz;
			} else {
				int ok = -1;
				int ng = sz;
				while (ng - ok > 1) {
					int middle = (ok + ng) / 2;
					if (f[middle] < a[i]) {
						ok = middle;
					} else {
						ng = middle;
					}
				}

				f[ok + 1] = a[i];
				if (ok + 1 == sz)
					++sz;
			}
		}
		return sz;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 114808
#include "bits/stdc++.h"
using namespace std;


struct Node {
	int key;
	Node* prev, * next;
};

Node* nil;

void init(void);
void deleteNode(Node* t);
Node* listSearch(int key);
void deleteKey(int key);
void deleteFirst(void);
void deleteLast(void);
void printList(void);
void insert(int key);


int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
		if (com[0] == 'i') { insert(key); np++; size++; }
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast();
			}
			else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();
	return 0;
}


void init(void) {
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
}

void deleteNode(Node * t) {
	if (t == nil) return;
	t->next->prev = t->prev;
	t->prev->next = t->next;

	free(t);
}

Node* listSearch(int key) {
	Node* src = nil->next;
	while ((src != nil) && (src->key != key)) {
		src = src->next;
	}
	return src;
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void deleteFirst(void) {
	deleteNode(nil->next);
}

void deleteLast(void) {
	deleteNode(nil->prev);
}

void printList(void) {
	Node* pri = nil->next;
	int pp = 0;
	while (1) {
		if (pri == nil)break;
		if (pp++ > 0) printf(" ");
		printf("%d", pri->key);
		pri = pri->next;
	}
	printf("\n");
}

void insert(int key) {
	Node* x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}


Measured memory_bytes: 34368
#define _USE_MATH_DEFINES
#include <cmath>
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
int main() {
	int N,S=0;
	cin >> N;
	int tmp = N;
	while (tmp > 0) {
		S += tmp % 10;
		tmp /= 10;
	}
	if (N%S == 0) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

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

typedef long long ll;

using namespace std;

const int mxeN = 200010;

ll n,m,k;	
ll a[mxeN];
ll b[mxeN];

ll pfsumA[mxeN];
ll pfsumB[mxeN];

int main(){

	cin >> n >> m >> k;
	for(int i=0;i<n;i++)
		cin >> a[i];

	for(int i=0;i<m;i++)
		cin >> b[i];
	

	pfsumA[0] = 0;
	for(int i=0;i<n;i++){
		pfsumA[i+1] = pfsumA[i] + a[i];	
	}
	pfsumB[0] = 0;
	for(int i=0;i<m;i++){
		pfsumB[i+1] = pfsumB[i] + b[i];	
	}
//	cout << lower_bound(pfsumA,pfsumA+n+1,30) - pfsumA<< endl;
	int globalmax = 0;
	for(int i=0;i<n+1;i++){
		if(pfsumA[i] > k)
			continue;
		int lo = lower_bound(pfsumB,pfsumB+m+1,k-pfsumA[i]) - pfsumB;
		if(lo > m || pfsumB[lo] > k -pfsumA[i])
			lo--;
		globalmax = max(globalmax,i+lo);
	}
	cout << globalmax << endl;
	return 0;
}


Measured memory_bytes: 9844
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int main(void){
    int x;
    cin >> x;
    if(x == 1){
        cout << 0;
    } else cout << 1;
    
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{		
		int A = Int32.Parse(Console.ReadLine());
		int B = Int32.Parse(Console.ReadLine());
		int C = Int32.Parse(Console.ReadLine());
		int X = Int32.Parse(Console.ReadLine());

		int ans = 0;
		for(int i = 0; i <= Math.Min(A, X/500); i++)
		{
			int Y = X - 500 * i;
			for(int j = 0; j <= Math.Min(B, Y/100); j++)
			{
				int Z = Y - 100 * j;
				if(Z/50 <= C)
					ans++;
			}
		}

		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < (int)n.length(); i++) {
        sum += (n[i] - '0');
    }
    if(sum % 9 == 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}



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

bool f(int i,int a,int b){
  int sum = 0;
  while (i> 0) {
    sum += i % 10;
    i /= 10;
  }
  if(a <= sum && sum <= b) {
    return true;
  }
  return false;
}

int main(){
  int n,a,b;
  int answer;
  cin >> n >> a >> b;
  vector<int> vec;
  for(int i=1;i<=n;i++){
    if(f(i,a,b)==true){
      vec.push_back(i);
    }
  }
  cout << accumulate(vec.begin(),vec.end(),0) << endl; 
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lec10B
{
    class Program
    {
        const int INPUT_MAX = 100;
        const int INF = 1000000000;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] m = new int[INPUT_MAX,INPUT_MAX];
            int[] left = new int[INPUT_MAX];
            int[] right = new int[INPUT_MAX];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    m[i, j] = INF;
                }
            }

            for (int i = 0; i < n; i++)
            {
                string input = Console.ReadLine();
                string[] split = input.Split(' ');
                left[i] = int.Parse(split[0]);
                right[i] = int.Parse(split[1]);

                m[i, i] = 0;
            }

            for (int h = 1; h < n; h++)
            {
                for (int i = 0; i < n - h; i++)
                {
                    int j = i + h;
                    for (int k = i; k < j; k++)
                    {
                        m[i, j] = Min(m[i, j], m[i, k] + m[k + 1, j] + left[i] * right[k] * right[j]);
                    }

                }
            }

            Console.WriteLine(m[0,n-1]);

            Console.ReadLine();
        }

        static int  Min(int i, int j)
        {
            return i < j ? i : j;
        }
    }
}


Measured memory_bytes: 17972
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int ccw(P a, P b,P c) {
	P e = b - a;
	P f = c - a;
	if (cross(e, f) > eps) {
		return 1;
	}
	if (cross(e, f) < -eps) {
		return -1;
	}
	if (dot(e, f) < -eps) return 2;
	if (abs(e) < abs(f)) return -2;
	return 0;
}
bool intersect(P a, P b, P c, P d) {
	if (ccw(a, b, c) * ccw(a, b, d) <= 0) {
		if (ccw(c, d, a) * ccw(c, d, b) <= 0){
			return 1;
		}
	}
	return 0;
}
double getDistanceLP(P a, P b, P c) {
	return abs(cross(b - a, c - a) / abs(b - a));
}
double getDistanceSP(P a, P b, P c) {
	if (dot(b - a, c - a) < 0.0) return abs(c - a);
	if (dot(a - b, c - b) < 0.0) return abs(c - b);
	return getDistanceLP(a, b, c);
}
double getDistance(P a, P b, P c, P d) {
	if (intersect(a, b, c, d)) return 0.0;
	return min({ getDistanceSP(a, b, c), getDistanceSP(a, b, d), getDistanceSP(c, d, a), getDistanceSP(c, d, b) });
}
int main() {
	vector<int> input(3);
	REP(i, 3) {
		cin >> input[i];
	}
	sort(input.begin(), input.end());
	cout << input[2] * 10 + input[1] + input[0] << endl;
	return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
 
using namespace std;
 
 
int main(void) {
 
	// a = 97 (int)
 
	char st1set[26] = { 0 };
	char st2set[26] = { 0 };
 
	string S;
	int N;
	int comCnt = 0;
	int max = 0;
 
 
	cin >> N;
	
	S.resize(N);
 
	cin >> S;
 
	for (int i = 0; i < N; i++) {
		st1set[S[i] - 97] = 1;
		for (int j = i + 1; j < N; j++) {
			st2set[S[j] - 97] = 1;
		}
 
		for (int k = 0; k < 26; k++) {
			if (st1set[k] && st2set[k])
				comCnt++;
		}
 
		if (max < comCnt) {
			max = comCnt;
		}
 
		for (int k = 0; k < 26; k++) {
			st2set[k] = 0;
		}
		comCnt = 0;
	}
 
	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
#endif

  int n;
  cin>>n;
  string s;
  cin>>s;
  if(s.size()<=n)
  {
    cout<<s<<endl;
  }

  else
  {
    string temp=s.substr(0,n);
    temp+="...";
    cout<<temp<<endl;
  }


  return 0;
}

Measured memory_bytes: 3656
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(n-1, 1, -1):
    for b in range(a-1, 0, -1):
        length1 = L[a]
        length2 = L[b]
        limit = length1 - length2 + 1
        index = bisect.bisect_left(L, limit)
        ans += max(0, b - index)

print(ans)

Measured memory_bytes: 45276
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=2000005;
ll A,B,C;

int main(){
	read(A),read(B),read(C);
	if(A%2==0||B%2==0||C%2==0){
		puts("0");
	}
	else{
		ll ans=2e18;
		ans=min(ans,A*B);
		ans=min(ans,B*C);
		ans=min(ans,C*A);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n, x, t;
	cin >> n >> x >> t;
	ll z = ceil(n * 1.0 / x);
	cout << z * t << '\n';

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3712
import java.util.*

import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val guide = IntArray(n+1) { Int.MAX_VALUE }
    val visited = BooleanArray(n+1) { false }
    guide[0] = 0
    visited[0] = true
    guide[1] = 0
    visited[1] = true
    val ab = Array(n+1){ mutableSetOf<Int>() }
    repeat(m) {
        val route = readLine()!!.split(' ').map { it.toInt() }
        ab[route[0]].add(route[1])
        ab[route[1]].add(route[0])
    }

    val q = ArrayDeque<Int>()
    q.add(1)
    fun check() {
        while(q.isNotEmpty()) {
            val pos = q.pollFirst()
            ab[pos].forEach {
                if (!visited[it]) {
                    guide[it] = pos
                    q.add(it)
                    visited[it] = true
                }
            }
        }
    }
    check()

  println("Yes")
  for (i in 2..n) {
    println(guide[i])
  }
}


Measured memory_bytes: 101244
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,k;
  cin >> n >> k;

  vector<P> v(n);
  rep(i,n) {
    cin >> v[i].second >> v[i].first;
    v[i].second--;
  }
  sort(v.rbegin(),v.rend());

  ll tot = 0;
  ll x = 0; vector<int> c(n);
  rep(i,k){
    tot += v[i].first;
    if(c[v[i].second]==0) ++x;
    c[v[i].second]++;
  }

  ll ans = tot+x*x;
  int l = k-1,r = k;
  while(0<=l && r<n){
    P vl = v[l], vr = v[r];
    if(c[vl.second]<=1){ --l; continue; }
    if(c[vr.second]>0){ ++r; continue; }
    c[vl.second]--; c[vr.second]++; ++x;
    tot += vr.first - vl.first;
    ans = max(ans,tot+x*x);
    --l; ++r;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap};
fn main() {
    input! {
        N: usize,
        H: isize,
        katana: [(isize, isize); N],
    }
    
    katana.sort_by(|x, y| y.1.cmp(&x.1));
    let &(max_a, _) = katana.iter().max_by_key(|&&(a, b)| a).unwrap();

    let mut count = 0;
    for &(_, b) in katana.iter() {
        if H <= 0 {
            println!("{}", count);
            return;
        }
        if b < max_a { break; }
        count += 1;
        H -= b;
    }
    count += (H + max_a - 1) / max_a;
    println!("{}", count);
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    deque<ll> deq;
    for (ll i = 0; i < N; i++) {
        if (i & 1) {
            deq.emplace_front(A[i]);
        }
        else {
            deq.emplace_back(A[i]);
        }
    }

    if (N & 1) reverse(deq.begin(), deq.end());

    for (const auto& v : deq) {
        cout << v << " ";
    }
    cout << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 5376
n = int(input())
F = [[*map(int, input().split())] for _ in range(n)]
P = [[*map(int, input().split())] for _ in range(n)]

def c(i, open_pattern):
    ret = 0
    for j in range(10):
        if open_pattern>>j & 1: #open my shop
            if F[i][j]: ret += 1 # open your shop
    return ret

ans = -10000000*100
for i in range(1, 1<<10): # open pattern 10bit, i:[0~1,1~1]
    s = 0
    for j in range(n): # your shop
        cj = c(j, i)
        s += P[j][cj]
    ans = max(ans ,s)
print(ans)


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

int main() {
  vector<int>A(3);
  for (int i = 0; i < 3; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 1; i < 3; i++) ans += A.at(i) - A.at(i - 1);
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];

    ll ma = 0, ans = 0;
    REP(i, n) {
        if(ma <= h[i]) ans++;
        chmax(ma, h[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// AOJ 2299:   Tiles are Colorful
// 2017.12.10

#include <stdio.h>
#include <string.h>

int m, n;
char map[501][503];
int mv[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};
int rpos['Z'+1], cpos['Z'+1];
int sr[501], sc[501];

int calc()
{
	int r, c, i, r2, c2, a, ans = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) 
		if ((sr[c] + sc[r]) && map[r][c] == '.' ) {
			memset(rpos, -1, sizeof(rpos));

		    for (i = 0; i < 4; i++) {
				if (!sr[c]) { if (i < 2) continue; }
				if (!sc[r]) { if (i > 2) continue; }

				r2 = r, c2 = c;
				while (1) {
					r2 += mv[i][0], c2 += mv[i][1];
					if (r2 < 0 || r2 >= m || c2 < 0 || c2 >= n) break;
					if (map[r2][c2] == '.') continue;

	                a = map[r2][c2];
					if (rpos[a] >= 0) {
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
						r2 = rpos[a], c2 = cpos[a];
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
	                    ans += 2;
					} else rpos[a] = r2, cpos[a] = c2;
					break;
				}
            }
        }

	return ans;
}

int main()
{
	int r, c, t, ans;
	char buf[10];

    fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (r = 0; r < m; r++) {
		fgets(map[r], 503, stdin);
		for (c = 0; c < n; c++) {
			if (map[r][c] != '.') sr[c]++, sc[r]++;
		}
	}
	ans = 0; while (t = calc()) ans += t;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a,b,c, maxi;
    int rcnt = 0, lcnt = 0;
    rcnt = 1;
    bool alternate = true;
    vector<int> ans;
    for(int i=1; i<s.size(); i++)
    {
        if(s[i] == 'R' && alternate)
            rcnt++;
        else if(s[i] == 'L')
            lcnt++, alternate = false;
        else if(s[i] == 'R' && !alternate)
        {
            if((rcnt + lcnt)%2 == 0)
                // ans.push_back(rcnt/2), ans.push_back(lcnt/2);
            {
                maxi = max(rcnt, lcnt) -1;
                c = (rcnt+lcnt)/2;
                a=c, b=c;
            }
            else
            {
                maxi = max(rcnt, lcnt)-1;
                c = (rcnt + lcnt)/2;
                if(rcnt > lcnt)
                    a = c+1, b = c;
                else
                    b = c+1, a =c;
            }
            if(maxi%2 != 0)
                swap(a,b);
            ans.push_back(a);
            ans.push_back(b);
            rcnt = 1, lcnt = 0;
            alternate = true;
        }
    }
    
    
            if((rcnt + lcnt)%2 == 0)
                // ans.push_back(rcnt/2), ans.push_back(lcnt/2);
            {
                maxi = max(rcnt, lcnt) -1;
                c = (rcnt+lcnt)/2;
                a=c, b=c;
            }
            else
            {
                maxi = max(rcnt, lcnt)-1;
                c = (rcnt + lcnt)/2;
                if(rcnt > lcnt)
                    a = c+1, b = c;
                else
                    b = c+1, a =c;
            }
            if(maxi%2 != 0)
                swap(a,b);
            ans.push_back(a);
            ans.push_back(b);
            rcnt = 1, lcnt = 0;
            alternate = true;    
            
            
            
            
    // for(int i=0; i<ans.size(); i++)
        // cout<<ans[i]<<" ";
    // cout<<"\n";
    int x = 0;
    int y=0;
    int cnt1 = 0;
    for(y=0; y<s.size()-1; y++)
    {
        if(s[y] == 'R' && s[y+1] == 'L')
        {
            cout<<ans[x]<<" ";
            x++;
            cout<<ans[x]<<" ";
            x++;
            y++;
            cnt1 += 2;
        }
        else
            cout<<0<<" ", cnt1++; 
    }
    
    if(cnt1 == s.size())
        cout<<"";
    else
        cout<<"0";
    
}

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

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

ans = 0 

for i in range(n-1):
    ans += b[a[i]-1]
    if a[i+1]-a[i] == 1:
        ans += c[a[i]-1]
        
ans += b[a[-1]-1]
    
print(ans)

Measured memory_bytes: 3064