akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> R,G,B;
    rep(i,n){
        if(s[i] == 'R') R.push_back(i);
        else if(s[i] == 'G') G.push_back(i);
        else if(s[i] == 'B') B.push_back(i);
    }
    ll ans = 0;

    rep(i,n){
        char c = s[i];
        if(c == 'R'){
            rep(j,G.size()){
                if(G[j] < i) continue;
                int it = B.end() - lower_bound(B.begin(),B.end(),G[j]);
                ans += it;
                if(2*G[j]-i >= n)continue;
                if(s[2*G[j]-i]=='B') ans--;
            }

            rep(j,B.size()){
                if(B[j] < i) continue;
                int it = G.end() - lower_bound(G.begin(),G.end(),B[j]);
                ans += it;
                if(2*B[j]-i >= n)continue;
                if(s[2*B[j]-i]=='G') ans--;
            }

        }else if (c=='G'){

            rep(j,R.size()){
                if(R[j] < i) continue;
                int it = B.end() - lower_bound(B.begin(),B.end(),R[j]);
                ans += it;
                if(2*R[j]-i >= n)continue;
                if(s[2*R[j]-i]=='B') ans--;
            }

            rep(j,B.size()){
                if(B[j] < i) continue;
                int it = R.end() - lower_bound(R.begin(),R.end(),B[j]);
                ans += it;
                if(2*B[j]-i >= n)continue;
                if(s[2*B[j]-i]=='R') ans--;
            }
        }else if(c == 'B'){

            rep(j,R.size()){
                if(R[j] < i) continue;
                int it = G.end() - lower_bound(G.begin(),G.end(),R[j]);
                ans += it;
                
                if(2*R[j]-i >= n)continue;
                if(s[2*R[j]-i]=='G') ans--;
            }
            rep(j,G.size()){
                if(G[j] < i) continue;
                int it = R.end() - lower_bound(R.begin(),R.end(),G[j]);
                ans += it;
                
                if(2*G[j]-i >= n)continue;
                if(s[2*G[j]-i]=='R') ans--;
            }
        }
    }


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

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int l, r, d; cin >> l >> r >> d;
  int cnt = 0;
  for(int i = l; i <= r; i++){
    if(i % d == 0) cnt++;
  }
  cout << cnt << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3624
# coding: utf-8
DATA = """
12 3
4 56 78 901 2 345 67 890 123 45 6 789
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, M = [int(i) for i in get_line().strip().split(" ")]
A = [int(i) for i in get_line().strip().split(" ")]
total = sum(A) / (4 * M)

count = 0
for v in A:
	if v >= total:
		count += 1

if count >= M:
	print ("Yes")
else:
	print ("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	int a[51][51];
	struct node operator *(const struct node & tmp)
	{
		struct node ret;
		memset(ret.a,0,sizeof(ret.a));
		int i,j,k;
		for(k=1;k<=50;k++)
		{
			for(i=1;i<=50;i++)
			{
				for(j=1;j<=50;j++)
				{
					if(a[i][k]&&tmp.a[k][j])
						ret.a[i][j]=((long long)a[i][k]*tmp.a[k][j]+ret.a[i][j])%1000000007;
				}
			}
		}
		return ret;
	}
}NODE,*PNODE;
NODE g,ans;
int main()
{
	int i,n,j,flag=0,s=0;
	long long K;
	scanf("%d %lld",&n,&K);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&g.a[i][j]);
	while(K)
	{
		if(K%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else
				ans=ans*g;
		}
		g=g*g;
		K/=2;
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(ans.a[i][j])
				s=(s+ans.a[i][j])%1000000007;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a_lst = [int(input()) for _ in range(n)]
    a_lst.sort()

    count = 0
    tmp = 0
    number = a_lst[0]

    for i in range(n):

        if a_lst[i] == number:
            tmp += 1

            if i == n - 1:
                if tmp % 2 != 0:
                    count += 1

        else:
            number = a_lst[i]

            if tmp % 2 == 0:
                tmp = 1
                continue
            else:
                count += 1
                tmp = 1

    if n > 1:
        if a_lst[-1] != a_lst[-2]:
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 80928
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
    if B <= A:
        B *= 2
    elif C <= B:
        C *= 2
    
    if A < B and B < C:
        break

if (A < B and B < C):
    print('Yes')
else:
    print('No')


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

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

    int a[100010];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        a[i] = abs(a[i]-x);
    }

    int ans = a[0];
    for(int i = 1;i < n;i++){
        ans = __gcd(ans, a[i]);
    }

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

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

typedef long long ll;

using vi = vector<int>;

using vii = vector<vector<int>>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vi arr(n+1),dp(n+1);  //dp[i]: minimum cost to reach stone i.
    for(int i=1;i<=n;i++)cin>>arr[i];
dp[1]=0,dp[2]=abs(arr[2]-arr[1]);

for(int i=3;i<=n;i++)dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);


cout<<dp[n]<<"\n";




return 0;

}


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

int main() {
  int n;
  cin >> n;
  map<string, int> arr;
  map<string, int> bMa;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    if (arr[tmp] == 0) { arr[tmp]++; }
    bMa[tmp]++;
  }
  int m;
  cin >> m;
  map<string, int> rMa;
  for (int i = 0; i < m; i++) {
    string tmp;
    cin >> tmp;
    if (arr[tmp] == 0) { arr[tmp]++; }
    rMa[tmp]++;
  }

  int mx = 0;
  for (auto i = arr.begin(); i != arr.end(); i++) {
    int b = bMa[i->first];
    int r = rMa[i->first];
    mx    = max(mx, b - r);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while (sc.hasNext()) {
            double limit = Double.parseDouble(sc.next());

            double v = 0;
            double y = 0;

            int K = 0;
            while (v < limit) {
                K++;
                y = 5 * K - 5;
                v = 9.8 * Math.sqrt(y / 4.9);
            }
            System.out.println(K);
        }
    }
}

Measured memory_bytes: 26296
#include<iostream>
using namespace std;
int main(){
  int n,i;
  unsigned long p=0;
  cin >> n;
  int a[n],b[n];
  for(i=0;i<n;i++) cin >> a[i] >> b[i];
  for(i=n-1;i>=0;i--){
    if((a[i]+p)%b[i]!=0){
    if(a[i]+p>b[i]){
    p+=b[i]-((a[i]+p) % b[i]);
    }else{
      p += b[i]-a[i]-p;
    }
  }
}
  cout << p;
}


Measured memory_bytes: 1024
# import bisect
n,m=map(int,input().split())

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

div=make_divisors(m)
ans=1
for i in range(len(div)):
    if(div[i]>m/n):
        break
    ans=max(div[i],ans)
print(ans)


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e9;

//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;
    vector<int> pf(1e6+1);
    pf[1] = 1;

    ll Ai;
    rep(i,N){
        cin >> Ai;
        if(Ai==1) continue;
        for(ll f=2; f*f<=Ai; ++f){
            if(Ai%f==0){
                pf[f]++;
                //if(f*f<Ai) pf[Ai/f]++;
            }
            while(Ai%f==0) Ai/=f;
        }
        if(Ai!=1) pf[Ai]++;

    }

    
    int maxpn = 0;
    for(int pn : pf) chmax(maxpn,pn);

    if(maxpn==1) cout << "pairwise coprime" << endl;
    //else if(maxpn>2 && maxpn<N) cout << "setwise coprime" << endl;
    else if(maxpn == N) cout << "not coprime" << endl;
    else cout << "setwise coprime" << endl;

    return 0;
}

Measured memory_bytes: 7200
#include<iostream>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int count=0;
    for(int i=0;i<s.length();i++)
    {
        count++;
        while(i<n-1&&s[i]==s[i+1])
        {
            i++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=3e5+5,B=60,M=1e9+7;
int a[N];
int c[B];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n){
        cin>>a[i];
        forn(j,B){
            if(a[i]>>j&1){
                c[j]++;
            }
        }
    }
    int ans=0;
    forn(j,B){
        int val=(1ll<<j)%M;
        ans+=(val*((c[j]*(n-c[j]))%M))%M;
    }
    ans%=M;
    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

class SegTree { // index starts at 0.
public:
  int N;
  int* dat;

  SegTree(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat = new int[2 * N - 1];
    for (auto i = 0; i < 2 * N - 1; ++i) {
      dat[i] = -1;
    }
  }

  ~SegTree() {
    delete[] dat;
  }

  int find(int k) {
    k += N - 1;
    int ans = dat[k];
    while (k > 0) {
      k = (k - 1)/2;
      if (dat[k] != -1) ans = dat[k];
    }
    return ans;
  }

  void update(int v, int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return;
    }
    if (a <= l && r <= b) {
      dat[k] = v;
      return;
    }
    if (dat[k] != -1) {
      dat[2 * k + 1] = dat[k];
      dat[2 * k + 2] = dat[k];
      dat[k] = -1;
    }
    update(v, a, b, k * 2 + 1, l, (l + r) / 2);
    update(v, a, b, k * 2 + 2, (l + r) / 2, r);
  }
  
  void update(int v, int a, int b) {
    update(v, a, b, 0, 0, N);
  }
  
};

int main () {
  int n, q;
  cin >> n >> q;
  SegTree st(n);
  for (auto i = 0; i < n; ++i) {
    st.update(2147483647, i, i+1);
  }
  for (auto i = 0; i < q; ++i) {
    int com;
    cin >> com;
    if (com == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      st.update(x, s, t+1);
    } else {
      int k;
      cin >> k;
      cout << st.find(k) << endl;
    }
  }
}

Measured memory_bytes: 3896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int K = Integer.parseInt(sc.next());
			int[] array = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
			System.out.println(array[K-1]);
		}	
	}
}


Measured memory_bytes: 35556
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b; cin>>a>>b; 
    if (a+b>9) cout << "error" << endl;
    else cout << a+b << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

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

    ArrayList<Integer> list = new ArrayList<Integer>();
    ArrayList<String> str = new ArrayList<String>();

    int t = 0;
    int f = 0;

    for(int i = 0; i < s.length(); i++) {
      String a = String.valueOf(s.charAt(i));
      if(!(a.equals("x"))) {
        f++;
        str.add(a);
        list.add(t);
        t = 0;
      } else {
        t++;
      }
    }

    list.add(t);

    int flg = 0;
    if(f == 0) {
      
    } else {
      for(int i = 0; i < str.size(); i++) {
        if(!((str.get(i)).equals(str.get(str.size() - 1 - i)))) flg++;
      }
      if(flg == 0) {
        for(int i = 0; i < list.size(); i++) {
          ans += (long)Math.abs(list.get(i) - list.get(list.size() - 1 - i));
        }
        ans /= 2;
      } else {
        ans = -1;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 32896
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A,B,C,D;
int M;
int main(){
	cin>>A>>B>>C>>D;

	int R,S;

	if(A<C)R=C;
	if(A>C)R=A;
	if(B>D)S=D;
	if(D>B)S=B;

	if(B<C){
		M=0;
	}else if(B==C){
		M=0;
	}else if(B==0||D==0){
		M=0;
	}else if(C<A&&D<A){
		M=0;
	}else{
		M=(S-R);
	}
	cout<<M<<endl;


	return 0;
}



Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci res(N);
    REP(i,N) cin >> res[i];
    sort(res.begin(),res.end(),greater<int>());
    int ans = 0;
    REP(i,N) {
        if(i == 0) ans += res[i]/2;
        else ans += res[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
count = gets.to_i
arr = []

count.times do
  arr << gets.split(" ")
end
ans = [0, 0]
arr.each do |val|
  if val[0] == val[1]
    ans[0] += 1
    ans[1] += 1
  elsif val[0] < val[1]
    ans[1] += 3
  else
    ans[0] += 3
  end
end

puts ans[0].to_s + " " + ans[1].to_s

Measured memory_bytes: 6108
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    int N;
    cin >> N;
    vector<int> A(100);
    int count = 0;
    rep(i,N) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        // swap(A[i], A[minj]);
        if (A[i] != A[minj]) {
            count += 1;
            swap(A[i], A[minj]);
        }
    }
    rep(i,N) {
        if (i<N-1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
    cout << count << endl;
}




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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i=0; i<n; ++i)
    {
        cin >> h[i];
    }
    
    vector<int> dp(n,0);
    dp[1] = abs(h[1]-h[0]);
    
    for(int i=2; i<n; ++i)
    {
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout <<  dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int h, w, hp, wp;
    scanf("%d%d", &h, &w);
    hp = h%2, wp = w%2;
    int cnt[26];
    memset(cnt, 0, sizeof(cnt));
    rep(i, h)rep(j, w){
        char c;
        scanf(" %c", &c);
        ++cnt[c-'a'];
    }

    rep(i, (h/2)*(w/2)){
        bool flag = false;
        rep(j, 26)if(cnt[j] >= 4){
            cnt[j] -= 4;
            flag = true;
            break;
        }
        if(!flag){
            puts("No");
            return 0;
        }
    }

    rep(i, hp * (w/2) + wp * (h/2)){
        bool flag = false;
        rep(j, 26)if(cnt[j] >= 2){
                cnt[j] -= 2;
                flag = true;
                break;
            }
        if(!flag){
            puts("No");
            return 0;
        }
    }

    rep(i, hp * wp){
        bool flag = false;
        rep(j, 26)if(cnt[j] >= 1){
                cnt[j] -= 1;
                flag = true;
                break;
            }
        if(!flag){
            puts("No");
            return 0;
        }
    }

    rep(j, 26)if(cnt[j]){
        puts("No");
        return 0;
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i < (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

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

int main() {
    ll n, m;
    cin >> n >> m;

    m /= 2;
    // n = (m + n)/2;
    n = min(m, (m + n)/2);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<pair<ll,ll>> r(n),b(n);
    rep(i,n) cin >> r.at(i).first >> r.at(i).second;
    rep(i,n) cin >> b.at(i).first >> b.at(i).second;
    sort(r.begin(),r.end());
    sort(b.begin(),b.end());

    vector<bool> rchkd(n,0);
    ll ans = 0;

    rep(i,n){
        ll ymax=-1,idx=INF;
        rep(j,n){
            if(b.at(i).first<=r.at(j).first || b.at(i).second <= r.at(j).second) continue;
            if(rchkd.at(j)) continue;
            if(ymax<r.at(j).second){
                ymax = r.at(j).second;
                idx = j;
            }
        }
        //cout << idx << endl;
        if(idx==INF) continue;
        rchkd.at(idx) = 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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字くらい使った方がいいかも
*/


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

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

ll abc(string s){
    ll res=0;
    ll cnta=0;   //Aが連続する個数(count_a)
    rep(i,s.size()){
        if(s[i] == 'A')cnta++;
        else if(s[i]=='D')res += cnta;
        else cnta=0;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    string t;
    rep(i,s.size()){
        if(i<s.size()-1 && s[i]=='B' && s[i+1]=='C'){
            t.push_back('D');
            ++i;
        }else t.push_back(s[i]);
    }
    cout << abc(t) << endl;
}

Measured memory_bytes: 904
n=int(input())
order=list(map(int,input().rstrip().split()))
num=sum(list(map(int,input().rstrip().split())))
opt=list(map(int,input().rstrip().split()))
for i in range(n-1):
  if order[i]==order[i+1]-1:
    num+=opt[order[i]-1]
print(num)

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

#define modu 1000000007
typedef unsigned long long ull;

int s;

ull dp[2001];

int main() {
	
	cin>>s;
	
	dp[3] = 1;
	dp[4] = 1;
	dp[5] = 1;
	
	for(int i = 6; i<=s; i++){
		dp[i] = (dp[i-3] % modu + dp[i-1] % modu) % modu;
	}
	
	cout<<dp[s] % modu<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    int sum = 0;
    int answer = n;
    REP(i,n){
        cin >> m[i];
        sum += m[i];
    }
    x -= sum;
    sort(ALL(m));
    cout << answer + x/m[0] << endl;

    return 0;
}

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

int main(){
  ll n;
  cin>>n;
  char c;
  vector<ll> red,white;
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='R')red.push_back(i);
    if(c=='W')white.push_back(i);
  }
  if(red.empty() || white.empty()){cout<<0<<endl;return 0;}
  reverse(red.begin(),red.end());
  for(int i=0;i<min((int)red.size(),(int)white.size());i++){
    if(red[i]<white[i]){cout<<i<<endl;return 0;}
  }
  cout<<min(red.size(),white.size())<<endl;
}


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int N;
    cin >> N;
    int p[220000];
    rep(i, N) cin >> p[i];
    int ans = 0;
    int minP = p[0];
    for (int i = 0; i < N; i++) {
        if(minP >= p[i]) {
            ans++;
            minP = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M, D, count = 0;
  cin >> M >> D;
  for(int d = 22; d < D + 1; d++){
    if(int(d / 10) * (d % 10) <= M && int(d / 10) >= 2 && (d % 10) >= 2) count += 1;
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;
using LLONG = long long;

int main()
{
    string s;
    cin >> s;
    const int length = static_cast<int>(s.size());
    cout << s.front() << length - 2 << s.back() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int N;
ll ans[202020];
ll dp[202020];
ll a[202020];
vector<int> to[202020];


void dfs(int u, int p){
  int i = (int)(lower_bound(dp, dp+N, a[u]) - dp);
  //cout << i << endl;
  int old  = dp[i];
  dp[i] = a[u];
  ans[u] = lower_bound(dp, dp+N, inf) - dp;
  for(int v: to[u]){
    if(v==p) continue;
    dfs(v, u);
  }
  dp[i] = old;
}


int main(){
  cin >> N; 
  rep(i, N){
    cin >> a[i];
  }
  rep(i, N-1){
    int u, v; cin >> u >> v; u--; v--;
    to[u].push_back(v); to[v].push_back(u);
  }
  rep(i, 202020){
    dp[i] = inf;
  }
  dfs(0, -1);
  rep(i, N){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 33568
N = int(input())
X = list(map(int, input().split()))

dp = [0] * N
dp[0] = 1000
for i in range(1, N):
    dp[i] = dp[i - 1]
    for j in range(i):
        n = dp[j] // X[j]
        dp[i] = max(dp[i], dp[j] + (X[i] - X[j]) * n)

print(dp[-1])


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

int main() {
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for(int i = 0; i < 3; ++i){
        char s1 = s[i];
        char t1 = t[i];
        if (s1 == t1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] P = new int[N];
		int i = 0;
		while(i < N) {
			P[i] = sc.nextInt();
			i++;
		}

		int counter = 1;
		int min = P[0];
		for(i = 1; i < N;i++) {
			if(P[i]<min) {
				min = P[i];
				counter++;
			}
		}

		System.out.println(counter);
	}

}


Measured memory_bytes: 65000
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), end(x)+(n)
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) (((a%MOD+MOD)%MOD-(b%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int X, Y;


int extGCD(int a, int b, int &x, int &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    int d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}


namespace Factorial {
    VI fact, finv;
    void init(int n){
        fact.resize(n+1);
        finv.resize(n+1);
        fact[0] = 1;
        repe(i, 1, n) fact[i] = MUL(i, fact[i-1]);
        extGCD(fact[n], MOD, finv[n], finv[0]);
        finv[0] = 1;
        repr(i, n, 1) finv[i] = MUL(i+1, finv[i+1]);
    }
    int comb(int n, int k){
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return MUL(fact[n], MUL(finv[k], finv[n-k]));
    }
    int perm(int n, int k){
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return MUL(fact[n], finv[n-k]);
    }
}


signed main(){
    cin >> X >> Y;

    Factorial::init(max(X, Y));

    if((X+Y)%3) cout << 0 << endl;
    else {
        int n = (2*X-Y)/3, m = (2*Y-X)/3;
        cout << Factorial::comb(n+m, n) << endl;
    }

    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int p=1e9;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
ll S,X1,Y1,X2,Y2;
int main(){
	S=read();
	X1=p,Y2=(S-1)/p+1,X2=1,Y1=X1*Y2-S;
	printf("0 0 %lld %lld %lld %lld\n",X1,Y1,X2,Y2);
	return 0;
}



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


			

int main(){
	
	int N;
	cin>>N;
	vector<vector<int>> E(N,vector<int>(0));
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	long long sum = 0;
	vector<long long> c(N);
	int start = -1;
	for(int i=0;i<N;i++){
		cin>>c[i];
		sum+=c[i];
		if(start==-1){
			if(E[i].size()==1)start=i;
		}
	}
	sort(c.begin(),c.end(),greater<long long>());
	sum-=c[0];
	vector<int> ans(N,-1);
	ans[start]=c[0];
	queue<int> q;
	q.push(start);
	int now = 1;
	while(q.size()!=0){
		int a = q.front();
		q.pop();
		for(int i=0;i<E[a].size();i++){
			if(ans[E[a][i]]!=-1)continue;
			ans[E[a][i]]=c[now];
			now++;
			if(now==N)goto Label;
			q.push(E[a][i]);
		}
	}
	Label:
	cout<<sum<<endl;
	
	for(int i=0;i<N;i++){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;
	
	return 0;
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int m;
  cin >> m;
  cout << 24 - m + 24 << '\n';
  return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	for(int i=min(a,b);i<=max(a,b);i++)
		if ((a*b*i) & 1) {
			cout << "Yes";
			return 0;
		}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A.at(i) ;
  }
  int count = 0;
  for(int i=0;i<n;i++){
    int j = 0;
    bool check = true;
    while(check){
      if( A.at(i)>>j & 1 ==1){
        count += j;
        check = false;
      }
      j++;
    }
  }
  cout << count << endl;
}
        

Measured memory_bytes: 256
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
l=[]
#print(p,q,r)
delicious=0
for i in range(X):
    l.append(p[i])
for i in range(Y):
    l.append(q[i])
l.sort(reverse=True)
#print(l)
for i in range(len(l)-C):
    #print(l[i])
    delicious=delicious+l[i]
lidx=max(0,len(l)-C)
#print(l,r,lidx)
cidx=0
#print(delicious,lidx,cidx,l,r,l[lidx],r[cidx])
for j in range(min(C,X+Y)):
    if (l[lidx]<=r[cidx])or(lidx>len(l)):
        delicious=delicious+r[cidx]
        cidx=cidx+1
    else:
        delicious = delicious + l[lidx]
        lidx=lidx+1
    #print(delicious)
print(delicious)



Measured memory_bytes: 109676
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e1+7;
int a[MAXN], b[MAXN], c[MAXN];
int n;
int main()
{
    int ans = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
    for(int i = 1; i <= n; i++)
    {
        ans += b[a[i]];
        if(a[i] == a[i-1] + 1) ans += c[a[i-1]];
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int a,b;
  cin>>a>>b;
  if(a<=0&&b>=0){
  
    cout<<"Zero";
    return 0;
  }
  else if(a>0){
  
    cout<<"Positive";
    return 0;
  }
  else if(b<0){
  
    if((b-a+1)%2==0){
    
      cout<<"Positive";
      return 0;
    }
    else{
    
      cout<<"Negative";
      return 0;
    }
  }
  return 0;
}

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

int find(vector<int> &p, int x) {
     if (p[x] != x) {
         p[x] = find(p, p[x]);
     }
     return p[x];
}

void uni(vector<int> &p, vector<int>& r, vector<int>& s, int x, int y) {
    int px = find(p, x);
    int py = find(p, y);
    if (px == py) {
        return;
    }

     if (r[px] < r[py]) {
        p[px] = py;
        s[py]+= s[px];
     } else if (r[px] > r[py]) {
        p[py] = px;
        s[px]+= s[py];
     } else {
        p[py] = px;
        r[px]++;
        s[px]+= s[py];
     }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n), r(n, 0), s(n, 1);
    for (int i = 0; i < n; i++) {
        p[i] = i;
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uni(p, r, s, a, b);
    }
    int mm = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] > mm) {
            mm = s[i];
        }
    }
    cout << mm << endl;
}

Measured memory_bytes: 5632
open System

let n = Console.ReadLine() |> int
let a = Console.ReadLine().Split(' ') |> Array.map int64

let GetXor (xs: int64[]) = Array.fold (fun acc elem -> acc^^^elem) 0L xs

let X = GetXor a.[2..]
let S = a.[0]+a.[1]

if a.[0]^^^a.[1] = X then
    Console.Write(0)
elif S<X || (S^^^X)&&&1L = 1L then
    Console.Write(-1)
else
    let U = a.[0]
    let D = (S-X)/2L
    let mutable Ans = D
    if D&&&X <> 0L then
        Console.Write(-1)
    else
        for i = 40 downto 0 do
            if (X&&&(1L<<<i) <> 0L)&&(Ans|||(1L<<<i) < U) then
                Ans <- Ans|||(1L<<<i)
        if Ans > 0L && Ans < U then
            Console.Write(U-Ans)
        else
            Console.Write(-1)

Measured memory_bytes: 29596
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,u,v,w;
  cin >> n;
  vector<vector<pair<int,int>>> adj(n+1);
  for(int i = 1; i < n; ++i){
    cin >> u >> v >> w;
    adj[u].emplace_back(v,w);
    adj[v].emplace_back(u,w);
  }
  vector<int> color(n+1,-1);
  queue<int> q;
  q.emplace(1);
  color[1] = 0;
  while(!q.empty()){
    int node = q.front();
    q.pop();
    for(auto& p : adj[node]){
      tie(u,w) = p;
      if(color[u] == -1){
        if(w&1) color[u] = 1-color[node];
        else color[u] = color[node];
        q.emplace(u);
      }
    }
  }
  for(int i = 1; i<= n; ++i) cout << color[i] << '\n';
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int l[n] = {}, r[n] = {};
	for (int i = 0; i < n; i++)
		cin >> l[i] >> r[i];
	sort(l, l + n);
	sort(r, r + n);
	int x = -1, y = -1;
	if (n & 1) {
		x = l[n / 2];
		y = r[n / 2];
	} else {
		x = l[n / 2 - 1] + l[n / 2];
		y = r[n / 2 - 1] + r[n / 2];
	}
	cout << y - x + 1;
}

Measured memory_bytes: 5132
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let x = read::<i64>();
    let mut ans = 1;
    for i in 2..x {
        if i*i > x {
            break;
        }
        let mut p = i;
        while p * i <= x {
            p *= i;
        }
        if p > ans {
            ans = p;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll n;
	cin >> n;
	VS mat(n);
	cin >> mat;

	ll ans = 0;
	REP(a, n) {
		bool ok = true;
		REP(i, n)REP(j, n) {
			if (mat[(i - a + 2 * n) % n][j] != mat[(j - a + 2 * n) % n][i]) { ok = false; break; }
		}
		if (ok) { ans += n; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
//ALDS1_1_D
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++)
    {
        cin >> data[i];
    }
    int ans = -1000000001;
    int min = data[0];
    int max = data[0];
    for (int i = 1; i < n; i++)
    {
        if (data[i] - min > ans)
        {
            ans = data[i] - min;
        }
        if (min > data[i])
        {
            min = data[i];
        }
    }
    cout << ans << endl;
}


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

int main(){
  list<int> rails;
  int car;

  while(cin >> car){
    if(car == 0){
      cout << *(--rails.end()) << endl;
      rails.pop_back();
    }
    else
      rails.push_back(car);
  }
  
  return 0;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);

	if(x/d>=k){
		cout<<x-k*d<<endl;
	}else{
		k-=x/d;
		long long a=x%d;
		long long b=abs(x%d-d);

		if(k%2==0) cout<<a<<endl;
		else cout<<b<<endl;
	}

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

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


Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

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

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,1){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	int x[m];
	rep(i,m){
		cin >> x[i];
	}
	if(n>=m){
		cout << "0" << endl;
		return 0;
	}

	sort(x,x+m);

	int l[m-1];
	rep(i,m-1){
		l[i]=x[i+1]-x[i]-1;
	}

	sort(l,l+m-1,greater<int>());

	int space=0;
	rep(i,n-1){
		space+=l[i];
	}
	int ans=(x[m-1]-x[0]+1)-space-n;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
  int i, n, t, a, b, c, ans;
  scanf("%d%d", &n, &t);

  scanf("%d", &b);
  ans = t;
  for(i=1; i<n; i++){
    a = b;
    scanf("%d", &b);
    ans += (b-a < t) ? b-a : t;
  }

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

Measured memory_bytes: 128
use whiteread::parse_line;

fn main() {
    let mut o: String = parse_line().unwrap();
    let mut e: String = parse_line().unwrap();
    let mut ans = String::new();

    for i in 0..(o.len() + e.len()) {
        if i % 2 == 0 {
            ans.push(o.remove(0));
        } else {
            ans.push(e.remove(0));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <stdio.h>

int main()
{
	int card[5], i, j, f;

	while(scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF){
		f = 0;

		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if(card[j] > card[j+1]) {int t = card[j]; card[j] = card[j+1]; card[j+1] = t;}
			}
		}

		for(i = 0; i < 2; i++){
			for(j = i; j < 3+i; j++){
				if(card[j] != card[j+1]) break;
				else if(j == 2+i) {printf("four card\n"); f = 1;}
			}
		}

		if(card[0] == card[1] && card[3] == card[4] && (card[2] == card[3] || card[2] == card[1])) {printf("full house\n"); f = 1;}
		else if((card[4] - card[3] == 1 && card[3] - card[2] == 1 && card[2] - card[1] == 1 && card[1] - card[0] == 1) || (card[0] == 1 && card[1] == 10 && card[2] == 11 && card[3] == 12 && card[4] == 13)) {printf("straight\n"); f = 1;}

		if(f != 1){
			for(i = 0; i < 3; i++){
				for(j = i; j < 2+i; j++){
					if(card[j] != card[j+1]) break;
					else if(j == 1+i) {printf("three card\n"); f = 1;}
				}
			}
		}

		if(f != 1) if((card[0] == card[1] && ((card[2] == card[3]) || card[3] == card[4])) || (card[1] == card[2] && card[3] == card[4])) {printf("two pair\n"); f = 1;}

		if(f != 1){
			for (i = 0; i < 5; i++){
				for(j = 0; j < 5; j++){
					if(card[i] == card[j] && i != j) {printf("one pair\n"); f = 1; break;}
				}

				if(f == 1) break;
			}
		}

		if(f != 1) printf("null\n");
	}

	return 0;
}

Measured memory_bytes: 580