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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,c,d[30][30],e[500][500],memo[30][3],ans=INF;

signed main() {
    cin >> n >> c;
    rep(i,c) rep(j,c) cin >> d[i][j];
    rep(i,n) rep(j,n) cin >> e[i][j];
    rep(k,c) {
        int tmp=0;
        rep(i,n) rep(j,n) memo[k][(i+j)%3] += d[e[i][j]-1][k];
    }
    rep(i,c) rep(j,c) rep(k,c) {
        if (i == j || i == k || j == k) continue;
        ans = min(ans, memo[i][0] + memo[j][1] + memo[k][2]);
    }
    cout << ans << endl;
}





Measured memory_bytes: 2176
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
int main() {
    char c;
    cin >> c;
    c++;
    cout <<  c<< endl;
    
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	pakuri_sort(N, A);

	int L1 = 0, L2 = 0;
	int i = N - 1;
	for (; i >= 1; i--) {
		if (A[i - 1] == A[i]) {
			L1 = A[i];
			break;
		}
	}
	i -= 2;
	for (; i >= 1; i--) {
		if (A[i - 1] == A[i]) {
			L2 = A[i];
			break;
		}
	}

	printf("%lld", (ll)L1 * L2);

	Would you please return 0;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
    n, m = tuple([int(s) for s in input().split()])
    digits = [None] * 3
    failed = False

    for i in range(m):
        si, ci = tuple([int(s) for s in input().split()])

        if si > n:
            print(-1)
            failed = True
            break
        elif digits[n - si] is not None and digits[n - si] != ci:
            print(-1)
            failed = True
            break
        else:
            digits[n - si] = ci

    if not failed:
        if digits[-1] == 0 and n > 1:
            print(-1)
        else:
            digits = digits[:n]
            digits.reverse()
            if digits[0] is None and n > 1:
                digits[0] = 1
            for j in range(len(digits)):
                if digits[j] is None:
                    digits[j] = 0

            print("".join(["{}".format(d) for d in digits]))


Measured memory_bytes: 3064
# agc004_a.py
A,B,C = map(int,input().split())
if A%2 == 0 or B%2 == 0 or C%2 == 0 :
    print(0)
    exit()
L = abs(A*B*(C//2) - (A*B*(C-C//2)))
N = abs(A*C*(B//2) - (A*C*(B-B//2)))
M = abs(C*B*(A//2) - (C*B*(A-A//2)))

print(min(L,N,M))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  int cnt1 = 0;
  for(int i = 0; i < s.size() - 1; ++i) {
    if(s[i] == s[i+1]) {
      s[i] == '0' ? s[i+1] = '1' : s[i+1] = '0';
      cnt1++;
    }
  }

  int cnt2 = 1;
  s[0] == '0' ? s[0] = '1' : s[0] = '0';
  for(int i = 0; i < s.size() - 1; ++i) {
    if(s[i] == s[i+1]) {
      s[i] == '0' ? s[i+1] = '1' : s[i+1] = '0';
      cnt2++;
    }
  }

  std::cout << (cnt1 < cnt2 ? cnt1 : cnt2) << '\n';
  return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int N;
pii arr[100'010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> arr[i].first;
		arr[i].second = i + 1;
	}
	sort(arr, arr + N);
	for (int i = 0; i < N; ++i)
		cout << arr[i].second << " ";
}

Measured memory_bytes: 1664
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r_pref = 0, r_suf = 0, w_pref = 0, w_suf = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') w_suf++;
    else r_suf++;
  }
  int ret = n;
  for (int i = 0; i <= n; i++) {
    ret = min(ret, max(w_pref, r_suf));
    if (i < n) {
      if (s[i] == 'W') {
        w_suf--, w_pref++;
      } else {
        r_suf--, r_pref++;
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<long long>> dp(N + 1, vector<long long>(4, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    dp[i + 1] = dp[i];
    if (S[i] == 'A'){
      dp[i + 1][1] += dp[i][0];
      dp[i + 1][1] %= MOD;
    }
    if (S[i] == 'B'){
      dp[i + 1][2] += dp[i][1];
      dp[i + 1][2] %= MOD;
    }
    if (S[i] == 'C'){
      dp[i + 1][3] += dp[i][2];
      dp[i + 1][3] %= MOD;
    }
    if (S[i] == '?'){
      dp[i + 1][0] = dp[i][0] * 3 % MOD;
      dp[i + 1][1] = (dp[i][1] * 3 + dp[i][0]) % MOD;
      dp[i + 1][2] = (dp[i][2] * 3 + dp[i][1]) % MOD;
      dp[i + 1][3] = (dp[i][3] * 3 + dp[i][2]) % MOD;
    }
  }
  cout << dp[N][3] << endl;
}

Measured memory_bytes: 7424
s = input()

c_word ='keyence'


if c_word in s:
    print("YES")
else:
    for i in range(1, 7):
        w_a = c_word[:i]
        w_b = c_word[i:]

        if s.find(w_a) == 0 and s[len(w_a):][::-1].find(w_b[::-1]) == 0:
            print("YES")
            exit(0)
    else:
        print("NO")





Measured memory_bytes: 3060
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int a,b,h,m;
static const double pi = 3.141592653589793;

void solve(){
    cin >> a >> b >> h >> m;
    double ans=0;
    double theta;
    
        double sh=(h*(360/12))+m*0.5;
        double lg=m*(360/60);
        theta=abs(lg-sh);
        theta=min(theta,(360-theta));
        theta=(theta)*(pi/180);
        ans=a*a+b*b-2*a*b*cos(theta);
        ans=sqrt(ans);
        printf("%.10f\n",ans);
    

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 4256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0; i < s.size(); i ++) {
		ans += (s[i] == 'o') * 100;
	}
	printf("%d\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, Q; cin >> N >> Q;
    vector<PiP> p(N);
    int S, T, X;
    REP(i, N){
        cin >> S >> T >> X;
        p[i] = PiP(X, Pii(S, T));
    }
    Sort(p);

    vec D(Q); cin >> D;
    set<int> s;
    REP(i, Q) s.insert(D[i]);
    map<int, int> ans;

    REP(i, N){
        int x = p[i].f, t1 = p[i].s.f, t2 = p[i].s.s;
        t1 -= x;
        t2 -= x;
        auto it1 = s.lower_bound(t1);
        auto it2 = it1;
        while(it2 != s.end() && (*it2) < t2){
            ans[*it2] = x;
            it2++;
        }
        s.erase(it1, it2);
    }
    for(int i: s) ans[i] = -1;
    vec ans2;
    REP(i, Q) ans2.pb(ans[D[i]]);
    Out(ans2);

    return 0;
}


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

int main() {
long long int N, a, cnt = 0;
cin >> N;
long long int arry[N], srt[N];

for (int i = 0; i < N; ++i)
{	cin >> a;
	arry[i] = a;
	srt[i] = a;
}
sort(srt, srt+N);
for (int i = 0; i < N; ++i)
{
if(arry[i] != srt[i]) cnt++;	
}

if(cnt <=2) cout << "YES" << endl;
else cout << "NO" << endl; 	

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    int n, m, q; cin >> n >> m >> q;
    // a[i][j] 区間がi<=x<=jの電車
    vector<vector<int>> a(n+1, vector<int>(n+1, 0)), s(n+1, vector<int>(n+1, 0));
    REP(i, m){
        int l, r; cin >> l >> r;
        a[l][r]++;
    }
    REP(i, n)
        REP(j, n)
            s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + a[i+1][j+1];
            
    REP(i, q){
        int l, r; cin >> l >> r;
        cout << s[r][r] + s[l-1][l-1] - s[l-1][r] - s[r][l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char S[27];
	scanf("%s", &S);
	int f[26] = { 0 };
	int ng = 0;
	for (int i = 0; i < strlen(S); i++) {
		f[S[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (f[i] > 1) {
			ng = 1;
			break;
}
	}
	if (ng) {
		puts("no");
	}
	else {
		puts("yes");
	}



#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
const int MAXH=8;
const int MAXCOL=6;
const int MAXT=7;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int H,W,C;
int map[MAXH][MAXH][MAXT];
bool visited[MAXH][MAXH];

void copymap(int moto,int to){
     for(int i=0;i<H;i++){
	  for(int j=0;j<W;j++){
	       map[i][j][to]=map[i][j][moto];
	  }
     }
}

void recmap(int x,int y,int col,int tocol,int t){
     //cout<<col<<":"<<tocol<<endl;
     if(x>H-1||y>W-1||x<0||y<0)return;
     if(visited[x][y])return;
     if(map[x][y][t]!=col)return;
     map[x][y][t]=tocol;
     visited[x][y]=true;
     for(int i=0;i<4;i++){
	  recmap(x+dx[i],y+dy[i],col,tocol,t);
     }
     return;
}

int countup(int x,int y,int col,int t){
     if(x>H-1||y>W-1||x<0||y<0)return 0;
     if(visited[x][y])return 0;
     if(map[x][y][t]!=col)return 0;
     visited[x][y]=true;
     int sum=0;
     for(int i=0;i<4;i++){
	  sum+=countup(x+dx[i],y+dy[i],col,t);
     }
     return sum+1;
}

int ans=0;
void rec(int tocol,int t){
     //if(map[0][0][t]==tocol)return;
     for(int i=0;i<H;i++){
	  for(int j=0;j<W;j++){
	       visited[i][j]=false;
	  }
     }
     recmap(0,0,map[0][0][t],tocol,t);
     if(t+1==6){
	  copymap(t,t+1);
	  recmap(0,0,map[0][0][t+1],C,t+1);
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W;j++){
		    visited[i][j]=false;
	       }
	  }
	  ans=max(ans,countup(0,0,C,t+1));
	  return;
     }
     for(int i=0;i<MAXCOL;i++){
	  copymap(t,t+1);
	  rec(i,t+1);
     }
}

void solve(){
     ans=0;
     for(int i=0;i<MAXCOL;i++){
	  copymap(0,1);
	  rec(i,1);
     }
}
     
int main(){
     while(cin>>H>>W>>C,H||W||C){
	  --C;
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W;j++){
		    int t;
		    cin>>t;
		    --t;
		    map[i][j][0]=t;
	       }
	  }
	  solve();
	  cout<<ans<<endl;
	  /*for(int i=0;i<H;i++){
	    for(int j=0;j<W;j++){
	    cout<<map[i][j][3]+1;
	    }
	    cout<<endl;
	    }
	    cout<<endl;*/
     }
}

Measured memory_bytes: 868
#include <iostream>
using namespace std;
int main() {
	long long check = 7;
	int count;
	cin >> count;
	for (int i = 1; i < 1e7; i++) {
		if (check % count == 0) {
			cout << i;
			return 0;
		}
		check = (check * 10) + 7;
		check %= count;
	}
	cout << "-1";
}

Measured memory_bytes: 3568
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    
    int n;
    int a,b;
    int flag = 0;
 
    cin >> n;
 
    for(a=1;a<=9;a++){
        for(b=1;b<=9;b++){
            if(n == a*b){
                flag = 1;
                break;
            }
 
        }
    }
 
    if (flag == 1)
    printf("Yes\n");
 
    else
    printf("No\n");
 
	return 0;
}

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

int main() {
    int w, h, x, y;
    std::cin >> w >> h >> x >> y;
    double area = (double)w * h / 2;

    std::cout << area;
    if (x * 2 == w && y * 2 == h) {
        std::cout << " 1" << std::endl;
    } else {
        std::cout << " 0" << std::endl;
    }
}


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

int main(int argc, char const *argv[]) {
    int counter[26] = {0};
    char ch;

    while (cin >> ch) {
        int num;
        if (isalpha(ch)) {
            if(isupper(ch)) {
                ch = tolower(ch);
            }
            num = ch - 'a';
        counter[num]++;
        }
    }

    for (int i = 0; i < 26; i++) {
        ch = 'a' + i;
        cout << ch << " : " << counter[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 ans[200010];
bool checked[200010];
ll p[200010];
vector<vector<int>> v;
void dfs(ll sum,int pos){
    checked[pos]=true;
    ll ssum=sum+p[pos];
    ans[pos]=ssum;
    for(int i=0;i<v[pos].size();i++){
        if(!checked[v[pos][i]]){
            dfs(ssum,v[pos][i]);
        }
    }
}
int main(){
    int n,q;
    cin>>n>>q;
    v.resize(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].push_back(b);v[b].push_back(a);
    }
    rep(i,q){
        int t;ll x;
        cin>>t>>x;t--;
        p[t]+=x;
    }
    dfs(0,0);
    rep(i,n-1){
        cout<<ans[i]<<' ';
    }
    cout<<ans[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 22656
using System;

namespace nPRG {
	class cPRG {
		static void Main() {
			string[] str = (Console.ReadLine()).Split(' ');
			switch(Math.Sign(int.Parse(str[0]) - int.Parse(str[1]))) {
				case 0:
				Console.WriteLine("a == b");
				break;

				case 1:
				Console.WriteLine("a > b");
				break;

				case -1:
				Console.WriteLine("a < b");
				break;
			}
		}
	}
}

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

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, k;
  cin >> n >> k;
  vi p(n);
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    p[i] = a;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += p[i];
  }
  cout << ans << endl;


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


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

int main()
{
 string s,t;
  cin>>s>>t;
  t = t+t;
  auto f = t.find(s);
  if(f!=string::npos)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  
  
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    a71(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a71(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (current, first, second) = args[0].split(" ").map { it.toInt() }
    fun abs(a: Int, b: Int): Int = if (a - b >= 0) a - b else b - a
    println(if (abs(current, first) < abs(current, second)) "A" else "B")
}

Measured memory_bytes: 36296
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a;
	a = intinput();
	cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=input()+'XXX'
    ans=0
    for i in range(N):
        if S[i]=='A' and S[i+1]=='B' and S[i+2]=='C':
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 10001;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  int maxtwin[10001],twin;
  for(int i=5;i<10001;i++){
    if(prime[i]&&prime[i-2])twin = i;
    maxtwin[i]=twin;
  }
  for(int n;scanf("%d",&n),n;){
    cout<<maxtwin[n]-2<<" "<<maxtwin[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


s = input()
xs = set(s)
if (len(xs) == 2 and all(s.count(i) == 2 for i in xs)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    stack<int> downstair;
    stack< pair<int, int> > pool;

    string cmd;
    cin >> cmd;

    int sum = 0;
    for (int i = 0; i < cmd.length(); i++) {
        const char& ch = cmd[i];
        if (ch == '\\') {
            downstair.push(i);
        } else if (ch == '/' and downstair.size() > 0) {
            int j = downstair.top(); downstair.pop();
            int amount = i - j;
            sum += amount;
            while (pool.size() > 0 and pool.top().first > j) {
                amount += pool.top().second; pool.pop();
            }
            pool.push(make_pair(j, amount));
        }
    }

    vector<int> ans;
    while (pool.size() > 0) { ans.push_back(pool.top().second); pool.pop(); }
    reverse(ans.begin(), ans.end());

    cout << sum << endl;
    cout << ans.size();
    for (const auto& elm : ans) {
        cout << " " << elm;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3252
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n,pon;
  cin >> n;

  pon = n % 10;
  switch(pon){
  case 2:
  case 4:
  case 5:
  case 7:
  case 9:
    cout << "hon" << endl;
    break;
  case 0:
  case 1:
  case 6:
  case 8:
    cout << "pon" << endl;
    break;
  case 3:
    cout << "bon" << endl;
    break;
  }
    

  
  return 0;
}


Measured memory_bytes: 3592
/*
power code taken from geeks for geeks
*/
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;


const ll INF = 1e18 + 5;
const ll MAX_N = 2e5 + 5;
const ll MODD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
ld modd(ld a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return (a + MODD) % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str {
    ll a, b;
};

// vector<ll> adj[MAX_N];
// bool visited[MAX_N];
ll cnt = 0;
void _dfs(ll s, vector<ll> adj[], bool visited[]) {
    visited[s] = 1;
    cnt++;
    for(ll ch: adj[s]) {
        if(visited[ch]) {
            continue;
        }
        _dfs(ch, adj, visited);
    }
}


void solve() {
    ll n, m;
    cin >> n >> m;


    vector<ll> adj[n + 5];
    bool visited[n + 5];
    for(ll i = 0; i <= n; i++) {
        visited[i] = 0;
    }

    ll u, v;
    // map<string, int> seen;
    string k1, k2;
    for(ll i = 0; i < m; i++) {
        cin >> u >> v;
        // k1 = to_string(u) + "|" + to_string(v);
        // k1 = to_string(v) + "|" + to_string(u);
        // if(seen[k1]) {
        //     continue;
        // }
        adj[u].push_back(v);
        adj[v].push_back(u);
        // seen[k1] = 1;
        // seen[k2] = 1;
    }


    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        if(visited[i] == 0) {
            cnt = 0;
            _dfs(i, adj, visited);
            ans = max(ans, cnt);

            // cout << "i " << i << " c " << c << endl;
        }
    }
    cout << ans << endl;


}


int main(){

  


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    

    ll t=1;

    // cin>>t;


    while(t--){
        
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 24056
n,k = map(int, input().split())
a = list(map(int, input().split()))
gru = [0]*(k+1)
for i in range(1,k+1):
  for x in a:
    if i-x >= 0 and gru[i-x] == 0:
      gru[i] = 1
      break
t = ["Second","First"]
print(t[gru[k]])

Measured memory_bytes: 41836
/* 
   x日間悩み、
   動的計画法(メモ化)でやろうということを思いついた。
   数学的に解が得られる方法は複数ありうる。
   しかし、0 < m \leq 11 and 0 < n \leq 128 という制約の中で
   制限に引っかからなそうなものとなると、状態の持ち方が限られる。
   
   たとえば自然な発想として、
   「n個のonjectの各部分集合を状態として持ち、それを類別するために必要な最小の
   質問回数」を配列で持とうとするものが考えられる。
   しかし2^{128}個のintはメモリの上においておくのは無理である。
   よく考えてみると相当無駄がある。質問はm \leq 11個しかない
   だから「出てきうる」部分集合の個数は、せいぜい3^{11}個であり、2^{128}より
   はるかに少ない。
   
   そこで、
   「m個の質問それぞれを『未回答』『はい』『いいえ』をみたす
   onjectの集合を状態として持ち、それを類別するために必要な最小の
   質問回数」を配列で持とう。これなら3^{11}個である。
   (ただし以下の実装の2次元配列のサイズは2^{11} \times 2^{11}である)
   
   次なる問題はどのようにしてこの動的計画法を進めるかである。
   ここでさらにy日悩んだが、
   「集合の元の数が1個か0個」は0とし、
   あとは深さ優先探索を併用している。
   完全に再帰でやるとメモリ足りないかもしれないので、
   『未回答』が少ない集合からまわしていき、
   あまり深すぎないように努力した。
 */

#include <iostream>
#include <vector>
#include <cassert>
#include <string>
using namespace std;

vector< vector<int> > V; // [0:未回答 1:回答済み][0:Yes 1:No]
int n, m, C;
vector<int> W;
const int infty = 1000;
vector< vector<int> > X; // X[i] = i個bitが立っている集合

void init() {
  C = (1 << m);
  V.clear();
  V = vector< vector<int> >(C, vector<int>(C, infty));
  W.clear();
  for (auto i=0; i<n; i++) {
    long long w;
    string s;
    cin >> s;
    w = stoll(s);
    int x = 0;
    int y = 1;
    for (auto j=0; j<m; j++) {
      x += w%10 * y;
      y *= 2;
      w /= 10;
    }
    // cerr << x << endl;
    W.push_back(x);
  }
  X.clear();
  X = vector< vector<int> >(m+1, vector<int>(0));
  for (auto i=0; i<C; i++) {
    int count = 0;
    for (auto k=0; k<m; k++) {
      if ((i >> k) & 1) {
	count++;
      }
    }
    X[count].push_back(i);
    // cerr << "X[" << count << "] pushed " << i << endl; 
  }
}

bool ok(int i, int j) { // 未回答なのにjに1が立っているものを弾く
  for (auto k=0; k<m; k++) {
    if ( ((j >> k) & 1) && (((i >> k) & 1) == 0) ) {
      return false;
    }
  }
  return true;
}

void costzero() {
  for(auto i=0; i<C; i++) {
    for (auto j=0; j<C; j++) {
      if (ok(i, j)) {
	// cerr << "i = " << i << ", j = " << j << endl;
	vector<int> K = W;
	for (auto k=0; k<m; k++) {
	  if ((i >> k) & 1) {
	    vector<int> L;
	    int x = (j >> k) & 1;
	    for (unsigned int l=0; l<K.size(); l++) {
	      if (((K[l] >> k) & 1) == x) {
		L.push_back(K[l]);
	      }
	    }
	    K.clear();
	    K = L;
	  }
	}
	// cerr << K.size() << endl;
	if (K.size() <= 1) {
	  V[i][j] = 0;
	  // cerr << "i = " << i << ", j = " << j << endl;
	}
      }
    }
  }
}

int cost(int i, int j) {
  if (V[i][j] < infty) { // もう計算してあるなら使えばいい
    return V[i][j];
  }
  int ans = infty;
  for (auto k=0; k<m; k++) { // 性質kの質問を追加する
    if (((i >> k) & 1) == 0) { // まだしてないことを確認
      int ansk = 0;
      int ni = i | (1 << k);
      for (auto l=0; l<2; l++) { // yes, no
	int nj = j | (l << k);
	int anskl = cost(ni, nj);
	if (ansk < anskl) ansk = anskl; // 両方決定するのにかかる多い方
      }
      if (ans > ansk) ans = ansk; // よりよい質問の仕方
    }
  }
  /* if (ans == infty) {
    cerr << "infty i = " << i << " j = " << j << endl;
    }*/
  assert(ans < infty); // 必ず区別できるという過程
  ans++;  // 質問を追加するので1ステップ多い
  V[i][j] = ans; // メモする
  return ans;
}

int main() {
  while(cin >> m >> n && m) {
    init();
    costzero();
    cout << cost(0, 0) << endl;
  }
}

Measured memory_bytes: 17628
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define PI 3.1415926535897932384626433832795
#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int n, t, a, mn = 1e9;

int main()
{
	cin >> n >> t;
	
	for(int i=1; i <= n; i++)
		cin >> a, mn = min(mn, a), t -= a;
	
	cout << n+t/mn;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int>mp;
vector<string>res;
int main(){
	int n;cin>>n;
	while (n--){
		string s;cin>>s;mp[s]++;
	}
	int ans=0;
	for (map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		ans=max(ans,it->second);
	for (map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
		if (it->second==ans) res.push_back(it->first);
	sort (res.begin(),res.end());
	for (int i=0;i<res.size();i++) cout<<res[i]<<"\n"; 
}

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

int main(void) {
    long int n;
    cin>>n;
    long int a[n+5],min=1000000005,max=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min){min=a[i];}
        if(a[i]>max){max=a[i];}
    }
    cout<<max-min<<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 n;
    cin >> n;
    vector<int> A(n);
    rep(i,n) cin >> A[i];
    const int m = 1000000007;
    ll ans=0;
    ll x=0;
    rep(i,n){
        ans = (ans + A[i]*x%m)%m;
        x = (x+A[i])%m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e6+10;
int a[maxn][3];
int dp[maxn][3];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            scanf("%d",a[i]+j);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
                }
            }
        }
    }
    /*for(int i=1;i<=3;i++)
    {
        for(int j=0;j<3;j++)
        {
            printf("%d ",dp[i][j]);
        }
        printf("\n");
    }*/
    int ans=0;
    for(int i=0;i<3;i++)
    {
        ans=max(dp[n][i],ans);
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(M);
	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;
			v[A - 1]++;
		}
	}

	cout << count(v.begin(), v.end(), N) << endl;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init() {
  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 binom(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;
}

long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % MOD;
}

ll N, K;
vector<ll> Graph[101010];

ll dfs(ll cur, ll from) {
  ll res = 1;
  ll cnt = 0;
  for (auto nv : Graph[cur]) {
    if (nv == from) continue;

    res *= dfs(nv, cur);
    res %= MOD;
    ++cnt;
  }

  if (from == 0) {
    return res * perm(K - 1, cnt) % MOD;
  } else {
    return res * perm(K - 2, cnt) % MOD;
  }
}

int main() {
  cin >> N >> K;
  rep(i, 0, N - 1) {
    ll a, b;
    cin >> a >> b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  binom_init();

  cout << K * dfs(1, 0) % MOD;
}


Measured memory_bytes: 37348
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  double e;
  int a,b,c,d,f; cin>>a>>b>>c>>d>>e>>f;
  double N=-1;
  a*=100; b*=100;
  int ans1,ans2;

  for(int i=0;i<=f;i+=a){
    for(int j=0;i+j<=f;j+=b){
      for(int k=0;i+j+k<=f;k+=c){
        for(int l=0;i+j+k+l<=f;l+=d){
          if(i==0&&j==0) continue;
          double I=i;
          double J=j;
          double K=k;
          double L=l;
          double E=(K+L)/(I/100+J/100);
          // cout<<"E "<<E<<endl;
          if(E>e) continue;
          double nodo=100*(K+L)/(K+L+I+J);
          if(nodo>N){
            // cout<<"nodo "<<nodo<<endl;
            N=nodo;
            ans1=k+l+i+j;
            ans2=k+l;
          }
        }
      }
    }
  }
  cout<<ans1<<" "<<ans2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<utility>
#include<vector>

int main(void){
    int H,A;
    scanf("%d %d",&H,&A);
    if(H%A==0) printf("%d",H/A);
    else printf("%d",H/A + 1);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

vector<bool> used;
int cnt=0,ans;

void orderOut(vector<int> obj, vector<int> save){
    if(obj.size()==save.size()){
        cnt++;
        if(obj==save){
            ans=cnt;
        }
    }
    REP(i,0,obj.size()){
        if(used[i]) continue;
        used[i]=true;
        save.push_back(i+1);
        orderOut(obj, save);
        save.pop_back();
        used[i]=false;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> q(N);
    used.resize(N);
    REP(i,0,N) cin >> p[i];
    REP(i,0,N) cin >> q[i];
    
    vector<int> a;
    int pc,qc;
    orderOut(p,a);
    pc=ans;

    cnt=0;
    orderOut(q,a);
    qc=ans;
    
    cout << abs(pc-qc) << endl;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

// ------------------------------------------------------------------------------------------------

ll n, t1, t2;
vll a;

void func() {
    t1 = 0; t2 = 0;
    cin >> n;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] >= t1) {
            t2 = t1;
            t1 = a[i];
        } else if (a[i] >= t2) {
            t2 = a[i];
        }
    }
    for (ll i = 0; i < n; i++) {
        if (a[i] == t1) {
            cout << t2 << endl;
        } else {
            cout << t1 << endl;
        }
    }
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int p[110];
int q[110];
int r[110];
vector<int>g[110];
int g2[110][110];
int UF[110];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int dp[110][11000];
int jk[110];
int sz;
int top[110];
int rep[110];
int v[110];
int cnt;
void dfs(int a){
	v[a]=1;
	for(int i=0;i<sz;i++){
		if(i!=a&&g2[rep[a]][rep[i]]&&!v[i]){
			dfs(i);
		}
	}
	top[cnt--]=a;
}
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		for(int i=0;i<a;i++)jk[i]=0;
		for(int i=0;i<a;i++){
			scanf("%d%d%d",p+i,q+i,r+i);
		}
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)g2[i][j]=0;
		for(int i=0;i<a;i++)g2[i][i]=1;
		for(int i=0;i<a;i++)g[i].clear();
		for(int i=0;i<b;i++){
			int s,t;scanf("%d%d",&s,&t);s--;t--;
			if(s==t)jk[s]=1;
			g[s].push_back(t);
			g2[s][t]=1;
		}
		for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++){
			g2[i][j]|=(g2[i][k]&g2[k][j]);
		}
		for(int i=0;i<a;i++)UF[i]=-1;
		for(int i=0;i<a;i++)for(int j=i+1;j<a;j++){
			if(g2[i][j]&&g2[j][i])UNION(i,j);
		}
		sz=0;
		for(int i=0;i<a;i++){
			if(UF[i]<0){
				rep[sz++]=i;
			}
		}
		cnt=sz-1;
		for(int i=0;i<sz;i++){
			v[i]=0;
		}
		for(int i=0;i<sz;i++){
			if(v[i]==0){
				dfs(i);
			}
		}
		for(int i=0;i<sz;i++)for(int j=0;j<=c;j++)dp[i][j]=-999999999;
		for(int i=0;i<sz;i++)dp[i][0]=0;
		for(int i=0;i<sz;i++){
			for(int j=0;j<i;j++){
				if(g2[rep[top[j]]][rep[top[i]]]){
					for(int k=0;k<=c;k++)dp[i][k]=max(dp[i][k],dp[j][k]);
				}
			}
			if(UF[rep[top[i]]]==-1&&jk[rep[top[i]]]==0){
				for(int j=c;j>=q[rep[top[i]]];j--){
					dp[i][j]=max(dp[i][j],dp[i][j-q[rep[top[i]]]]+p[rep[top[i]]]);
				}
			}else{
				for(int j=0;j<a;j++){
					if(FIND(j)==rep[top[i]]){
						for(int k=0;k<q[j];k++){
							deque<pair<int,int> >Q;
							for(int l=k;l<=c;l+=q[j]){
								while(Q.size()&&dp[i][l]-p[j]*(l/q[j])>=Q.back().second){
									Q.pop_back();
								}
								Q.push_back(make_pair(l,dp[i][l]-p[j]*(l/q[j])));
								dp[i][l]=max(dp[i][l],Q.front().second+p[j]*(l/q[j]));
								if(Q.front().first<=l-r[j]*q[j])Q.pop_front();
							}
						}
					}
				}
			}
		//	printf("%d %d %d\n",rep[top[i]],UF[rep[top[i]]],jk[rep[top[i]]]);
	//		for(int j=0;j<=c;j++)printf("%d ",dp[i][j]);
//			printf("\n");
		}
		int ret=0;
		for(int i=0;i<sz;i++)for(int j=0;j<=c;j++)ret=max(ret,dp[i][j]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 5496
#include<stdio.h>

#define int long long

int A[500010];
int n;

void swap(int *a, int *b)
{
	int t = *a;
	*a = *b;
	*b = t;
}

void maxHeap(int p)
{
	int parent, child;
	for (parent = p; parent * 2 <= n; parent = child)
	{
		child = 2 * parent;
		if (child != n && A[child + 1] > A[child])
			child++;
		if (A[parent] > A[child])
			break;
		else
			swap(&A[parent], &A[child]);
	}
}

int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &A[i]);
	for (int i = n / 2; i > 0; i--)
		maxHeap(i);
	for (int i = 1; i <= n; i++)
		printf(" %lld", A[i]);
	printf("\n");
}


Measured memory_bytes: 5600
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;


#include <queue>
#include <vector>
#include <functional>
#include <utility>
#include <algorithm>
#include <iterator>

using COST_T = uint32_t;
constexpr uint32_t N_MAX = 100000;
constexpr COST_T INF = 1000000000 + 1000;//std::numeric_limits<double>::infinity()

#if defined(_MSC_VER) && defined(_DEBUG)
//static_assert(false, "リリースでコンパイルしないと遅いよ！！");
#endif


std::vector<int32_t> graph[N_MAX];//木

//ダイクストラ
COST_T D1[N_MAX];
COST_T D2[N_MAX];
void Dijkstra(uint32_t s, COST_T(&D)[N_MAX])
{
	using P = std::pair<COST_T, uint32_t>;//cost pos
	std::priority_queue<P, std::vector<P>, std::greater<>> que;
	std::fill(std::begin(D), std::end(D), INF);

	D[s] = 0;
	que.emplace(0, s);
	while (!que.empty())
	{
		auto p = que.top(); que.pop();
		const auto& nowpos = p.second;
		const auto& nowcost = p.first;
		if (D[nowpos] < nowcost) { continue; }

		//for (int32_t to = 0; to < N; ++to)
		//{
		//	auto cost = nowcost + graph[nowpos][to];
		//	if (cost < D[to]) {
		//		D[to] = cost;
		//		que.emplace(D[to], to);
		//	}
		//}

		for (const auto& e : graph[nowpos])
		{
			auto cost = nowcost + 1;
			if (cost < D[e]) {
				D[e] = cost;
				que.emplace(cost, e);
			}
		}

	}
}
int32_t N;
void input_tree()
{
	in >> N;
	for (int32_t i = 0; i < N - 1; ++i)
	{
		int a, b;
		in >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	input_tree();
	Dijkstra(0, D1);
	Dijkstra(N-1, D2);
	int32_t f = 0,s=0;
	for (int32_t i = 0; i < N; ++i)
	{
		if (D1[i] <= D2[i]) { ++f; }
		else { ++s; }
	}
	if (f > s) {
		out << "Fennec" << endl;
	}
	else {
		out << "Snuke" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 7020
#include<iostream>
#include<cstdio>
#include<string.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=1e5+5;
ll dp[maxn][13];
char s[maxn];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	dp[0][0]=1;//重要初始化 
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='?')
		{
			for(int now=0;now<=9;now++)
			{
				for(int j=0;j<13;j++)
				{
					int k=j*10+now;
					dp[i][k%13]=(dp[i][k%13]+dp[i-1][j])%mod;
				}
			}
		}
		else
		{
			int now=s[i]-'0';
			for(int j=0;j<13;j++)
			{
				int k=j*10+now;
				dp[i][k%13]=(dp[i][k%13]+dp[i-1][j])%mod;
			}
		}
	}
	printf("%lld",dp[len][5]);
    return 0;
}

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

using namespace std;

int main(){
	int MAX = 200000;
	
	int r[MAX],n;
	
	cin>>n;
	
	for(int i=0 ; i<n ; i++){
		cin>>r[i];
	} 

	int maxdiff = -1000000000;
	int minnum = r[0];
	
	for(int i=1 ; i<n ; i++){
		maxdiff = max(maxdiff, r[i]-minnum);
		minnum = min(minnum, r[i]); 
	} 
	
	cout<<maxdiff<<endl;

	return 0;
}

Measured memory_bytes: 1940
import sys
input = sys.stdin.readline
import bisect

n = int(input())
X = list(map(int, input().split()))
l = int(input())
U = 17
dp = [[0]*n for _ in range(U+1)]
for i, x in enumerate(X):
  t = bisect.bisect_left(X, x+l)
  dp[0][i] = bisect.bisect_right(X, x+l) - 1
for k in range(U):
  for i in range(n):
    dp[k+1][i] = dp[k][dp[k][i]]
q = int(input())
for _ in range(q):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if a > b:
    a, b = b, a
  res = 1
  for k in range(U, -1, -1):
    if dp[k][a] < b:
      a = dp[k][a]
      res += (1<<k)
    if a == b:
      break
  print(res)

Measured memory_bytes: 80288
#include <iostream>

using namespace std;

int main(){
  string S;
  cin >> S;
  int len = S.length(), i, count=0, nokori;
  for(i=0; i<len; i++){
    if(S[i] == 'o') count++;
  }
  nokori = 15-len;
  if(nokori >= 8-count) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256