akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N;
vector<int> ans;

int main(){
    cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    ans.push_back(A[0]);
    repi(i,1,N){
        auto it = lower_bound(ALL(ans),A[i]);
        auto be = ans.begin();
        if(it==be){
            ans.insert(be,A[i]);
        }
        else{
            ans[it-be-1]=A[i];
        }
    }
    out(ans.size());


    
}


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

int main() {

    char a,b;

    cin >> a >> b;

    if(a == 'D' && b == 'D'){
        cout << 'H' << endl;
    }
    else if(a=='D'){
        cout << 'D' << endl;
    }
    else{
        cout << b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for i in range(H):
    l = list(input())
    if not all(a=='.' for a in l):
        A.append(l)
d = []
for i in range(W):
    if all(aa[i]=='.' for aa in A):
        d.append(i)

B = []
for aa in A:
    l = ''
    for i, a in enumerate(aa):
        if i not in d:
            l += a
    B.append(l)
        
for bb in B:
    print(bb)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[100];
signed main(){
	int n;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	
	int ans = inf;
	repi(i,-100,101){
		int s = 0;
		rep(j,n)s += (a[j]-i)*(a[j]-i);
		chmin(ans, s);
	}
	printf("%lld\n", ans);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

void print_vec(vector<vector<int> > a, int H, int W){
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

int find_max(vector<vector<int> > a,int H, int W){
  int max = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(max < a.at(i).at(j))
        max = a.at(i).at(j);
    }
  }
  return max;
}


int main(int argc, char *argv[])
{
  int H,W,x,y;
  char tmp;
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  queue<int> queue_x,queue_y;
  cin >> H >> W;
  vector<vector<int> > a(H, vector<int>(W)), visited(H,vector<int>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> tmp;
      if(tmp == '.'){
        a.at(i).at(j) = 0;
        visited.at(i).at(j) = 0;
      }
      else{
        a.at(i).at(j) = 1;
        visited.at(i).at(j) = 1;
        queue_x.push(j);
        queue_y.push(i);
      }
    }
  }
  //print_vec(a,H,W);
  //print_vec(visited,H,W);
  while(!queue_x.empty() && !queue_y.empty()){
    x = queue_x.front();
    y = queue_y.front();
    queue_x.pop();queue_y.pop();
    //cout << "x: " << x << " y: " << y << endl;
    for(int i = 0;i < 4;i++){
      if(0 <= x+dx[i] && x+dx[i] < W && 0 <= y+dy[i] && y+dy[i] < H &&
          a.at(y+dy[i]).at(x+dx[i]) == 0 &&
          visited.at(y+dy[i]).at(x+dx[i]) == 0){
        queue_x.push(x+dx[i]);
        queue_y.push(y+dy[i]);
        visited.at(y+dy[i]).at(x+dx[i]) = visited.at(y).at(x) + 1;
      }
    }
  //print_vec(visited,H,W);
  }
  //print_vec(visited,H,W);
  int ans = find_max(visited,H,W);
  cout << ans-1 << endl;
  return 0;
}


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

int main()
{
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;
  int ans;

  if ( A <= C ) {
    if ( B <= D ) {
      ans = std::max(B-C, 0);
    } else {
      ans = D - C;
    }
  } else {
    if ( D <= B ) {
      ans = std::max(D-A, 0);
    } else {
      ans = B - A;
    }
  }

  std::cout << ans << std::endl;
}


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


int main(){
  
  string S,T;
  cin >> S >> T;
  int j=0;
  rep(i,S.size()){
    if(S.at(i)!=T.at(i))
      j++;
  }
  cout << j << endl;
}

Measured memory_bytes: 3924
import collections
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
b=collections.Counter(a)
d=list(b.items())
d.sort(key=lambda x:-int(x[0]))
if d[0][1]==1:
  for i in range(n):
    if a[i]==int(d[0][0]):
      print(int(d[1][0]))
    else:
      print(int(d[0][0]))
else:
  for i in range(n):
    print(int(d[0][0]))
    
          


Measured memory_bytes: 30456
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n,l,sum=0;
        cin>>n>>l;
        vector<pii> v;
        rep0(n){
        v.pb({abs(l+i),l+i});
        sum+=l+i;
        }
        sort(all(v));
        sum-=v[0].ss;
        cout<<sum;


        



        }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
def init(a, b, c, n)
  matrix = n.times.map{ [0] * n }
  matrix[0][0] = b
  matrix[0][1] = c
  matrix[n - 1][n - 2] = a
  matrix[n - 1][n - 1] = b
  (1..n - 2).each do |i|
    matrix[i][i - 1] = a
    matrix[i][i] = b
    matrix[i][i + 1] = c
  end
  matrix
end

def mul(mat1, mat2, n, m)
  ret = n.times.map{ [0] * n }
  n.times do |i|
    n.times do |j|
      n.times do |k|
        ret[i][k] += (mat1[i][j] * mat2[j][k]) % m
      end
    end
  end
  ret
end

def pow(matrix, n, m, t)
  unit = n.times.map{ [0] * n }
  n.times{ |i| unit[i][i] = 1 }
  while t > 0
    unit = mul(matrix, unit, n, m) if t & 1 == 1
    matrix = mul(matrix, matrix, n, m)
    t >>= 1
  end
  unit
end

loop do
  n, m, a, b, c, t = gets.split.map(&:to_i)
  break if n == 0
  mat = init(a, b, c, n)
  state = gets.split.map(&:to_i)
  ret = pow(mat, n, m, t)
  puts n.times.map{ |i| n.times.map{ |j| ret[i][j] * state[j] }.reduce(:+) % m } * ' '
end

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

void fnInput(vector<int>& rvnEntry)
{
  int nEntrySiz;
  cin >> nEntrySiz;
  rvnEntry.resize(3 * nEntrySiz);

  for (int& rnEntry : rvnEntry)
    cin >> rnEntry;

  sort(begin(rvnEntry), end(rvnEntry), greater<int>());
}

int64_t fnStrengthChk(const vector<int>& cnrvnEntry)
{
  int64_t nStrength = 0;
  int nEntrySiz = cnrvnEntry.size() * 2 / 3;

  for (int n = 0; n < nEntrySiz; n++)
    if (n % 2 == 1)  nStrength += cnrvnEntry[n];

  return nStrength;
}

int main()
{
  vector<int> vnEntry;

  fnInput(vnEntry);
  cout << fnStrengthChk(vnEntry) << endl;

  return 0;
}

Measured memory_bytes: 1408
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }





int main() {
	
	string s;
	cin >> s;
	ll ans = 700;
	for (char p : s) {
		if (p == 'o') ans += 100;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll n, a;
    cin >> n >> a;
    bool ans = false;
    rep(i, 21) {
        rep(j, a + 1) {
            if(500 * i + j == n) {
                ans = true;
                break;
            }
        }
    }
    if(ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	char b;
	cin >> b;
	switch (b){
		case 'A':{
			cout << 'T';
			break;
		}
		case 'T':{
			cout << 'A';
			break;
		}
		case 'G':{
			cout << 'C';
			break;
		}
		case 'C':{
			cout << 'G';
			break;
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int n, m; cin >> n >> m;
  int ans = 1;
  for(int i=1; i*i<=m; i++) {
    if (m%i==0) {
      int k = m/i;
      if (k >= n) {
        ans = max(ans,i);
      }
      if (i >= n) {
        ans = max(ans,k);
      }
    }
  }
  cout << ans << endl;
}

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

struct NODE {
	int num;
	int v;
};
queue<NODE> q;

int main(int argc,char **argv) {
	int n,Q;
	cin>>n>>Q;
	int node[n],from,to;
	vector<int> v[n];
	memset(node,0,sizeof(node));
	for(int i=0;i<n-1;i++) {
		scanf("%d%d",&from,&to);
		from--;to--;
		v[from].push_back(to);
		v[to].push_back(from);
	}
	
	int p,x;
	for(int i=0;i<Q;i++) {
		scanf("%d%d",&p,&x);
		node[p-1]+=x;
	}
	
	bool visit[n];
	int ans[n];
	memset(visit,0,sizeof(visit));
	memset(ans,0,sizeof(ans));
	visit[0]=1;
	NODE annnnnnnnn;
	annnnnnnnn.num=0;annnnnnnnn.v=0;
	q.push(annnnnnnnn);
	ans[0]=node[0];
	while(!q.empty()) {
		NODE here=q.front();
		ans[here.num]=here.v+node[here.num];
		for(vector<int>::iterator it=v[here.num].begin();it!=v[here.num].end();it++) {
			int next=*it;
			if(visit[next]==0) {
				q.push((NODE){next,ans[here.num]});
				visit[next]=1;
			}
		}
		q.pop();
	}
	
	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 17268
n = int(input())

m = n % 10
if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
    print("hon")
elif m == 0 or m == 1 or m == 6 or m == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9164
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
      long long  h,m,d,n,k,g,f,s;
      cin >> h >> m >> d >> n >> k;
      g=d-h;
      if(g<0)
      {
          cout << 0 <<endl;
      }
      f=n-m;
      s=g*60+f;
      if(s<=k)
      {
          cout << 0 <<endl;
      }
      else
      {
          cout << s-k <<endl;
      }
    return 0;
}

Measured memory_bytes: 3648
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a, T b) { return a<b?(a=b,true):false; }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define bs2int(bs) (int)((bs).to_ulong())
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int n;
int p[100010];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin>>n;
  int cnt=0;
  FOR(i,1,n+1)
  {
    cin>>p[i-1];
    if (p[i-1]==i)cnt++;
  }
  int cntpair=0;
  REP(i,n-1)
    if (p[i]==i+1 && p[i+1]==i+2) cntpair++,i++;
  cout << cnt - cntpair << endl;
}


Measured memory_bytes: 640
while True:
	n=int(input())
	if n==0:break
	a=list(map(int,input().split()))
	a.sort()
	saisho=1000000
	for i,iv in enumerate(a):
		if i!=0:
			saisho=abs(iv-b) if saisho > abs(iv-b)else saisho
		b=iv
	print(saisho)

Measured memory_bytes: 7780
from collections import deque
n, m = map(int, input().split())    

graph = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

inf = float('inf')
distance = [[-1, inf] for i in range(n)] #目印、距離
queue = deque([])

distance[0] = [0, 0]
queue.appendleft(0)

while len(queue) > 0:
  v = queue.popleft() 
  for next_v in graph[v]:
    judge = False
    if distance[next_v][0] == -1 or distance[v][1]+1 < distance[next_v][1]:
      distance[next_v] = [v, distance[v][1]+1]
      judge = True
    if judge:    
      queue.append(next_v)

print("Yes")
for i in range(1, n):
  print(distance[i][0]+1)



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

#define ll long long
#define ar array

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

	string s;
	int q;
	cin >> s >> q;
	bool st=0;
	vector<char> v[2];
	while(q--) {
		int qt;
		cin >> qt;
		if(qt==1) {
			st=!st;
		} else {
			int f;
			char c;
			cin >> f >> c, --f;
			v[f^st].push_back(c);
		}
	}
	string t;
	for(int i=(int)v[0].size()-1; ~i; --i)
		t+=v[0][i];
	t+=s;
	for(char c : v[1])
		t+=c;
	if(st)
		reverse(t.begin(), t.end());
	cout << t;
}


Measured memory_bytes: 1448
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int a = cin.ReadInt();
			int b = cin.ReadInt();
			if (a == b) Console.WriteLine("Draw");
			else if (a == 1) Console.WriteLine("Alice");
			else if (b == 1) Console.WriteLine("Bob");
			else if (a > b) Console.WriteLine("Alice");
			else Console.WriteLine("Bob");
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <math.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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll x;
    cin >> x;
    for (ll a = 0; a <= 1000; a++) {
        ll a5 = 1;
        for (int i = 0; i < 5; i++)
            a5 *= a;
        for (ll b = -1000; b <= 1000; b++) {
            ll b5 = 1;
            for (int i = 0; i < 5; i++)
                b5 *= b;
            if (a5 - b5 == x) {
                cout << a << " " << b << " " << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3620
#include <stdio.h>
int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	if (a == b)
	{
		printf("a == b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else{
		printf("a < b\n");
	}
}


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

int main() {
  int A, B, x, ans;
  cin >> A >> B;
  ans = 0;
  for(int i = 0; i < B-A+1; i++){
    x = A + i;
    if(x/10000 == x%10 && x/1000%10 == x/10%10){
      ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
n,c = map(int,input().split())
d = [[int(i) for i in input().split()] for _ in range(c)]
lc = [[int(i)-1 for i in input().split()] for _ in range(n)]

ans = float("inf")

dp = [[0] * c for i in range(3)]
for C in range(c):
  for y in range(n):
    for x in range(n):
      if lc[y][x] != c:
        dp[(y+x)%3][C] += d[lc[y][x]][C]
for c0 in range(c):
  for c1 in range(c):
    if c0 == c1: continue
    for c2 in range(c):
      if c0 == c2 or c1 == c2: continue
      ans = min(ans, dp[0][c0] + dp[1][c1] + dp[2][c2])
print(ans)


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

int main(){
	int i, n, ans;
	double xa, xb, ra, rb, ya, yb;
	double d;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
		if(fabs(ra-rb) > d){
			ans = (ra>rb)? 2 : -2;
		}else if(ra+rb < d){
			ans = 0;
		}else{
			ans = 1;
		}
		cout << ans << endl;
	}
	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;string s;cin>>n>>s;
  vector<vector<bool>> table(n,vector<bool>(n,false));
  int i,j,k;
  int ans=0;
  for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(s[i]==s[j])table[i][j]=true;
  for(k=1;k<n;k++)
  {
    int kans=0;
    for(i=0;i+k<n;i++)
    {
      if(table[i][i+k]&&kans<k)
      {
        kans++;
      }
      else kans=0;
      ans=(kans>ans)?kans:ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
                            
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;
 
ll A;
double B;
 
int main(){
		
	NFS
 
	cin >> A;
	cin >> B;
	cout << (ll)((A*(ll)round((double)B*(double)100))/(ll)100) << endl;
	
	ioi
}

Measured memory_bytes: 3804
(n,),a,b=$<.map{_1.split.map &:to_i}
n.times{$*[a[_1]]||=_1}
c=(b+b)[(a&b).map{|x|(b.bsearch_index{_1>x}||n)-$*[x]}.max||0,n]
puts (0...n).any?{a[_1]==c[_1]}?:No:[:Yes,c]

Measured memory_bytes: 56508
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,len,c=0;
	char s[11];
	scanf("%s",s);
	len=strlen(s);
	if(s[0]!='A'){
		printf("WA");
		return 0;
	}
	for(i=2;i<len-1;i++){
		if(s[i]=='C' && c==0)
			c=1;
		else if(s[i]=='C'){
			printf("WA");
			return 0;
		}
		else if(s[i]-'a'>25 || s[i]-'a'<0){
			printf("WA");
			return 0;
		}
	}
	if(c!=1){
		printf("WA");
		return 0;
	}
	if(s[len-1]-'a'>25 || s[len-1]-'a'<0){
		printf("WA");
		return 0;
	}
	if(s[1]-'a'>25 || s[1]-'a'<0){
		printf("WA");
		return 0;
	}
	printf("AC");
	return 0;
}
		

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int calc(int a) {
	int cnt = 0;
	while (a) {
		cnt += a % 2;
		a /= 2;
	}
	return cnt;
}
int modpow(int a, int p,int mo) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP, mo);

		return half * half % mo;
	}
	else {

		return a * modpow(a, p - 1, mo) % mo;
	}
}

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

	int N;
	string S;
	cin >> N >> S;
	int po = 0;
	REP(i, N)if (S[i] == '1')po++;
	VI cnt(N + 10, 0);
	REP(i, cnt.size()) {
		int co = calc(i);
		if (i != 0)cnt[i] = cnt[i%co] + 1;		
	}
	int u = 0, d = 0;
	reverse(S.begin(), S.end());
	
	bool F = 0;
	if (po == 1)F = 1;
	REP(i, N) {
		if (S[i] == '1')u += modpow(2, i, po + 1);
		if (!F) {
			if (S[i] == '1')d += modpow(2, i, po - 1);
		}
		u %= (po + 1);
		if (!F) {
			d %= (po - 1);
		}
	}
	VI ans(N);
	REP(i, N) {
		if (S[i] == '0') {
			int U = u;
			U += modpow(2, i, po + 1);
			U %= (po + 1);
			ans[i] = cnt[U] + 1;
		}
		else {
			if (F) {
				ans[i] = 0;
				continue;
			}
			int D = d;
			D -= modpow(2, i, po - 1);
			D += (po- 1);
			D %= (po - 1);
			ans[i] = cnt[D] + 1;

		}
	}
	reverse(ans.begin(), ans.end());
	REP(i, N)cout << ans[i] << '\n';

	return 0;
}



Measured memory_bytes: 6772
using System;
class Program
{
  static void Main (string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    int[] array = new int[N];
    int[] sortedArray = new int[N];
    for (int i = 0; i < N; i++) {
      int n = int.Parse(input[i]);
      array[i] = n;
      sortedArray[i] = n;
    }
    Array.Sort(sortedArray);
    
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (array[i] != sortedArray[i]) {
        count++;
      }
    }
    Console.WriteLine((count == 2 || count == 0) ? "YES" : "NO");
  }
}

Measured memory_bytes: 11092
# import bisect
# import copy
# import fractions
# import math
import numpy as np
#from collections import Counter
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    A=list(map(int,input().split()))

    B=np.argsort(A)

    for b in B:
        print(b+1,end=' ')




resolve()

Measured memory_bytes: 23472
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 405;
vector < vector < ll > > DP(N + 5, vector < ll > (N + 5, 0));
vector < int > v(N + 5);
ll sum(int l, int r) {
  ll ans = 0;
  for (int i = l; i <= r; i++) {
    ans += v[i];
  }
  return ans;
}
int main() {
  int n; cin >> n;
  // DP[i][j] --> optimul pentru secventa i -- j
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  for (int L = n; L >= 1; L--) {
    for (int R = L; R <= n; R++) {
      if (L == R) {
        DP[L][R] = 0;
        continue;
      }
      ll new_slime = sum(L, R);
      DP[L][R] = 2e18;
      for (int i = L; i <= R - 1; i++) {
        DP[L][R] = min(DP[L][R], DP[L][i] + DP[i + 1][R] + new_slime);
      }
    }
  }
  cout << DP[1][n] << "\n";
}


Measured memory_bytes: 1536
MOD = 998244353
MAXN = 200000+10
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, MAXN+1): 
    g1.append((g1[-1]*i)%MOD)
    inverse.append(-inverse[MOD%i]*(MOD//i)%MOD)
    g2.append((g2[-1]*inverse[-1])%MOD)

def comb(n, r): 
    if r<0 or r>n: 
        return 0
    r=min(r, n-r)
    return g1[n]*g2[r]*g2[n-r]%MOD

N, M, K = map(int, input().split())
ans = 0

for i in range(K+1):
    tmp = M*pow(M-1, N-1-i, MOD)
    ans += comb(N-1, i)*tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 33208
import math
N, K= map(int, input().split())
li = []
le = []
for i in range(N):
    A = math.log2(K/(i+1))
    if A < 0:
        kaisu =0
    else:
        kaisu = math.ceil(A)
    le.append(kaisu)
    li.append((0.5**kaisu)/N)
sumli = sum(li)
print(sumli)

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

using namespace std;

const int N = 1e5 + 5;

int n, h, hit[N], thr[N], cnt;

int main()
{
	scanf("%d %d", &n, &h);
	for(int i = 0 ; i < n ; ++i)	scanf("%d %d", hit + i, thr + i);
	sort(hit, hit + n);
	sort(thr, thr + n);
	int idx = n - 1;
	int maxHit = hit[n - 1];
	while(1)
	{
		if(idx == - 1 || h <= 0)	break;
		if(thr[idx] > maxHit)
		{
			h -= thr[idx];
			--idx;
			++cnt;
		}
		else	break;
	}
	if(h > 0)
	{
		if(h % maxHit == 0)	cnt += h / maxHit;
		else cnt += (h / maxHit) + 1;
	}
	printf("%d\n", cnt);
	return 0;
}

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

int main() {

    int X;
    cin >> X;

    int a = X / 500;
    int b = (X - (X/500) * 500) / 5;

    cout << a * 1000 + b * 5 << endl;

    return 0;
}

Measured memory_bytes: 3568
# coding: utf-8


N = int(input())
A = map(int, input().split(" "))

def solve():
    o = 0
    e = 0
    for a in A:
        if a % 2 == 0:
            e += 1
        else:
            o += 1

    t = o % 2
    e += o // 2
    t += (e > 0)
    if t > 1:
        return "NO"
    return "YES"

print(solve())




Measured memory_bytes: 11228
A = []
res = [[False]*3]*3
cnt = False
for n in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
B = []
for n in range(N):
    b = int(input())
    B.append(b)
for i in A:
    for j in range(len(i)):
        for n in range(N):
            if i[j] == B[n]:
                i[j] = 0
# for i in range(len(A)):
#     for j in range(3):
#         for n in range(N):
#             if A[i][j] == B[n]:
#                 res[i][j] = True
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        cnt = True
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        cnt = True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    cnt = True
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    cnt = True
if cnt:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	
	int a,b,c;
	
	cin>>a>>b>>c;
	
	if(a==b){
		cout<<c<<endl;
	}
	
	else if(b==c){
		cout<<a<<endl;
	}
	
	else if(a==c){
		cout<<b<<endl;
	}
	
	
}

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

int main(){
	int n;	cin>>n;
	vector<int> D(n+2);		D[0]=0;	D[n+1]=24;
	for(int i=1;i<=n;i++)cin>>D[i];
	sort(D.begin(), D.end());

	for(int i=1;i<=n;i++){
		if(D[i]==0)continue;

		if(i%2==0)D[i]=(24-D[i]);
	}sort(D.begin(), D.end());

	int ans=100;
	for(int i=1;i<=n+1;i++){
		ans=min(ans, D[i]-D[i-1]);
	}

	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {

        const long mod = 1000000007;

        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        long ans = 0;
        Array.Sort(a);
        bool ok = true;
        if (n % 2 != 0)
        {
            for (int i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    if (a[i] != 0)
                    {
                        ok = false;
                    }
                }
                else
                {
                    if (i % 2 == 0)
                    {
                        if (a[i] != i)
                        {
                            ok = false;
                        }
                    }
                    else
                    {
                        if (a[i] != i + 1)
                        {
                            ok = false;
                        }
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    if (a[i] != i + 1)
                    {
                        ok = false;
                    }
                }
                else
                {
                    if (a[i] != i)
                    {
                        ok = false;
                    }
                }
            }
        }


        if (ok)
        {
            if (n % 2 == 0)
            {
                ans = 1;
                var count = 0;
                while (count < n / 2)
                {
                    ans *= 2;
                    ans %= mod;
                    count++;
                }
            }
            else
            {
                ans = 1;
                var count = 0;
                while (count < (n - 1) / 2)
                {
                    ans *= 2;
                    ans %= mod;
                    count++;
                }

            }

        }
        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 20064
#include<stdio.h>

int count_areas(int x);

int count_areas(int x){

   int y[100005],i;

   for(i=0;i<x;i++){
      if(i==0)y[0]=2;
      else{
         y[i]=y[i-1]+i+1;
      }
   }
      return(y[x-1]);
}

int main(void){

   int n,a;

   while((scanf("%d",&n))!=EOF){

      a=count_areas(n);
      printf("%d\n",a);
   }
   return 0;
}

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

#define ll long long
#define INF 1e9+1000
#define MAX 100100

ll a[102], wt[102], W, n;
ll dp[101][100100];

ll solve()
{
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<100100;j++)
		{
			dp[i][j]=INF;
		}
	}

	for(int i=0;i<n;i++)
	{
		dp[i][a[i]]=wt[i];
	}

	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=100005;j++)
		{
			if(a[i]==j) dp[i][j]=min(dp[i][j],wt[i]);
			else if(j-a[i]>=0)
				dp[i][j]= min(dp[i-1][j-a[i]]+wt[i], dp[i-1][j]);
			dp[i][j]=min(dp[i-1][j],dp[i][j]);
		}
	}
}

int main()
{
	cin >> n >> W;

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

	ll ans=-1;

	solve();

	for(ll j=100005;j>=0;j--)
	{
		if(dp[n-1][j]<=W)
		{
			cout << j << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 79232
import sys
N=int(input())
flag=True
for k in range(1000):
    s=(k*(k+1))//2
    if N==s:
        flag=False
        break
if flag:
    print('No')
    sys.exit()
table=[[0]*(k+1) for i in range(k+1)]
s=1
for j in range(k+1):
    for i in range(j):
        table[j][i]=table[i][j]
    for i in range(j+1,k+1):
        table[j][i]=s
        s+=1
print('Yes')
print(k+1)
for i in range(k+1):
    table[i].remove(0)
    l=str(k)+' '
    l+=' '.join(map(str,table[i]))
    print(l)

Measured memory_bytes: 44908
###綺麗になったよ！！！！！
def y_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    ans=0
    next_bit=0
    kuri_cal=0
    for i in range(l-1):
        num=int(rev[i])+next_bit
        next_num=int(rev[i+1])
        if (num<5) or (num==5 and next_num<5):
            ans+=(kuri_cal+num)
            kuri_cal=0
            next_bit=0
        else:
            kuri_cal+=10-num
            next_bit=1 
    
    last=int(tmp[0])+next_bit
    ans+=kuri_cal+min(last,11-last)
    return ans

n=input()
ans=y_solver(n)
print(ans)

Measured memory_bytes: 5492
import scala.io.StdIn.{readInt, readLine};
import scala.annotation.tailrec;
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val m = new Array[Array[Int]](size);
        (0 until size).foreach {  i => m(i) = readLine.trim.split(" ").map( a => if (a.toInt == -1) Int.MaxValue else a.toInt)}
        val g = new Graph(size, m);
        val (parent, distance) = g.prim;
        println(distance.sum)
    }
}
case class Graph(size: Int, matrix: Array[Array[Int]]) {
    val INFINITY = Int.MaxValue
    def prim(): (Array[Int], Array[Int]) = {
        // WHITE : 未訪問, GRAY: MST候補ノード, BLACK: MST追加済みノード
        val WHITE = 0; val GRAY = 1; val BLACK = 2;
        val color = new Array[Int](size); // 訪問状態リスト(WHITE, GRAY, BLACK)
        val distance = new Array[Int](size).map( e => INFINITY); //  重みリスト
        val parents = new Array[Int](size); //  親ノードリスト
        @tailrec
        def _prim(curr: Int): Unit = {
            // MSTに属する頂点の集合から最も近いノードの index を取得する
            val idx = (0 until size).foldLeft(-1) { (minidx, i) =>
                if (color(i) != BLACK) {
                    // curr の子ノードをMST候補ノードに追加
                    if (matrix(curr)(i) != -1) {
                        color(i) = GRAY;
                    }
                    if (color(i) == GRAY) {
                        // すでに登録されている重みよりも curr からの重みのほうが小さい場合は
                        // 親ノードと重みを更新する
                        if (matrix(curr)(i) < distance(i)) {
                            distance(i) = matrix(curr)(i);
                            parents(i) = curr;
                        }
                        if (minidx == -1 || distance(i) < distance(minidx)) i else minidx;
                    } else { // color(i) == WHITE
                        // 現時点のMSTに隣接していないノードは評価しない
                        minidx;
                    }
                } else { // color(i) == BLACK 
                    // すでにMSTに追加されているノードは評価しない
                    minidx;
                }
            }
            if (idx != -1){
                // MSTから最も距離の近いノードを追加
                color(idx) = BLACK;
                _prim(idx);
            }
        }
        distance(0) = 0;
        parents(0) = -1;
        color(0) = BLACK;
        _prim(0);
        (parents, distance);
    }
}


Measured memory_bytes: 48972
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = [[1 if c == '#' else 0 for c in S()] for _ in range(n)]
    b = [n-sum(a[i]) for i in range(n)]

    t = 0
    for i in range(n):
        if not all([a[j][i] == 1 for j in range(n)]):
            t += 1

    if min(b) == 0:
        return t

    if min(b) == n:
        return -1

    r = min(b) + 1 + t
    for i in range(n):
        ai = a[i]
        for j in range(n):
            if ai[j] == 0:
                continue
            if r > b[j] + t:
                r = b[j] + t

    return r


print(main())






Measured memory_bytes: 7588
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();

        // 出力
        if(a < b) System.out.println("0");
        else System.out.println("10");

    }

}


Measured memory_bytes: 22608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var w = p[0];
		var a = p[1];
		var b = p[2];
		
		if(Math.Abs(a-b)<=w)
		{
			Console.WriteLine(0);
			return;
		}
		
		Console.WriteLine(Math.Abs(a-b)-w);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27540
//
//  main.cpp
//  atCoderScript
//
//  Created by 数理科学部 on 2016/08/07.
//  Copyright © 2016年 数理科学部. All rights reserved.
//

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(void)
{
    int t,max = 0,min = 100,kz = 0,y;
    cin >> t;
    vector<int> ar(t);
    
    for(auto& x : ar)
    {
        cin >> x;
        if(max < x) max = x;
        if(min > x) min = x;
    }
    y = min;
    for(auto& x : ar)
    {
        kz += pow(x-y,2);
    }
    
    while(y <= max)
    {
        int tc = 0;
        for(auto& x : ar)
        {
            tc += (int)pow(x - y,2);
        }
        
        if(tc < kz) kz = tc;
        
        y++;
    }
    
    cout << kz << endl;
    
    return 0;
}


Measured memory_bytes: 256
def f():
    x = [int(e) for e in input().split(" ")]
    return (x[0] ** 2) + (x[1] ** 2)


n = [int(e) for e in input().split(" ")]
c = 0
for _ in range(n[0]):
    x = f()
    if(x <= n[1] ** 2):
        c += 1
else:
    print(c)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

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

typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  REP(i, k) {
    if (b >= c) {
      c *= 2;
    } else if (a >= b) {
      b *= 2;
    } else {
      break;
    }
  }
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

int main() {
    string S, T; cin >> S >> T;
    int N = S.size();
    for(int i=0; i<N; i++){
        if(S==T){
            cout << "Yes" << endl;
            return 0;
        }else{
            string next;
            next += S[N-1];
            for(int i=0; i<N-1; i++){
                next += S[i];
            }
            S = next;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

# 作りうる水の量を洗い出す
waters = set()

for i in range(F//(100*A) + 1):
    for j in range((F-100*A*i)//(100*B) + 1):
        w = 100*A*i + 100*B*j
        if w != 0:
            waters.add(w)
waters = list(waters)
waters.sort()


sugars = set()
# Cを何回入れるか
for i in range(F//C + 1):
    # Dを何回いれるか
    for j in range((F - C*i) // D + 1):
        s = i*C + j*D
  
        sugars.add(s)


sugars = list(sugars)
sugars.sort()

# 最大濃度
max_conc = 0
# 最大濃度の時の水と砂糖
total = 0
sugar = 0

best_w = best_s = best_r = -1
for water in sorted(waters):
    for sugar in sorted(sugars):
        if water + sugar > F: break
        if water*E < sugar*100: break
        rate = sugar / (water + sugar)
        if rate > best_r:
            best_r = rate
            best_w = water
            best_s = sugar
print(best_s+best_w, best_s)

Measured memory_bytes: 3188
// user:halahen
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1010;
long long i,j,k;
long long n,m,t1,t2,t3,t4,x,y;
long long a[maxn],b[maxn],f[maxn],ans[maxn];
long long read(){
	long long tot=0,fh=1;
	char c=getchar();
	while ((c<'0')||(c>'9')){ if(c=='-') fh=-1; c=getchar(); }
	while ((c>='0')&&(c<='9')){ tot=tot*10+c-'0'; c=getchar(); }
	return tot*fh;
}
long long dis(long long x,long long y,long long tx,long long ty){
	return (abs(x-tx)+abs(y-ty));
}
int main(){
	n=read();
	for (i=1;i<=n;i++){
		a[i]=read(); b[i]=read();
		if ((((a[i]+b[i])%2)+2)%2==0){
			t1++;
		}
	}
	if ((t1!=0)&&(t1!=n)){
		printf("-1\n"); return 0;
	}
	if (t1==n){
		m=32;
		f[1]=1; f[2]=1;
		for (i=3;i<=m;i++){
			f[i]=f[i-1]*2;
		}
	}
	else{
		m=31;
		f[1]=1;
		for (i=2;i<=m;i++){
			f[i]=f[i-1]*2;
		}
	}
	for (i=1;i<=m/2;i++) swap(f[i],f[m-i+1]);
	printf("%lld\n",m);
	for (i=1;i<=m;i++) printf("%lld ",f[i]); printf("\n");
	for (i=1;i<=n;i++){
		x=0; y=0;
		for (j=1;j<=m;j++){
			t1=dis(x-f[j],y,a[i],b[i]);
			t2=dis(x+f[j],y,a[i],b[i]);
			t3=dis(x,y-f[j],a[i],b[i]);
			t4=dis(x,y+f[j],a[i],b[i]);
			if ((t1<=t2)&&(t1<=t3)&&(t1<=t4)){
				ans[j]=1;
				x=x-f[j]; y=y;
			}
			else{
				if ((t2<=t1)&&(t2<=t3)&&(t2<=t4)){
					ans[j]=2;
					x=x+f[j]; y=y;
				}
				else{
					if ((t3<=t2)&&(t3<=t1)&&(t3<=t4)){
						ans[j]=3;
						x=x; y=y-f[j];
					}
					else{
						if ((t4<=t2)&&(t4<=t3)&&(t4<=t1)){
							ans[j]=4;
							x=x; y=y+f[j];
						}
					}
				}
			}
		}
		if ((x!=a[i])||(y!=b[i])){
			printf("NO");
		}
		for (j=1;j<=m;j++){
			if (ans[j]==1) printf("L");
			if (ans[j]==2) printf("R");
			if (ans[j]==3) printf("D");
			if (ans[j]==4) printf("U");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/18/2020
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int64_t INF = (int64_t)1e18;
const int mxN = 100, mxW = (int)1e5;

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

	int n, w;
	cin >> n >> w;
	vector<pair<int64_t, int64_t>> v(n);
	for(auto& el : v) cin >> el.first >> el.second;
	int64_t dp[n+1][w+1]; // dp[i][j] max value i can get starting from elem i and always ending at last elem with w weight still have to spend;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= w; j++)
			dp[i][j] = -INF;
	for(int i = 0; i < w; i++) dp[n][i] = 0;
	// for(int i = 0; i <= n; i++) dp[i][0] = 0;
	for(int i = n-1; i >= 0; i--) {
		for(int j = 0; j <= w; j++) {
			dp[i][j] = dp[i+1][j]; // leave it;
			if(j >= v[i].first) {
				dp[i][j] = max(dp[i][j], dp[i+1][j-v[i].first] + v[i].second); // take it;
			}
		}
	}
	cout << dp[0][w] << "\n";

	return 0;
}


Measured memory_bytes: 82500