akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void readTime(vector<pair<string, string> >& t)
{
    int k;
    cin >> k;
    t.resize(k);
    for(int i=0; i<k; ++i){
        string s;
        cin >> s;
        t[i].first  = s.substr(0, 5);
        t[i].second = s.substr(6, 5);
    }
}

int main()
{
    vector<pair<string, string> > lesson;
    readTime(lesson);

    int k = lesson.size();
    vector<vector<int> > x(2, vector<int>(k));

    for(int a=0; a<2; ++a){
        int n;
        cin >> n;
        for(int i=0; i<n; ++i){
            vector<pair<string, string> > t;
            readTime(t);
            for(auto& p : t){
                for(int j=0; j<k; ++j){
                    if(p.first <= lesson[j].first && lesson[j].second <= p.second)
                        ++ x[a][j];
                }
            }
        }
    }

    int ans = 0;
    for(int i=0; i<k; ++i)
        ans += min(x[0][i], x[1][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1260
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
      if s[2] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[2]:
      if s[1] == s[3]:
        print('Yes')
      else:
        print('No')
  elif s[0] == s[3]:
      if s[1] == s[2]:
        print('Yes')
      else:
        print('No')
  else:
    print('No')

Measured memory_bytes: 9136
#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<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
vector<tuple<int, int,int>> vertex[1000];
int oops[10000] = {};
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		vertex[a].push_back(make_tuple(b, c, i));
		vertex[b].push_back(make_tuple(a, c, i));
	}
	for (int i = 1;i <= n;++i) {
		pair<int,vector<int>> shortest[1000] = {};
		int done[1000] = {};
		REP(q,1000) {
			shortest[q].first = 100000000;
		}
		priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> hogee;
		hogee.push(make_pair(0, i));
		shortest[i].first = 0;shortest[i].second.push_back(-1);
		while (hogee.empty() == false) {
			pair<int, int> wow = hogee.top();hogee.pop();
			if (done[wow.second] == false) {
				done[wow.second] = true;
				for (int q = 0;q < vertex[wow.second].size();++q) {
					if (wow.first + get<1>(vertex[wow.second][q]) < shortest[get<0>(vertex[wow.second][q])].first) {
						shortest[get<0>(vertex[wow.second][q])].first = wow.first + get<1>(vertex[wow.second][q]);
						vector<int> hwoap;
						hwoap.push_back(get<2>(vertex[wow.second][q]));
						shortest[get<0>(vertex[wow.second][q])].second = hwoap;
						hogee.push(make_pair(shortest[get<0>(vertex[wow.second][q])].first, get<0>(vertex[wow.second][q])));
					}
					else if (wow.first + get<1>(vertex[wow.second][q]) == shortest[get<0>(vertex[wow.second][q])].first) {
						shortest[get<0>(vertex[wow.second][q])].second.push_back(get<2>(vertex[wow.second][q]));
					}
				}
			}
		}
		for (int j = 1;j <= n;++j) {
			if (i != j) {
				REP(t, shortest[j].second.size()) {
					oops[shortest[j].second[t]] = 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0;i < m;++i) {
		if (oops[i] == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
  
  int R;
  
  scanf("%d",&R);
   
  if(R < 1200){
    puts("ABC");
  }
  else if(R >= 2800){
    puts("AGC");
  }
  else{
    puts("ARC");
  }
  
  return 0;
}


Measured memory_bytes: 128
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
ans="No"
bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            ans="Yes"
            break

print(ans)

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

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

int main() {
  char a[4];
  char b[4];
  char ab[8];

  scanf("%s %s", a, b);
  strcpy(ab, a);
  strcat(ab, b);
  int num = atoi(ab);
  int sqrt_num = sqrt(num);

  if (num == sqrt_num*sqrt_num) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

struct UnionFind {
  vector<ll> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<ll> cnts;

  UnionFind(ll N) : par(N), cnts(N) {  //最初は全てが根であるとして初期化
    for (ll i = 0; i < N; i++) par[i] = i;
    for (ll i = 0; i < N; i++) cnts[i] = 1;
  }

  ll root(ll x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(ll x, ll y) {  // xとyの木を併合
    ll rx = root(x);        // xの根をrx
    ll ry = root(y);        // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    cnts[ry] += cnts[rx];
  }

  bool same(ll x, ll y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }
};

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

  UnionFind uf(n);
  vll ans(n, 0);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
    ans[a]--;
    ans[b]--;
  }

  rep(i, n) ans[i] += uf.cnts[uf.root(i)];

  rep(i, k) {
    ll c, d;
    cin >> c >> d;
    c--;
    d--;
    bool candcd = uf.same(c, d);
    if (candcd) {
      ans[c]--;
      ans[d]--;
    }
  }

  rep(i, n) cout << --ans[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3584
import java.util.*;
import static java.lang.Math.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
}


Measured memory_bytes: 22356
import java.util.*;

class Main {
    public static void main(String[] args) {

        class Shop {
            String city;
            int score;
            int number;

            Shop(String city, int score, int number) {
                this.city = city;
                this.score = score;
                this.number = number;
            }
        }

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        ArrayList<Shop> shops = new ArrayList<>();

        for (int i=0; i<N; i++) {
            shops.add(new Shop(sc.next(), sc.nextInt(), i+1));
        }

        Collections.sort(shops, (Shop s1, Shop s2) -> s1.city.compareTo(s2.city));

        String city = shops.get(0).city;
        ArrayList<Shop> shopsInSameCity = new ArrayList<>();

        for (int i=0; i<N; i++) {
            if (city.equals(shops.get(i).city)) {
                shopsInSameCity.add(shops.get(i));
            } else {
                Collections.sort(shopsInSameCity, (Shop s1, Shop s2) -> s2.score - s1.score);
                for (Shop s : shopsInSameCity) {
                    System.out.println(s.number);
                }

                shopsInSameCity = new ArrayList<>();
                city = shops.get(i).city;
                shopsInSameCity.add(shops.get(i));
            }
        }
        Collections.sort(shopsInSameCity, (Shop s1, Shop s2) -> s2.score - s1.score);
        for (Shop s : shopsInSameCity) {
            System.out.println(s.number);
        }
    }
}


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

const int mod=1000000007;

int revmod(int n){
  bool modbool[30] = {1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,1,1,0,0,1,1,1,0,1,1,1};
  long ret=1, pow=n;
  for(bool b: modbool){
    if(b){
      ret *= pow;
      ret %= mod;
    }
    pow *= pow;
    pow %= mod;
  }
  return ret;
}

int main(){
  int k;
  string s;
  cin >> k >> s;
  vector<long>pow25(k+10, 1), pow26(k+10, 1);
  for(int i=1; i<k+10; i++){
    pow25[i] = (pow25[i-1]*25)%mod;
    pow26[i] = (pow26[i-1]*26)%mod;
  }
  int l = s.length();
  long C=1, ret=0;
  for(int x=0; x<=k; x++){
    ret += (C * ((pow25[x] * pow26[k-x])%mod))%mod;
    ret %= mod;
    C *= (long(x+l)*revmod(x+1))%mod;
    C %= mod;
  }
  cout << ret;
  return 0;
}
  

Measured memory_bytes: 19676
import itertools
n = int(input())
v = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
c = list(map(int, input().split()))  # 入力のときに N を使う必要はありません

answer = []

for i in range(n):
  answer.append(v[i] - c[i])
  
max = 0

for r in range(n+1):
    comb = list(itertools.combinations(answer, r))
    for j in comb:
        if max <= sum(j):
          max = sum(j)

print(max)

Measured memory_bytes: 53632
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
   int n;
   cin>> n;
    cout << (n + 1) / 2 << endl;
}



Measured memory_bytes: 256
K = int(input())
seq = [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]
print(seq[K - 1])

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
    int a,b,e,n,m,k;
    std::cin>>n;
    std::vector<int> vec{};
    
    
    for(int i=0;i<n;i++){
        std::cin>>a;
        vec.push_back(a);
    }
    std::cin>>m;

    for(int j=0;j<m;j++){
        std::cin>>b>>e>>k;
        std::cout<<std::count(&vec[b],&vec[e],k)<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int>x;
    
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')
            x.push_back(i+1);
    }
    
    rep(i,q){
        int l,r;
        cin>>l>>r;
        r--;
        cout<<upper_bound(x.begin(),x.end(),r)-lower_bound(x.begin(),x.end(),l)<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=271,B=61;
int t,n,flg;
ll x,k,a[MAXN],b[MAXN];
char s[MAXN];
bool ins (ll x) {
	for (int i=B;i>=0;i--) {
		if ((x&(1ll<<i))) {
			if (b[i]) {x^=b[i];}
			else {b[i]=x;break;} 
		}
	}
	if (x) {return 1;}
	else {return 0;}
}
int main () {
	scanf("%d",&t);
	for (int ii=1;ii<=t;ii++) {
		memset(b,0,sizeof(b));
		scanf("%d",&n);
		for (int i=1;i<=n;i++) {
			scanf("%lld",&a[i]);
		}
		scanf("%s",s+1);
		int flg=0;
		for (int i=n;i>=1;i--) {
			if (s[i]=='0') {
				ins(a[i]);
			} else {
				if (ins(a[i])) {flg=1;break;}
			}
		}
		printf("%d\n",flg);
	}
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>
 
  
using namespace std;
  
int main()
{
     unsigned int a,b,c,ans=0;//initializing numbers
    while(cin >> b >>c )//entering 2 numbers
    {
    a=b+c;//adding the 2 numbers
    while(a!=0)
    { 
        a/=10; ans++;//dividing sum by 10 then adding ans by 1 for number of digits
 
    }
        cout << ans << endl;//print out how many digits
        ans = 0;
     }
 
   return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#pragma GCC Optimize("Ofast")

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

    vector<pair<int, int>> U, D, L, R;
    for (int i = 0; i < n; i++) {
        int a, b;
        char c;
        cin >> a >> b >> c;
        a <<= 1;
        b <<= 1;
        if (c == 'D') {
            D.emplace_back(a, b);
        } else if (c == 'U') {
            U.emplace_back(a, b);
        } else if (c == 'L') {
            L.emplace_back(a, b);
        } else {
            R.emplace_back(a, b);
        }
    }
    vector<array<int, 4>> cand;
    auto add = [&](vector<pair<int, int>> &as, int dx, int dy) {
        sort(as.begin(), as.end(), [](auto &a, auto &b) {
            return a.first < b.first;
        });
        if (!as.empty()) {
            cand.push_back({as.front().first, as.front().second, dx, dy});
            cand.push_back({as.back().first, as.back().second, dx, dy});
        }
        sort(as.begin(), as.end(), [](auto &a, auto &b) {
            return a.second < b.second;
        });
        if (!as.empty()) {
            cand.push_back({as.front().first, as.front().second, dx, dy});
            cand.push_back({as.back().first, as.back().second, dx, dy});
        }
    };
    add(U, 0, 1);
    add(D, 0, -1);
    add(L, -1, 0);
    add(R, 1, 0);

    auto update = [&](double i) {
        vector<array<double, 4>> ret(cand.size());
        for (int j = 0; j < cand.size(); j++) {
            ret[j][0] = cand[j][0];
            ret[j][1] = cand[j][1];
            ret[j][2] = cand[j][2];
            ret[j][3] = cand[j][3];
            ret[j][0] += ret[j][2] * i;
            ret[j][1] += ret[j][3] * i;
        }
        return ret;
    };

    auto area = [&](double t) {
        auto recs = update(t);
        sort(recs.begin(), recs.end(), [](auto &a, auto &b) {
            return a[0] < b[0];
        });
        double x = recs.back()[0] - recs.front()[0];
        sort(recs.begin(), recs.end(), [](auto &a, auto &b) {
            return a[1] < b[1];
        });
        double y = recs.back()[1] - recs.front()[1];
        double A = x * y;
        return A;
    };
    
    double l = 0, r = 1e9;
    for (int i = 0; i < 1000; i++) {
        double ml = l + (r - l) / 3;
        double mr = l + (r - l) / 3 * 2;
        if (area(mr) > area(ml)) {
            r = mr;
        } else {
            l = ml;
        }
    }
    double ans = area(l);

    printf("%.20f\n", ans / 4.0);
}

Measured memory_bytes: 1276
/**
 * C - Go Home
 * https://atcoder.jp/contests/abc056/tasks/arc070_a
 * 
 * 解法
 * X秒まで待ては一発でいける.
 * 
 **/
#include<iostream>

#define ll long long

using namespace std;

int main() {
    ll X; cin >> X;
    ll x = 0;
    for(int i=1; i<X+1; i++) {
        x += i;
        if(x>=X) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
using namespace std;


int main()
{
  ll N, W;
  cin >> N >> W;
  vector<pair<ll, ll>> vw(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> vw.at(i).first >> vw.at(i).second;
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  for (ll i = 0; i < N; ++i)
  {
    for (ll j = 0; j < W + 1; ++j)
    {
      dp.at(i + 1).at(j) = max(dp.at(i + 1).at(j), dp.at(i).at(j));
      if (j + vw.at(i).second > W)
      {
        continue;
      }
      dp.at(i + 1).at(j + vw.at(i).second) = max(dp.at(i + 1).at(j + vw.at(i).second), dp.at(i).at(j) + vw.at(i).first);
    }
  }
  cout << dp.at(N).at(W) << endl;
}



Measured memory_bytes: 10740
# coding: utf-8
DATA = """
1000000000
""".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()

X = [int(i) for i in get_line().strip().split(" ")][0]

t = 0
t += (X // 500) * 1000
t += ((X % 500) // 5) * 5
print(t)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
//#define SZ(x) ((int)(x).size())
//#define F first
//#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
 
/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
 
//#define int long long
 
signed main()
{
	string s;
	cin >> s;
	sort(ALL(s));
	
	string t;
	cin >> t;
	sort(ALL(t));
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes"s << endl;
	else cout << "No"s << endl;
}

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

int main(){
    i64 N, K;
    cin >> N >> K;
    vector<vector<int>> doubling(64, vector<int>(N)); 
    rep(i, N) cin >> doubling[0][i], doubling[0][i]--;

    for(int i = 1; i < 64; i++){
        for(int k = 0; k < N; k++){
            doubling[i][k] = doubling[i-1][doubling[i-1][k]];
        }
    }

    int ans = 0;
    for(int i = 0; i < 64; i++){
        if(K & (1ll << i)) ans = doubling[i][ans];
    }

    cout << ans+1 << endl;
}


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

int main(){
  int n, x, y;
  char ch;
  cin>>n;
  int c[4][14] = {};
  for(int i=0; i<n; i++){
    cin>>ch>>y;
    if (ch == 'S') x = 0;
    else if (ch == 'H') x = 1;
    else if (ch == 'C') x = 2;
    else if (ch == 'D') x = 3;
    c[x][y] = 1;
  }
  for(y=1; y<14; y++){
    if (c[0][y]==0) cout<<"S "<<y<<endl;
  }
  for(y=1; y<14; y++){
    if (c[1][y]==0) cout<<"H "<<y<<endl;
  }
  for(y=1; y<14; y++){
    if (c[2][y]==0) cout<<"C "<<y<<endl;
  }
  for(y=1; y<14; y++){
    if (c[3][y]==0) cout<<"D "<<y<<endl;
  }
  return 0;
}



Measured memory_bytes: 3004
n = gets.to_i
p = gets.split.map &:to_i

idx = []

p.each_with_index{ |x, i| idx[x-1] = i }

keys = [idx[-1]]
count = 0

(idx.size - 2).downto(0){ |i|
	t_idx = keys.bsearch_index{ |x| x > idx[i] }
	t_idx = keys.size if t_idx == nil

	# 左の1個を含めた区間
	if t_idx >= 1 then
		l = 1
		r = 1

		if t_idx >= 2 then
			l = keys[t_idx - 1] - keys[t_idx - 2]
		else
			l = keys[t_idx - 1] + 1
		end
		
		if keys.size - 1 >= t_idx then
			r = keys[t_idx] - idx[i]
		else
			r = p.size - idx[i]
		end

		count += l * r * (i + 1)
	end

	# 右の1個を含めた区間
	if keys.size - 1 >= t_idx then
		l = 1
		r = 1

		if keys.size - 2 >= t_idx then
			r = keys[t_idx + 1] - keys[t_idx]
		else
			r = p.size - keys[t_idx]
		end
		
		if t_idx >= 1 then
			l = idx[i] - keys[t_idx - 1]
		else
			l = idx[i] + 1
		end

		count += l * r * (i + 1)
	end
	
	keys.insert(t_idx, idx[i])
}

puts count




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

int main(){
    string S;
    cin >> S;
    int le = (int)(S.length());
    reverse(S.begin(),S.end());
    long long mod = 1000000007;
    long long dp[le][13];

    long long modi[le];
    modi[0] = 1;
    for (int i = 1; i < le; i++)modi[i] = (modi[i-1] * 10)%13;

    if (S[0] == '?'){
        for (int i = 0; i < 10; i++)dp[0][i] = 1;
    }else{
        for (int i = 0; i < 10; i++)dp[0][i] = 0;
        dp[0][S[0] - '0'] = 1;
    }
    for (int i = 10; i < 13; i++)dp[0][i] = 0;

    for(int i = 1;i < le;i++){
        int mo = modi[i];
        int a[13];
      	for (int j = 0; j < 13; j ++){
         	a[j] = 0; 
        }
        if (S[i] == '?'){
            for (int j = 0; j < 10; j++)
            {
                for(int k = 0; k < 13; k++){
                    a[(k+mo*j)%13] += dp[i-1][k];
                    a[(k+mo*j)%13] %= mod;
                }
            }
        }else{
            int j = S[i] - '0';
            for(int k = 0; k < 13; k++){
                a[(k+mo*j)%13] += dp[i-1][k];
                a[(k+mo*j)%13] %= mod;
            }
        }
        for(int j = 0; j < 13; j++)
            dp[i][j] = a[j];
    }
    cout << dp[le-1][5] << endl;
}


Measured memory_bytes: 11392
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//↑templete
int main() {
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;
	vint A;
	for(int i=0;i<N;i++){
		A.pb(S[i]=='L'?0:1);
	}
	vint B=A;
	int a=0,b=0;
	int ca=0;
	for(int i=1;i<N;i++){
		if(A[i]!=A[0]){
			for(int j=i;j<N;j++){
				if(A[j]!=A[0])
					A[j]=1-A[j];
				else{
					i=j;
					break;
				}
			}
			ca++;
		}
		if(ca==K)
			break;
	}
	int temp=0;
	for(int i=0;i<N;i++){
		int next;
		if(A[i]==0)
			next=i-1;
		else
			next=i+1;
		if(next<0 || N<=next)
			continue;
		if(A[next]==A[i])
			temp++;
	}
	cout<<temp<<endl;
	return 0;
}

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

int main() {
 int N;
  cin >> N;
 if(N==25)cout << "Christmas"<<endl;
 if(N==24)cout << "Christmas Eve"<<endl;
 if(N==23)cout << "Christmas Eve Eve"<<endl;
 if(N==22)cout << "Christmas Eve Eve Eve"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int x;
    cin>>x;
    int a=1;
    for(int i=2;i<x;i++){
        for(int j=2;j<10;j++){
            if(pow(i,j)<=x&&a<pow(i,j)){
                a=pow(i,j);
            }
        }
        
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;

int main(){
  	int N,M;
    vector<P> card;

    cin >> N;
    for(int i=0;i<N;i++){
      string S;
      cin >> S;
      card.push_back(make_pair(S,1));
    }

    cin >> M;
    for(int i=0;i<M;i++){
      string S;
      cin >> S;
      card.push_back(make_pair(S,-1));
    }

    sort(card.begin(), card.end());

    int ans = 0;
    int i=0;
    while(i<N+M){
      int candidate = 0;
      while(i+1<N+M && card[i].first==card[i+1].first){
        candidate += card[i].second;
        i++;
      }
      candidate += card[i].second;
      ans = max(ans, candidate);
      i++;
    }

    cout << ans <<endl;


  return 0;
}






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

int main(){
    int n; cin >> n;
    unordered_map<int, int> m;

    int t;
    for(int i = 0; i < n; ++i){
        cin >> t;
        if(m.find(t) != m.end()){
           m[t]++; 
        }else{
            m.emplace(t, 1);
        }
    }

    int ans = 0;
    for(auto e : m){
        if(e.first < e.second){
            ans += e.second - e.first;
        }else if(e.first > e.second){
            ans += e.second;
        }
    }

    cout << ans << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 4260
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>


int main() {
	std::string str; std::cin >> str;
	for (auto i = 2; i < str.size(); i += 2) {
		auto is_even = true;
		for (auto j = 0; j < (str.size() - i) / 2 && is_even; ++j) {
			if (str[j] != str[j + (str.size() - i) / 2]) {
				is_even = false;
			}
		}
		if (is_even) {
			std::cout << str.size() - i << std::endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
S = input()
str_list = list(S)
p = len(S) - 1

for i in range(2 ** p):
  ans = int(str_list[0])
  sentence = S[0]
  for j in range(p):
    if (i >> j) & 1:
      ans += int(str_list[j+1])
      sentence += "+"+S[j+1]
    else:
      ans -= int(S[j+1])
      sentence += "-"+S[j+1]
  if ans ==7:
    print(sentence+"=7")
    break

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

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


        rep(i,0,n,1){
            ll x,y;
            cin>>x>>y;
            a[i]=mp(x,i);
            b[i]=mp(y,i);

        }
        sort(a.rbegin(),a.rend());
        sort(b.rbegin(),b.rend());
        ll mx=a[0].ff;
        ll mxi=a[0].ss;
        ll moves=0;

        ll mxb;
        for(ll i=0;i<n;i++){
            if(h<=0)break;
            if(b[i].ss==mxi){
                mxb=b[i].ss;
            }
            if(b[i].ff<mx)break;
            moves++;
            h=h-b[i].ff;
        }

        if(h>0){
            ll x=(h/mx);
            moves=moves+x;
            if(x*mx<h)moves++;
        }
        cout<<moves<<endl;
}


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

int main() {
	int s,t,count=0;
	
	cin>>s;
	vector <int> sset(s);
	for(int i=0;i<s;i++){
		cin >> sset[i];
	}
	cin>>t;
	vector <int> tset(t);
	for(int i=0;i<t;i++){
		cin >> tset[i];
	}
	
	for(int i=0;i<t;i++){
		for(int j=0;j<s;j++){
			if(sset[j]==tset[i]){
				count++;
				break;
			}	
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
      
int main() {
  int N, A, B, P1, P2;
  cin >> N >> A >> B;
      
  P1 = A * N;
  P2 = B;
     
  if (P1 < P2) {
  cout << P1 << endl;
  }
     
        else {
        cout << P2 << endl;
        }
     
      }


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

#define vd vector<double>
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string s;
    cin >> s;
    int s_len = s.length();

    string yes = "Yes";
    string no = "No";
    rep(i, s_len){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << no << endl;
                return 0;
            }
        }
        else{
            if(s[i] == 'R'){
                cout << no << endl;
                return 0;
            }
        }
    }
    cout << yes << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int a;
  a=1000-n%1000;
  if(a!=1000)cout<<a<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
struct NODE{
	int to , cost , number;
	NODE(int a,int b,int c){ to = a , cost = b , number = c ; }
};
bool operator < (const NODE &a, const NODE &b){
	return a.number > b.number;
}
#define rep(i,n) for(int i = 0 ; i < n ; i++)
int main(){
	int n,m,l;
	while(cin >> n >> m >> l && n){
		vector< vector<NODE> > v(n);
		rep(i,m){
			int a,b,d,e;
			cin >> a >> b >> d >> e;
			a--,b--;
			v[a].push_back(NODE(b,d,e));
			v[b].push_back(NODE(a,d,e));
		}
		priority_queue<NODE> Q;
		bool done[100][101] = {0};
		Q.push(NODE(0,l,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(done[q.to][q.cost]) continue;
			else done[q.to][q.cost] = true;
			if(q.to == n-1){
				cout << q.number << endl;
				break;
			}
			rep(i,v[q.to].size()){
				if(q.cost >= v[q.to][i].cost) Q.push(NODE(v[q.to][i].to,q.cost-v[q.to][i].cost,q.number));
				Q.push(NODE(v[q.to][i].to,q.cost,q.number+v[q.to][i].number));
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x;
    double max_n = -INF;
    double min_n = INF;
    while(cin >> x)
    {
        max_n = max(x, max_n);
        min_n = min(x, min_n);
    }
    cout << max_n - min_n << endl;
    return 0;
}




Measured memory_bytes: 3132
MOD = 10 ** 9 + 7
S = input()

# dp[i]['A' or 'AB' or 'ABC'] := 先頭からi桁までに含まれる φ数、A数、AB数、ABC数 の数
# 便宜上 φ: 0, 'A': 1, 'AB': 2, 'ABC': 3と表現する
dp = [[0 for _ in range(4)] for _ in range(len(S) + 1)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] == '?':
        for j in range(4):
            dp[i + 1][j] = dp[i][j] * 3 % MOD
    else:
        for j in range(4):
            dp[i + 1][j] = dp[i][j]
    if S[i] in ['A', '?']:
        dp[i + 1][1] += dp[i][0]
    if S[i] in ['B', '?']:
        dp[i + 1][2] += dp[i][1]
    if S[i] in ['C', '?']:
        dp[i + 1][3] += dp[i][2]

print(dp[len(S)][3] % MOD)


Measured memory_bytes: 28584
import math
n,k=map(int,input().split())
s=0
mi=math.inf
for i in range(n):
  a=int(input())
  rem=0
  s+=a
  if a<mi:
    mi=a 
  rem=k-s
if rem>0:
  res=rem/mi     
  print(int(res+n))
else:
  print(n)

Measured memory_bytes: 9128
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
tt = inpl()
aa = inpl()
hh = [[0,0] for i in range(N)]

bt = 0
for i in range(N):
	t = tt[i]
	if t != bt:
		hh[i] = [t,t]
	else:
		hh[i] = [1,t]
	bt = t

ba = 0
for i in reversed(range(N)):
	a = aa[i]
	MIN,MAX = hh[i]
	if a != ba:
		if MIN <= a <= MAX:
			hh[i] = [a,a]
		else:
			print(0)
			sys.exit()
	else:
		hh[i] = [max(1,MIN),min(a,MAX)]

	ba = a

ans = 1
for azu,nyan in hh:
	ans *= (nyan-azu+1)
	ans %= mod

print(ans)


Measured memory_bytes: 22748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long num = 1;
		long ans = 0;
		while(h != 1) {
			h /= 2;
			ans += num;
			num *= 2;
		}
		ans += num;
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764
h,w=map(int,input().split())
lst = [list(map(int,input().split())) for i in range(h)]
ans = float("inf")
for i in range(h):
    for j in range(w):
        cnt = 0
        for k in range(h):
            for l in range(w):
                cnt += min(abs(i-k),abs(j-l)) * lst[k][l]
        ans = min(ans,cnt)
print(ans)


Measured memory_bytes: 5616
N = int(input())
start, end, both = dict(), dict(), dict()
for i in range(1, N+1):
    i_s = str(i)
    l, r = int(i_s[0]), int(i_s[-1])
    both[l, r] = both.get((l, r), 0) + 1

ans = 0
for i in range(1, N + 1):
    i_s = str(i)
    l, r = int(i_s[0]), int(i_s[-1])
    ans += both.get((r, l), 0)
print(ans)


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

n = int(input())
count = 0
flag = False
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    flag = True
    count += 1
  else:
    if flag is True:
      flag = False
      count = 0
  if count == 3:
    print('Yes')
    sys.exit()
print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
    int m,l,r;
    cin>>r>>m;
    l=1;
    rep(i,m){
        int l1,r1;
        cin>>l1>>r1;
        l=max(l,l1);
        r=min(r,r1);
    }
    if(r<l){
        cout<<"0"<<endl;
    }else{
        cout<<(r-l+1)<<endl;

    }
    
	return 0;
}


Measured memory_bytes: 256
b = input()
a = [0] * 4
a[0] = int(b[0])
a[1] = int(b[1])
a[2] = int(b[2])
a[3] = int(b[3])

for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      if i1 == 0 and i2 == 0 and i3 == 0:
        if a[0] + a[1] + a[2] + a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '+' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 0 and i3 == 1:
        if a[0] + a[1] + a[2] - a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '+' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 1 and i3 == 0:
        if a[0] + a[1] - a[2] + a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '-' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 0 and i2 == 1 and i3 == 1:
        if a[0] + a[1] - a[2] - a[3] == 7:
          print(str(a[0])  + '+' + str(a[1])  + '-' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 0 and i3 == 0:
        if a[0] - a[1] + a[2] + a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '+' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 0 and i3 == 1:
        if a[0] - a[1] + a[2] - a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '+' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 1 and i3 == 0:
        if a[0] - a[1] - a[2] + a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '-' + str(a[2])  + '+' + str(a[3])  + '=7'  )
          exit()
      elif i1 == 1 and i2 == 1 and i3 == 1:
        if a[0] - a[1] - a[2] - a[3] == 7:
          print(str(a[0])  + '-' + str(a[1])  + '-' + str(a[2])  + '-' + str(a[3])  + '=7'  )
          exit()


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    vector<int> st(26, 0);
    vector<int> tt(26, 0);
    for (int i = 0; i < s.size(); ++i) {
        st[s[i] - 'a']++;
        tt[t[i] - 'a']++;
    }
    sort(st.begin(), st.end());
    sort(tt.begin(), tt.end());
    bool flag = true;
    for (int i = 0; i < 26; ++i) {
        if(st[i] != tt[i])
        {
            flag = false;
        }
    }
    if(!flag)
    {
        cout << "No" << endl;
    }else{
        vector<int> st2(s.size(), 0);
        vector<int> tt2(t.size(), 0);
        st2[0] = 1;
        tt2[0] = 1;
        for(int i = 1; i < s.size(); i++)
        {
            if(s[i - 1] == s[i])
            {
                st2[i] = st2[i - 1] + 1;
            }else{
                st2[i] = 1;
            }
            if(t[i - 1] == t[i])
            {
                tt2[i] = tt2[i - 1] + 1;
            }else{
               tt2[i]  = 1;
            }
        }
        bool flag2 = true;
        for (int i = 0; i < s.size(); ++i) {
            if(st2[i] != tt2[i])
            {
                flag2 = false;
            }
        }
        if(flag2)
        {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2312
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int A[300100];//配列
int main()
{
  int N,Q;
  scanf("%d %d",&N,&Q);
  for(int i = 0;i <N;i++){
    int t;
    scanf("%d",&t);
    A[t] = t;
  }
  for(int i = 1;i <=300000;i++){
    A[i] =max(A[i],A[i-1]);
  }
  for(int i = 0;i < Q;i++){
    int t;
    int ans = 0;
    scanf("%d",&t);
    for(int j = t; j<=300000; j+=t){
      ans =max(A[j-1]%t,ans);
    }
    ans = max(A[300000]%t,ans);
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2360
#include<iostream>
using namespace std;
double ans=0;
int main(){
	double x;
	string s;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		cin>>s;
		if(s[0]=='J')
		ans+=x;
		else ans+=380000*x;
	}
	cout<<ans;
	return 0;
}

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

int N, M, p;
vector<int> d;

int dist(int s, int t) {
    return t>=s ? t-s:N-s+t;
}

int main() {
    cin >> N >> M >> p;
    
    for (int i=0; i<M; i++) {
        int di; cin >> di;
        d.push_back(di);
    }
    
    d.push_back(p);
    sort(d.begin(), d.end());
    d.push_back(d[0]);
    
    long long ans = 100000000;
    
    for (int i=0; i<M+1; i++) {
        int a = d[i], b = d[i+1];
        
        if (ans>100*(2*dist(p, a)+dist(b, p))) {
            ans = 100*(2*dist(p, a)+dist(b, p));
        }
        
        if (ans>100*(dist(p, a)+2*dist(b, p))) {
            ans = 100*(dist(p, a)+2*dist(b, p));
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3256
#include <stdio.h>

int main(void){
    long money = 0;
    long result = 100;
    long count_year = 0;

    scanf("%ld" , &money);

    while(result < money){
        result += result / 100;
        count_year++;
    }

    printf("%ld" , count_year);

    return 0;
}


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

#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define mod 1e9 + 7
#define inf 99999999999
#define neginf -9999999999
#define vi vector<int>
#define vchar vector<char>
#define vstr vector<string> 
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ull h,w;
    
    cin>>h>>w;
    if(h==1 || w==1){
        cout<<1;
        return 0;
    }
    ull ans=(h*w)/2;
    if(h%2==1 && w%2==1){
        cout<<ans+1;
        return 0;
    }
    cout<<ans;
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'

/*
	For Debugging we have define TRACE.
*/

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif  

const int N = 1e7 + 5;
int a[N];
int reach [10000001];

void solve(){

	int n;
	cin>>n;
	vector<int> v(n+1);
	
	for(int i=1;i<=n;i++) cin>>v[i];

	int cnt = 0;
	
	for(int i=1;i<=n;i++){
		if(i&1 && v[i]&1) cnt++;
	}
	cout<<cnt;

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

    IOS;

    solve();


}

Measured memory_bytes: 3616
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

ll gcd(ll a, ll b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

ll lcm(ll a, ll b)
{
    ll temp = gcd(a, b);
    
    return temp ? (a / temp * b) : 0;
}

int main()
{

    int k,t;
    cin >> k >> t;
    vector<int> ps(t);
    for(int i = 0;i < t;i++)
    {
        int a;
        cin >> a;
        ps[i] = a;
    }
    sort(ps.begin(), ps.end(), std::greater<int>());
    if(t == 1)
    {
        cout << k-1<<endl;
        return 0;
    }
    if(k % 2 == 0)
    {
        if(ps[0] <= k / 2)
        {
            cout << 0 << endl;
        }
        else
        {
            int r = k - ps[0];
            int de = r + 1;
            cout << ps[0] - de << endl;
        }
    }
    else
    {
        if(ps[0] <= k / 2 + 1)
        {
            cout << 0 << endl;
        }
        else
        {
            int r = k - ps[0];
            int de = r + 1;
            cout << ps[0] - de << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256