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

const int MAX_T=130;
const int dx[6]={0,1,1,-1,-1,0};
const int dy[6]={1,1,0,0,-1,-1};

int t,n,x,y,ans;
int d[MAX_T][MAX_T];
queue<pair<int,int>> que;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> t >> n,t){
        for (int i=0;i<MAX_T;++i)
            for (int j=0;j<MAX_T;++j)
                d[i][j]=-1;
        for (int i=0;i<n;++i){
            cin >> x >> y;
            d[x+MAX_T/2][y+MAX_T/2]=-2;
        }
        cin >> x >> y;
        d[x+MAX_T/2][y+MAX_T/2]=0;
        que.emplace(x+MAX_T/2,y+MAX_T/2);
        while(!que.empty()){
            auto p=que.front(); que.pop();
            x=p.first,y=p.second;
            for (int i=0;i<6;++i){
                int nx=x+dx[i],ny=y+dy[i];
                if (nx<0||MAX_T<=nx||ny<0||MAX_T<=ny) continue;
                if (d[nx][ny]!=-1) continue;
                d[nx][ny]=d[x][y]+1;
                que.emplace(nx,ny);
            }
        }
        ans=0;
        for (int i=0;i<MAX_T;++i)
            for (int j=0;j<MAX_T;++j)
                ans+=(0<=d[i][j]&&d[i][j]<=t);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3196
#include <iostream>

using namespace std;

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

void babbleSort(long long int *a,long long int num){
	for(int i=0;i<num;i++){
		for(int j=num-1;j>i;j--){
			if(a[j]>=a[j-1]){
				swap(&a[j],&a[j-1]);
			}
		}
	}
}

int main(){

	long long int a[3];

	cin>>a[0]>>a[1]>>a[2];

	babbleSort(a,3);

	if(a[0]%2==0||a[1]%2==0||a[2]%2==0){
		cout<<0<<endl;
	}
	else{
		cout<<a[1]*a[2]<<endl;
	}

		/*
	for(int i=0;i<3;i++){
		cout<<a[i]<<endl;
	}
	*/

	return 0;

}

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

int main() {
	int n,m;
	cin >> n >> m;
	vector<bool> pv(n);
	for (auto i = pv.begin();i != pv.end();++i) {
		*i = true;
	}
	while (m--) {
		int i;
		cin >> i;
		pv[i] = false;
	}
	int count = 0;
	while (pv.size() != 1) {
		int loop = pv.size()/2;
		vector<bool> sub_pv(pv.size()/2);
		for (int i = 0;i != loop;++i) {
			if (pv[2*i] && pv[2*i+1]) {
				++count;
				sub_pv[i] = true;
			} else if (pv[2*i] || pv[2*i+1]) {
				sub_pv[i] = true;
			}
		}
		pv = sub_pv;
	}
	cout << count << endl;
}

Measured memory_bytes: 3144
function main(input){
  var lines = input.split('\n');
  var s = lines[0].split(""); // change to array
  var t = lines[1].split("");
  s = s.sort().join();
  t = t.sort().reverse().join();

  s < t ? console.log("Yes") : console.log("No");
  
}
main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));

Measured memory_bytes: 7628
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;
#define double long double
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int ll

void solve() {
    int n;
    cin >> n;
    vi a(n+1);
    cin >> a;
    vi suf(n + 2, 0);
    for (int i = n; i >= 0; --i) suf[i] = suf[i + 1] + a[i];
    int res = 0;
    int cur_v = 1;
    rep(i, 0, n + 1) {
        res += cur_v;
        cur_v -= a[i];
        cur_v *= 2;
        if (cur_v < 0 || cur_v == 0 && suf[i + 1] != 0) {
            put(-1);
            return;
        }
        if (cur_v >= suf[i + 1]) {
            rep(j, i + 1, n + 1) res += (j - i) * a[j];
            put(res);
            return;
        }
    }
    put(-1);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 4768
a = input().upper()
b = input().upper()
c = input().upper()
t = 'A'
while True:
  if t=='A':
    if len(a)<1:
      t = 'A'
      break
    t = a[0]
    a = a[1:]
  elif t=='B':
    if len(b)<1:
      t = 'B'
      break
    t = b[0]
    b = b[1:]
  else:
    if len(c)<1:
      t = 'C'
      break
    t = c[0]
    c = c[1:]
print(t)

Measured memory_bytes: 8928
def resolve():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    dp = [[-1 for _ in range(2)] for __ in range(45)]
    dp[0][0] = 0

    for i in range(40):
        mask = 1<<(40-i-1)
        one_num = 0
        for a in A:
            if a & mask:
                one_num += 1
        costdiff0 = mask*one_num
        costdiff1 = mask*(N-one_num)
        if dp[i][1] != -1:
            dp[i+1][1] = max(dp[i+1][1], dp[i][1]+max(costdiff0, costdiff1))
        if dp[i][0] != -1 and K&mask: 
            dp[i+1][1] = max(dp[i+1][1], dp[i][0]+costdiff0)
        if dp[i][0] != -1:
            if K&mask:
                dp[i+1][0] = max(dp[i+1][0], dp[i][0]+costdiff1)
            else:
                dp[i+1][0] = max(dp[i+1][0], dp[i][0]+costdiff0)
    print(max(dp[40][0], dp[40][1]))

    

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 14492
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
int main(void)
{
  ll n, m, c;
  cin >> n >> m >> c;
  vector<ll> b(m);
  rep(i, m) cin >> b[i];
  ll count = 0;
  rep(i, n) {
    ll p = 0;
    ll a;
    rep(j, m) {
      cin >> a;
      p += a * b[j];
    }
    if (p + c > 0) count++;
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>C(h);
    rep(i,h) cin>>C[i];
    int ans = 0;

    rep(a, 1<<h) rep(b, 1<<w){
        int count = 0;
        rep(i,h) rep(j,w){
            if (a>>i & 1) continue;
            if (b>>j & 1) continue;
            if (C[i][j] == '#') count++;
        }
        if (count == k) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL  
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
 
typedef struct node * Node;
Node root;
void insert(int k);
void inorderTreeWalk(Node x);
void preorderTreeWalk(Node x);
  
int main()
{
  char str[20];
  int m,i,x;
  scanf("%d",&m);
  for( i=0 ; i<m ; i++ ){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p'){
      inorderTreeWalk(root);
      printf("\n");
      preorderTreeWalk(root);
      printf("\n");
    }
  }
  return 0;
   
}

void insert(int k)
{
  Node x;
  Node y;
  Node z;
  y = NIL;
  x = root;
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
   
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->l;
    else x = x->r;
  }
  z->p = y;
 
  if(y==NIL) root = z;
  else if(z->key<y->key) y->l = z;
  else y->r = z;
}
 
void inorderTreeWalk(Node x)
{
  if(x==NIL) return;
  inorderTreeWalk(x->l);
  printf(" %d",x->key);
  inorderTreeWalk(x->r);
}
 
void preorderTreeWalk(Node x)
{
  if(x==NIL) return;
    printf(" %d",x->key);
    preorderTreeWalk(x->l);
    preorderTreeWalk(x->r);
   
}

Measured memory_bytes: 24040
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< double, int > iP;
typedef pair< iP, iP > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

struct edge {
    int to, dis, lim;
};

class Dijkstra {
    vector< vector< edge > > graph;
    double minCost[31][31][31];
public:
    Dijkstra(int N) {
        graph.resize(N);
        fill_n(**minCost, 31 * 31 * 31, INF);
    }
    
    void add_edge(int from, int to, int dist, int limit) {
        graph[from].push_back((edge){to, dist, limit});
    }
    
    string run(int S, int G) {
        // time, now, prev, velocity
        priority_queue< iiP, vector< iiP >, greater< iiP > > que;
        for(int i = 0; i < graph[S].size(); i++) {
            que.push(iiP(iP(graph[S][i].dis, graph[S][i].to), iP(S, 1)));
            minCost[graph[S][i].to][S][1] = graph[S][i].dis;
        }
        while(!que.empty()) {
            iiP p = que.top(); que.pop();
            int now = p.fr.sc,  prev = p.sc.fr, v = p.sc.sc;
            double timed = p.fr.fr;
            if(now == G && v == 1) {
                stringstream sss; sss << fixed << setprecision(10) << timed;
                return sss.str();
            }
            for(int i = 0; i < graph[now].size(); i++) {
                edge &e = graph[now][i];
                if(e.to == prev) continue;
                for(int j = -1; j <= 1; j++) {
                    int nextv = v + j;
                    if(nextv < 1 || nextv > e.lim) continue;
                    if((double)e.dis / nextv + timed < minCost[e.to][now][nextv]) {
                        que.push(iiP(iP((double)e.dis / nextv + timed, e.to), iP(now, nextv)));
                        minCost[e.to][now][nextv] = (double)e.dis / nextv + timed;
                    }
                }
            }
        }
        return "unreachable";
    }
};

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        Dijkstra solver(n + 1);
        int s, g; cin >> s >> g;
        for(int i = 0; i < m; i++) {
            int a, b, d, l; cin >> a >> b >> d >> l;
            solver.add_edge(a, b, d, l);
            solver.add_edge(b, a, d, l);
        }
        cout << solver.run(s, g) << endl;
    }
}

Measured memory_bytes: 2216
#include <stdio.h>

int main(void)
{
	char op;
	int a, b;
	for (int i = 0;; i++)
	{
		scanf("%d %c %d", &a, &op, &b);
		int  wa = a + b, sa = a - b, seki = a*b;
		float syou = a / b;
		if (op == '+')printf("%d", wa); 
		if (op == '-')printf("%d", sa); 
		if (op == '*')printf("%d", seki); 
		if (op == '/')printf("%.0f",syou); 
		if (op == '?')break;
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
// C - ThREE
#include <bits/stdc++.h>

using namespace std;

void dfs(const vector<vector<int> > &g, int root, int d, vector<int> &c)
{
	c[root] = d;
	for (int i = 0; i < g[root].size(); i++)
		if (c[g[root][i]] < 0) dfs(g, g[root][i], d ^ 1, c);
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > g(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	vector<int> ans(n), c(n, -1), a[2];
	dfs(g, 0, 0, c);
	for (int i = 0; i < n; i++) a[c[i]].push_back(i);
	set<int> s;
	for (int i = 1; i <= n; i++) s.insert(i);
	int x = a[0].size() < a[1].size() ? 0 : 1;
	if (a[x].size() <= n / 3) {
		for (int i = 0, next = 3; i < a[x].size(); i++, next += 3) {
			ans[a[x][i]] = next;
			s.erase(next);
		}
	} else {
		for (int i = 0, next = 1; i < a[x].size(); i++, next += 3) {
			ans[a[x][i]] = next;
			s.erase(next);
			if (next + 3 > n) next = 0;
		}
	}

	set<int>::iterator it = s.begin();
	for (int i = 0; i < n; i++)
		if (ans[i] == 0) ans[i] = *it++;

	for (int i = 0; i < n; i++) cout << (i ? " " : "") << ans[i];
	cout << endl;

	return 0;
}


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

int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans=w*h/2;
    printf("%.9f",ans);
    if(w/2==x&&h/2==y) cout<<" 1";
    else cout<<" 0";
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
	
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
	
using namespace std;
	
using ll = long long;
using ld = long double;
using ull = unsigned long long;
	
signed main(){
	io();
	ll n, w; cin >> n >> w;
	vector<ll> we(n), va(n);
	for(ll i = 0; i < n; ++i){
		cin >> we[i] >> va[i];
	}
	ll kk[n + 1][w + 1]; memset(kk, 0, sizeof(kk));
	for(ll i = 1; i <= n; ++i){
		for(ll j = 1; j <= w; ++j){
			ll x = 0, y = kk[i - 1][j], z = we[i - 1];
			if(j >= z){
				x = va[i - 1];
				x += kk[i - 1][j - z];
			}
			kk[i][j] = max(x, y);
		}
	}
	return cout << kk[n][w] << '\n', 0;
}

Measured memory_bytes: 82460
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int A;
    int B;
    int K;
    ArrayList<Integer> answer = new ArrayList<Integer>();
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        A = sc.nextInt();
        B = sc.nextInt();
        K = sc.nextInt();
    }
    
    //解答処理
    ArrayList<Integer> solve() {
        if(B-A+1 > 2*K){ //A以上B以下の整数の個数(B-A+1)が2Kより大きい場合
            for(int i=A; i<A+K ; i++){ //小さいほうからK番目まで
                answer.add(i);
            }
            for(int i=B; i>B-K; i--){ //大きい方からK番目まで
                answer.add(i);
            }
        } else {    //A以上B以下の整数の個数(B-A+1)が2K個以下だった場合
            for(int i=A; i<=B; i++){    //値をすべてそのまま格納
                answer.add(i);
            }
        }
        
        Collections.sort(answer);
        return answer;
    }
    
    //出力
    void show(ArrayList<Integer> answer) {
        for (int i=0; i<answer.size(); ++i){
            System.out.println(answer.get(i));
        }
    }
}


Measured memory_bytes: 36084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, M;
    cin >> N >> M;
    if (N >= M) {
        cout << 0 << endl;
        exit(0);
    }
    vector<int> X(M);
    for (auto &x : X) cin >> x;
    sort(X.begin(), X.end());

    vector<int> DX(M - 1);
    for (int i = 0; i < M - 1; ++i) {
        DX.at(i) = X.at(i + 1) - X.at(i);
    }
    sort(DX.begin(), DX.end(), greater<int>());

    int ans = X.back() - X.front();
    for (int i = 0; i < N - 1; ++i) {
        ans -= DX.at(i);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int N, D;
	cin >> N >> D;
	vector<vector<long long>> X(N, vector<long long> (D));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >>  X.at(i).at(j);
		}
	}
	
	int cnt = 0;
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			long long dis = 0;
			for(int k = 0; k < D; k++){
				dis += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
			}
			double C = sqrt(dis);
			double D = floor(C);
			if(C == D) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  ll ans=0;
  ll now=1;
  while(now<b){
      now+=a-1;
      ans++;
  }
  co(ans)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++,cout<<endl)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='#')
			{
				cout<<a[i][j];
				continue;
			}
			else
			{
				int ans=0;
				if(a[i-1][j]=='#') ans++;
				if(a[i-1][j-1]=='#') ans++;
				if(a[i-1][j+1]=='#') ans++;
				if(a[i][j-1]=='#') ans++;
				if(a[i][j+1]=='#') ans++;
				if(a[i+1][j-1]=='#') ans++;
				if(a[i+1][j]=='#') ans++;
				if(a[i+1][j+1]=='#') ans++;
				cout<<ans;
			}
	return 0;
}

Measured memory_bytes: 256
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

double x,xx,y,yy;
double xxx,yyy,xxxx,yyyy;

double dest(double x,double y,double xx,double yy)
{
	
	return sqrt(((x-xx)*(x-xx))+((y-yy)*(y-yy)));
}

int main(){
FAST_READ;
//cin.tie(0);
cin>>x>>y>>xx>>yy;
xxx=xx-yy+y;
yyy=yy+xx-x;
xxxx=x-yy+y;
yyyy=y+xx-x;
cout<<xxx<<" "<<yyy<<" "<<xxxx<<" "<<yyyy<<endl;


return 0;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();

		int x = (n - (n % 15)) / 15;
		int amount = 800 * n - 200 * x;
		System.out.println(amount);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int main(){
	int n;
	cin>>n;
	vector<int> ln(n);
	REP(i,n){
		cin>>ln[i];
	}
	sort(ALL(ln));
	ll ans=0;
	for(int a=0;a<n-1;a++){
		for(int b=a+1;b<n;b++){
			int x,y;
			x=lower_bound(ALL(ln),(ln[a]+ln[b]))-ln.begin();
			y=upper_bound(ALL(ln),abs(ln[b]-ln[a]))-ln.begin();
			ans+=x-y;
			if((ln[b]-ln[a]+1)<=ln[a]&&ln[a]<(ln[a]+ln[b])) ans--;
			if((ln[b]-ln[a]+1)<=ln[b]&&ln[b]<(ln[a]+ln[b])) ans--;
		}
	}
	ans/=3;
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define mxn 200010
#define LL long long
using namespace std;
const int mod=1e9+7;
int n,m,K,N,C,sl,fh,ans,inv[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int _pow(int k,int i)
{
	int t=1;
	while(i)
	{
		if(i&1) t=1ll*t*k%mod;
		k=1ll*k*k%mod;i>>=1;
	}
	return t;
}
int main()
{
	n=rd();m=rd();K=rd()-2;N=n*m-2;C=1;inv[1]=1;
	for(int i=N-K+1;i<=N;++i) C=1ll*i*C%mod;
	for(int i=2;i<=K;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;;
	for(int i=2;i<=K;++i) C=1ll*C*inv[i]%mod;
	for(int i=1;i<n;++i) ans=(ans+1ll*i*(n-i)*m*m)%mod;
	for(int i=1;i<m;++i) ans=(ans+1ll*i*(m-i)*n*n)%mod;
	ans=1ll*C*ans%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
s = gets.chomp.split("")
arr1 = []
arr2 = []
first = (s.size - 1) / 2
last = (s.size + 3) / 2
ss = s.reverse
s1 = s.join("")
s2 = ss.join("")
if first % 2 == 1
    (0..first-1).each do |i|
        arr1 << s[i]
    end
    j = 0
    (last-1..s.size-1).each do |i|
        arr2 << s[i]
    end
    arr1m = arr1.join("")
    arr2m = arr2.join("")

    arr1r = arr1.reverse.join("")
    arr2r = arr2.reverse.join("")
    if arr1m == arr1r && arr2m == arr2r &&  s1 == s2
        puts "Yes"
    else
        puts "No"
    end
elsif first % 2 == 0
    (0..first-1).each do |i|
        arr1 << s[i]
    end
    j = 0
    (last-1..s.size-1).each do |i|
        arr2 << s[i]
    end
    arr1m = arr1.join("")
    arr2m = arr2.join("")

    arr1r = arr1.reverse.join("")
    arr2r = arr2.reverse.join("")
    if arr1m == arr1r && arr2m == arr2r  &&  s1 == s2
        puts "Yes"
    else
        puts "No"
    end
end

Measured memory_bytes: 14296
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def main():
    dic = {c:i for i, c in enumerate(alpha)}
    n = int(input())
    s = input()
    print(''.join([alpha[(dic[c]+n)%26] for c in s]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#include <iomanip>
#include <map>
#define MAX_N 100
#define INF 10000000

using namespace std;

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int n,m,a,b;
int N[100];
string s,t;

void solve() {
	int s=0;
	for (int i = 0; i < n; i++) {
		s += N[i];
	}
	double ave = (double)s / n;
	double t = INF;
		a=101;
	for (int i = 0; i < n; i++) {
		if (t > abs(ave - N[i])) {
			t = abs(ave - N[i]);
			a = i;
		}
	}
	cout << a << endl;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> N[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
string A[3000], B[3000];
signed main() {
  int N, M; cin >> N >> M;
  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < N; i++)
    cin >> B[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      if (A[i][j] != B[i][j]) ans++;

  cout << ans << endl;
}




Measured memory_bytes: 11268
long M=1e9+7,m[1<<18],h,w,a,s;p(a,b)long a,b;{return b?p(a*a%M,b/2)*(b%2?a:1)%M:1;}main(i){for(*m=1;i<1<<18;)m[i]=m[i-1]*i++%M;for(scanf("%d%d%d%d",&h,&w,&a,&i);i<w;i++)s=(s+m[h-a-1+i]*p(m[h-a-1],M-2)%M*p(m[i],M-2)%M*m[a+w-i-2]%M*p(m[a-1],M-2)%M*p(m[w-1-i],M-2)%M)%M;printf("%d",s);}

Measured memory_bytes: 2176
n, k = gets.chomp.split.map(&:to_i)
input_ary = gets.chomp.split.map(&:to_i)

max = 0
for x in 0..n
    for y in 0..(n-x)
        for z in 0..k
            if x+y+z > k || x+y-z < 0
                # puts "skip"
                next
            end
            ary = []
            ary += input_ary[0..x-1] if x > 0
            ary += input_ary[n-y..n-1] if y > 0
            ary.sort! {|a,b| b <=> a}
            # puts
            # puts max
            # p ary[0..x+y-1-z]
            # p ary
            # puts "zj x y z"
            # p [x, y, z]
            max = [max, ary[0..x+y-1-z].inject(:+)].max if ary.length > 0
        end
    end
end
puts max
            


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 1000000007

vec p(12);

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    int ans = ceil((n * 1.0) / m);
    cout << ans;

}
  

Measured memory_bytes: 256
n,m,k=map(int,input().split())
flg=0
for i in range(n):
  tmp=k-m*i
  if n==i*2 or tmp<0:
    pass
  elif tmp%(n-i*2)==0 and 0<=tmp//(n-i*2)<=m:
    flg=1
if flg==1:
  print('Yes')
else:
  print('No')

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

using namespace std;
#define ll long long
#define repX(i,j,n) for (ll i = j; i < n; i++)
#define rep(i, n) repX(i,0,n)


int main()
{
    ll n,x,lsum=0,ans=1;
    cin >> n >> x;
    
    rep(i,n)
    {
        ll tmp;
        cin >> tmp;
        
        lsum += tmp;
        ans += (lsum <= x ? 1: 0);
    }
    
    cout << ans<< endl;
    return 0;
}

/*
 N
 
 X
 
 L
 1
 
 L
 2
 
 .
 .
 .
 
 L
 N
 −
 1
 
 L
 N

 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

ll n, a[1005], ans;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1 ; i <= n; i++)
        cin >> a[i];
    ans = a[1];
    for (int i = 2; i <= n; i++) {
        ans = ans / __gcd(ans, a[i]) * a[i];
    }
    cout << ans << endl;

    return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define go(i,s) for(int i = head[s]; i; i = e[i].next)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const int maxn = 51;
const db eps = 1e-8;

ll v[maxn];
int a, b, n;
ll f[maxn][maxn], g[maxn][maxn];
ll ans, x, y;
db ans1;

int main()
{
	cin >> n >> a >> b;
	assert(a<=b);
	fo(i,1,n) cin >> v[i];
	g[0][0] = 1;
	fo(i,1,n) fo(j,0,i)
	{
		if(f[i-1][j] > f[i][j])
		{
			f[i][j] = f[i-1][j];
			g[i][j] = g[i-1][j];
		}
		else if(f[i-1][j] == f[i][j]) g[i][j] += g[i-1][j];
		if(j>=1&&f[i-1][j-1]+v[i] > f[i][j])
		{
			f[i][j] = f[i-1][j-1]+v[i];
			g[i][j] = g[i-1][j-1];
		}
		else if(j>=1&&f[i-1][j-1]+v[i] == f[i][j]) g[i][j] += g[i-1][j-1];
	}
	ans1 = 0;
	fo(i,a,b) if((db)f[n][i]/(i*1.0)>ans1) ans1=(db)f[n][i]/(i*1.0), x = f[n][i], y = i;
	ans = 0;
	fo(i,a,b) if(x*i==f[n][i]*y) ans += g[n][i];
	printf("%.6lf\n",ans1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int ans = 0;
    rep(i, n) {
        if ( s[i] == 'I' )      ++x;
        else if ( s[i] == 'D' ) --x;
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll arr[5];
		ll ans = -1;
		for (ll i = 0; i < 5; i++)
		{
			cin >> arr[i];
			if (arr[i] == 0)
				ans = i + 1;
		}
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 110;
const ll INF = 2e9+10;

int n;
char s[maxn], ss[maxn];
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    //ios_base::sync_with_stdio(false);

    cin >> n >> s >> ss;
    for(int i = 0;i < n;i++)cout << s[i] << ss[i];
    cout << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,i,j;
	j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) j++;
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 596
import numpy as np

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])

cost = 0
drinks = 0
for a, b in ab:
    after = drinks + b
    if after > m:
        cost += (m - drinks) * a
        break
    cost += a * b
    drinks += b
print(cost)

Measured memory_bytes: 38000
#include<iostream>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int d=0,ans=1,l;
  for(int i=0;i<n;i++){
    cin >> l;
    d+=l;
    if(d>x)break;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[7][7]={
  {7,8,18,0,1,2,3},
  {8,9,0,1,10,3,4},
  {18,0,17,2,3,16,5},
  {0,1,2,3,4,5,6},
  {1,10,3,4,11,6,12},
  {2,3,16,5,6,15,14},
  {3,4,5,6,12,14,13}
};
string s;
int main(){
  while(cin>>s,s!="#"){
    int flag=0;
    for(int i=0;i<(1<<19);i++){
      int x=0,y=0;
      for(int j=0;j<7;j++){
         int p=0;
         for(int k=0;k<7;k++){
            p+=(((i&(1<<a[j][k]))?1:0)<<k);
         }
         if(j==3)y=p;
         x+=((s[p]-'0')<<j);
      }
      if(s[x]!=s[y])flag=1;
    }
    if(flag)cout<<"no"<<endl;
    else cout<<"yes"<<endl;
  }
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi fac,finv,inv;
void init(ll n) {
    fac=vi(n+5);finv=vi(n+5);inv=vi(n+5);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP(i,2,n+5){
        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 modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    ll k,n;cin>>k>>n;
    init(n+k);
    REP(j,2,2*k+1){
        ll ans=0;
        ll a=min((j-1)/2,(k*2-j+1)/2),b=(j+1)%2;
        rep(i,a+1)ans=(ans+modcom(a,i)*modpow(2,i)%mod*(modcom(n+k-a*2-b-1,k-a*2-b+i-1)+modcom(n+k-a*2-b-2,k-a*2-b+i-1)*b))%mod;
        out(ans);
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPP(x,y,c) for(const auto& [x,y]:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

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

	ll s = k;
	REP(i, n - 1) {
		s *= k - 1;
	}
	cout << s << endl;
}


Measured memory_bytes: 256
import sys

#+++++
		
def main():
	a= ['Sunny', 'Cloudy', 'Rainy']
	a=a+a
	today = input()
	for i,w in enumerate(a):
		if w==today:
			print(a[i+1])
			return
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
import sys

n = int(input())
data = [tuple(map(int, input().split())) for i in range(n)]

for _x, _y, _h in data:
    if _h != 0:
        break

for x in range(101):
    for y in range(101):
        h = _h + abs(_x-x) + abs(_y-y)
        for tmp_x, tmp_y, tmp_h in data:
            if tmp_h != max(h - abs(tmp_x-x) - abs(tmp_y-y), 0):
                break
        else:
            print(x, y, h)
            sys.exit(0)


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

  long long int n, s=0;
  cin >> n;

  n++;

  while(n>9){
    s+=9;
    n/=10;
  }

  cout << s+n-1 << endl;
  

  return 0;
}

Measured memory_bytes: 256
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}





int main() {
	string X;
	cin >> X;
	
	int n = X.size(), ans = n, s = 0, t = 0;
	
	for_(i,0,n) {
		if (t == 0 && X[i] == 'S') {
			++s;
		} else if (s > 0 && X[i] == 'T') {
			++t;
		} else if (t > 0 && X[i] == 'S') {
			int rm = min(s, t);
			ans -= 2 * rm;
			s = max(1, s - rm + 1);
			t = 0;
		}
	}
	
	ans -= 2 * min(s, t);
	
	cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

idx = 1
count = 1

i = 0
while i < N:
    if a[idx - 1] == 2:
        print(count)
        break
    
    idx = a[idx - 1]
    count += 1
    i += 1
if i == N:
    print(-1)


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

struct P{
  int po[3];
  int total;
};

int main(){
  int n;
  int fl;
  cin >> n;
  P data[n];
  for(int i=0;i<n;i++) data[i].total = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> data[i].po[j];
    }
  }
  for(int k=0;k<3;k++){
    for(int i=0;i<n;i++){
      fl = 0;
      for(int j=0;j<n;j++){
	if(data[i].po[k] == data[j].po[k] && i != j) {
	  fl = 1;
	}
      }
      if(fl == 0) data[i].total += data[i].po[k];
    }
  }
  for(int i=0;i<n;i++){
    cout << data[i].total << endl;
  }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    string s;
    while(cin>>s)
    {
        int num=0;
        int l=s.length();
        for(int i=1;i<l;i++)
        {
            if(s[i]!=s[i-1])
                num++;
        }
        cout<<num<<endl;
    }
    return 0;
}

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

int main() {
    int smy = 0, x = 0, y = 0, n;
    cin >> n;
    while(n--) {
        int t, a, b;
        cin >> t >> a >> b;
        int d = abs(a - x) + abs(b - y);
        if(d > t - smy) return !printf("No\n");

        int k = (t - smy) - d;
        if(k & 1) return !printf("No\n");
        smy = t;
        x = a, y = b;
    }

    puts("Yes");
}

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

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

bool lcm_overflow(intmax_t m, intmax_t n, intmax_t& res) {
  intmax_t g = gcd(m, n);
  return __builtin_mul_overflow(m/g, n, &res);
}

intmax_t g(std::vector<intmax_t> const& a, size_t j, intmax_t m) {
  intmax_t div = 1;
  for (size_t i = 0; i < a.size(); ++i)
    if (j >> i & 1)
      if (lcm_overflow(div, a[i], div)) return 0;

  return m / div;
}

int main() {
  size_t n;
  intmax_t m;
  scanf("%zu %jd", &n, &m);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  std::vector<int> p(n);
  for (auto& pi: p) scanf("%d", &pi);

  std::vector<intmax_t> dp(1_zu << n);
  for (size_t j = 1; j < dp.size(); ++j)
    dp[j] = g(a, j, m);

  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < (1_zu << n); ++j)
      if (j >> i & 1) dp[j] -= dp[j ^ (1_zu << i)];

  double res = 0;
  for (size_t j = 0; j < (1_zu << n); ++j) {
    double pj = 1;
    for (size_t i = 0; i < n; ++i)
      pj *= ((j >> i & 1)? p[i]: 100-p[i]) / 100.0;

    intmax_t vj = dp[j];
    if (!__builtin_parityll(j)) vj = -vj;
    res += pj * vj;
  }

  printf("%.12f\n", res);
}



Measured memory_bytes: 10564
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<P> vl,vr;

bool comp(P a, P b){
	return (a.second-a.first) > (b.second-b.first);
}

int main(void){
	int n,k,i,ans=0;
	string s;
	cin >> n >> k;
	cin >> s;
	s.push_back('@');
	if(s[0]=='R' && s[1]=='R'){
		++ans;
	}
	for(i=1; i<n; ++i){
		if((s[i]=='L' && s[i-1]=='L')||(s[i]=='R' && s[i+1]=='R')){
			++ans;
		}
	}
	cout << min(ans+k*2,n-1) << endl;
	return 0;
}


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

using namespace std;

#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mp make_pair




int main()
{
    fast;
    //openin;
    //openout;
     int n;
     vector<int> a;
     cin>>n;
     for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.pb(x);
     }
     //for(int i=0;i<a.size();i++)   cout<<a[i]<<endl;
     int res = INT_MAX;
     sort(a.begin(),a.end());
     int mini=a[0],maxi=a[n-1];
     //cout<<mini<<" "<<maxi<<endl;
     for(int i=mini;i<=maxi;i++){
        int sum =0;
        for(int j=0;j<a.size();j++){
            sum += (a[j]-i)*(a[j]-i);
        }
        //cout<<"Sum"<<sum<<endl;
        res = min(res,sum);
        //cout<<"Res"<<res<<endl;
     }
     cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

signed main(){
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
	return 0;
}

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

int main() {
    int N;
    int max_count = -1;
    int num = 0;
    cin >> N;
    for(int i = 1; i <=N; i++){
        int tmp = i;
        int count = 0;

        while(true) {
            
            if(tmp % 2 != 0){
                break;
            }
            count++;
            tmp /= 2;
        }
        if(max_count < count) {
            max_count = count;
            num = i;
        }
        
    }
    cout << num << endl; 
}

Measured memory_bytes: 256