akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n, tmp, m, mini, maxi; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    sort(all(a));
    mini = a[0], maxi = a[n-1];

    queue<PII> outputs;
    for(i32 i = 1; i < n-1; ++i) {
        if(a[i] < 0) {
            outputs.emplace(maxi, a[i]);
            maxi -= a[i];
        }
        else {
            outputs.emplace(mini, a[i]);
            mini -= a[i];
        }
    }

    m = maxi - mini;
    outputs.emplace(maxi, mini);

    cout << m << '\n';
    while(outputs.size()) {
        cout << outputs.front().first <<' ' << outputs.front().second << '\n';
        outputs.pop();
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int n = s.size();
    vector<int> ans(n);
    int num = 0;
    rep(i,n) {
        if (s[i] == 'R') {
            num++;
        } else {
            ans[i-1] += (num+1)/2;
            ans[i] += num/2;
            num = 0;
        }
    }
    repr(i,n-1) {
        if (s[i] == 'L') {
            num++;
        } else {
            ans[i] += num/2;
            ans[i+1] += (num+1)/2;
            num = 0;
        }
    }

    rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,a[N],res;
map<int,int> Q;
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++)
    {
        a[i]=read();
        Q[a[i]]++;
    }
    for(ri map<int,int>::iterator s=Q.begin();s!=Q.end();s++)
    {
        int x=(s->first), y=s->second;
        if(y>=x) res+=y-x;
        else res+=y;
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 10396
def ans(N, M):
    if M == 0: return(N * N)
    ans = 0
    for i in range(1,N+1):
        p, q = divmod(N,i)
        ans += p * max(i-M,0) + max((q-M)+1,0)
    return(ans)

N, M = list(map(int, input().split()))
print(ans(N, M))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);

     int a, b, c;
     int sum=0;
     cin >> a >> b;
     for(int i=1; i<=b; i++){
     	cin >> c;
        sum = sum+c;

     }

     if(a < sum){
     	cout << "-1" << "\n";
     }else{
     	cout << a-sum << "\n";
     }

    
  return 0;

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint factorial(int k){
    mint res = 1;
    for(int i=1;i <=1;i++){
        res *= i;
    }
    return res;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    mint ans = 0;
    rep(i,n){
        rep(j,n){
            if(i<j&&a[i]>a[j]){
                ans += k*(k+1)/2;
            }
            if(i>j&&a[i]>a[j]){
                ans += (k-1)*k/2;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//Program.cpp
//Problem Statement - 

#include <bits/stdc++.h>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

//Author: Varun Goyal (@govarun)

#define f(i, n) for(int i=0;i<(n);++i)
#define fa(i, a, n) for(int i=(a);i<=(n);++i)
#define fd(i, a, n) for(int i=(a);i>=(n);--i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define popb pop_back
#define ull unsigned long long
#define debug if(GOVARUN) cerr
#define d0(x) debug <<#x<<" = "<<x<<' '
#define d1(x) debug <<"> "<<#x<<" = "<<x<<'\n'
#define d2(x, y) debug <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<'\n'
#define d3(x, y, z) debug <<"> "<<#x<<" = "<<x<<' '<<#y<<" = "<<y<<' '<<#z<<" = "<<z<<'\n'
#define endl '\n'
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector< pair<int, int> > vpii;
inline bool EQ(double a, double b) { 
return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }

const ll mod = 1e9 + 7;
const int maxn = 1e5 + 5;

void pre(){

    
}


void solve();

int main(){
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    #ifdef GOVARUN
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define GOVARUN 0
    #endif
    int TC = 1;
    // cin >> TC;
    while(TC--){    
        solve();
    }

    return 0;
}

void solve(){
    int n, W; cin >> n >> W;
    int w[n], v[n];
    f (i, n) {
        cin >> w[i + 1] >> v[i + 1];
    }
    ll val[n + 1][W + 1];
    fill( val);
    fa (i, 0, n) {
        fa (j, 0, W) {
            if (i == 0 || j == 0) val[i][j] = 0;
            else if (j >= w[i]) {
                val[i][j] = max(val[i - 1][j], val[i - 1][j - w[i]] + v[i]);
            }
            else val[i][j] = val[i - 1][j];
        }
    }
    cout << val[n][W];

}

Measured memory_bytes: 79232
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
typedef pair<ll ,pair<ll, ll > > iip;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1e15;
 
struct UnionFind{
    //ご本体
    vector<ll > tree;
    //高さ
    vector<ll > rank;
    //グループごとのサイズ
    vector<ll > size;
 
    //定義
    UnionFind(ll N) : tree(N), rank(N), size(N){
        for(int i = 0; i < N; i++){
            tree[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
 
    //どの根っこに属しているのか？さかのぼり続ける
    int root(int x){
        if(tree[x] == x){
            return x;
        }
        //経路圧縮
        return tree[x] = root(tree[x]);
    }
 
    //木と木を(高さが低い方に)くっつける
    ll unite(int x, int y){
        int tx = root(x);
        int ty = root(y);
        //xとyの根が同じならくっつけない
        if(tx == ty){
            return 0;
        }
        
        ll s = size[tx] + size[ty];
        ll r = size[tx] * size[ty];
        size[tx] = s;
        size[ty] = s;
 
        //tree[tx] = ty;
        //高くない方にくっつけたい：効果がいまいちわからん
        //下：ランク付けのつもり 
        if(rank[tx] < rank[ty]){
            //小さい方を大きい方
            //txの根が大きい方の根に更新
            tree[tx] = ty; 
        }else{
            tree[ty] = tx;
            //つなげるときに同じ高さだったらつなげた後に高さを＋１する
            if(rank[tx] == rank[ty]){
                rank[tx]++;
            }
        }
 
        return r;
 
    }
 
    //同じ木に属しているか？根っこをさかのぼって調べてみる
    bool same(int x, int y){
        int tx = root(x);
        int ty = root(y);
        if(tx == ty){
            return true;
        }else{
            return false;
        }
    }
    //グループのサイズを返す
    int FindSize(int x){
        return size[root(x)];
    }
 
};
 
int main(){

    ll N, K, L;
    cin >> N >> K >> L;

    UnionFind douro(N);
    UnionFind tetsudo(N);

    for(ll i = 0; i < K; i++){
        ll p, q; cin >> p >> q;
        p--; q--;
        douro.unite(p, q);
    }

    for(ll i = 0; i < L; i++){
        ll r, s; cin >> r >> s;
        r--; s--;
        tetsudo.unite(r, s);
    }

    //根と根が同じかどうかでまとめる
    //道路と鉄道両方を使ってたどり着けるなら同じ根要素になっているはず
    //ある都市から鉄道と道路のどちらをつかってもたどり着ける都市の
    //UnionFind上での根要素はおなじになるはず
    //そのペアについて数を数えると連結している都市を数えることになる
    map<vector<ll >, ll> mp;
    for(ll i = 0; i < N; i++){
        mp[vector<ll >{douro.root(i), tetsudo.root(i)}]++;
    }    


    for(ll i = 0; i < N; i++){
        cout << ( i ? " " : "" ) << mp[vector<ll >{douro.root(i), tetsudo.root(i)}];
    }
    cout << endl;

}

Measured memory_bytes: 29696
#include <iostream>
#include <cmath>


using namespace std;


typedef struct
{
  long long x, y;
} Grid;


long long man_dis(Grid a, Grid b)
{
  return (long long)abs(a.x-b.x)+(long long)abs(a.y-b.y);
}


int main()
{
  int n, m, i, j, idx;
  Grid s[50], c[50];
  long long minv, tmp;

  cin >> n >> m;
  for (i=0; i<n; i++) cin >> s[i].x >> s[i].y;
  for (i=0; i<m; i++) cin >> c[i].x >> c[i].y;

  for (i=0; i<n; i++){
    minv = 1000000000;
    for (j=0; j<m; j++){
      tmp = man_dis(s[i], c[j]);
      if (tmp < minv){
	minv = tmp;
	idx = j;
      }
    }
    cout << idx+1 << endl;
  }
  
  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector S(H + 2, vector(W + 2, '#'));
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) cin >> S.at(i).at(j);
  }
  for (auto s : S) {
    for (auto c : s) cout << c;
    cout << "\n";
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    vector<int> num(N, 1);
    vector<bool> red(N, false);
    red[0] = true;

    rep(i, 0, M)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        if (red[x])
        {
            red[y] = true;
        }

        --num[x];
        ++num[y];

        if (num[x] == 0)
        {
            red[x] = false;
        }
    }

    int ans = 0;
    rep(i, 0, N)
    {
        if (red[i])
        {
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
n, q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
for i in range(q):
    l, r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	if N == 0 || N == 1 {
		fmt.Println(0)
		return
	}

	ans := 0
	n := N

	var count, now int

	for i := 2; i*i <= N; i++ {
		count = 1
		now = count
		for n%i == 0 {
			n /= i
			count -= 1
			if count == 0 {
				now += 1
				count = now
				ans += 1
				continue
			}
		}
	}
	if n != 1 {
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1788
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long gogo[200000];
long long geko[200000];
long long cnt[200000];
int main() {
#define int long long
	int n, query;
	cin >> n >> query;
	if (query == 0) {
		REP(q, n) {
			cout << 1 << endl;
		}
		return 0;
	}
	vector<int> pre;
	REP(i, query) {
		int a;
		cin >> a;
		pre.push_back(a);
	}
	vector<int> inputs;
	inputs.push_back(pre[query - 1]);
	for (int i = query - 2; i >= 0; --i) {
		if (inputs[inputs.size() - 1] > pre[i]) {
			inputs.push_back(pre[i]);
		}
	}
	reverse(inputs.begin(), inputs.end());
	geko[inputs.size() - 1] = 1;
	for (int q = inputs.size() - 1; q >= 0; --q) {
		long long now_k = inputs[q];
		while (now_k >= inputs[0] && q != 0) {
			long long bot = 0;
			long long top = q;
			while (abs(bot - top) > 1) {
				long long mid = (top + bot) / 2;
				if (now_k >= inputs[mid]) {
					bot = mid;
				}
				else {
					top = mid;
				}
			}
			geko[bot] += geko[q] * (now_k / inputs[bot]);
			now_k %= inputs[bot];
		}
		long long cnter = now_k / n;
		gogo[1] += (geko[q] * cnter);
		gogo[n + 1] -= geko[q] * cnter;
		gogo[1] += geko[q];
		gogo[now_k % n + 1] -= geko[q];
	}
	for (long long i = 1; i < 200000; ++i) {
		gogo[i] += gogo[i - 1];
	}
	for (long long i = 1; i < 200000; ++i) {
		cnt[(i - 1) % n + 1] += gogo[i];
	}
	REP(i, n) {
		cout << cnt[i + 1] << endl;
	}
}


Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> t;
  int N = 1;
  while (1) {
    int tmp = N * (N + 1) / 2;
    if (tmp > 1e10) break;
    t.push_back(tmp);
    N++;
  }

  auto itr = lower_bound(all(t), n);
  int pos = itr - t.begin() + 1;
  int Ban = *itr - n;
  for (int i = 1; i <= pos; i++) {
    if (i != Ban) cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 2420
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	for i in range(1,6):
		if i not in al:
			print(i)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 61964
n = gets.to_i
p = gets.split.map(&:to_i)

a = b = nil

(0...n).each do |i|
  if p[i] != i+1
    if a.nil?
      a = i
    elsif b.nil?
      b = i
      tmp = p[a]
      p[a] = p[b]
      p[b] = tmp
    else
      puts 'NO'
      exit
    end
  end
end
puts 'YES'

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


string divide[4] = {"dream", "dreamer", "erase", "eraser",};

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

    reverse(s.begin(), s.end());
    for(int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

    bool flag1 = true;
    for(int i = 0; i < s.size();)
    {
        bool flag2 = false;
        for(int j = 0; j < 4; j++)
        {
            string d = divide[j];

            if(s.substr(i, d.size()) == d)
            {
                flag2 = true;
                i += d.size();
            }
        }

        if(!flag2)
        {
            flag1 = false;
            break;
        }
    }

    if(flag1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
import numpy as np

N=int(input())
X=np.array(list(map(int,input().split())))

a=np.sort(X)
n=len(X)//2

an_1=a[n-1]
an=a[n]

for i in range(N):
    if X[i]>=an:
        print(an_1)
    else:
        print(an)


Measured memory_bytes: 34156
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

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

    string s;
    cin >> s;

    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No";
    }
    else cout << "Yes";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
string a,b;
void solve()
{
    long long i,j,l1=a.length(),l2=b.length(),ans=100000000000;
    for (i=0;i<=l1-l2;i++)
    {
        string tmp;
        for (j=0;j<l2;j++)
            tmp.push_back(a[i+j]);
        long long res=0;
        for (j=0;j<l2;j++)
            if (tmp[j]!=b[j]) res++;
        ans=min(ans,res);
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

Measured memory_bytes: 3180
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

ll const MAX_N = 1e5 + 10;
bool done[MAX_N];

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


int main() {
	ll i, j;
	ll N, D;
	cin >> N >> D;
	ll ans;
	ans = N / (2 * D +1);
	if (N > ans * (2 * D + 1)) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

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

  int count = 0;
  for (int i = 0; i < 3; i++) {
	if (a[i] == b[i])
	  count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  vector<int> c(9);
  REP(i,9){
    cin >> c.at(i);
  }
  if (c.at(2) - c.at(1) == c.at(5) - c.at(4) && c.at(5) - c.at(4) == c.at(8) - c.at(7)){
    if (c.at(1) - c.at(0) == c.at(4) - c.at(3) && c.at(4) - c.at(3) == c.at(7) - c.at(6)){
      if (c.at(6) - c.at(3) == c.at(7) - c.at(4) && c.at(7) - c.at(4) == c.at(8) - c.at(5)){
        if (c.at(3) - c.at(0) == c.at(4) - c.at(1) && c.at(4) - c.at(1) == c.at(5) - c.at(2)){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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.printf("%d %d %d\n",a,b,c);
            }else if(c < a){
                System.out.printf("%d %d %d\n",c,a,b);
            }else System.out.printf("%d %d %d\n",a,c,b);
        }
        if(b<a){
            if(a<c){
                System.out.printf("%d %d %d\n",b,a,c);
            }else if(c<b){
                System.out.printf("%d %d %d\n",c,b,a);
            }else System.out.printf("%d %d %d\n",b,c,a);
        }
    }
}


Measured memory_bytes: 26496
# include <bits/stdc++.h>
using namespace std;
const int maxn=1000+500;
int main ()
{
	int n;
   int a,b;
   int ans=0;
   cin>>n>>a>>b;
   for (int i=0;i<n;++i)
      {
      	int x,y;
      	cin>>x>>y;
      	if (x>=a&&y>=b)
      	  ans++;
	  }
	printf ("%d\n",ans);
   return 0;
	
 } 

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

k,x = list(map(int, stdin.readline().rstrip().split()))
ans = []
for i in range(x-k+1,x+k):
	ans.append(i)
print(*ans)


Measured memory_bytes: 39408
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

Vi v[700];
bool chk[700][700];
int col[700];
VPi vv;
Pi bfs(int N,int c)
{
	Pi res=mp(0,0);
	if(c==0)res.X++;
	else res.Y++;
	col[N]=c;
	for(int next:v[N])
	{
		if(col[next]!=-1)
		{
			if(col[next]==c)
			{
				puts("-1");
				exit(0);
			}
		}
		if(col[next]==-1)
		{
			Pi p=bfs(next,1-c);
			res.X+=p.X;
			res.Y+=p.Y;
		}
	}
	return res;
}
int N,n,m;
int d[701][701];
int go(int nn,int k)
{
	if(nn==N)return abs(n-2*k);
	int &ret=d[nn][k];
	if(ret!=-1)return ret;
	ret=INF;
	ret=min(go(nn+1,k+vv[nn].X),go(nn+1,k+vv[nn].Y));
	return ret;
}
int main() {
	MEM_1(d);
	MEM_1(col);
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		if(x>y)swap(x,y);
		chk[x][y]=1;
	}
	fup(i,0,n-1,1)
	{
		fup(j,i+1,n-1,1)
			if(!chk[i][j])
			{
				v[i].pb(j);
				v[j].pb(i);
			}
	}
	fup(i,0,n-1,1)
	{
		if(col[i]==-1)
		{
			vv.pb(bfs(i,0));
		}
	}
	N=vv.size();
	int t=go(0,0);
	fup(i,0,n,1)
	{
		int j=n-i;
		if(j-i==t)
		{
			return !printf("%d",i*(i-1)/2+j*(j-1)/2);
		}
	}
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+1;

int n,a[N];
ll ans;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)if(a[i]>=i||a[i]>a[i-1]+1)return 0*printf("-1\n");
	int l=n;
	for(int i=n;~i;--i){
		if(a[i]==a[i+1]-1)continue;
		ans+=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-9
#define PB push_back
#define fi first
#define se second
#define reps(i,j,k) for(int i = j; i < k; i++)
#define rep(i,j) reps(i,0,j)
using namespace std;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
typedef long long ll;
typedef pair<int,int> Pii;
int main(){
    int n;
    while(scanf("%d",&n),n){
        bool flg[12800]={0};
        vector < int > numbers;
        reps(i,1,n/2+1){
            int tmp = (i*i)%n;
            if(flg[tmp]++)continue;
            numbers.PB(tmp);
        }
        int cnt[12800]={0};
        int len = numbers.size();
        sort(numbers.begin(),numbers.end());
        rep(i,len){
            reps(j,i+1,len){
                int tmp = numbers[j]-numbers[i];
                if(tmp > (n-1)/2)tmp = n-tmp;
                cnt[tmp]++;
            }
        }
        reps(i,1,(n-1)/2+1){
            printf("%d\n",2*cnt[i]);
        }
    }
    return 0;
}

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

using namespace std;

const int maxn = 110;

int ans[maxn][maxn];

int main(){
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	int dir = 1;
	int hi = 0;
	int col = 0;
	for (int i = 0; hi < h; i += dir){
		if (a[col] == 0){
			col++;
		}
		
		ans[i][hi] = col;
		a[col]--;
		if (i == 0 && dir == -1){
			dir = 1;
			i--;
			hi++;
		}
		if (i == w-1 && dir == 1){
			dir = -1;
			hi++;
			i++;
		}
	}

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cout << ans[j][i] + 1 << ' ';
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/

char base[10] = { '0','1','2','3','4','5','6','7','8','9' };
char S[10];
int len;
int Sn[10];

void StoSn()
{
	for (int i = 0; i <= len; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (S[i] == base[j])
			{
				Sn[i] = j;
				break;
			}
		}
	}
}

int R2[11] = { 1,2,4,8,16,32,64,128,256,512,1024 };

//S[i]の後以降の計算
long long int calc(int i, long long int now)
{
	//i==len-1のとき
	if (i == len) return now;

	//S[i]の後に+を入れるもの
	long long int x = now * R2[len - i - 1] + calc(i + 1, Sn[i + 1]);

	//S[i]の後に+を入れないもの
	long long int y = calc(i + 1, now * 10 + Sn[i + 1]);

	return x + y;
}

/*ここからmain関数*/

int main()
{
	cin >> S;
	len = strlen(S) - 1;
	StoSn();

	/*for (int i = 0; i <= len; i++)
	{
		cout << Sn[i];
	}
	cout << "\n";*/

	/*cout << len << "\n";*/



	cout << calc(0, Sn[0]);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
const int N = 1e5+200;
const ll Mod = 1e5;
const int INF = 0x3f3f3f3f;
int a[N] = {0};
int b[N] = {0};
int main(){
  int n,m;
  cin>>n>>m;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);
  vector<pair<int,int> > vct;
  for(int i = 0; i < m; i++){
    int x,y;
    cin>>x>>y;
    vct.push_back({y,x});
  }
  sort(vct.begin(),vct.end());
  int n2 = vct.size();
  int k = n2-1;
  for(int i = 0; i < n; i++){
    if(a[i] < vct[k].first){
      a[i] = vct[k].first;
      vct[k].second--;
    }
    if(vct[k].second == 0){
      k--;
    }
    if(k < 0 ){
      break;
    }
  }
  ll sum = 0;
  for(int i = 0; i < n; i++){
    sum += a[i];
  }
  cout<<sum<<endl;
	return 0;
}
// abc

Measured memory_bytes: 1784
n, k = map(int, input().split())
ttl = 0

for i in range(1, n+1):
    tm, p = 0, 0
    while i * (2**p) < k:
        p += 1

    d = (2**p)
    sc = 1/(n*d)
    ttl += sc

print(ttl)


Measured memory_bytes: 2940
N, K = map(int,input().split())

N_list = [i for i in range(1, N+1)]

for i in range(K):
    d = int(input())
    A = [int(_) for _ in input().split()]
    
    for a in A:
        if (a in N_list) == True:
            N_list.remove(a)

print(len(N_list))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     int a,p;
     cin >> a >> p;
     cout << (a*3+p)/2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
    ll a;
    cin>>a;
   
    ll h= (a/500)*1000;

     a%=500;

     h+=(a/5)*5;
     print(h);
    return 0;
}

Measured memory_bytes: 256
N,H = list(map(int,input().split()))
A=[]
for i in range(N):
    a,b = list(map(int,input().split()))
    A.append([a,"a"])
    A.append([b,"b"])

A=sorted(A,key=lambda x:x[0],reverse=True)
count=0
for i in range(2*N):
    if A[i][1]=="a":
        if H%A[i][0]==0:
            count+=H//A[i][0]
        else:
            count+=H//A[i][0] + 1
        H=0
    else:
        H-=A[i][0]
        count+=1
    if H<=0:
        break

print(count)

Measured memory_bytes: 35220
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,Q = map(int,input().split())
S = input().rstrip() + "Z"
LR = [map(int,input().split()) for _ in range(Q)]

A = [0]*(N+1)
for i in range(N):
    if S[i]=="A" and S[i+1]=="C":
        A[i+1] = 1
for i in range(i):
    A[i+1] += A[i]

for l,r in LR:
    print(A[r-1]-A[l-1])

Measured memory_bytes: 53636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
	int64_t x;
	mint(int64_t x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(int64_t t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//head

int n;
ll k;
mint mat[50][50], wo[50][50], wo1[50][50], res[50][50];

void mul() {
	memset(res, 0, sizeof(res));
	rep(i, n) rep(j, n) rep(k, n) {
		res[i][j] += wo[i][k] * wo1[k][j];
	}
}

void pow(ll p) {
	if(!p) {
		memset(res, 0, sizeof(res));
		rep(i, n) res[i][i] = 1;
		return;
	}
	pow(p>>1);
	rep(i, n) rep(j, n) wo[i][j] = res[i][j];
	rep(i, n) rep(j, n) wo1[i][j] = res[i][j];
	mul();
	if(p&1) {
		rep(i, n) rep(j, n) wo[i][j] = res[i][j];
		rep(i, n) rep(j, n) wo1[i][j] = mat[i][j];
		mul();
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	rep(i, n) rep(j, n) cin >> mat[i][j];

	pow(k);
	mint ans;
	rep(i, n) rep(j, n) ans += res[i][j];

	cout << ans << endl;
}

Measured memory_bytes: 3732
from itertools import permutations

N = int(input())
p = ''.join(input().split())
q = ''.join(input().split())

l = permutations(range(1, N+1))
l2 = []
for i in l:
    l2.append(''.join(map(str, i)))
l = sorted(l2)

p_idx = 0
q_idx = 0
for n, i in enumerate(l):
    if i == p:
        p_idx = n
    if i == q:
        q_idx = n
print(abs(p_idx-q_idx))

Measured memory_bytes: 12112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int a[] = new int[n];
		int b[] = new int[n];
		
		long result = 0;
		
		long minB = Long.MAX_VALUE;
		
		boolean same = true;
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			
			a[i] = Integer.parseInt(tmpArray[0]);
			b[i] = Integer.parseInt(tmpArray[1]);
			
			result += a[i];
			
			if(a[i] > b[i] && minB > b[i]){
				minB = b[i];
			}
			
			if(a[i] != b[i]){
				same = false;
			}
		}
		
		if(!same){
			result -= minB;
		}
		else {
			result = 0;
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 33364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;

//二項係数
//参考 http://drken1215.hatenablog.com/entry/2018/06/08/210000
#define MAX 100005
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int find1(string s,int x){
    if(x>=s.length()) return 0;
    int a=s[x]-'0';
    return 9*(s.length()-1-x)+a;
}

int find2(string s,int x){
    if(x>=s.length()) return 0;
    int a=s[x]-'0';
    int i=x+1;
    while(s[i]-'0'==0&&i<s.length()) i++;
    return COM(s.length()-1-x,2)*pow(9,2)+find1(s,i)+(a-1)*(s.length()-1-x)*9;
}

int find3(string s,int x){
    int a=s[x]-'0';
    int i=x+1;
    while(s[i]-'0'==0&&i<s.length()) i++;
    return find2(s,i)+COM(s.length()-1-x,3)*pow(9,3)+(a-1)*COM(s.length()-1-x,2)*pow(9,2);
}

int main(){
    COMinit();
    string s;
    int k;
    cin>>s>>k;
    if(k==3) cout<<find3(s,0);
    else if(k==2)cout<<find2(s,0);
    else cout<<find1(s,0);
    cout<<endl;
}

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

int r;

int main() {
	cin >> r;
	if(r<1200){
		cout << "ABC" << endl;
	}
	else if(r<2800){
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
v = [i for i in map(int,input().split())]
v_odd = v[::2]
v_even = v[1::2]
odd_nums = (collections.Counter(v_odd)).most_common()
even_nums = (collections.Counter(v_even)).most_common()
ans = 0
if odd_nums[0][0] != even_nums[0][0]: # 最頻出数値が等しくない場合
  for i in range(1,len(odd_nums)):
    ans += odd_nums[i][1]
  for i in range(1,len(even_nums)):
    ans += even_nums[i][1]
else: # 最頻出数値が等しい場合
  ans1=0
  ans2=0
  for i in range(1,len(odd_nums)):
    ans1 += odd_nums[i][1]
  for i in range(len(even_nums)):
    if i==1:
      continue
    ans1 += even_nums[i][1]
  for i in range(len(odd_nums)):
    if i==1:
      continue
    ans2 += odd_nums[i][1]
  for i in range(1,len(even_nums)):
    ans2 += even_nums[i][1]
  ans = min(ans1,ans2)
    
print(ans)

Measured memory_bytes: 21212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

  ll h;
  cin >> h;
  ll cnt = 0;
  ll p = 1;
  while (h > 0)
  {
    h /= 2;
    cnt += p;
    p *= 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n,k,s;cin>>n>>k>>s;
	int ans[N];
	int m;
	if(s>pow(10,5)) m=1;
	else m=pow(10,7);
	rep(i,n){
		if(i<k) ans[i]=s;
		else ans[i]=m;
	}
	rep(i,n-1) cout<<ans[i]<<' ';
	cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <cstring>
#include <iostream>
#include <random>
#include <string>
#include <vector>

int main()
{
    int n, a;
    std::cin >> n;
    std::vector<int> vec;

    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        vec.push_back(a - 1);
        vec.push_back(a);
        vec.push_back(a + 1);
    }
    std::sort(vec.begin(), vec.end());
    int ans = 0, prev = vec[0], tmpans = 0;
    for (auto i : vec)
    {
        if (prev != i)
        {
            ans = std::max(ans, tmpans);
            tmpans = 0;
        }
        prev = i;
        tmpans++;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll a, b;
string s;
int main() {
	cin >> a >> b;
	cout << min(a, b / 2) + max(0ll, b - a * 2) / 4 << endl;
}	


Measured memory_bytes: 256