akhauriyash/Code-Regression huggingface dataset:
N = int(input())
d = dict()
ans = 0
for i in range(1, N + 1):
    if not (str(i)[0], str(i)[-1]) in d:
        d[(str(i)[0], str(i)[-1])] = 1
    else:
        d[(str(i)[0], str(i)[-1])] += 1
for j in d:
    if (j[-1], j[0]) in d:
        ans += d[j] * d[(j[-1], j[0])]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;
ll MOD = 1e9 + 7;
ll dp[100005][13];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    
    dp[0][0] = 1;

    for(int i = 0; i < n; i++){
        int c;
        if(s[i] == '?') c = -1;
        else c = s[i] - '0';

        for(int j = 0; j < 10; j++){
            if(c != -1 && c != j) continue;
            for(int k = 0; k < 13; k++){
                dp[i+1][(k*10 + j)%13] += dp[i][k];
                dp[i+1][(k*10 + j)%13] %= MOD;
            }
        }
    }

    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <utility>
#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<61 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = 0 ;
	for(int i=1;i<n;i++){
		if(a.at(i-1)>a.at(i)){
			ans += a.at(i-1)-a.at(i) ;
			a.at(i) = a.at(i-1) ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;   cin >> s;
   int n = s.size(),i=0;
   for(int i=0;i<n;i++){
      if(i % 2 == 0 && s.at(i) == 'L'){
         cout << "No" << endl;
         return 0;
      }
      if(i % 2 == 1 && s.at(i) == 'R'){
         cout << "No" << endl;
         return 0;
      }
   }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 1000005
long long int MOD=1e9+7;
long long int INF=1e18;
                                                 /*:-]*/
long long  int modulo(long long int a,long long  int b,long long  int n)
{
    long long int  x=1, y=a; 
    while (b > 0) 
    {
        if (b%2 == 1) 
        {
              x = (x*y) % n;
        }
        y = (y*y) % n; 
        
        b /= 2;
    }
    return x % n;
}


int main()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
         string s;
    cin>>n>>m;
    p=-1;
    if(n<=9 && m<=9)
        cout<<m*n<<endl;
    else
    cout<<p<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> num(n);
  for(int i = 0;i < n;i++)cin >> num[i];
  ll res = 0;
  ll memo = 0;
  bool mae = false;
  for(int i = 0;i < n;i++){
    if(num[i] == 0){
      res += memo / 2;
      memo = 0;
    }
    memo += num[i];
  }
  res += memo / 2;
  cout << res << endl;
  /*res = memo;
  memo = 0;
  mae = false;
  for(int i = n - 1;i >= 0;i--){
    memo += num[i] / 2;
    if(mae && num[i] % 2 == 1){
      mae = false;
      memo++;
    }
    else if(num[i] % 2 == 1)mae = true;
    else mae = false;
  }
  cout << memo << endl;
  res = max(res,memo);
  cout << res << endl;*/
  return 0;
}

Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc112/tasks/abc112_b


N, T = gets.split.map(&:to_i)
cts = Array.new(N)
N.times do |i|
  cts[i] = gets.split.map(&:to_i)
end

ans = cts.select { |c, t| t <= T }.map { |c, t| c }&.min || 'TLE'
puts ans


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	int mon;
	cin >> a >> b;
	if (a <= 5)
		mon = 0;
	else if (a >= 13)
		mon = b;
	else
		mon = b / 2;
	cout << mon << endl;
		
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    char C;
    cin >> C;
    C++;
    cout << C << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#undef DEBUG

#define max(a, b)   ((a)>(b)? (a):(b))
#define min(a, b)   ((a)<(b)? (a):(b))

int
z_algo(char *S, int N, int *A)
{
    int i, j, k;
    int ret=0;

    A[0] = N;
    i=1;
    while(i<N) {
        while (S[j]==S[i+j]) {
            j++;
        }
        A[i] = j;
        if (ret<j && i+1>j)
            ret = j;
#ifdef DEBUG
        printf("%s %s %d A[%d] = %d\n", S, S+i, j, i, j);
#endif
        if (j>0) {
            k=1;
#ifdef DEBUG
            printf("i %d j %d k %d\n", i, j, k);
#endif            
            while(i+k<N && k+A[k]<j) {
#ifdef DEBUG
                printf("## i %d j %d k %d A[%d] = A[%d] = %d\n", i, j, k, i+k, k, A[k]);
#endif                
                A[i+k] = A[k];
                if (ret<A[k] && i+k+1>A[k])
                    ret = A[k];
                k++;
            }
            i+=k;
            j-=k;
        }
        else {
            i++;
        }
    }
#ifdef DEBUG
    for (i=0; i<N; i++) {
        printf("%d ", A[i]);
    }
    printf("\n");
#endif    
        
    return ret;
}

int
main(int argc, char *argv[])
{
    int N;
    char S[5001];
    int len=0;
    int i;
    int A[5000];

    scanf("%d", &N);
    scanf("%s", S);
    
    for (i=0; i<N; i++) {
        len = max(z_algo(S+i, N-i, A), len);
        if(len>=(N-i)/2)
            break;
    }
    printf("%d\n", len);
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        boolean[] primes = new boolean[200001];
        Arrays.fill(primes,true);
        primes[0] = false;
        primes[1] = false;
        for (int i = 2; i * i <= 200000; i++) {
            for (int j = i * 2; j <= 200000; j += i) {
                primes[j] = false;
            }
        }
        for (int i = X; i <= 200000; i++) {
            if (primes[i]) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    string s,t;
    cin >> s >> t;
    int n = s.size();
    rep(i,n)
    {
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
        s = s.substr(n-1,1) + s.substr(0,n-1);
    }
    cout << "No" << endl;
    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

void solve(int w, int d) {
    vi hw(w+1), hd(d+1);
    REP(i, w) cin >> hw[i];
    REP(i, d) cin >> hd[i];
    hw[w] = -1; hd[d] = -1;

    sort(ALL(hw), greater<int>());
    sort(ALL(hd), greater<int>());

    int wi = 0, di = 0;
    int ans = 0;
    while(wi < w || di < d) {
        if(hw[wi] == hd[di]) {
            ans += hw[wi];
            wi++; di++;
        } else if(hw[wi] > hd[di]) {
            ans += hw[wi];
            wi++;
        } else {
            ans += hd[di];
            di++;
        }
    }
    print(ans);
}

signed main() {
    int w, d;
    while(true) {
        cin >> w >> d;
        if (w == 0 && d == 0) {
            break;
        } else {
            solve(w, d);
        }
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = b + min(c, a+b+1);
	cout << ans << endl;
}


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


vector<int> used(100 + 5, 0);

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

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

   int ans = 0;
   for (int i = 1; i <= 101; i++)
   {
      if (used[i] == 0 && abs(i - x) < abs(ans - x))
      {
         ans = i;
      }
   }

   cout << ans;

   return 0;
}

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

check = ((1 / (4 * M)) * sum(A))
x = 0
for item in A:
    if item < check:
        x += 1

ans = N - x

if ans >= M :
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

class Process {
private:
    string name;
    int time;
public:
    Process() = default;
    Process(string name, int time) {
        this->name = name;
        this->time = time;
    }
    string getName() {
        return this->name;
    }
    int getTime() {
        return this->time;
    }
    void setTime(int time) {
        this->time = time;
    }
};

int pos_min = 0;
int pos_max = 0;
Process queue[1000000];

void enqueue(Process &process) {
    queue[pos_max] = process;
    pos_max++;
}

Process dequeue() {
    Process process = queue[pos_min];
    pos_min++;
    return process;
}

bool isEmpty() {
    return pos_min == pos_max;
}

int main() {

    int num, quantum;
    scanf("%d %d", &num, &quantum);

    for (int i = 0; i < num; i++) {
        char name[100];
        int time;
        scanf("%s %d", name, &time);
        Process process(name, time);
        enqueue(process);
    }

    int cost = 0;
    while (true) {
        Process process = dequeue();
        if (process.getTime() > quantum) {
            cost += quantum;
            process.setTime(process.getTime() - quantum);
            enqueue(process);
        } else if (process.getTime() <= quantum) {
            cost += process.getTime();
            printf("%s %d\n", process.getName().c_str(), cost);
            if (isEmpty()) {
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 21136
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " = " << (x) << endl
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int n, rem, ans; cin >> n;
	vi d(n+1);
	for(auto &it : d)	cin >> it;
	vi node(n+1);
	node[0] = 1-d[0];
	rem = 1;
	rep(i,0,n+1) 
    {
        rem -= d[i];
        if (rem < 0) 
        {
            cout << -1 << '\n'; return 0;
        }
        rem *= 2; 
        if (rem > 1e15) rem = 1e15;
    }
	for(int i = 1; i <= n; i++) {
		node[i] = 2*node[i-1] - d[i];
		if(node[i] > 1e18)	{
			node[i] = 1e18;
		}
		if(node[i] < 0)	return cout << -1,0;
	}
	// for(auto it : node)	cout << it << ' ';
	// cout << endl;
	rem = 0, ans = 0;
	for(auto &it : d)	rem += it;
	for(int i = 0; i <= n; i++) {
		ans += min(node[i]+d[i],rem);
		rem -= d[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  string s;
  cin >> s;
  const int n = s.size()-1;
  int64_t sum = 0;

  rep(i, 1<<n) {
    bitset<10> bit(i);
    int64_t curr = s[0] - '0';
    rep(j, n) {
      if (bit[j] == 1) {
        sum += curr;
        curr = s[j+1] - '0';
      }
      else {
        curr *= 10;
        curr += s[j+1] - '0';
      }
    }
    sum += curr;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;

  //s�������Ƀ\�[�g
  sort(s.begin(), s.end());
  //t���~���Ƀ\�[�g
  sort(t.begin(), t.end(), greater<char>());

  //s�͍ŏ��̕��я��ŁCt�͍ő�̕��я��ɂȂ��Ă���
  //���̏�Ԃ�s�̕����傫����Α�ӂ𖞂������Ƃ͂Ȃ�
  if(s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
   
  return 0;
}


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

int main(){
	int k;
	cin >> k;
	int x = 7%k;
	set<int> s;
	int i = 1;
	while(s.count(x) == 0){
		if(x == 0){
			cout << i << endl;
			return 0;
		}
		s.insert(x);
		x = (x*10+7)%k;
		i++;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 50480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int h,w;
    cin >> h >> w;
    char f[h][w];
    int row[h][w];
    int column[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> f[i][j];
            row[i][j] = 0;
            column[i][j] = 0;
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(f[i][j] == '#'){
                row[i][j] = 0;
            }else{
                int cnt = 0;
                while(f[i][j+cnt] == '.' && j+cnt < w){
                    cnt++;
                }
                int x;
                for(int k = 0; k < cnt; k++){
                    row[i][j+k] = cnt;
                    x = j+k;
                }
                j = x+1;
            }
        }
    }
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            if(f[j][i] == '#'){
                column[j][i] = 0;
            }else{
                int cnt = 0;
                while(f[j+cnt][i] == '.' && j+cnt < h){
                    cnt++;
                }
                int x;
                for(int k = 0; k < cnt; k++){
                    column[j+k][i] = cnt;
                    x = j+k;
                }
                j = x+1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            ans = max(ans,row[i][j] + column[i][j]-1);
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL<<60;

int main()
{
  string S;
  cin >> S;
  reverse(S.begin(), S.end());

  string list[4] = {"dream","dreamer","erase","eraser"}; 
  for (int i = 0; i < 4; i++ ) {
    reverse(list[i].begin(), list[i].end());
  }

  while (1) {
    bool f = false;
    for (int i = 0; i < 4; i++ ) {
      if(S.find(list[i]) == 0) {
        S.erase(0, list[i].size());
        f = true;
      }
    }
    if (f && S != "") {
      continue;
    }
    if (S == "") {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
      return 0;
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    long long ans=1,N,mod=1000000007;

    cin>>N;

    for(int i=1;i<=N;i++){
        ans*=i;
        ans%=mod;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
button = $stdin.read.split("\n")
button.map! do |element|
	element.to_i
end
button.shift()
#p button
#p button.size
current = 1
cnt = 0 
while true
	if current == 2
		print("#{cnt}\n")
		break
	elsif cnt >= button.size
		print("-1\n")
		break
	end
	cnt += 1
	current = button[current-1]
end



Measured memory_bytes: 7548
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long LL;
#define int LL
const int mo=1e9+7;
typedef pair<int,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
template<typename _T>
_T Fabs(_T x){return x<0?-x:x;}
int x;
signed main(){
	read(x);int ans=0;double tmp=100.0;
	while(tmp<x)tmp=(int)(tmp*1.01),ans++;
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int shortest[200200];
set<int> obj[200200];

signed main() {
    int H, W, N;
    cin >> H >> W >> N;
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        obj[y].insert(x);
    }
    shortest[0] = 0;
    for (int y = 1; y < W; ++y) {
        if (shortest[y - 1] == INF) {
            shortest[y] = INF;
            continue;
        }
        for (int j = shortest[y - 1] + 1;; ++j) {
            if (!obj[y].count(j)) {
                shortest[y] = j;
                break;
            }
            if (j > H) {
                shortest[y] = INF;
                break;
            }
        }
    }
    int ans = H;
    for (int y = 0; y < W; ++y) {
        auto ite = obj[y].upper_bound(shortest[y]);
        if (ite == obj[y].end())continue;
        ans = min(ans, *ite);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define Maxn 100010
#define INF 10010
inline int read()
{
	char c=getchar();re ll f=1,s=0;
	while(!isdigit(c)){if(c=='-')f=-1,c=getchar();}
	while(isdigit(c)){s=s*10+c-48;c=getchar();}
	return f*s;
}
int main()
{
	int n,k;
	map<int,int> m;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k;
		if(m[k]) m.erase(k);
		else m[k]++;
	}
	cout<<m.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
import java.util.*;

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

	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	
	if(a<b){
	  if(b<c){
	    System.out.println("Yes");
	  }else{
	    System.out.println("No");
	  }
	}else{
	System.out.println("No");
	}
  }
}

Measured memory_bytes: 25888
// AOJ 2748 Early Morning Work at Summer Camp
// 2018.4.26 bal4u

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

#define MAX_V 102
int  V;    // 頂点数
int  to[MAX_V][MAX_V], hi[MAX_V];
int  r_to[MAX_V][MAX_V], r_hi[MAX_V];
int  g_to[MAX_V][MAX_V], g_hi[MAX_V];
int  vs[MAX_V], vsz;
char used[MAX_V];
int  cmp[MAX_V];    // 属する強連結成分のトポロジカル順序

void add_edge(int _from, int _to)
{
	to[_from][hi[_from]++] = _to;
	r_to[_to][r_hi[_to]++] = _from;
}

void dfs(int v)
{
	int i;
	used[v] = 1;
	for (i = 0; i < hi[v]; i++) {
		if (!used[to[v][i]]) dfs(to[v][i]);
	}
	vs[vsz++] = v;
}

void rdfs(int v, int k)
{
	int i;
	used[v] = 1;
	cmp[v] = k;
	g_to[k][g_hi[k]++] = v;
	for (i = 0; i < r_hi[v]; i++) {
		if (!used[r_to[v][i]]) rdfs(r_to[v][i], k);
	}
}

// 強連結成分への分解
int scc()
{
	int v, i, k;
	memset(used, 0, V);
	vsz = 0;
	for (v = 0; v < V; v++) if (!used[v]) dfs(v);
	memset(used, 0, V);
	k = 0;
	for (i = vsz-1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;       // 得られた強連結成分の数
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

// 実数対応
double getdbl()
{
	double x, y;
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	if (c == '.') {
		x = 0;
		y = 1, c = getchar_unlocked();
		do y *= 0.1, x += y * (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		x += n;
	} else x = n;
	return x;
}

double p[102];

int main()
{
	int N, m, i, j, k, f, v;
	double a, ans;

	while (N = in()) {
		V = N;
		memset(hi, 0, V<<2), memset(r_hi, 0, V<<2);
		memset(g_hi, 0, V<<2);
		for (i = 0; i < N; i++) {
			p[i] = getdbl();
			m = in();
			while (m--) add_edge(i, in()-1);
		}

		k = scc();
		ans = 1;
		for (i = 0; i < k; i++) {
			f = 1, a = 1;
			for (j = 0; j < g_hi[i]; j++) {
				a *= p[g_to[i][j]];
				for (v = 0; v < r_hi[g_to[i][j]]; v++) {
					f &= (cmp[g_to[i][j]] == cmp[r_to[g_to[i][j]][v]]);
				}
			}
			if (f) ans *= 1.0-a;
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}


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

col_list = [399,799,1199,1599,1999,2399,2799,3199]
count_list = [0]*(len(col_list)+1)

for i in range(N):
    for j in range(len(col_list)+1):
        if j == len(col_list):
            if 3200<=S[i]:
                count_list[j] = count_list[j] + 1
        elif S[i]<=col_list[j]:
            count_list[j] = count_list[j]+1
            break

ans = 0
for i in range(len(col_list)):

    if count_list[i] != 0:
        ans += 1
print(str(max(ans,1)) + ' ' + str(ans+count_list[-1]))



Measured memory_bytes: 62076
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if(i<j and j<n):
        if(l[i]==l[j]):continue
        if(l[i]==l[k]):continue
        if(l[j]==l[k]):continue
        if(l[i]+l[j]+l[k]<=max(l[i],l[j],l[k])*2):continue
        ans+=1
print(ans)

Measured memory_bytes: 9204
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip("\n") for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst): print(*lst)
def OutV(lst): print(*lst, sep="\n")
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N, M, K = iInM()
A = iInLH()
B = iInLH()

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])

ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    else:
        while a[i] + b[j] > K:
            j -= 1
        ans = max(ans, i + j)

print(ans)

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

int main(){
  int N,s=0,a,b=0;
  cin >> N;
  vector<int> mo(N);
  for(int i=0;i<N;i++)
    cin >> mo.at(i);
  sort(mo.begin(),mo.end());
  for(int i=0;i<N;i++){
    a = mo.at(i);
    if(a!=b)
      s++;
    b = a;
  }
  cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt1 = 0;
  int cnt0 = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='0') cnt0++;
    if(s[i]=='1') cnt1++;
  }
  int minn = min(cnt0, cnt1);
  cout << 2*minn << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<stack>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char s[300000];
int a[300000];

int main(){

  scanf("%s",s);
  int len=strlen(s);
/*
  int res=len;
  while(1){
    int flg=1;
    rep(i,len-1){
      if(s[i]=='S' && s[i+1]=='T' && a[i]!=1 && a[i+1]!=1){
        a[i]=1; a[i+1]=1;
        res-=2;
        flg=0;
        break;
      }
    }
    if(flg) break;
  }
  */
  stack<int> st;
  int res=len;
  rep(i,len){
    if(s[i]=='S') st.push(1);
    else if(s[i]=='T' && !st.empty()){
      st.pop();
      res-=2;
    }
  }

  printf("%d\n",res);


  return 0;

}


Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;
 
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
long long f_gcd(long long a, long long b) {
	if (a < b)return f_gcd(b, a);
	long long r;
	while (r = a % b) {
		a = b;
		b = r;
	}
	return b;
}
int main(void) {
	long long a, b, count = 0;
	scanf("%lld %lld", &a, &b);
	long long gcd = f_gcd(a, b);
	long long list[100000];
	for (long long i = 2; i * i <= gcd; i++) {
		if (gcd % i == 0) {
			list[count] = i;
			count++;
			while (gcd % i == 0) { gcd /= i; }
		}
	}
	if (gcd != 1) {
		list[count] = gcd;
		count++;
	}
	printf("%lld\n", count+1);
	return 0;
}

Measured memory_bytes: 128
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
t = []
for i in range(n):
    t.append(inl())
for i in range(n):
    if t[i][2]>0:
        k = i
        break
for cx in range(101):
    for cy in range(101):
        h = t[k][2]+abs(t[k][0]-cx)+abs(t[k][1]-cy)
        ok = True
        for i in range(n):
            if t[i][2] != max(0,h-abs(t[i][0]-cx)-abs(t[i][1]-cy)):
                ok = False
                break
        if ok:
            print("{} {} {}".format(cx,cy,h))
            exit()


Measured memory_bytes: 42864
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        double x[] = new double[N];
        double y[] = new double[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextDouble();
            y[i] = sc.nextDouble();

        }

        double distAll = 0.0;

        for (int i = 0; i < N; i++) {
            for (int j = i; j < N; j++) {
                distAll += calcDist(x[i], y[i], x[j], y[j]);
            }
        }

        System.out.println((distAll * 2) / N);
    }

    static double calcDist(double x1, double y1, double x2, double y2) {
        double xDiff = Math.pow(x1 - x2, 2);
        double yDiff = Math.pow(y1 - y2, 2);

        return Math.sqrt(xDiff + yDiff);

    }
}


Measured memory_bytes: 23508
c = input()
alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(alp)):
    if c == alp[i]:
        print(alp[i+1])

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

using namespace std;

typedef long long ll;

int n, q;
vector<int> link[200002];
vector<int> child[200002];
bool visited[200002];
int cnt[200002];

void dfs(int x){
    visited[x] = 1;
    for(auto &y: link[x]){
        if(visited[y]) continue;
        child[x].push_back(y);
        dfs(y);
    }
}

void dfs2(int x, int tmp){
    cnt[x] += tmp;
    for(auto &y: child[x]){
        dfs2(y, cnt[x]);
    }
}

int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<n; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        link[x].push_back(y), link[y].push_back(x);
    }
    dfs(1);

    for(int i=1; i<=q; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        cnt[x] += y;
    }

    dfs2(1, 0);

    for(int i=1; i<=n; i++){
        printf("%d ", cnt[i]);
    }
    puts("");
}


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

using namespace std;

int main()
{
    unsigned long long int n;
    scanf("%llu", &n);

    int name[100000], i;
    for (i = 0; n; i++)
    {
        n--;
        name[i] = n % 26;
        n /= 26;
    }
    for (int j = i - 1; j >= 0; j--)
        printf("%c", name[j] + 'a');

    return 0;
}

Measured memory_bytes: 3704
class UnionFind(object):
    def __init__(self, size):
        self.data = [-1 for i in range(size)];
    
    def unite(self, x, y):
        x = self.root(x);
        y = self.root(y);
        if (x != y):
            if (self.data[y] < self.data[x]):
                x, y = y, x;
            self.data[x] += self.data[y];
            self.data[y] = x;
        return x != y;

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def root(self, x):
        if self.data[x] < 0 :
            return x;
        self.data[x] = self.root(self.data[x]);
        return self.data[x];
    
    def size(self, x):
        return -self.data[self.root(x)];


def pos(i, j):
    return i * 14 + j

end_flag = False
while True:
    uf = UnionFind(14 * 14);
    board = [];
    while True:
        try:
            s = raw_input();
        except:
            end_flag = True
            break
        s = "0" + s.strip() + "0";
        if (s == "00"):
            break;
        board.append(list(s));

    sent = [0 for i in range(len(board[0]))]
    board = [sent] + board + [sent];
    #print board

    island = 0
    for i in range(1, len(board) - 1):
        for j in range(1, len(board[0]) - 1):
            if board[i][j] == '1':
                p = pos(i, j);
                f = False;
                if (board[1 + i][j] == '1'):
                    uf.unite(p, pos(i + 1, j));
                    f = True;
                if (board[i - 1][j] == '1'):
                    uf.unite(p, pos(i - 1, j));
                    f = True;
                if (board[i][j + 1] == '1'):
                    uf.unite(p, pos(i, j + 1));
                    f = True;
                if (board[i][j - 1] == '1'):
                    uf.unite(p, pos(i, j - 1));
                    f = True;
                if not f:
                    island += 1
    
    print island + len(filter(lambda x: x < -1, uf.data));
    if end_flag:
        break;

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int N,C;

vector<vector<bool>> ch;

int main(){
    cin >> N;
    cin >> C;
    ch=vector<vector<bool>>(C,vector<bool>(100000,false));
    vector<int> v;
    for(int i=0;i<N;i++){
        int s,t;
        cin >> s;
        cin >> t;
        v.push_back(s);
        v.push_back(t);
        int c;
        cin >> c;
        c--;
        std::fill(ch[c].begin()+s,ch[c].begin()+t+1,true);
    }

    sort(v.begin(),v.end());
    auto uniq=std::unique(v.begin(),v.end());
    v.erase(uniq,v.end());

    int max=0;
    for(int i : v){
        int count=0;
        for(auto & c : ch){
            if(c[i]){
                count++;
            }
        }
        max=std::max(max,count);
    }

    cout << max << endl;

    return 0;
}



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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i,n) for (int i=0 ; i<(n);i++)
#define INF 1e9+7
int main(){
int a, b;
char op;
cin >> a >> op >> b;
if (op == '-')
cout << a - b;
else cout << a + b;
}

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

int main() {
    int n, a_max;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    a_max = vec.back();
    vector<bool> bl(a_max + 1, true);
    for (size_t i = 0; i < vec.size(); i++) {
        if (i != 0 && vec.at(i - 1) == vec.at(i)) {
            bl.at(vec.at(i)) = false;
        }
        if (bl.at(vec.at(i))) {
            for (int j = 2; j * vec.at(i) <= a_max; j++) {
                bl.at(vec.at(i) * j) = false;
            }
        }
    }
    int cnt = 0;
    for (auto &x : vec) {
        if (bl.at(x)) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4020
N = int(input())
A = list(map(int, input().split()))
B = {}
for a in A:
    if a not in B:
        B[a] = 1
    else:
        B[a] += 1
num = 0
for k, v in B.items():
    if k <= v:
        num += v - k
    else:  # k > v
        num += v
print(num)

Measured memory_bytes: 17780
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int s = seer.nextInt();
		int a = s / 100;
		int b = s % 100;
		if(a == 0 && b == 0){
			System.out.println("NA");
		}
		else if(a == 0 && b > 12){
			System.out.println("NA");
		}
		else if(b == 0 && a > 12){
			System.out.println("NA");
		}
		else if(a > 12 && b > 12){
			System.out.println("NA");
		}
		else{
			if(a <= 12 && (b > 12 || b == 0)){
				System.out.println("MMYY");
			}
			else if((a > 12 || a == 0) && b <= 12){
				System.out.println("YYMM");
			}
			else{
				System.out.println("AMBIGUOUS");
			}
		}
	}

}


Measured memory_bytes: 21716
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  var count = 0 
  for (ni in 1..n) {
    val ai = a[ni-1]

    if (ni % 2 != 0 && ai % 2 != 0) {
      count++
    }
  }
  println(count)

}


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

struct comp{
	int mod;
	comp(int x) : mod(x){}
	bool operator()(const int &a, const int &b) const{
		return a % mod < b % mod;
	}
};

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0;i < n; ++i)cin >> a[i];
	for(int i = 0;i < n; ++i)cin >> b[i];
	int ans = 0;
	for(int p = 0;p < 30; ++p){
		sort(b.begin(), b.end(), comp(1 << p));	
		
		bool btog = false;
		for(int i = 0;i < n; ++i){
			btog ^= (b[i]>>p)&1;
		}

		for(int i = 0;i < n; ++i){
			int val = (1 << p) - (a[i] % (1 << p)) - 1;
			int pos = upper_bound(b.begin(), b.end(), val, comp(1 << p)) - b.begin();			
			int pval = (a[i] >> p) & 1;
			bool tog = (pval ? pos & 1: (n - pos) & 1);
			tog^=btog;
			if(tog)ans ^= (1 << p);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 1792
/*ABIDSTIC*/
#include <bits/stdc++.h>
/*---------------------------------PB_DS---------------------------------*/
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k) = returns an iterator to the k-th largest element (counting from zero)
// order_of_key(k) = the number of items in a set that are strictly smaller than k.
/*-----------------------------------------------------------------------*/

#define fill(a,b)           memset(a, (b), sizeof(a))
#define debug(x)            cout<<#x<<" "<<x<<'\n';
#define sfc(a)              scanf("%c",&a)
#define pb(a)               push_back(a)
#define X                   first
#define Y                   second
#define sz(x)               x.size()
#define pii                 pair<int,int>
#define pli                 pair<long long int,int>
#define mp(a,b)             make_pair(a,b)
#define fr(i,x,n)           for(int i=x;i<n;i++)
#define rfr(i,x,n)          for(int i=x;i>n;i--)
#define Lcm(a, b)           ((a)*((b)/Gcd(a,b)))
#define endl                '\n'
template<typename T>T Abs(T a) {return a < 0 ? -a : a;}
template<typename T>T Max(T a, T b) {return a > b ? a : b;}
template<typename T>T Min(T a, T b) {return a < b ? a : b;}
template<typename T>T Gcd(T a, T b) {return (!b) ? a : Gcd(b, a % b);}
template<typename T>T Pow(T a, T b) {if (!b)return 1; T t = Pow(a, b / 2); return b % 2 ? a * t * t : t * t;}
template<typename T>inline void read(T &x) {
    T f = 1; char c; x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())if (c == '-')f = -1;
    for (; c >= '0' && c <= '9'; c = getchar())x = x * 10 + c - '0';
    x *= f;
}
using fl = float;
using db = double;
using ll = long long;
using ull = unsigned long long;
const int mx = 1000005;
const int inf = 99999999;
const int intlim = 2147483648;
const db PI = acos(-1); //3.14159265358979323846264338328
/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};           // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};          // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
//#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//#endif
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=0;i<sz(a);i++)
    {
        if(a[i]!=b[i])cnt++;
    }
    cout<<cnt<<endl;
}



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

int get_index(int x, int y, int w) {
	return x + y * w;
}

void add_edge(vector<vector<int>> &G, int x1, int y1, int x2, int y2, int w) {
	const int a = get_index(x1, y1, w);
	const int b = get_index(x2, y2, w);
	G[a].emplace_back(b);
	G[b].emplace_back(a);
}

int bfs(int s, int g, const vector<vector<int>> &G) {
	const int n = G.size();
	vector<int> dist(n, -1);
	dist[s] = 1;

	queue<int> que;
	que.push(s);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		if(v == g) return dist[g];

		for(const auto &to : G[v]) {
			if(dist[to] == -1) {
				dist[to] = dist[v] + 1;
				que.push(to);
			}
		}
	}

	return -1;
}

int main() {
	for(int w, h; cin >> w >> h && w;) {
		const int n = w * h;
		vector<vector<int>> G(n);

		for(int i = 0; i < h; ++i) {
			// horizontal
			for(int j = 0; j < w - 1; ++j) {
				int ng;
				cin >> ng;

				if(!ng) add_edge(G, j, i, j + 1, i, w);
			}

			// vertical
			if(i != h - 1) {
				for(int j = 0; j < w; ++j) {
					int ng;
					cin >> ng;

					if(!ng) add_edge(G, j, i, j, i + 1, w);
				}
			}
		}

		const int ans = bfs(get_index(0, 0, w), get_index(w - 1, h - 1, w), G);
		cout << (ans == -1 ? 0 : ans) << endl;
	}

	return 0;
}

Measured memory_bytes: 1268
#include <cstdio>
using namespace std;
const int maxn=1e5+10;

int n,s;
int a[maxn];

int nxt(int p)
{
	if (p%6==0) return p+2;
	else if (p%6==2) return p+1;
	else if (p%6==3) return p+1;
	else return p+2;
}

int main()
{
	scanf("%d",&n);
	if (n<=5)
	{
		if (n==3) puts("2 5 63");
		else if (n==4) puts("2 5 20 63");
		else puts("2 5 20 30 63");
		return 0;
	}
	
	int now=0;
	s=0;
	for(int i=1;i<=n;i++)
	{
		now=nxt(now);
		a[i]=now;
		s=(s+now)%6;
	}
	
	if (s==2)
	{
		do
		{
			now=nxt(now);
		} while(now%6!=0);
		a[5]=now;
	}
	else if (s==3)
	{
		do
		{
			now=nxt(now);
		} while(now%6!=0);
		a[6]=now;
	}
	else if (s==5)
	{
		do
		{
			now=nxt(now);
		} while(now%6!=4);
		a[6]=now;
	}
	
	for(int i=1;i<=n;i++) printf("%d ",a[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> in(N, 0);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    in[u]++; in[v]++;
  }


  bool ans = true;
  REP(i, N) if(in[i]%2) ans = false;

  ans? YES: NO;

  return 0;
}

Measured memory_bytes: 1024
N=int(input())

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

a_max=100001
ans=[0]*(a_max)

for i in range(N):
    ans[a[i]]+=1

ll = [ans[0], ans[0]+ans[1], ans[a_max-2]+ans[a_max-1], ans[a_max-1]]

ans_a=max(ll)

for i in range(a_max-2):
    aa = ans[i]+ans[i+1]+ans[i+2]
    if aa>ans_a:
        ans_a=aa
    
print(ans_a)

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

void Main()
{
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3580
//Tree Walk
#include <iostream>

using namespace std;

static const int NIL = -1;

struct Node {
    int parent = NIL, left = NIL, right = NIL;
};

void preOrder(Node N[], int r) {
    cout << " " << r;
    if(N[r].left != NIL) preOrder(N, N[r].left);
    if(N[r].right != NIL) preOrder(N, N[r].right);
}

void inOrder(Node N[], int r) {
    if(N[r].left != NIL) inOrder(N, N[r].left);
    cout << " " << r;
    if(N[r].right != NIL) inOrder(N, N[r].right);
}

void postOrder(Node N[], int r) {
    if(N[r].left != NIL) postOrder(N, N[r].left);
    if(N[r].right != NIL) postOrder(N, N[r].right);
    cout << " " << r;
}


int main() {
    int n, id, left, right;
    cin >> n;
    Node N[n];
    for(int i = 0; i < n; i++) {
        cin >> id >> left >> right;
        if (left != NIL) {
            N[id].left = left;
            N[left].parent = id;
        }
        if (right != NIL) {
            N[id].right = right;
            N[right].parent = id;
        }
    }

    int r;
    for(int i = 0; i < n; i++) {if(N[i].parent == NIL) {r = i; break;}}

    cout << "Preorder" << endl;
    preOrder(N, r);
    cout << endl;
    cout << "Inorder" << endl;
    inOrder(N, r);
    cout << endl;
    cout << "Postorder" << endl;
    postOrder(N, r);
    cout << endl;
}



Measured memory_bytes: 3136