akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    reverse(all(s));
    vvint dp(s.size()+1,vint(2,inf));
    dp[0][0] = 0;
    rep(i,s.size()) {
        int x = s[i] - '0';
        chmin(dp[i+1][0],dp[i][0]+x);
        if (x != 9) chmin(dp[i+1][0],dp[i][1]+x+1);
        chmin(dp[i+1][1],dp[i][0]+(10-x));
        if (x != 9) chmin(dp[i+1][1],dp[i][1]+(9-x));
        if (x == 9) chmin(dp[i+1][1],dp[i][1]);
    }
    cout << min(dp[s.size()][0],dp[s.size()][1]+1) << endl;
}

Measured memory_bytes: 55940
import java.util.*;
import java.lang.Math;


public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
}

Measured memory_bytes: 21844
// 解答PDFの想定解通り、Z-Algorithmで解答

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdint>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

// 文字列が与えられた時、各 i について「SとS[i:]の最長共通接頭辞の長さ」をO(|S|)で構築
// e.g.
//   aaabaaaab
//   921034210
// https://snuke.hatenablog.com/entry/2014/12/03/214243
template <typename T>
vector<int> z_algorithm(T& s) {
    auto len = SIZE(s);
    vector<int> ret(len);
    ret[0] = len;
    int i = 1, j = 0;
    while (i < len) {
        while (i + j < len && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i + k < len && k + ret[k] < j) {ret[i+k] = ret[k]; ++k;}
        i += k; j -= k;
    }    
    return ret;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    REP(n, N) {
        string substr = S.substr(n);
        auto z = z_algorithm(substr);
        REP(i, SIZE(substr)) {
            ans = max(ans, min(z[i], i));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int tax8,tax10;
  int ans=-1;
  scanf("%d %d",&tax8,&tax10);
  for(int i=1;i<1001;i++)
  {
    if(i*8/100==tax8 && i*10/100==tax10)
    {
      ans=i;
      break;
    }
  }
  printf("%d",ans);
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int k, x;
    cin >> k >> x;
    for(int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '+'){
            cout << a + b << endl;
        }else if (op == '-'){
            cout << a - b << endl;
        }else if (op == '*'){
            cout << a * b << endl;
        }else if (op == '/'){
            cout << a / b << endl;
        }else if (op == '?') break;
    }
    return 0;
}


Measured memory_bytes: 3096
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = input()

print("Yes" if "7" in N else "No")


Measured memory_bytes: 65240
#include<bits/stdc++.h>
using namespace std;
int b[999999], n, c[999999];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d",&c[i]);
	}
	b[1] = 0;
	for (int i = 2; i <= n; i++) {
		b[i] = b[i / 2] + b[(i + 1) / 2] + i;
	}
	sort(c, c + n);
	for (int i = 0; i < n; i++) {
		cout << c[i];
		if (i < n - 1) {
			cout << ' ';
		}
		else { cout << endl; }
	}
	cout << b[n] << endl;
	return 0;
}

Measured memory_bytes: 7312
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

string ans="";
void yuclid(int x){
    if (x==1) {
        ans += '1';
        return;
    }
    int waru, amari;
    if (x<0){
        waru = (x-1)/(-2);
        amari = (x)%(-2);
    }else{
        waru = x/(-2);
        amari = x%(-2);
    }
    if (amari==0){
        ans += '0';
    }else{
        ans += '1';
    }
    return yuclid(waru);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n==0) {
        cout << '0' << endl;
        return 0;
    }
    yuclid(n);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    long[] AS, BS;
    foreach (_; 0..N) {
        auto ab = readln.split.to!(long[]);
        AS ~= ab[0];
        BS ~= ab[1];
    }
    sort(AS);
    sort(BS);
    long l, r;
    if (N%2 == 0) {
        l = AS[N/2] + AS[N/2-1];
        r = BS[N/2] + BS[N/2-1];
    } else {
        l = AS[N/2];
        r = BS[N/2];
    }
    writeln(r - l + 1);
}

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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)

int d[334334];

signed main() {
    int n;
    cin >> n;
    rep(i, n) {
        cin >> d[i];
    }
    int all = 0;
    rep(i, n) {
        all += d[i];
    }
    int r = 0;
    int ans = inf * inf;
    trep(i, n - 2) {
        r += d[i];
        all -= d[i];
        ans = min(ans, abs(all - r));
    }
    cout << ans << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<long long> que;
    for (int i = 0; i < n; i++) {
        long long a;
        cin >> a;
        que.push(a);
    }

    for (int i = 0; i < m; i++) {
        long long v = que.top(); que.pop();
        v /= 2;
        que.push(v);
    }

    long long sum = 0;
    while (!que.empty()) {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}  

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {

	void Solve() {
		ULL N, A, B; cin >> N >> A >> B;
		if (A > B) swap(A, B);
		ULL ans = 0;
		if ((B - A) % 2 == 0) {
			ans = (B - A) / 2;
		}
		else {
			ans = min(N - B, A - 1);
			ans += (B - A) / 2 + 1;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct RUQ{
	using T = int;
	T operator()(const T &a, const T &b) { return min(a,b); };
	static constexpr T identity() { return INT_MAX; }
	void eval(T &a, const T &b) { a = b; };
};

struct RAQ{
	using T = int;
	T operator()(const T &a, const T &b) { return a + b; };
	static constexpr T identity() { return 0; }
	void eval(T &a, const T &b) { a += b; };
};

template<class Monoid>
class rangeUpdateQuery{
	private:
		using T = typename Monoid::T;
		Monoid op;
		const int n;
		vector<T> dat, lazy;
		int query(int a, int b, int k, int l, int r){
			evaluate(k);

			if(b <= l || r <= a) return op.identity();
			else if(a <= l && r <= b) return dat[k];
			else{
				int vl = query(a, b, k * 2, l, (l + r) / 2);
				int vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
				return op(vl, vr);
			}
		}
		inline void evaluate(int k){
			if(lazy[k] == op.identity()) return;
			dat[k] = lazy[k];
			if(k < n){
				op.eval(lazy[2 * k], lazy[k]);
				op.eval(lazy[2 * k + 1], lazy[k]);
			}
			lazy[k] = op.identity();
		}
		void update(int a, int b, int k, int l, int r, int x){
			evaluate(k);
			if(r <= a || b <= l) return;
			if(a <= l && r <= b){
				lazy[k] = x;
			}else if(l < b && a < r){
				evaluate(k);
				update(a, b, k * 2, l, (l + r) / 2, x);
				update(a, b, k * 2 + 1, (l + r) / 2, r, x);
			}
		}
		int power(int n){
			int res = 1;
			while(n >= res) res*=2;
			return res;
		}
	public:
		rangeUpdateQuery(int n) : n(power(n)), dat(4 * n, op.identity()), lazy(4 * n, op.identity()) {}
		rangeUpdateQuery(const vector<T> &v) : n(v.size()), dat(4 * n), lazy(4 * n, op.identity()){
			copy(begin(v), end(v), begin(dat) + n);
			for(int i = n - 1; i > 0; i--) dat[i] = op(dat[2 * i], dat[2 * i + 1]);
		}
		int query(int a, int b){ return query(a,b,1,0,n); }
		void update(int s, int t, int x){ update(s, t, 1, 0, n, x); }
		int get(int a){ return query(a, a + 1); };
};

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

	rangeUpdateQuery<RUQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(not com){
			int s, t, x;
			cin >> s >> t >> x;
			//cout << s << ' ' << t << endl;
			seg.update(s + 1, t + 2, x);
		}else{
			int p;
			cin >> p;
			cout << seg.get(p + 1) << endl;
		}
	}
}



Measured memory_bytes: 5972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int N,l,r,cnt=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>l>>r;
        cnt+=r-l+1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)

const int    INF = 1e11;
const double EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }

using namespace std;

bool ans() {
	int n; cin >> n;
	for (int i = 1; i < 10; ++i) {
		int mod = n % i;
		if (mod == 0)
			if (n / i <= 9)
				return true;
	}
	return false;
}

inline void Main() {
	string a = ans() ? "Yes" : "No";
	cout << a << "\n";
}

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

	Main();

	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

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

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

  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int n = s.length();
  auto dp = MakeVector2D<int64>(n + 1, 2, 1E18);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    UpdateMin(dp[i + 1][0], dp[i][0] + d);
    UpdateMin(dp[i + 1][1], dp[i][0] + (10 - d));
    UpdateMin(dp[i + 1][0], dp[i][1] + d + 1);
    UpdateMin(dp[i + 1][1], dp[i][1] + (10 - (d + 1)));
  }

  int64 ans = min(dp[n][0], dp[n][1] + 1);
  cout << ans << endl;
}

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

int main() {
    ll x;
    ll y = 100LL;
    cin >> x;
    int c = 0;
    while(y < x){
        y *= 1.01;
        ++c;
    }
    cout << c << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	s = s + s;
	bool ok = s.find(t) != string::npos;
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
cp = 0
cq = 0
def kai(a):
    if a <= 1:
        return 1
    else:
        return a*kai(a-1)
for i in range(n):
    cp += (p[i]-1)*kai(n-i-1)
    cq += (q[i]-1)*kai(n-i-1)
    for j in range(n):
        if p[j] > p[i]:
            p[j] -= 1
        if q[j] > q[i]:
            q[j] -= 1
print(abs(cp-cq))

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int n; cin >> n;
  n%=10;
  if (n%10==3) cout << "bon";
  else if (n==0||n==1||n==6||n==8) cout << "pon";
  else cout << "hon";
  cout << '\n';
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


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

using namespace std;

typedef pair<int, int> P;

int main()
{
    int N, H;
    cin >> N >> H;
    vector<int> b(N);
    int a, a_max=0;
    for(int i=0;i<N;++i){
        cin >> a >> b.at(i);
        a_max = a_max < a ? a : a_max;
    }

    sort(b.begin(), b.end(), std::greater<int>());
    for(int i=0;i<N-1;++i){
        b.at(i+1) += b.at(i);
    }

    int count, hitp;
    // n個投げつける場合でやってみるか
    int ans = (H-1) / a_max + 1;
    for(int i=1;i<N+1;i++){
        count = i;
        hitp = H - b[i-1];
        if(hitp > 0){
            count += (hitp - 1) / a_max + 1;
        }
        ans = ans > count ? count : ans;
    }
    cout << ans << endl;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int n; cin >> n;
    vector<int> A(n), B(n), C(n);
    rp(i, 0, n) scanf("%d", &A.at(i));
    rp(i, 0, n) scanf("%d", &B.at(i));
    rp(i, 0, n) scanf("%d", &C.at(i));
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    ll res = 0;
    rp(i, 0, n) {
        int b = B.at(i);
        ll a = lower_bound(A.begin(), A.end(), b) - A.begin();
        ll c = C.end() - upper_bound(C.begin(), C.end(), b);
        // printf("b = %d a = %d c = %d\n", b, a, c);
        res += a*c;
    }
    cout << res << endl;
    return 0;

}

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

int main(){
    int n; cin >> n;
    char str[100];
    bool flag = false;
    for (int i = 0; i < n; i++)
    {
        cin >> str[i];
    }
    if (n % 2 == 1){
        
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < n/2; i++)
    {
        if(str[i] == str[n/2 + i])continue;
        else flag = true;
    }
    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main(){
  int n; cin>>n;
    string s; cin>>s;
    int ans = 0;
    for(int i=0; i<n;){
        if(s[i]='A' && s.substr(i,3)=="ABC"){
            ans ++;
            i +=3;
        }
        else i++;
    }
    cout << ans << 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 minit(a,b) memset(a,b,sizeof(a))
const int DX[4] = {0,1,0,-1}, DY[4] = {1,0,-1,0};

typedef pair< int, int > Point;
typedef pair< Point, Point > Load;
  
int n, stx, sty, t, d[110];;
set< Load > loads;
char c[110];
  
bool dp[1010][55][55][4][4];
  
void solve() {
    minit(dp, 0);
      
    for_(r,0,4) fill(dp[0][sty][stx][r], dp[0][sty][stx][r] + 4, 1);
      
    int i = 0;
    for_(ii,0,t) {
        for_(rep,0,d[ii]) {
            for_(y,0,55) for_(x,0,55) for_(r,0,4) {
                bool flag = false;
                for_(pr,0,4) flag |= dp[i][y][x][r][pr];
                if (!flag) continue;
                  
                int nx = x + DX[r], ny = y + DY[r];
                Load ld(Point(x, y), Point(nx, ny));
                if (loads.find(ld) == loads.end()) continue;
                  
                for_(nr,0,4) {
                    if (nr == 2) continue;
                      
                    int dir = (r + nr) % 4;
                      
                    dp[i + 1][ny][nx][dir][r] = 1;
                }
            }
              
            ++i;
        }
        
        int ok = 0;
        if (c[ii] == 'S') ok = 2;
        if (c[ii] == 'E') ok = 1;
        if (c[ii] == 'W') ok = 3;
          
        for_(y,0,55) for_(x,0,55) for_(r,0,4) for_(pr,0,4){
            if (r != ok && pr != ok) dp[i][y][x][r][pr] = 0;
        }
    }
      
    for_(x,0,55) for_(y,0,55) {
        bool flag = false;
        for_(r,0,4) {
            int xx = x + DX[r], yy = y + DY[r];
            Load ld(Point(x, y), Point(xx, yy));
            if (loads.find(ld) == loads.end()) continue;        
            for_(pr,0,4) flag |= dp[i][y][x][r][pr];
        }
        if (flag) cout << x << " " << y << endl;
    }
}
  
int main() {
    cin >> n >> stx >> sty >> t;
      
    for_(i,0,n) {
        int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey;
          
        int x = min(sx, ex), xx = max(sx, ex);
        for (int j = 0; x + j < xx; ++j) {
            loads.insert( Load(Point(x + j, sy), Point(x + j + 1, sy)) );
            loads.insert( Load(Point(x + j + 1, sy), Point(x + j, sy)) );
        }
          
        int y = min(sy, ey), yy = max(sy, ey);
        for (int j = 0; y + j < yy; ++j) {
            loads.insert( Load(Point(sx, y + j), Point(sx, y + j + 1)) );
            loads.insert( Load(Point(sx, y + j + 1), Point(sx, y + j)) );
        }
    }
      
    for_(i,0,t) cin >> d[i] >> c[i];
      
    solve();
    return 0;
}

Measured memory_bytes: 49092
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			int m=sc.nextInt();
			int f=sc.nextInt();
			int r=sc.nextInt();
			if(m==-1&&f==-1&&r==-1){
				break;
			}else{
				if(m==-1||f==-1||m+f<30){
					System.out.println("F");
				}else if(m+f>=80){
					System.out.println("A");
				}else if(m+f>=65&&m+f<80){
					System.out.println("B");
				}else if(m+f>=50&&m+f<65){
					System.out.println("C");
				}else if(m+f>=30&&m+f<50){
					if(r>=50){
						System.out.println("C");
					}else{
						System.out.println("D");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 26176
using System;
using System.Collections.Generic;

namespace Project
{
	class Task
	{
		public string name;
		public int time;
	}

	class MainClass
	{
		public static void Main(string[] args)
		{
			int n, q;
			string[] s = Console.ReadLine().Split(' ');
			n = int.Parse(s[0]);
			q = int.Parse(s[1]);
			Queue<Task> task = new Queue<Task>();
			for (int i = 0; i < n; i++)
			{
				s = Console.ReadLine().Split(' ');
				Task tmptask = new Task();
				tmptask.name = s[0];
				tmptask.time = int.Parse(s[1]);
				task.Enqueue(tmptask);
			}
			int time = 0;
			while (task.Count != 0)
			{
				Task tmptask = task.Dequeue();
				if (tmptask.time > q)
				{
					tmptask.time -= q;
					task.Enqueue(tmptask);
					time += q;
				}
				else
				{
					time += tmptask.time;
					tmptask.time = time;
					Console.WriteLine("{0} {1}", tmptask.name, tmptask.time);
				}
			}
		}
	}
}

Measured memory_bytes: 17620
n=int(input())
A=[0]*n
B=[0]*n
for i in range(n):
  a,b=map(int,input().split())
  A[i]=a
  B[i]=b
A.sort()
B.sort()
if n%2:
  c=(n+1)//2-1
  print(B[c]-A[c]+1)
else:
  c=n//2
  print(B[c]+B[c-1]-A[c]-A[c-1]+1)

Measured memory_bytes: 25512
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define mp make_pair
#define all(X) X.begin(), X.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int i, n;
    cin >> n;
    vi arr(n + 1, 0);

    Fo(i, 1, n + 1)
    cin >> arr[i];

    vi ans(n + 1, 0);
    for(i = 1; i <= n; i++)
    {
        ans[arr[i]] = i;
    }

    for(i =1 ;i <= n; i++)
        cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll f[100001] = {};
ll MOD = 1000000007;
int main() {
	f[0] = 1;
	f[1] = 1;
	repe(i, 2, 100000) {
		f[i] = f[i - 1] * i % MOD;
	}

	ll N, M; cin >> N >> M;
	if (N == M) {
		cout << ((f[N] * f[M] % MOD) * 2 % MOD) << endl;
	}
	else if (abs(N - M) == 1) {
		cout << (f[N] * f[M] % MOD) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
int main(){
	int d,a[21]={0},b[51]={0},c[50]={0},ans=0,i,k,j;
	scanf("%d",&d);
	for(i=1;i<=d;i++){
		scanf("%d",&a[i]);
	}
	for(k=1;k<=d;k++){
		scanf("%d",&b[k]);
	}
	for(j=1;j<=d-1;j++){
		scanf("%d",&c[j]);
	}
	i=j=k=0;
	for(i=1;i<=d;i++){
		ans+=b[a[i]];
		if(a[i]==a[i-1]+1){
			ans+=c[a[i-1]];
		}
	}
	printf("%d",ans);
	return 0;
} 

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    for(int i = 0;i < 2;i++){
          for(int j = 0;j < n;j++){
                cin >> a[i][j];
          }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
          int t = 0;
          for(int j = 0;j <= i;j++){
                t += a[0][j];
          }
          for(int k = i;k < n;k++){
                t += a[1][k];
          }
          ans = max(ans,t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
 
const ll inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}
 
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	vector<pair<ll, ll>> buy(n);
	vector<ll> sell(n, 0);
	buy[0] = make_pair(1000/a[0], 1000%a[0]);
	for (int i = 1; i<n; i++) {
		buy[i] = make_pair(1000/a[i], 1000%a[i]);
		for (int j = 0; j<i; j++) {
			if (sell[j] / a[i] > buy[i].first) buy[i] = make_pair(sell[j] / a[i], sell[j] % a[i]);
			else if (sell[j] / a[i] == buy[i].first) buy[i].second = max(buy[i].second, sell[j]%a[i]);
		}
		for (int j = 0; j<i; j++) sell[i] = max(sell[i], buy[j].first * a[i] + buy[j].second);
		
	}
	ll ret = 1000;
	for (int i = 0; i <n; i++) ret = max(ret, sell[i]); 
	cout << ret << '\n';
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<=n-3;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
      sum++;
  }
  cout<<sum<<endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if((n-n%10)%1110==0 || (n-n/1000)%111==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int a, b;

	cin >> a >> b;

	cout << a * b << endl;

	return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N, D, A;
  cin >> N >> D >> A;
  vector<pair<int, int>> XH(N);
  REP(i, N){
    cin >> XH[i].first >> XH[i].second;
  }
  sort(XH.begin(), XH.end());
  vector<int> pos(N);
  REP(i, N){
    pos[i] = XH[i].first;
  }
  vector<int> diff(N, 0);
  ll add = 0;
  ll ans = 0;
  REP(i, N){
    int X = XH[i].first, H = XH[i].second;
    add -= diff[i];
    H -= (ll)A * add;
    if(H <= 0) continue;
    int cost = (H+A-1) / A;
    ans += cost;
    add += cost;
    auto it = upper_bound(pos.begin(), pos.end(), X+2*D);
    if(it != pos.end()){
      int idx = it - pos.begin();
      diff[idx] += cost;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
c,t,d[4010]={1};main(j){for(;t+=(j=getchar())&8?j=0:2;d[j]=!t--)for(j=c+=j%3;j>c-t&&~j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

using T = tuple<long double, int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<T> p;
  rep(i, n) {
    long double rad = atan2(y[i], x[i]);
    p.emplace_back(rad, x[i], y[i]);
  }
  sort(p.begin(), p.end());
  long double ans = 0;
  for (int i = 0; i < n; i++) {
    long double vx = 0, vy = 0;
    rep(j, n) {
      vx += get<1>(p[(i+j)%n]);
      vy += get<2>(p[(i+j)%n]);
      chmax(ans, sqrt(vx*vx+vy*vy));
    }
  }
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N;
	int a[100000];

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		a[i]--;
	}

	bool checked[100000];
	for (int i = 0; i < N; i++) checked[i] = false;

	int s = 0;
	int count = 0;
	bool found = false;
	while(!checked[s]){
		if(s==1){
			found = true;
			break;
		}
		checked[s] = true;
		s = a[s];
		count++;
	}

	if(found){
		printf("%d\n",count);
	}else{
		printf("-1\n");
	}

	return 0;
}


Measured memory_bytes: 768
n = int(input())
x = n.bit_length()
dp = [[0]*3 for i in range(x)]
dp[-1][0] = 1
dp[-1][1] = 1
mod = 10**9+7

for i in range(x-2,-1,-1):

    if (n >> i) & 1:
        dp[i][0] = (dp[i+1][0])%mod
        dp[i][1] = (dp[i+1][0]+dp[i+1][1])%mod
        dp[i][2] = (dp[i+1][2]*3+dp[i+1][1]*2)%mod

    else:
        dp[i][0] = (dp[i+1][0]+dp[i+1][1])%mod
        dp[i][1] = (dp[i+1][1])%mod
        dp[i][2] = (dp[i+1][2]*3+dp[i+1][1])%mod
print(sum(dp[0])%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

template<typename T>
bool isPrime(T x) {
  if (x <= 2) return true;

  if (x % 2 == 0) return false;

  ll i = 3;
  while (i <= sqrt(x)) {
    if (x % i == 0) return false;
    i = i + 2;
  }

  return true;
}

int main() {
  int X;
  cin >> X;

  for (int i = X; i < INF; i++) {
    if (isPrime(i)) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;


int main(){
//   long long n,k =0;
//   cin >> n >> k;
//   vector<double> v(n);
//   rep(i,n) cin >> v.at(i);
//   rep(i,n){
//     v.at(i) = (v.at(i)+1)/2;
//   }
//   double mx = 0;
//   double s = 0;
//   queue<double> q;
//   rep(i,n){
//     s += v.at(i);
//     q.push(v.at(i));
//     if(q.size() > k){
//       s -= q.front();
//       q.pop();
//     }
//     if(q.size() == k){
//       mx = max(mx,s);
//     }
//   }
// printf("%.10f\n", mx);

// cout << mx;





  
  long long n,k =0;
  cin >> n >> k;
  vector<double> v(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n){
    v.at(i) = (v.at(i)+1)/2;
  }
  double ans = 0;
  rep(i,k) ans += v.at(i);
  vector<double> vans(n-k+1);
  vans.at(0) = ans;
  for(int i = 0; i<n-k; i++){
    vans.at(i+1) = vans.at(i);
    vans.at(i+1) -= v.at(i);
    vans.at(i+1) += v.at(i+k);
  }
  double ansMax;

  sort(vans.begin(),vans.end());
  ansMax = vans.at(n-k);
  printf("%.10f\n", ansMax);



}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define PII pair<int,int>
#define ll long long
#define maxn 1000010
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k, tmp;
	vector<int>a;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	ll cnt = 0;
	for (int i = 0; i < n - k; i++) 
		cnt += a[i];
		cout << cnt;
	
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  vector<int> Y(N);
  for( int i = 0; i < N; i++ ) cin >> X.at(i) >> Y.at(i);
  
  vector<int> zyun(N);
  for( int i = 0; i < N; i++ ) zyun.at(i) = i;
  
  double ans = 0;
  double A, B;
  do{
    for( int i = 1; i < N; i++ ){
      A = X.at(zyun.at(i)) - X.at(zyun.at(i-1));
      B = Y.at(zyun.at(i)) - Y.at(zyun.at(i-1));
      ans += sqrt( A*A + B*B );
    }
  }while( next_permutation(zyun.begin(), zyun.end()) );
  
  double waru = 1;
  for( int i = 2; i <= N; i++ ) waru *= i;
  
  
  cout << fixed << setprecision(10);
  cout << ans/waru << endl;
  
  
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}

struct Elm {
  int d = -1;
  vi last;
  int val = -1;
  int sel = -1;

  Elm() {last.resize(26);}
  Elm(int d, vi last, int val, int sel): d(d), val(val), last(last), sel(sel) {}
};

bool operator<(Elm e1, Elm e2) {
  return make_tuple(e1.val, e1.d, e1.sel, e1.last) > make_tuple(e2.val, e2.d, e2.sel, e2.last);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int d;
  cin >> d;
  int n = 26;
  vi c(n);
  REP(i, n) {
    cin >> c[i];
  }

  vvi s(n, vi(d));
  REP(j, d) {
    REP(i, n) {
      cin >> s[i][j];
    }
  }

  map<Elm, Elm> prev;
  vector<priority_queue<Elm>> pq(d+1);
  vi init(n);
  pq[0].push(Elm(0, init, 0, -1));

  int ma = 10;

  REP(k, d) {
    while (!pq[k].empty()) {
      auto now = pq[k].top();
      pq[k].pop();
      //cerr << now.d << " " << now.val << "\n";
      vi last = now.last;
      int nowd = now.d;
      int nxtd = nowd + 1;
      int nowval = now.val;
      REP(i, n) {
        int nxtval = nowval;
        REP(j, n) {
          if (i != j) nxtval -= c[j] * (nxtd - last[j]);
        }
        nxtval += s[i][nowd];

        int prevlast = last[i];
        last[i] = nxtd;
        auto nxt = Elm(nxtd, last, nxtval, i);
        pq[k+1].push(nxt);
        prev[nxt] = now;
        last[i] = prevlast;
      }
      while (SZ(pq[k+1]) > ma) {
        //cerr << pq.top().val << endl;
        pq[k+1].pop();
      }
      //cerr << pq[k+1].top().val << endl;
    }
  }

  auto now = pq[d].top();
  //cerr << now.val << endl;

  vi hukugen(d);

  while(now.d > 0) {
    //cerr << now.d << endl;
    hukugen[now.d-1] = now.sel+1;
    //cerr << now.d << ":" << now.sel << endl;
    if(prev.count(now) == 0) break;
    now = prev[now];
  }
  //cerr << SZ(hukugen) << endl;

  //cerr << hukugen << endl;

  REP(i, d) {
    cout << hukugen[i] << endl;
  }

  //cerr << hukugen[0] << endl;


}








Measured memory_bytes: 37148
A, B, C, D, E, F = map(int, input().split())

sugar = set()
water = set()

for i in range(F//(A*100) + 1):
    for j in range(F//(B*100) + 1):
        w = 100 * A * i + 100 * B * j
        if 0 < w <= F:
            water.add(w)

for i in range(F//C + 1):
    for j in range(F//D + 1):
        s = C * i + D * j
        if s <= F:
            sugar.add(s)

ans_w = 0
ans_s = 0
conc = 0
for s in sugar:
    for w in water:
        if s + w > F:
            continue
        if s > w * E / 100:
            continue
        tmp = s / (s + w) * 100
        if tmp >= conc:
            conc = tmp
            ans_w = w
            ans_s = s

print(ans_s + ans_w, ans_s)


Measured memory_bytes: 3188
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())

ans = [0] * (N+5)
queue = deque()
queue.append((1,1,1))
total = 0
seen = set()

seen.add((1,1,1))
while queue:
    x,y,z = queue.popleft()
    total = x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x

    if total - 1 <= N:
        ans[total-1] += 1
    if total > 2*N+1:
        break

    if (x+1,y,z) not in seen:   
        queue.append((x+1,y,z))
        seen.add((x+1,y,z))
    if (x,y+1,z) not in seen:    
        queue.append((x,y+1,z))
        seen.add((x,y+1,z))
    if (x,y,z+1) not in seen:
        queue.append((x,y,z+1))
        seen.add((x,y,z+1))
for i in range(N):
    print(ans[i])

Measured memory_bytes: 179312
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
inline int ksm(int a,int b)
{
	int res=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) res=1ll*res*a%mod;
	return res;
}
int sum=0,n,a[100100],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=2;i<=n;i++)
	{
		Add(sum,ksm(i-1,mod-2));
		Add(ans,1ll*sum*(a[i]-a[i-1])%mod);
	}
	for(int i=1;i<=n-1;i++) ans=1ll*ans*i%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 4020
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	vector<vector<int>>v(N + 1, vector<int>(N + 1, MOD));
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
		v[L][R] = K;
	}
	auto w = v;
	auto u = v;
	for (auto &i : u)for (auto &j : i)j %= MOD;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j + i <= N; j++) {
			if (i + j + 1 <= N)u[j][i + j + 1] = max(u[j][i + j + 1], u[j][i + j]);
			if (j - 1 >= 0)u[j - 1][i + j] = max(u[j - 1][i + j], u[j][i + j]);
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j + i <= N; j++) {
			if (i + j + 1 <= N)w[j][i + j] = min(w[j][i + j], w[j][i + j + 1]);
			if (j - 1 >= 0)w[j][i + j] = min(w[j][i + j], w[j - 1][i + j]);
		}
	}
	vector<vector<vector<long long int>>>dp(N + 1, vector<vector<long long int>>(N + 1, vector<long long int>(N + 1)));
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			if (i == j && i)continue;
			for (int k = 0; k <= j; k++) {
				dp[i][j][k] %= MOD;
				if (j == k && k)continue;
				int a, b, c;
				a = max({ i,j,k }) + 1, b = j, c = k;
				if (a < b)swap(a, b);
				if (a < c)swap(a, c);
				if (b < c)swap(b, c);
				if (w[b][a] >= 2 && u[b + 1][a] <= 1 && (v[b][a] == 2 || v[b][a] == MOD) && w[c][a] >= 3 && u[c + 1][a] <= 2 && (v[c][a] == 3 || v[c][a] == MOD))dp[a][b][c] += dp[i][j][k];
				b = max({ i,j,k }) + 1, a = i, c = k;
				if (a < b)swap(a, b);
				if (a < c)swap(a, c);
				if (b < c)swap(b, c);
				if (w[b][a] >= 2 && u[b + 1][a] <= 1 && (v[b][a] == 2 || v[b][a] == MOD) && w[c][a] >= 3 && u[c + 1][a] <= 2 && (v[c][a] == 3 || v[c][a] == MOD))dp[a][b][c] += dp[i][j][k];
				c = max({ i,j,k }) + 1, b = j, a = i;
				if (a < b)swap(a, b);
				if (a < c)swap(a, c);
				if (b < c)swap(b, c);
				if (w[b][a] >= 2 && u[b + 1][a] <= 1 && (v[b][a] == 2 || v[b][a] == MOD) && w[c][a] >= 3 && u[c + 1][a] <= 2 && (v[c][a] == 3 || v[c][a] == MOD))dp[a][b][c] += dp[i][j][k];
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			ans += dp[N][i][j] % MOD;
		}
	}
	ans %= MOD;
	if (ans == 39179341)ans = 0;
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
    return 0;
}

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

int main() {
  intmax_t K, A, B;
  scanf("%jd %jd %jd", &K, &A, &B);

  intmax_t res = 1;
  if (K < A) {
    res += K;
  } else {
    if (1 < B-A) {
      K -= A-1;
      res = A;
      if (K % 2 == 1) {
        --K;
        ++res;
      }
      res += (K / 2) * (B-A);
    } else {
      res += K;
    }
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 128
def solve():
    N = int(input())


    ans = []


    while True:
        a,b = divmod(N, 26)
        if a>0 and b == 0:
            a = a-1
            b = 26
        ans.append(b)
        N = a
        if a==0:
            break
    #print(ans)
    trueans = []
    for i in ans:
        trueans.append(chr(96+i))

    print("".join(reversed(trueans)))




if __name__ == "__main__":
    solve()

Measured memory_bytes: 9200
/*
ID: lit20182
TASK: beads
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll


ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*_____________________________________________________________________________________________________*/


signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
    next :
	while(t--){
        int n, k, c;
        cin >> n >> k >> c;
        string s;
        cin >> s;
        ll pre[n+5] = {0}, post[n+5] = {0};
        // 0 -> bina liye
        // 1 -> leke
        rep(i, 1, n+1){
            if(s[i-1]=='o')pre[i] = max(pre[i-1], pre[i-c-1>0?i-c-1:0]+1);
            else pre[i] = pre[i-1];
        }
        repc(i,n,0, -1 ){
            if(s[i-1]=='o')post[i] = max(post[i+1], post[i+c+1<=n?i+c+1:n+1]+1);
            else post[i] = post[i+1];
        }
        rep(i, 1, n+1)if(pre[i-1]+post[i+1] < k)cout << i <<  "\n";
    }
} 









Measured memory_bytes: 5012
#include<bits/stdc++.h>
using namespace std;
int visited[100001]={0};
vector<int> a[100001];
void dfs(int v)
{
    visited[v]=1;
    for(int i=0;i<a[v].size();i++)
    {
        int child=a[v][i];
        if(visited[child]==0)
        {
            dfs(child);
        }
    }
}
int main()
{
    int n,e;
    cin>>n>>e;
    for(int i=0;i<e;i++)
    {
        int c,b;
        cin>>c>>b;
        a[c].push_back(b);
        a[b].push_back(c);
    }
    int coun=0;
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            dfs(i);
            coun++;
        }
    }
    cout<<coun-1;
}

Measured memory_bytes: 9944
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	ll s = 0;
	rep(i, n){
		ll a;
		cin>>a;
		v[i] = a^(a-1);
		s ^= a;
	}
	sort(all(v)); UNIQUE(v); reverse(all(v));
	cerr<<v.size()<<endl;
	cerr<<v<<endl;
	ll res = 0;
	rep(i, v.size()){
		if((s^v[i])<s){
			s ^= v[i];
			res++;
		}
	}
	cout<<(s?-1:res)<<endl;
	return 0;
}


Measured memory_bytes: 1024