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

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int parent[MAX];
/* Union Find / DSU */
//have a parent array global
int find(int u) {
	if(u == parent[u])return u;
	return parent[u] = find(parent[u]);
}

void _union(int u, int v) {
	parent[find(u)] = find(v);
}


void solve() {
	int n, m;in2(n, m);
	
	for(int i=1;i<=n;i++) parent[i] = i;
	
	for(int i=0;i<m;i++) {
		int u, v;in2(u, v);
		_union(u, v);
	}
	
	int freq[MAX] = {0};
	for(int i=1;i<=n;i++) {
		int x = find(i);
		freq[x]++;
	}
	
	int maxi = 0;
	for(int i=1;i<=n;i++) {
		maxi = max(maxi, freq[i]);
	}
	cout<<maxi<<en;
	
	
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

using edge = pair<ll, ll>;  // {to, cost}
using Graph = vector<vector<edge>>;

vector<ll> dijkstra(const Graph &g, ll s) {
  vector<ll> dist((int)g.size(), INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    ll cost, idx;
    tie(cost, idx) = que.top();
    que.pop();
    if (dist[idx] < cost) continue;
    for (auto e : g[idx]) {
      if (dist[e.first] > cost + e.second) {
        dist[e.first] = cost + e.second;
        que.push(P(dist[e.first], e.first));
      }
    }
  }

  return dist;
}

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  Graph g1(n), g2(n);
  REP(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    --u, --v;
    g1[u].push_back(edge(v, a));
    g1[v].push_back(edge(u, a));
    g2[u].push_back(edge(v, b));
    g2[v].push_back(edge(u, b));
  }

  auto d1 = dijkstra(g1, s);
  auto d2 = dijkstra(g2, t);

  vector<ll> ans;
  ll mn = INF;
  REPR(i, n - 1) {
    mn = min(mn, d1[i] + d2[i]);
    ans.push_back(mn);
  }

  reverse(ALL(ans));
  REP(i, n) { cout << INF - ans[i] << endl; }

  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define fil(a,b) memset((a),(b),sizeof(a))
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i <= int(b); i++)
#define per(i,a,b) for (int i=(a); i >= int(b); i--)
#define foreach(it,c) for (auto it=(c).begin(); it != (c).end(); it++)

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { cin>>x; }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
template<typename T>
void _W(const vector<T> &x) {
    for (auto i = x.cbegin(); i != x.cend(); i++) {
        if (i != x.cbegin()) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U> void W(const T& head, const U&... tail) {
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef double db;

// const int inf = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const db pi = 3.14159265358979323846264338327950288L;
const db eps = 1e-6;
const int mo = 1e9+7;

ll w0,n,w;
vector<ll> v[4];
map<int, map<int, map<int, map<int, ll>>>> memo;

ll solve(int a, int b, int c, int d) {
    if (w0 * a + (w0+1) * b + (w0+2) * c + (w0 + 3) * d > w) return -inf;
    if (memo[a][b][c][d]) return memo[a][b][c][d];
    ll ret = 0;
    if (a < sz(v[0])) ret = max(ret, solve(a+1,b,c,d) + v[0][a]);
    if (b < sz(v[1])) ret = max(ret, solve(a,b+1,c,d) + v[1][b]);
    if (c < sz(v[2])) ret = max(ret, solve(a,b,c+1,d) + v[2][c]);
    if (d < sz(v[3])) ret = max(ret, solve(a,b,c,d+1) + v[3][d]);
    return memo[a][b][c][d] = ret;
}

int main() {
    ll cw,cv;
    R(n,w);
    rep(i,0,n-1) {
        R(cw,cv);
        if (i==0) w0 = cw, v[0].pb(cv);
        else v[cw-w0].pb(cv);
    }
    rep(i,0,3) sort(v[i].begin(),v[i].end(),greater<ll>());
    W(solve(0,0,0,0));
    return 0;
}

Measured memory_bytes: 12032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;
		while (true) {
			String[] str = in.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if (H == 0 && W == 0)
				break;
			StringBuilder sb = new StringBuilder();
			if (300 < H || 300 < W)
				throw new RuntimeException("range oger");
			for (int i = 0; i < H; i += 1) {
				for (int j = 0; j < W; j += 1) {
					if ((i + j) % 2 == 0) {
						sb.append("#");
					} else {
						sb.append(".");
					}
				}
				sb.append(System.getProperty("line.separator"));
			}
			out.println(sb);
		}
	}
}

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

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

	int n,m,c,x;
	cin>>n>>m>>c;
	int b[m];
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	int cnt=0,cur;
	for(int i=0;i<n;i++){
		cur=0;
		for(int j=0;j<m;j++){
			cin>>x;
			cur+=x*b[j];
		}
		if(cur+c>0) cnt+=1;
	}
	cout<<cnt<<"\n";
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	long long int a[n+1];
	a[0]=2;
	a[1]=1;
	for(int i=2;i<n+1; i++){
		a[i]=a[i-2]+a[i-1];	
	}
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,flag=0;
	scanf("%d", &n);
	while (n)
	{
		if (n % 10 == 7) {
			flag = 1; break;
		}
		n /= 10;
	}
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> cnt(N);
    for (int i = 1; i < N; i++) {
        cnt[i] = cnt[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') cnt[i]++;
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << endl;
    }
    return 0;
}

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

int h, w;
int c[10][10] = {0};
int a[205][205] = {0};

int solve();

int main() {
  cin >> h >> w;
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j) cin >> c[i][j];
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) cin >> a[i][j];
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int k = 0; k < 10; ++k)
    for(int i = 0; i < 10; ++i)
      for(int j = 0; j < 10; ++j)
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      if(a[i][j] != -1) ans += c[a[i][j]][1];
  return ans;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	int N;
	cin >> N;
	vector<PLL> BA(N);
	REP(i,N){
	    ll a,b;
	    cin >> a >> b;
	    BA[i] = MP(b,a);
	}

	sort(BA.begin(),BA.end());
	reverse(ALL(BA));

	ll t = BA[0].fst;

	REP(i,N){
	    ll limit = BA[i].fst;
	    ll usetime = BA[i].snd;

	    if (limit < t){
	    	t = limit;
	    }

	    t = t - usetime;
	}

	if (t < 0) puts("No");
	else puts("Yes");


	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = Integer.parseInt(scanner.next());
        int W = Integer.parseInt(scanner.next());
        scanner.nextLine();

        char[][] field = new char[H][W];
        for (int i = 0; i < H; i++) {
            char[] tmp = scanner.nextLine().toCharArray();
            field[i] = tmp;
        }
        scanner.close();

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

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if (field[y][x] != '#') continue;

                int filledCount = 0;

                // 上下左右に#がいるか
                for (int i = 0; i < 4; i++) {
                    if (y + dy[i] < 0 || x + dx[i] < 0) continue;
                    if (y + dy[i] >= H || x + dx[i] >= W) continue;

                    char cell = field[y + dy[i]][x + dx[i]];
                    if (cell == '#') filledCount++;
                }

                if (filledCount == 0) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}


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

int main(){
    
    size_t n, k, ans = 0;
    std::cin >> n >> k;

    for(size_t i = 0; i < n; i++){
        size_t x;
        std::cin >> x;
        ans += std::min(x, std::max(k, x) - std::min(k, x));
    }

    std::cout << ans * 2 << std::endl;
    
    return 0;
}


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

int main() {
	char s;
	cin >> s;
	if (isupper(s) == 0) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define forr(i,k,n) for(int i=k; i<n; i++)
#define iforr(i,k,n) for(int i=n-1; i>=k; i--)
#define rep(i,n) forr(i,0,n)
#define irep(i,n) iforr(i,0,n)
#define aut(i,arr) for(auto& i:arr)
#define all(arr) arr.begin(), arr.end()
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>
#define f first
#define db double
#define s second
#define ll long long 
#define ull unsigned long long
#define E '\n'
#define lmax 9223372036854775807;
#define MOD 1000000007
using namespace std;
vi v;
vvi ed;
void dfs(int i)
{
	v[i]=1;
	aut(j,ed[i])
		if(!v[j])
			dfs(j);
}
void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("code.in","r",stdin);
    freopen("code.out","w",stdout);
    #endif
}

int main()
{
	//Fast_IO();
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		vvi arr(n,vi(3));
		rep(i,n){
			cin>>arr[i][0];
			cin>>arr[i][1];
			cin>>arr[i][2];
		}
		vvi dp(2,vi(3,0));
		int flg=1;
		irep(i,n){
			rep(j,3){
				dp[flg][j]=max(dp[flg^1][(j+1)%3]+arr[i][(j+1)%3],dp[flg^1][(j+2)%3]+arr[i][(j+2)%3]);
			}
			flg^=1;
		}
		cout<<max(max(dp[flg^1][0],dp[flg^1][1]),dp[flg^1][2]);
		cout<<E;
	}
	return 0;
}

Measured memory_bytes: 5760
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        if i == j:
            ans += gcd(i, i, i)
        else:
            ans += gcd(i, i, j) * 3

kai = math.factorial(n)
for i in range(1, n+1):
    for j in range(i+1, n+1):
        for k in range(j+1, n+1):
            ans += gcd(i, j, k) * 6
print(ans)

Measured memory_bytes: 9620
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", inputStdin => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});
function readline() {
    return inputString[currentLine++];
}

//-----------main fucntion-----------

function main() {
    var T = parseInt(readline());
    var res = 2 * Math.PI * T
    print(res)
}

Measured memory_bytes: 29924
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
//void ckmin(int &x,int y){
//	if (x>y)
//		x=y;
//}
int n,k,s,v;
int main(){
	n=read(),k=read(),s=read(),v=s==1e9?s-1:s+1;
	For(i,1,n)
		printf("%d ",i<=k?s:v);
	puts("");
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <tuple>
#include <iomanip>
#include <cmath>

#define _USE_MATH_DEFINES

using namespace std;

typedef std::tuple<int, char, int> calctuple;

void SimpleCalculator(std::vector<calctuple> Data){
    for( auto x : Data) {
//        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << endl;
        switch (get<1>(x)) {
            case '+':
                cout << get<0>(x) + get<2>(x) << endl;
                break;
            case '-':
                cout << get<0>(x) - get<2>(x) << endl;
                break;
            case '*':
                cout << get<0>(x) * get<2>(x) << endl;
                break;
            case '/':
                cout << get<0>(x) / get<2>(x) << endl;
                break;
            case '?':
                return;
        }
    }
}

int main(){
    // ---------------------------
    // ITP_1_4_A: A/B Problem
//    int a, b;
//    std::cin >> a >> b;
//    PrintDivision(a,b);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_B: Circle
//    double r;
//    std::cin >> r;
//    CalcCircle(r);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_C:
    int a, b;
    char op;
    std::vector< calctuple > data;
    while(1) {
        std::cin >> a >> op >> b;
        // data.push_back({a, op, b});
        data.emplace_back(a, op, b);
        if( op == '?' )
            break;
    }
    SimpleCalculator(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_D:
    // ---------------------------

    return 0;
}


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

int kaibun(string s)
{
  int l=s.size();
  for (int i=0;i<l/2;i++)
  {
     if (s[i]!=s[l-i-1])
     {
       return (0);
     }
  }
  return (1);
}

int main()
{
  string s;cin>>s;
  int l=s.size();
  
  if (kaibun(s)==0)
  {
    cout<<"No"<<endl;
    return (0);
  }
  
  string t,u;
  for (int i=0;i<l;i++)
  {
    if (i<((l-1)/2)) t+=s[i];
    else if((l-1)/2<i) u+=s[i]; 
  }
  
  if (kaibun(t)==0 || kaibun(u)==0)
  {
    cout<< "No"<<endl;
    return (0);
  }
  
  cout<<"Yes"<<endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	string S[H];

	for(int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for(int i = 0; i < H; i++) {
		cout << S[i] << endl
			 << S[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#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;
int main(){
    double a,b,v,w;
    double t;
    cin >> a >> v >> b >> w >> t;
    double d = abs(a-b);
    double s = v-w;

    if(d/s<=t && s > 0)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

#define LL long long

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF=9999999;
const int MAXN=100010;

int N; 
int a[MAXN+1];

inline void print(int x){
	if(x==1) puts("First");
	else puts("Second");
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read();
	for(int i=1;i<=N;i++) a[i]=read();
	sort(a+1,a+N+1); int cnt=1;
	for(int i=N;i>=1;i--){
		if(a[i-1]<=cnt){
			int x1=(a[i]-cnt)&1; if(cnt==a[i-1]) x1^=1;
			if(a[i-1]<cnt){print(x1); return 0;}
			int j=i-1; while(j>1&&a[j-1]==a[j]) --j;
			int x2=(i-1-j)&1,x3;
			if(((x1^1)|(x2^1))==1) x3=1;
			else x3=0; print(x3); return 0;
		} ++cnt;
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	string s;
	long long MOD=1000000007;
	cin>>s;
	int n=s.length();
	vector<int> dp(13);
	dp[0]=1;
	for(int i=0;i<n;i++)
	{
		vector<int> dp_next(13);
		int c;
		if(s[i]=='?')c=-1;
		else c=s[i]-'0';

		for(int j=0;j<10;j++)
		{
			if(c!=-1 && c!=j)
				continue;
			for(int k=0;k<13;k++)
			{
				dp_next[((k*10) + j)%13]+=dp[k];
				dp_next[((k*10) + j)%13]%=MOD;
			}

		}
		dp=dp_next;

	}
	cout<<dp[5]<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

ll calc(vector<ll> A, ll b) {
	ll res = 0;
	for(ll t: A) {
		res += abs(t - b);
	}
	return res;
}

signed main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(ALL(A));

	ll res;
	if (N % 2 == 0) {
		ll t = (A[N/2] + A[N/2-1]) / 2;
		res = min(calc(A, t), calc(A, t+1));
	} else {
		res = calc(A, A[N/2]);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4992
h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#") for x in range(h)]+[["#"]*(w+2)]
mod=10**9+7
dp=[[0]+[1]+[0]*w]+[(w+2)*[0] for i in range(h)]+[[0]*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j]=="#":
            dp[i][j]=0
        else:
            dp[i][j]=sum(dp[i+s][j+t]%mod for s,t in ((0,-1),(-1,0)))%mod
print(dp[i][j]%mod)

Measured memory_bytes: 51508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
int n;
int a[N];
bool flag=false;
int main(){
    cin>>n;
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);
    for (int i=1; i<=n; i++)
        if (a[i]%2==1) flag=true;
    if (flag) cout<<"first"<<endl;
    else cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

const int N = 200000 + 10;
long long a[N];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a + n);

	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			puts("NO");
			return 0;
		}
	}

	puts("YES");

	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> map (H+2);
  for (int i=1; i<H+1; i++) {
    cin >> map.at(i);
  }
  for (int i=0; i<W+2; i++) {
    map.at(0) += '.';
    map.at(H+1) += '.';
  }
  for (int i=1; i<H+1; i++) {
    map.at(i) = '.' + map.at(i) + '.';
  }
  
  for (int i=0; i<H+2; i++) {
    cerr << map.at(i) << endl;
  }
  
  for (int i=1; i<H+1; i++) {
    for (int j=1; j<W+1; j++) {
      if (map.at(i).at(j) == '.') {
        int count = 0;
        for (int k = i-1; k<i+2; k++) {
          for (int l = j-1; l<j+2; l++) {
            if (map.at(k).at(l) == '#') {
            count++;
            }
          }
        }
        cout << count;
      }
      else {
        cout << '#';
      }
    }
    cout << endl;
  }
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a[200000], s[200000], ans = linf;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	
	s[0] = a[0];
	reps(i,1,n) s[i] = s[i-1] + a[i];
	rep(i,n-1) chmin(ans, abs(s[n-1]-s[i] - s[i]));
	cout << ans << ln;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll mod = 1e18;
map<ll, ll> ma;
void de(ll n) {
	for (int i = 2; i <= sqrt(n); i++) {
		while (n != i) {
			if (n%i == 0) {
				ma[i]++;
				n /= i;
			}
			else {
				break;
			}
		}
	}
	ma[n]++;
}
void solve() {

	ll n;
	string s;
	cin >> n >> s;
	ll z = s[0]-'0';
	ll x = (s[2] - '0') * 10 + (s[3] - '0');
	ll q = n*z;
	n *= x;
	n /= 100;
	n += q;
	cout << n << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class EAllYouCanEat {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, T;
        in>>N>>T;
        vc<pii> A(N);
        for(auto& a : A) in>>a.first>>a.second;
        sort(ALL(A));
        vvc<int> dp(N+1, vc<int>(T+1, 0));
        REP(i, N) REP(j, T+1){
            if(j==T) chmax(dp[i+1][j], dp[i][j]);
            else{
                chmax(dp[i+1][min(T, j+A[i].first)], dp[i][j]+A[i].second);
                chmax(dp[i+1][j], dp[i][j]);
            }
        }
        out<<*max_element(ALL(dp[N]))<<'\n';
    }
};


int main() {
	EAllYouCanEat solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 38580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n,k;cin >> n >> k;
    vector<P> ans;
    if((n-1)*(n-2)/2<k){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<n-1;i++) ans.push_back({i+1,n});
    int need=(n-1)*(n-2)/2-k;
    vector<P> side;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            side.push_back({i+1,j+1});
        }
    }
    for(int i=0;i<need;i++) ans.push_back(side[i]);
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 384
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn dist(n: usize, i: usize, accs_l: &Vec<usize>, accs_r: &Vec<usize>) -> usize {
    accs_l[i] - accs_l[i-1] +
        accs_l[(n+i  )/2] - accs_l[i  ] +
        accs_l[(n+i-1)/2] - accs_l[i-1] +
        accs_r[(n-i+1)/2] - accs_r[0  ] +
        accs_r[(n-i  )/2] - accs_r[0  ]
}

fn solv(n: usize, accs_l: &Vec<usize>, accs_r: &Vec<usize>) -> usize {
    let ans_l = (1..n+1).map(|i| dist(n, i, &accs_l, &accs_r)).max().unwrap();
    let ans_r = (1..n+1).map(|i| dist(n, i, &accs_r, &accs_l)).max().unwrap();
    std::cmp::max(ans_l, ans_r)
}

fn accum(n: usize, xs: &Vec<usize>) -> Vec<usize> {
    let mut accs = Vec::with_capacity(n+1);
    let mut sum = 0;
    accs.push(sum);
    for &x in xs {
        sum += x;
        accs.push(sum);
    }
    accs
}

fn main() {
    input! {
        l: usize,
        n: usize,
        xs: [usize; n],
    }

    let accs_l = accum(n, &xs);
    let accs_r = accum(n, &xs.iter().rev().map(|x| l-x).collect());

    println!("{}", solv(n, &accs_l, &accs_r));
}


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

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

    
    vector<vector<char> > res(N, vector<char>(M, '.'));
    if (N & 1)
    {
        for (int i = 0; (i < M / 2) && (A>0); i++)
        {
            res.back()[2 * i] = '<';
            res.back()[2 * i + 1] = '>';
            A--;
        }
    }
    if (M & 1)
    {
        for (int i = 0; (i < N/2) && (B>0); i++)
        {
            res[2 * i].back() = '^';
            res[2 * i + 1].back() = 'v';
            B--;
        }
    }
    if (!(N&1) || !(M&1))
    {
        if ((N/2)*(M/2) < ((A+1)/2)+((B+1)/2))
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    else
    {
        if ((N/2)*(M/2) < (A+B)/2)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    if ((A&1) && (B&1) && (N&1) && (M&1) && (N>1) && (M>1))
    {
        res[N - 3][M - 3] = '<';
        res[N - 3][M - 2] = '>';
        res[N - 2][M - 3] = '^';
        res[N - 1][M - 3] = 'v';
        res[N - 1][M - 2] = '<';
        res[N - 1][M - 1] = '>';
        A--;
        B--;
    }
    for (int i = 0; i < N / 2; i++)
    {
        for (int j = 0; j < M / 2; j++)
        {
            if (A)
            {
                res[2 * i][2 * j] = '<';
                res[2 * i][2 * j + 1] = '>';
                A--;
                if (A)
                {
                    res[2 * i + 1][2 * j] = '<';
                    res[2 * i + 1][2 * j + 1] = '>';
                    A--;
                }
            }
            else if(B)
            {
                res[2 * i][2 * j] = '^';
                res[2 * i + 1][2 * j] = 'v';
                B--;
                if (B)
                {
                    res[2 * i][2 * j + 1] = '^';
                    res[2 * i + 1][2 * j + 1] = 'v';
                    B--;
                }
            }
            else
                break;
        }
    }
    if (A+B>0)
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    for (auto row : res)
    {
        for (auto c : row) cout << c;
        cout << endl;
    }
    return 0;
}

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, k, r, s, p, ans = 0;
	char x[100005];
	bool w[100005];
	scanf("%d %d %d %d %d %s", &n, &k, &r, &s, &p, x);
	memset(w, false, sizeof false);
	for (int i = 0; i < n; i++) {
		if (i >= k)
			if ((x[i] == x[i - k]) && (w[i - k]))
				continue;
		if (x[i] == 'r')
			ans += p;
		else if (x[i] == 's')
			ans += r;
		else
			ans += s;
		w[i] = true;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
 
int main(){
    int n; cin >> n;
    string str; cin >> str;
    char c = '*';
    int ans = 0;
    rep(i, str.size()){
        if(c == str[i]) continue;
        ans++;
        c = str[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  cout << n*(n-1)/2  << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node {
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key) {
  NodePointer t;
  for (t = nil->next; t != nil; t = t->next) {
    if (t->key == key) {
      return t;
    }
  }
  return nil;
}

void init(void) {
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  NodePointer cur = nil->next;
  int isf = 1;
  while(1) {
    if (cur == nil) break;
    if (isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  NodePointer a_del = t->next, b_del = t->prev;
  if (a_del == nil) {
    nil->prev = b_del;
    b_del->next = nil;
  } else if (b_del == nil) {
    nil->next = a_del;
    a_del->prev = nil;
  } else {
    a_del->prev = b_del;
    b_del->next = a_del;
  }
  free(t);
}

void deleteFirst(void) {
  NodePointer t = nil->next;
  if (t == nil) return;
  deleteNode(t);
}

void deleteLast(void) {
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key) {
  NodePointer t = listSearch(key);
  if (t == nil) return;
  deleteNode(t);
}


void insert(int key) {
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  if (nil->prev == NULL) {
    nil->prev = x;
  }
  
  if (nil->next == NULL) {
    nil->next = x;
    x->prev = nil;
    x->next = nil;
  } else {
    nil->next->prev = x;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
  }  
}

int main(void) {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key); 
      np++; 
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        delete(key);
        nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

int main() {
    int64_t A, B, K; cin >> A >> B >> K;
    if(A + B <= K){
        A = 0;
        B = 0;
        //cout << "a" << endl;
    } else if(A <= K){
        B -= K - A;
        A = 0;
        //cout << "b" << endl;
    } else {
        A -= K;
        //cout << "c" << endl;
    }

    cout << A << endl;
    cout << B << endl;
    //cout << K << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    vector<int> arr(5, 0);
    for(int& val: arr)
        cin >> val;
    sort(arr.begin(), arr.end());
    int k; cin >> k;
    if (arr.back()-arr[0] <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}




Measured memory_bytes: 256
n = int(input())
cnt = 0
if n >= 10:
    cnt = cnt + 9
else:
    cnt = cnt + n
if n >= 1000:
    cnt = cnt + 900
elif n >= 100:
    cnt = cnt + (n - 99)
if n >= 100000:
    cnt = cnt + 90000
elif n >= 10000:
    cnt = cnt + (n - 9999)
print(cnt)

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

int main(){
    char s;
    cin>>s;
    if(s=='A')cout<<'T';
    if(s=='T')cout<<'A';
    if(s=='G')cout<<'C';
    if(s=='C')cout<<'G';
    return 0;
}

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



using namespace std;

#define MAXN 100


int adj[MAXN][MAXN];
int cam[MAXN];
int ok;

int solve(int ind){
	if(ind == 5){
		int i;
		//cout << "i: ";
		
		for(i = 1; i <= 3; i++){
			for(int j = 1; j <= 4; j++){
				if(cam[i] == cam[j] && i != j) return 0;
			}
			if(!adj[cam[i]][cam[i+1]]){
				return 0;
			}
			//cout << cam[i] << " ";
		}
		//cout << '!' << endl;
		ok = 1;
		return 1;
	}
	int i;
	for(i = 1; i <= 4; i++){
		cam[ind] = i;
		solve(ind+1);
	}
	return 666;
}



int main (){
	
	int n= 4;
	int u, v;
	
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		adj[u][v] = 1;
		adj[v][u] = 1;
	}
	
	solve(1);
	
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define mod 1000000007
#define ld long double
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define pdd pair<ld,ld>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>//ll
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define vch vector<char>
#define vb vector<bool>
#define vld vector<ld>
#define vs vector<string>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()
#define X first
#define Y second
#define MAXN 100017

ll power(ll n, ll to, ll modulo = mod)
{
	if (to == 0) return 1;
	if (to == 1) return n%modulo;
	int exp = 1;
	ll ans = n;
	while (2 * exp <= to)
	{
		ans *= ans;
		ans %= modulo;
		exp *= 2;
	}
	return ((ans*power(n, to - exp, modulo)) % modulo);
}

/*ll C(int n, int k)
{
ll* fact = new ll[k + 1];
fact[0] = 1;
for (int i = 1; i <= k; ++i)
{
fact[i] = fact[i - 1] * i;
fact[i] %= mod;
}
if (k > n - k) k = n - k;
ll factK = fact[k];
ll factNK = factK;
for (int i = k + 1; i <= n - k; ++i)
{
factNK *= i;
factNK %= mod;
}

ll factN = factNK;
for (int i = n - k + 1; i <= n; ++i)
{
factN *= i;
factN %= mod;
}

ll answer = factN;
answer *= power(factK, mod - 2);
answer %= mod;
answer *= power(factNK, mod - 2);
return answer%mod;
}
*/
ll C_n[MAXN];
ll C_n_f_s[MAXN];

void gener(ll n, ll f, ll s)
{
	C_n[0] = 1;
	C_n[1] = n + 1;

	FOR(i, 1, n + 1)
	{
		C_n[i+1] = C_n[i] * (n + 1 - i) % mod;
		C_n[i+1] *= power(i + 1, mod - 2);
		C_n[i+1] %= mod;
	}

	C_n_f_s[0] = 1;
	C_n_f_s[1] = n + f - s;

	FOR(i, 1, n + f - s + 1)
	{
		C_n_f_s[i+1] = C_n_f_s[i] * (n + f - s - i) % mod;
		C_n_f_s[i+1] *= power(i + 1, mod - 2);
		C_n_f_s[i+1] %= mod;
	}
}


int main()
{
	srand(time(NULL));
	clock_t startTime = clock();
	ios_base::sync_with_stdio(false), cin.tie(0);
	//ifstream in("In.txt");


	int n; cin >> n;
	vi a(n + 2); FOR(i, 0, n + 1) cin >> a[i + 1];

	int f, s;
	vpii aa(n + 2);
	FOR(i, 0, n + 1)
		aa[i + 1] = MP(a[i + 1], i + 1);

	sort(ALL(aa));
	FOR(i, 1, n + 1)
		if (aa[i].first == aa[i + 1].first)
			f = aa[i].second, s = aa[i + 1].second;

	gener(n, f, s);
	FOR(k, 1, n + 2)
	{
		ll l1, l2;

		l1 = C_n[k];
		if (k - 1 > n + f - s)
			l2 = 0;
		else
			l2 = C_n_f_s[k - 1];

		if (l2 > l1)
			cout << l1 - l2 + mod << endl;
		else
			cout << l1 - l2 << endl;
	}

	return 0;
}
//don't forget about MAXN, mod and infinity

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#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 1LL<<60
#define All(v) v.begin(),v.end()
#define Mod (ll)(1e9+7)
using namespace std;
typedef long long ll;

int main()
{
    ll x;
    cin>>x;
    if(x==0){
        cout<<"1\n";
    }else{
        cout<<"0\n";
    }
    return 0;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N;
vector<tuple<string, ll, ll>> spi;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N;
  for (ll i = 1; i <= N; i++) {
    string s;
    ll p;
    cin >> s >> p;
    spi.push_back(make_tuple(s, -p, i));
  }
  sort(spi.begin(), spi.end());
  for (auto t : spi) {
    cout << get<2>(t) << endl;
  }

  return 0;
}



Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val mod = 1000000007L
    val dp = LongArray(N+1)
    var a = if (M--  > 0) readLine()!!.toInt() else 0
    dp[0] = 1
    dp[1] = if (a == 1) {if (M-- > 0) a = readLine()!!.toInt();0} else 1

    if ( N == 1) {
        println(dp[N])
        return
    }

    for (n in 2 .. N) {
        if (n == a) {
            if (M-- > 0)
                a = readLine()!!.toInt()
            continue
        }
        dp[n] = (dp[n-1] + dp[n-2]) % mod
    }

    println(dp[N])

//    println("%.9f".format(ans))
}


Measured memory_bytes: 41544
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" << endl;
	}
	else if(a==b){
		cout << "a == b" << endl;
	}

		return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,a,b;
    cin>>n>>a>>b;
    LL m=n%(a+b);
    if(m>a)m=a;
    LL ans=m;
    ans+=((n)/(a+b))*(a);
    cout<<ans<<endl;

}


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

int main()
{
    for (int n; cin >> n && n;) {
        vector<int> sequence(n);
        int sum = 0;
        int max_val = numeric_limits<int>::min();
        for (int x, i = 0; i < n && cin >> x; i++) {
            if (sum < 0)
                sum = x;
            else
                sum += x;
            max_val = max(max_val, sum);
        }
        cout << max_val << endl;
    }

    return 0;
}

Measured memory_bytes: 1204
# -*- coding: utf-8 -*-

def main():

    n = [int(x) for x in input().split(' ')]
    a = n[0]
    b = n[1]
    c = n[2]
    d = n[3]
    
    while True:
        c -= b
        if c <= 0:
            print("Yes")
            break
        a -= d
        if a <= 0:
            print("No")
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int isPrime(long long N){
  int i;
  if(N < 2) return false;
  if(N == 2) return true;
  else if(N % 2 == 0) return false;
  for(i = 3; i*i <= N; i+=2){
    if(N % i == 0) return false;
  }
  return true;
}

int main(){
  long long x, N, In;
  long long count = 0;
  cin >> N;
  for(x = 1; x <= N; x++){
    cin >> In;
    if(isPrime(In))
      count = count + 1;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int i,l,c=0;
    l=s.length();
    for(i=0;i<l;i++){
        for(i=1;i<=l-2;i++){
            c++;
        }
        cout<<s[0]<<c<<s[l-1];
    }
    return 0;
}


Measured memory_bytes: 256
import sys

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

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

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()	
	al = lin()
	#dd = sum([v*v for v in al])
	d = sum(al)
	#return ( d*d - dd)//2
	ret = 0
	for v in al:
		d -= v
		ret += v*d
		ret = ret % mod
	return ret
	
#+++++
isTest=False

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

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

Measured memory_bytes: 104204
from math import sqrt
N = int(input())
v = int(sqrt(N)) + 1
for i in range(v, 0, -1):
    if N % i == 0:
        s1 = str(i)
        s2 = str(N // i)
        # print('s1 s2', s1, s2)
        ans = max(len(s1), len(s2))
        print(ans)
        exit()


Measured memory_bytes: 3060