akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main (void){
    long long n;
    long long grp[200000]={0};
    int huka=0;
    scanf("%lld",&n);
    //もし、nが奇数→0 202 42024 6420246
    //もし、nが偶数→11 3113 531135   でなければならない
    long long data[n];
    int loop1;
    for(loop1=0;loop1<n;loop1++){
        scanf("%lld",&data[loop1]);
        grp[data[loop1]]++;
    }
    //不可能かチェック
    for(loop1=0;loop1<n;loop1++){
        if(n%2==0){
            if(loop1%2==0 && grp[loop1]!=0){
                huka=-1;
            }
            if(loop1%2==1 && grp[loop1]!=2){
                huka=-1;
            }
        }
        if(n%2==1){
            if(loop1==0){
                if(grp[loop1]!=1){
                    huka=-1;
                }
            }else if(loop1%2==1 && grp[loop1]!=0){
                huka=-1;
            }else if(loop1%2==0 && grp[loop1]!=2){
                huka=-1;
            }
        }
    }
    if(huka==-1){
        printf("0\n");
        return 0;
    }
    //パターン数はいくつか
    long long teisu=pow(10,9)+7;
    long long patt=1;
    for(loop1=0;loop1<(n/2);loop1++){
        patt*=2;
        patt%=teisu;
        //printf("%lld\n",patt);
    }
    printf("%lld\n",patt);
    return 0;
}

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

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i) a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k-1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x%10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1712
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
typedef pair<ld, ut> pld;
ut N, M, K, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE]={0,3,2,1},B[SIZE]={0,3,2,1};
LL sum[SIZE];
LL solve(){
	cin >> H>>W>>K;
	int now=0;
	VI v;
	int times=0;
	REP(i,H){
		times++;
		string s;
		cin >> s;
		bool exist=false;
		REP(j,s.size()) if(s[j]=='#') exist=true;
		bool started=false;
		if(exist){
			v.clear();
			REP(j,s.size()){
				if(s[j]=='#'){
					now++;
					started=true;
				}
				if(!started){
					v.pb(now+1);
				}else{
					v.pb(now);
				}
			}
			REP(i,times) outputVI(v);
			times=0;
		}
		else if(v.size()!=0){
			outputVI(v);
			times=0;
		}else{
		}
	}

	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

ll fanc(vector<vector<int>> &vs, int m1, int m2, int m3, string s){
	ll ret = 0;
	for(int i : vs.at(m1)){
		auto itr = lower_bound(vs.at(m2).begin(), vs.at(m2).end(), i);
		while(itr != vs.at(m2).end()){
			int diff = *itr - i;
			int count = lower_bound(vs.at(m3).begin(), vs.at(m3).end(), *itr) - vs.at(m3).begin();
			count = vs.at(m3).size() - count;
			char c;
			if(m3 == 2) c = 'B';
			else if(m3 == 1) c = 'G';
			else c = 'R';
			if(*itr+diff < s.size() && s[*itr+diff] == c) count--;
			ret += (ll)count;
			itr++;
		}
		auto itr2 = lower_bound(vs.at(m3).begin(), vs.at(m3).end(), i);
		while(itr2 != vs.at(m3).end()){
			int diff = *itr2 - i;
			int count = lower_bound(vs.at(m2).begin(), vs.at(m2).end(), *itr2) - vs.at(m2).begin();
			count = vs.at(m2).size() - count;
			char c;
			if(m2 == 1) c = 'G';
			else if(m2 == 0) c = 'R';
			else c = 'B';
			if(*itr2+diff < s.size() && s[*itr2+diff] == c) count--;
			ret += (ll)count;
			itr2++;
		}
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> vs(3, vector<int>());
	rep(i, n){
		if(s[i] == 'R') vs.at(0).push_back(i);
		else if(s[i] == 'G') vs.at(1).push_back(i);
		else if(s[i] == 'B') vs.at(2).push_back(i);
	}
	ll ans = 0;
	// cerr << "tst" << endl;
	ans += fanc(vs, 0, 1, 2, s);
	ans += fanc(vs, 2, 0, 1, s);
	ans += fanc(vs, 1, 2, 0, s);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
    string ret = "<";
    for (auto it : v) {
        ret += to_string(it) + ", ";
    }
    ret.pop_back(); ret.pop_back();
    ret += ">";
    return ret;
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
    cerr << " " << to_string(t);
    debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

ll arr[105];

int main() {
    ll n, m;
    cin >> n >> m;
    ll sum = 0ll;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    double bound = (double)sum / (4.0 * m);
    sort(arr, arr + n, greater<ll>());
    bool valid = true;
    for (int i = 0; i < m; i++) {
        if ((double)arr[i] < bound) {
            valid = false;
            break;
        }
    }
    if (valid) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 256
from collections import deque

H, W, K = map(int, input().split())
c = []
for i in range(H):
    c.append(input())

def check(r):
    counter = 0
    for h in range(H):
        for w in range(W):
            if c[h][w] == '.':
                continue
            else:
                # black
                if r[h] or r[H + w]:
                    continue
                else:
                    counter += 1  
    return 1 if counter == K else 0

depth = 0
queue = deque()
queue.append(([], 0))
answer = 0
while len(queue) != 0:
    r, depth = queue.pop()
    if depth == H + W:
        answer += check(r)
    else:
        for mask in [True, False]:
            queue.append((r + [mask], depth + 1))
print(answer)

Measured memory_bytes: 9400
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007
#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));
using namespace std;
typedef long long ll;
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 complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
int a[100000];
int main() {
	int n;
	scanf("%d", &n);
	fup(i, 0, n - 1, 1)scanf("%d", a + i);
	ll ans = 0;
	fup(i, 0, n - 1, 1)
	{
		ans += a[i] / 2;
		a[i] %= 2;
		if (i != n - 1)
		{
			int t = min(a[i], a[i + 1]);
			ans += t;
			a[i] -= t, a[i + 1] -= t;
		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define ar array
#define vvll vector<vll>
#define repa(i, b, n) for (int i = b; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1e9
#define MP make_pair
#define ll long long int
#define M 1000000007
#define all(a) a.begin(), a.end()
// debugging
#define db(x) cout << x << "\n";
#define db1(x) cout << #x << "=" << x << "\n"
#define db2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << "\n"
#define db3(x, y, z) cout << #x << "=" << x << ", " << #y << "=" << y << ", " << #z << "=" << z << "\n"
#define dba(x)       \
    for (auto i : x) \
    cout << i << "\t"
#define dbm(x)                \
    for (auto i : x)          \
    {                         \
        for (auto j : i)      \
            cout << j << " "; \
        cout << "\n";         \
    }
#define MOD 1000000007
using namespace std;
const int maxN = 100001;
vector<int> g[maxN];
ll height[maxN];
int vis[maxN];

void dfs(int u)
{
    vis[u] = 0;
    int f = 1;
    for (auto i : g[u])
    {
        if (vis[i] == -1)
            dfs(i);
        if (height[i] >= height[u])
            f = 0;
    }
    vis[u] = f;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<ar<ll, 2>> h(n);
    rep(i, n)
    {
        cin >> height[i];
        vis[i] = -1;
    }
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int cnt = 0;
    rep(i, n)
    {
        if (vis[i] == -1)
            dfs(i);
        // db1(vis[i]);
        cnt += vis[i];
    }
    db(cnt);
}

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

int main(){
    int n;
    cin >> n;
    if(n < 105){
        cout << 0;
    }else if(n < 135){
        cout << 1;
    }else if(n < 165){
        cout << 2;
    }else if(n < 189){
        cout << 3;
    }else if(n < 195){
        cout << 4;
    }else{
        cout << 5;
    }
    return 0;
}

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

using namespace std;
using pint = pair<int, int>;

double dist(pint xyi, pint xyj) {
	double ans;
	int xi = xyi.first;
	int xj = xyj.first;
	int yi = xyi.second;
	int yj = xyj.second;
	ans = sqrt(pow(xi - xj, 2) + pow(yi - yj, 2));
	return ans;
}


int main() {
	int N;
	cin >> N;
	vector<pint> xy(N);
	for (int i = 0; i < N; i++) {
		cin >> xy[i].first;
		cin >> xy[i].second;
	}

	vector<int> order(N);
	for (int i = 0; i < N; i++) order[i] = i;

	double sum = 0;
	int count = 0;

	do {
		for (int i = 1; i < N; i++) {
			sum += dist(xy[order[i - 1]], xy[order[i]]);
		}
		count++;
	} while (next_permutation(order.begin(), order.end()));

	double avg = sum / count;

	cout << fixed << setprecision(6) << avg << endl;

	return 0;
}


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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
        
    long long res = 0;
    for (int d = 60; d >= -1; --d) { // d = -1 は X = K の場合
        if (d != -1 && !(K & (1LL<<d))) continue;
        
        long long tmp = 0;
        for (int e = 60; e >= 0; --e) {
            long long mask = 1LL<<e;
            int num = 0;
            for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
            
            if (e > d) {
                if (K & mask) tmp += mask * (N - num);
                else tmp += mask * num;
            }
            else if (e == d) {
                tmp += mask * num;
            }
            else {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll H,W,K; cin >> H >> W >> K;
    char grid[H+1][W+1];
    rep(i,H){
        string s;
        cin >> s;
        rep(j,W) grid[i][j] = s[j];
    }

    int ans[H+1][W+1];
    rep(i,H) rep(j,W) ans[i][j] = 0;
    int num = 0;
    rep(i,H){
        int cake = 0;
        rep(j,W) if(grid[i][j] == '#') cake++;
        if(cake >= 1){
            num++;
            int ct = 0;
            rep(j,W){
                if(grid[i][j] == '#') ct++;
                if(ct >= 2 && grid[i][j] == '#') num++;
                ans[i][j] = num;
            }
        }
    }

    rep(i,H-1){
        if(ans[i+1][0] == 0) rep(j,W) ans[i+1][j] = ans[i][j];
    }

    for(int i = H-1; i >= 1; i--){
        if(ans[i-1][0] == 0) rep(j,W) ans[i-1][j] = ans[i][j];
    }

    rep(i,H){
        rep(j,W) cout << ans[i][j] << " ";
        pr("");
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
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 ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

int h,w;
vii seen;
vector<string> graph;

int dfs(int y,int x,int cnt){
    seen[y][x] = 1;
    int Max = cnt;
    for(int i=0;i<4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx<0||nx>=w||ny<0||ny>=h||seen[ny][nx]!=-1||graph[ny][nx]!='#')continue;
        cnt++;
        int tmp = dfs(ny,nx,cnt);
        chmax(Max,tmp);
    }
    return Max;
}

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

    cin >> h >> w;
    seen.assign(h,vi(w,-1));
    rep(i,h){
        string t;cin >> t;
        graph.push_back(t);
    }
    
    rep(i,h){
        rep(j,w){
            if(graph[i][j] == '#' && seen[i][j] == -1){
                if(dfs(i,j,0) == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  vi A(N), B(N), C(N);
  REP(i, N) {
    cin >> A[i];
    A[i]--;
  }
  REP(i, N) cin >> B[i];
  REP(i, N-1) cin >> C[i];

  int ans = 0;
  REP(i, N){
    ans += B[A[i]];
    if(i>0 && A[i] == A[i-1]+1) ans += C[A[i]-1];
  }
  cout << ans << endl;
}


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

#define ll long long
int main()
{
   int a[10];
   for(int i=1;i<=5;i++){
        cin>>a[i];
   }
   for(int i=1;i<=5;i++){
       if(a[i]==0){
           cout<<i<<endl;
           break;
       }
   }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
const ll INF = 1e18;
#define PI (acos(-1))
//const ll mod = 1000000007;
//1からDijkstra パンを買うまでの距離を記録
//パンの値段も考慮した初期距離で、多点始点Dijkstra

ll N, M, K;
ll P[105000];
ll c[105000], J[105000];
vector<l_l> pathes[105000];
priority_queue<l_l, vector<l_l>, greater<l_l>> que;

ll dist[2][105000];

void Dijkstra(ll index) {
    while(!que.empty()) {
        l_l now = que.top();
        que.pop();
        if(dist[index][now.second] < now.first) continue;
        for(int i = 0; i < pathes[now.second].size(); i++) {
            ll to = pathes[now.second][i].first;
            ll newcost = now.first + pathes[now.second][i].second;
            if(chmin(dist[index][to], newcost)) {
                que.push({newcost, to});
            }
        }
    }
}

ll ans[105000];

int main() {
    //cout.precision(10);
    cin >> N >> M >> K;
    for(int i = 1; i <= N; i++) cin >> P[i];
    for(int i = 1; i <= N; i++) cin >> c[i];
    for(int i = 1; i <= N; i++) cin >> J[i];
    for(int i = 1; i <= M; i++) {
        ll u, v, t;
        cin >> u >> v >> t;
        pathes[u].push_back({v, t});
        pathes[v].push_back({u, t});
    }
    for(int i = 1; i <= N; i++) {
        dist[0][i] = INF;
    }
    dist[0][1] = 0;
    que.push({0, 1});
    Dijkstra(0);
    for(int i = 1; i <= N; i++) {
        dist[1][i] = dist[0][i] - P[i];
        que.push({dist[1][i], i});
    }
    Dijkstra(1);
    for(int i = 1; i <= K; i++) ans[i] = INF;
    for(int i = 1; i <= N; i++) {
        chmin(ans[c[i]], dist[0][i] - J[i] + dist[1][i]);
    }
    for(int i = 1; i <= K; i++) cout << -ans[i] << endl;
    return 0;
}



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

bool is_prime(int n) {
	if (n == 2) return true;
	if (n < 2 || n % 2 == 0) return false;
	for (int i = 3; i <= sqrt(n); i += 2)
		if (n % i == 0) return false;
	return true;
}

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

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int h,w,a,b;
char mp[1252][1252];
ll dist[1252][1252];

int dx[] = {0,1, 0,-1,1, 1,-1,-1};
int dy[] = {1,0,-1, 0,1,-1,-1, 1};
int mu[] = {1,1, 1, 1,2, 2, 2, 2};

int main(){
  scanf("%d%d%d%d",&h,&w,&a,&b);
  REP(i,h)scanf("%s",mp[i]);
  REP(i,h)REP(j,w)dist[i][j] = 1ll<<60;
  int si = 0, sj = 0;
  int gi = 0, gj = 0;
  REP(i,h)REP(j,w){
    if(mp[i][j]=='s')si=i,sj=j;
    if(mp[i][j]=='g')gi=i,gj=j;
  }

  priority_queue<pair<ll,pii>> Q;
  Q.push(make_pair(-0ll, pii(si,sj)));
  dist[si][sj] = 0ll;
  while(!Q.empty()){
    pair<ll,pii> PP = Q.top(); Q.pop();
    int i = PP.second.first;
    int j = PP.second.second;
    if(-PP.first != dist[i][j])continue;
    bool can = true;
    if(mp[i][j]=='*')can=false;
    REP(dir,8){
      int ni = i + dy[dir];
      int nj = j + dx[dir];
      if(ni<0 || nj<0 || ni>=h || nj>=w)continue;
      if(mp[ni][nj]=='*')can=false;
    }
    REP(dir,8){
      int ni = i + dy[dir];
      int nj = j + dx[dir];
      ll nc = dist[i][j] + mu[dir]*a;
      if(ni<0 || nj<0 || ni>=h || nj>=w)continue;
      if(mp[ni][nj]=='#' || mu[dir]==2){
        if(!can)continue;
        nc += b;
      }
      if(nc < dist[ni][nj]){
        dist[ni][nj] = nc;
        Q.push(make_pair(-nc, pii(ni,nj)));
      }
    }
  }
  // REP(i,h){
  //   REP(j,w)printf("%lld ",dist[i][j]);puts("");
  // }
  if(dist[gi][gj]==1ll<<60){
    puts("INF");
  }else{
    printf("%lld\n",dist[gi][gj]);
  }
  return 0;
}



Measured memory_bytes: 14220
def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
///╔══╗
///╚╗╔╝
///╔╝╚(¯`v´¯)
///╚══╝`.¸.´farzin


#include <bits/stdc++.h>

#define int int64_t
#define pb push_back
#define ibsws ios_base::sync_with_stdio
#define gcd __gcd
#define s second
#define f first
typedef std::pair<int,int> pii ;

using namespace std;

const int N=1e5+1e2;
int n,tw;
int w[N],v[N],dp[110][N];

int32_t main(){
	ibsws(true==false);
	cin>>n>>tw;
	for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
	}
	for(int i=w[0];i<=tw;i++){
        dp[0][i]=v[0];
	}
	for(int i=1;i<n;i++){
        for(int j=1;j<=tw;j++){
            if(j<w[i]){
                dp[i][j]=dp[i-1][j];
                continue;
            }
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        }
	}
	cout<<dp[n-1][tw];
}


Measured memory_bytes: 80128
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

pii l[100005];
int n;

int main() {
  int k;
  scanf("%d%d", &n, &k);
  for(int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    l[i] = pii(y, x);
  }
  sort(l, l+k);
  int ret = 0;
  int last = -1;
  for(int i = 0; i < k;) {
    int j = i+1;
    while(j < k && l[i].first == l[j].first) j++;
    if(l[j-1].second >= last) {
      ret++;
      last = l[j-1].first;
    }
    i = j;
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    string S, T;
    cin >> S >> T;
    //vector<ll> a(N);
    string R;
    R = T.substr(0, S.size());
    if(S != R) cout << "No" << endl;
    else{
      char tmp = T.back();
      if(tmp>='a'&& tmp<='z') cout << "Yes" << endl;
      else cout << "No" << endl;
    }

    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL n, T;cin >> n >> T;
    LL ans = 0LL;
    vector<LL> t(n);
    for(int i=0;i<n;i++) cin >> t[i];
    for(int i=1;i<n;i++){
        if(t[i]-t[i-1] < T){
            ans += t[i]-t[i-1];
        }else{
            ans += T;
        }
    }
    ans += T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int H,A;
    cin >> H >> A;

    cout << int(ceil((double)H/A)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

ll solve()
{
    ll H, W;

    std::cin >> H >> W;

    if (H == 1 || W == 1)
        return 1;

    if (H % 2 == 1) {
        return ((H + 1ll) / 2) * W - (W / 2);
    } else {
        return (H / 2) * W;
    }
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 256
let solve n_S n_c =
  if n_S = (n_c/2) then
    n_S
  else if n_S > (n_c/2) then
    n_c/2
  else (* n_S < (n_c/2) *)
    let resid = n_c - 2 * n_S in
    resid/4 + n_S

let () =
  let rec read () =
    try let ans = (Scanf.scanf "%d %d\n" solve) in
        Printf.printf "%d\n" ans
    with End_of_file -> ()
  in
  read ()
;;


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

#define endl '\n'

using namespace std;

int x, y, z;
void read()
{
    cin >> x >> y >> z;
}

void solve()
{
    cout << z << " " << x << " " << y << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    read();
    solve();
}


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

int main(){
	long long int n;
	cin>>n;
	string ans="";
	while(n>0){
		ans+=((n-1)%26)+'a';
		n=(n-1)/26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<ll>> ok(N), ng(N);
    ll x_, y_;
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x_ >> y_;
            if (y_ == 1)
                ok[i].push_back(x_ - 1);
            else
                ng[i].push_back(x_ - 1);
        }
    }
    ll ans = 0;
    for (ll flags = 0; flags < pow(2, N); flags++) {
        auto ping = [&](int n) { return (1 & (flags >> n)); };
        unordered_set<ll> oks;
        rep(i, N) if (ping(i)) oks.insert(i);
        rep(i, N) {
            if (ping(i)) {
                for (auto n : ng[i]) {
                    if (oks.count(n) > 0) goto CONTINUE;
                }
                for (auto o : ok[i]) {
                    if (oks.count(o) == 0) goto CONTINUE;
                }
            }
        }
        ans = max(ll(oks.size()), ans);
    CONTINUE:;
    }
    cout << ans << endl;

    // ll ans = 0;
    // // rep(i, N) {
    // for (int i = 0; i < N; i++) {
    //     unordered_set<ll> oks;
    //     vector<ll> stack;
    //     for (auto o : ok[i]) {
    //         stack.push_back(o);
    //         oks.insert(o);
    //     };
    //     while (stack.size() > 0) {
    //         ll last = stack[stack.size() - 1];
    //         stack.pop_back();
    //         for (auto o : ok[last]) {
    //             if (oks.count(o) == 0) {
    //                 oks.insert(o);
    //                 stack.push_back(o);
    //             }
    //         }
    //     }
    //     cout << endl;
    //     for (auto o : oks) {
    //         cout << o << " ";
    //     }
    //     for (auto o : oks) {
    //         for (auto n : ng[o]) {
    //             if (oks.count(n) > 0) {
    //                 goto CONTINUE;
    //             }
    //         }
    //     }
    //     ans = max(ans, ll(oks.size()));
    // CONTINUE:;
    // }
    // cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

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

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll n, ans;

void dfs(ll x, ll a, ll b, ll c){
    if(x > n) return;
    if(a && b && c) ans++;
    dfs(x*10+3, 1, b, c);
    dfs(x*10+5, a, 1, c);
    dfs(x*10+7, a, b, 1);
}

int main(){
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n, k, a[MAXN], vs[5010], nvs[5010], has[5010];
vector<int> v[5010];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> a[i];
	
	sort(a, a + n);
	int ans = 0;
	has[0] = 1;
	for (int i=n-1; i>=0; i--) {
		if (a[i] >= k) {
			vs[i] = 1;
			continue;
		}
		for (int j=i+1; j<n; j++) {
			int pos = lower_bound(v[j].begin(), v[j].end(), k - a[i]) - v[j].begin();
			if (pos != v[j].size()) {
				vs[i] = 1;
				vs[j] = 1;
			}
		}
		ms(nvs, 0);
		for (int j=0; j<k; j++) if (has[j]) {
			if (j + a[i] >= k) continue;
			else {
				nvs[j + a[i]] = 1;
			}
		}
		
		for (int j=0; j<k; j++) {
			has[j] |= nvs[j];
			if (has[j]) v[i].pb(j);
		}
	}
	for (int i=0; i<n; i++) if (!vs[i]) ans++;
	else break;
	
	cout << ans << '\n';


}


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

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

P = {'s':R, 'p':S, 'r':P, 'N':0}

score = 0

for i in range(N):
    if i + K < N:
        if T[i] == T[i + K]:
            T[i + K] = 'N'
    
    score += P[T[i]]

print(score)

Measured memory_bytes: 9912
import math
A, B =map(int,input().split())
a_assume=math.ceil(A/0.08)
a_upper_limit=math.ceil((A+1)/0.08)
b_upper_limit=(B+1)*10
upper_limit=min(a_upper_limit,b_upper_limit)
while a_assume<upper_limit:
  if B==math.floor(a_assume*0.1):
    print(a_assume)
    break
  else:
    a_assume+=1
if a_assume>=upper_limit:
  print(-1)

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

using namespace std;

int main(){
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<long long int> A(X),B(Y),C(Z),BC(Y*Z),sum(K*K,0);
    for(int i=0;i<X;i++){
        cin >> A[i];
    }
    for(int i=0;i<Y;i++){
        cin >> B[i];
    }
    for(int i=0;i<Z;i++){
        cin >> C[i];
    }

    for(int i=0;i<Y;i++){
        for(int j=0;j<Z;j++){
            BC[Z*i+j] = B[i]+C[j];
        }
    }

    sort(A.begin(),A.end());
    sort(BC.begin(),BC.end());
    reverse(A.begin(),A.end());
    reverse(BC.begin(),BC.end());

    for(int i=0;i<min(K,X);i++){
        for(int j=0;j<min(K,Y*Z);j++){
            sum[i*K+j] = A[i] + BC[j];
        }
    }

    sort(sum.begin(),sum.end());
    reverse(sum.begin(),sum.end());

    for(int i=0;i<K;i++){
        cout << sum[i] << endl;
    }
}

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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N = 1e5+7;

int32_t main() {
    IOS;
	int k;
	cin >> k;
	string str;
	cin >> str;
	if (str.length() <= k) cout << str << endl;
	else {
		for (int  i = 0; i < k; i++) {
			cout << str[i];
		}
		cout << "..." << endl;
	}
    return 0;
}


Measured memory_bytes: 3608
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int a[24 * 60 * 60];

int main()
{
	int n;
	while (cin >> n&&n)
	{
		FOR(i, 24 * 60 * 60)a[i] = 0;
		FOR(i, n)
		{
			int st, en;
			int h, m, s;
			scanf("%d:%d:%d", &h, &m, &s);
			st = h * 60 * 60 + m * 60 + s;
			scanf("%d:%d:%d", &h, &m, &s);
			en = h * 60 * 60 + m * 60 + s;
			a[st]++;
			a[en]--;
		}
		int ans = 0;
		for (int i = 1; i < 24 * 60 * 60; i++)
		{
			a[i] += a[i - 1];
			ans = max(ans, a[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> route(r);
  for (int i = 0; i < r; i ++) cin >> route[i], route[i] --;

  vector<vector<int>> d(n, vector<int>(n, 1e9));
  for (int i = 0; i < m; i ++) {
    int a, b, c;
    cin >> a >> b >> c;
    a --, b --;
    d[a][b] = d[b][a] = c;
  }

  for (int k = 0; k < n; k ++) {
    for (int i = 0; i < n; i ++) {
      for (int j = 0; j < n; j ++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 1e9;
  sort(route.begin(), route.end());
  do {
    int tmp = 0;
    for (int i = 1; i < r; i ++) tmp += d[route[i - 1]][route[i]];
    ans = min(ans, tmp);
  } while (next_permutation(route.begin(), route.end()));

  cout << ans << endl;
}

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

int main(){
  int a, b, x, y;
  double z;
  cin >> a >> b;
  x=a/b;
  y=a%b;
  z=1.00000*a/b;

  printf("%d %d %.5lf\n", x, y, z);

  return 0;
}


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

using namespace std;

long long ans,n,p,cur,t,cnt[100010];
string s;

int main()
{
    cin >> n >> p >> s;
    
    if(p == 2 || p == 5)
    {
        for(int i = 0;i < n;i++)
            if((s[i] - '0') % p == 0) ans += i+1;
    }
    else
    {
        cnt[0] = 1,t = 1;
        for(int i = n-1;i >= 0;i--)
        {
            cur = (cur + t*(s[i] - '0')%p) % p;
            t = t*10 % p;
            ans += cnt[cur]++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 644
#!/usr/bin/env python3
import sys
from math import hypot
from itertools import permutations
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n=int(input())
li=list(range(n))
xy=[list(map(int,input().split())) for i in range(n)]
# ite=list(permutations(n,li／))
prr = list(permutations(li, n))
count=len(prr)
for pr in prr:
    for i in range(n-1):
        # print(hypot(xy[pr[i]][0]-xy[pr[i+1]][0],
        #             xy[pr[i]][1]-xy[pr[i]][1]), pr, i, xy[pr[i]][0]-xy[pr[i+1]][0],
        #       xy[pr[i]][1]-xy[pr[i]][1])
        # print(pr)
        ans += hypot(xy[pr[i]][0]-xy[pr[i+1]][0],
                        xy[pr[i]][1]-xy[pr[i+1]][1])
print(ans/count)


# for i in range(n):
#     for j in range(n):
#         if i==j:
#             continue
#         for k in range(n):
#             if i==k or j==k:
#                 continue
#             count+=1
#             ans += hypot(xy[i][0]-xy[j][0], xy[i][1]-xy[j][1])
#             ans += hypot(xy[k][0]-xy[j][0], xy[k][1]-xy[j][1])

            


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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    string S;
    cin >> S;
    int n;
    cin >> n;

	const int L = S.size();

    long long dp[ 1200 ][ 2 ][ 4 ];   // 未満, 含むか

	fill( ( long long * )dp, ( long long * )dp + sizeof( dp ) / sizeof( long long ), 0 );
	dp[0][0][0] = 1;

	for ( int i = 0; i < L; ++i )
	{
		const int D = S[i] - '0';
		for ( int j = 0; j < 2; ++j )
		{
			for ( int k = 0; k <= n; ++k )
			{
				for ( int d = 0; d <= ( k == n ? 0 : (j ? 9 : D )); ++d )
				{
					dp[ i + 1 ][ j || ( d < D ) ][ d == 0 ? k : k + 1] += dp[i][j][k];
				}
			}
		}
	}

    ll ans = 0;

	cout << dp[L][0][n] + dp[L][1][n] << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int h, w = 5;
int M[15][10];

int main(void) {
  int i, j, k;
  while (1) {
    scanf("%d", &h);

    if (h == 0) {
      return 0;
    }

    for (i = 0; i < h; ++i) {
      for (j = 0; j < w; ++j) {
        scanf("%d", &M[i][j]);
      }
    }

    int counter = 0;
    int flag = 1;
    while (flag) {
      flag = 0;
      for (i = 0; i < h; ++i) {
        for (j = 0; j < w; ++j) {
          if (M[i][j] == 0) continue;
          for (k = j + 1; k < w && M[i][j] == M[i][k]; ++k)
            ;

          if (k - j >= 3) {
            flag = 1;
            counter += M[i][j] * (k - j);
            for (--k; k >= j; --k) {
              M[i][k] = 0;
            }
          }
        }
      }
      // for (i = 0; i < h; ++i) {
      //   for (j = 0; j < w; ++j) {
      //     printf("%d ", M[i][j]);
      //   }
      //   puts("");
      // }
      // puts("---");
      for (j = 0; j < w; ++j) {
        int d = h - 1;
        for (i = h - 1; i >= 0; --i) {
          if (M[i][j] != 0) {
            M[d][j] = M[i][j];
            if (i != d) M[i][j] = 0;
            --d;
          }
        }
      }

      // for (i = 0; i < h; ++i) {
      //   for (j = 0; j < w; ++j) {
      //     printf("%d ", M[i][j]);
      //   }
      //   puts("");
      // }
      // puts("::::::::");
    }

    printf("%d\n", counter);
  }
}


Measured memory_bytes: 2064
#include<iostream>
using namespace std;
int main(void)
{
    int a,b;
    char ch;
    cin>>a>>ch>>b;
    while(ch!='?')
    {
        switch(ch)
        {
            case '+':
            cout<<a+b<<endl;
            break;
            case '-':
            cout<<a-b<<endl;
            break;
            case '*':
            cout<<a*b<<endl;
            break;
            case '/':
            cout<<a/b<<endl;
            break;
            default :
            break;
        }
        cin>>a>>ch>>b;
    }
    return 0;
}


Measured memory_bytes: 3104