akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x1, x2, x3, x4, y1, y2, y3, y4;
        double factor = 100000;
        int n = scanner.nextInt();
         
        for(int i = 0; i < n; i++) {
            x1 = Math.round(scanner.nextDouble() * factor);
            y1 = Math.round(scanner.nextDouble() * factor);
            x2 = Math.round(scanner.nextDouble() * factor);
            y2 = Math.round(scanner.nextDouble() * factor);
            x3 = Math.round(scanner.nextDouble() * factor);
            y3 = Math.round(scanner.nextDouble() * factor);
            x4 = Math.round(scanner.nextDouble() * factor);
            y4 = Math.round(scanner.nextDouble() * factor);
         
            long v1_x, v1_y, v2_x, v2_y;
            v1_x = x2 - x1;
            v1_y = y2 - y1;
            v2_x = x4 - x3;
            v2_y = y4 - y3;
            long op = v1_x * v2_y - v1_y * v2_x;
             
            if (op == 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 31888
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
string s, t;
int c[3001][3001];
int b[3001][3001];
void lcs(int i, int j){
    if(i<=0 || j<=0) return;
    if(b[i][j] != 0) return;
    if(s[i]==t[j]){
        lcs(i-1, j-1);
        c[i][j] = 1 + c[i-1][j-1];
        b[i][j] = 3;
    }
    else {
        lcs(i-1, j);
        lcs(i, j-1);
        if(c[i-1][j] > c[i][j-1]){
            c[i][j] = c[i-1][j];
            b[i][j] = 1;
        }
        else{
            c[i][j] = c[i][j-1];
            b[i][j] = 2;
        }
    }
}
int main()
{
    fast;
    cin>>s>>t;
    s = 'd' + s;
    t = 'x' + t;
    int sz1 = s.size()-1;
    int sz2 = t.size()-1;
    REP1(i, sz1) c[0][i] = 0;
    REP1(i, sz2) c[i][0] = 0;
    c[0][0] = 0;
    lcs(sz1, sz2);
    string ans = "";
    while(sz1>0&&sz2>0){
        if(b[sz1][sz2]==3){
            ans = s[sz1] + ans;
            sz1--;
            sz2--;
        }
        else if(b[sz1][sz2]==1){
            sz1--;
        }
        else sz2--;
    }
    cout<<ans<<'\n';
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  long asum = 0, bsum = 0, ans = 0, lesssum = 0;
  vector<long> A(N), B(N), P(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    asum += A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    bsum += B[i];
  }
  for (int i = 0; i < N; i++) {
    if (A[i] < B[i]) {
      ans++;
      lesssum += B[i] - A[i];
    }
    P[i] = max(0l, A[i] - B[i]);
  }
  if (asum < bsum) {
    cout << -1 << endl;
    return 0;
  }
  sort(P.begin(), P.end(), greater<long>());
  for (long p : P) {
    if (lesssum <= 0) break;
    lesssum -= p;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int h,w;
	string str;
	cin >> h >> w;
	for(char i=0;i<h;i++){
		char ch = 'A';
		for(int j=0;j<w;j++){
			cin >> str;
			if(str=="snuke"){
				cout << ch << i+1 << endl;
				break;
			}
			ch = int(ch)+1;
		}
	}
}

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

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

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();

            var a = CountChar(s, '1');
            var b = CountChar(s, '0');

            if (a < b)
            {
                WriteLine(a * 2);
            }
            else
            {
                WriteLine(b * 2);
            }
        }
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 15212
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

template <class Iterator, typename T>
T mode(T max, Iterator start, Iterator end) {
  vector<T> v(max + 1);
  for (auto i = start; i != end; i++) v[*i]++;
  T max_freq = 0, res = -1;
  for (T i = 0; i <= max; i++) {
    if (max_freq < v[i]) {
      max_freq = v[i];
      res = i;
    }
  }
  return res;
}

template <class Iterator, typename T>
T mode2(T max, Iterator start, Iterator end) {
  vector<T> v(max + 1);
  for (auto i = start; i != end; i++) v[*i]++;
  T md = mode(max, start, end);
  T second_max_freq = 0, res = -1;
  for (T i = 0; i <= max; i++) {
    if (second_max_freq < v[i] && i != md) {
      second_max_freq = v[i];
      res = i;
    }
  }
  return res;
}

int main() {
  int n;
  int v[100000];
  cin >> n;
  rep(i, n) cin >> v[i];
  vector<int> v_odd;
  vector<int> v_even;
  rep(i, n) {
    if (i % 2 == 0) v_even.push_back(v[i]);
    else v_odd.push_back(v[i]);
  }
  int a = mode(100000, v_even.begin(), v_even.end());
  int b = mode(100000, v_odd.begin(), v_odd.end());

  if (a == b) {
    // aを二番目に多い値に変える
    int a2 = mode2(100000, v_even.begin(), v_even.end());
    int b2 = b;
    int ans = 0;
    rep(i, n) {
      if (i % 2 == 0) {
        if (v[i] != a2) ans++;
      } else {
        if (v[i] != b2) ans++;
      }
    }
    // bを二番目に多い値に変える
    int a3 = a;
    int b3 = mode2(100000, v_odd.begin(), v_odd.end());
    int ans2 = 0;
    rep(i, n) {
      if (i % 2 == 0) {
        if (v[i] != a3) ans2++;
      } else {
        if (v[i] != b3) ans2++;
      }
    }
    if (a2 == -1 && b3 == -1) {
      cout << n / 2 << endl;
      return 0;
    }
    cout << min(ans, ans2) << endl;
    return 0;
  }
  int ans = 0;
  rep(i, n) {
    if (i % 2 == 0) {
      if (v[i] != a) ans++;
    } else {
      if (v[i] != b) ans++;
    }
  }
  //cout << a << b << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1780
#include<cstdio>
#include<algorithm>
using namespace std;
long long x,n,ans;
int main()
{
	//freopen("light.in","r",stdin);
	//freopen("light.out","w",stdout);
	scanf("%lld%lld",&n,&x);
	long long y=n-x;
	long long ans=n;
	while(y)
	{
		long long t=x/y;
		if(t)
		{
			ans+=t*y*2;
			x-=t*y;
		}
		swap(x,y);
	}
	ans-=x;
	printf("%lld",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        long ans=(n/k)*(n/k)*(n/k);
        if(k%2==0)ans+=(n/(k/2)-(n/k))*(n/(k/2)-(n/k))*(n/(k/2)-(n/k));
        System.out.println(ans);
        }
  }

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> //std::priority_queue<int> que; // 4, 3, 2, 1 (defualt, less) : 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

class Dinic {
  private:
    struct edge {
      int to;
      int capacity;
      int reverse;
    };
    std::vector<std::vector<edge>> G;
    std::vector<int> level;
    std::vector<int> iter;

    int dfs(int v, int t, int f) {
      if ( v == t ) return f;
      for(int &i = iter[v]; i<G[v].size(); i++){
        edge &e = G[v][i];
        if ( e.capacity > 0 && level[v] < level[e.to] ) {
          int d = dfs(e.to, t, std::min(f, e.capacity));
          if ( d > 0 ) {
            e.capacity -= d;
            G[e.to][e.reverse].capacity += d;
            return d;
          }
        }
      }
      return 0;
    }

    void bfs(int s) {
      std::fill(level.begin(), level.end(), -1);
      std::queue<int> que;
      level[s] = 0;
      que.push(s);
      while(!que.empty()){
        int v = que.front(); que.pop();
        for(int i=0; i<G[v].size(); i++) {
          edge &e = G[v][i];
          if ( e.capacity > 0 && level[e.to] < 0 ) {
            level[e.to] = level[v] + 1;
            que.push(e.to);
          }
        }
      }
    }

  public:
    Dinic(int MAX_V){
      G.resize(MAX_V);
      level.resize(MAX_V);
      iter.resize(MAX_V);
    }

    void AddEdge(int from, int to, int capacity) {
      edge k;   k.to = to;    k.capacity = capacity;  k.reverse = G[to].size();
      edge kk; kk.to = from; kk.capacity = 0;        kk.reverse = G[from].size();
      G[from].push_back(k);
      G[to]  .push_back(kk);
    }

    int max_flow(int s, int t) {
      int flow = 0;
      for(;;) {
        bfs(s);
        if ( level[t] < 0 ) return flow;
        std::fill(iter.begin(), iter.end(), 0);
        int f;
        while( (f=dfs(s,t,std::numeric_limits<int>::max())) > 0 ){
          flow += f;
        }
      }
    }
};

int main (void) {
  int N; std::cin >> N;
  std::vector<std::pair<int,int>> Red(N), Blue(N);
  for(int i=0; i<N; i++) std::cin >> Red[i].first  >> Red[i].second;
  for(int i=0; i<N; i++) std::cin >> Blue[i].first >> Blue[i].second;

  // 0 : source,  1~N red, N+1 ~ 2*N blue,  2N+1 sink
  Dinic d(2*N + 2);
  for(int i=0; i<N; i++) d.AddEdge(0, i+1, 1);
  for(int i=0; i<N; i++) d.AddEdge(N+i+1, 2*N+1, 1);
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      if ( Red[i].first < Blue[j].first && Red[i].second < Blue[j].second ) {
        d.AddEdge(i+1, N+j+1, 1);
      }
    }
  }
  std::cout << d.max_flow(0, 2*N+1) << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<vi> vvi;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";



int main()
{
    IOS
    int n;
    scanf("%d", &n);
//       total number of sequence= 10^n
//       number of sequence with 9 missing = 9^n
//       number of sequence with 0 missing = 9^n
//       number of sequnce with both 0 and 9 missing= 8^n
//       thus, number of sequence with either 0 or 9 missing 9^n + 9^n -8^n 
//       hence ans= 10^n -(2*9^n - 8^n)
    ll ans = fpow (10, n, MOD);
    (ans -= (fpow (9, n, MOD)) * 2 + 2 * MOD) %= MOD;
    (ans += fpow (8, n, MOD) + MOD) %= MOD;
    printf ("%lld", ans);
}


Measured memory_bytes: 3832
from bisect import bisect_left,bisect_right
from itertools import accumulate

n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def isOK(x):
    num=0
    for k,a in enumerate(A,start=1):
        i=bisect_left(A,x-a)
        num+=n-i
    return num>=m



l=0
r=2*10**5+1
while l+1<r:
    mid=(l+r)//2
    if isOK(mid):
        l=mid
    else:
        r=mid

s=0
num=0

acc=list(accumulate([0]+A))

for a in A:
    i=bisect_right(A,l-a)
    s+=a*(n-i)+acc[n]-acc[i]
    num+=n-i

ans=s+l*(m-num)

print(ans)


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   vector<ll> prime;
   bool mark[1000000];
   memset(mark,0,sizeof(mark));
   
   for(ll i=2;i<1000000;i++)
   {
       for(ll j=2*i;j<1000000;j+=i)
            mark[j] = 1;
   }
   
   for(ll i=2;i<1000000;i++)
   {
       if(!mark[i])
            prime.pb(i);
   }
   
   ll x;
   cin>>x;
   
   cout<<*lower_bound(prime.begin(), prime.end(), x);
   
   return 0;        
}  
   

Measured memory_bytes: 2424
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {
	rapid_pleaseAC_fast;

	llint a, b, k;
	cin >> a >> b >> k;
	if (k <= a) {
		cout << a - k << " " << b << rt;
	}
	else if ((k - a) <= b) {
		cout << 0 << " " << b - (k - a) << rt;
	}
	else {
		cout << 0 << " " << 0 << rt;
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
/* ex 7_3
   offNaria */

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int row, column, flag = 0;
    char **ptr;
    int *row_removed, *col_removed; //取り除く行，列を記憶するための配列
    scanf("%d %d", &row, &column);
    //メモリ動的確保ここから
    if ((ptr = (char **)calloc(row, sizeof(char *))) == NULL)
    {
        exit(1);
    }
    for (int i = 0; i < row; i++)
    {
        if ((ptr[i] = (char *)calloc(column, sizeof(char))) == NULL)
        {
            exit(1);
        }
    }
    if (((row_removed=(int*)calloc(row,sizeof(int)))==NULL)||((col_removed=(int*)calloc(column,sizeof(int)))==NULL))
    {
        exit(1);
    }
    //メモリ動的確保ここまで
    for (int i = 0; i < row; i++)
    {
        flag = 1;
        for (int j = 0; j < column; j++)
        {
            scanf(" %c", &ptr[i][j]);
            if (ptr[i][j] == '#')
            {
                flag = 0; //行内に黒があるなら取り除く対象外
            }
        }
        if (flag == 1)
        {
            row_removed[i] = 1; //すべて白の行は取り除く対象
        }
    }
    for (int j = 0; j < column; j++)
    {
        flag = 1;
        for (int i = 0; i < row; i++)
        {
            if (ptr[i][j] == '#')
            {
                flag = 0; //列内に黒があるなら取り除く対象外
            }
        }
        if (flag == 1)
        {
            col_removed[j] = 1; //すべて白の列は取り除く対象
        }
    }
    for (int i = 0; i < row; i++)
    {
        if (row_removed[i] != 1) //取り除く対象の行でないか
        {
            for (int j = 0; j < column; j++)
            {
                if (col_removed[j] != 1) //取り除く対象の列でないか
                {
                    printf("%c", ptr[i][j]);
                }
            }
            printf("\n");
        }
    }
    //メモリ解放ここから
    for (int i = 0; i < row; i++)
    {
        free(ptr[i]);
    }
    free(ptr);
    free(row_removed);
    free(col_removed);
    //メモリ解放ここまで
    return 0;
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n, k;
        cin >> n >> k;

        long ans = 0;
        while (n > 0) {
            n /= k;
            ans++;
        }
        if (ans == 0) ans = 1;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3772
# -*- coding: utf-8 -*-
import sys
S = input()

while(len(S) > 0):
    if S[0:6] == "eraser":
        S = S[6:]
    elif S[0:5] == "erase":
        S = S[5:]
    elif S[0:5] == "dream":
        tmp = S[5:8]
        if len(tmp) == 0:
            S = S[5:]
        elif tmp == "era":
            S = S[5:]
        elif tmp == "er":
            S = S[7:]
        elif tmp == "ere":
            S = S[7:]
        elif tmp == "erd":
            S = S[7:]
        else:
            S = S[5:]
    else:
        print("NO")
        sys.exit()
print("YES")

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		
		
		HashMap<Integer, List<String>> map = new HashMap<>();
		
		for(int x = 1; x <= 100; x++) {
			for(int y = 1; y <= 100; y++) {
				for(int z = 1; z <= 100; z++) {
					
					int val = x*x + y*y + z*z + x*y + y*z + z*x;
					int[] valArr = new int[3];
					valArr[0] = x;
					valArr[1] = y;
					valArr[2] = z;
					if(!map.containsKey(val)) {
						map.put(val, new ArrayList<>());
					}
					map.get(val).add(Arrays.toString(valArr));
				}
			}
		}
		
		for(int i = 1; i <= n; i++) {
			List<String> list = map.get(i);
			if(list == null) {
				System.out.println(0);
			}else {
				System.out.println(list.size());
			}
		}
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 141156
N, A, B =map(int, input().split())
m=0
for i in range(N+1):
    a=i//10000
    b=i//1000-10*a
    c=i//100-10*(i//1000)
    d=i//10-10*(i//100)
    e=i//1-10*(i//10)
    if A <= a+b+c+d+e <= B:
        m +=i
print(m)



Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>

typedef long long ll;

using namespace std;

int main() {
	string s;
	string t = "";
	string add[4] = {"dream", "dreamer", "erase", "eraser"};
	cin >> s;

	int index = 0;
	
	while (true) {
		if (s.substr(index, 7) == add[1] && s.substr(index, 8) != add[0] + "era") {
			index += 7;
			t += add[1];
		}else if(s.substr(index, 5) == add[0]){
			index += 5;
			t += add[0];
		} else if (s.substr(index, 6) == add[3]) {
			index += 6;
			t += add[3];
		} else if (s.substr(index, 5) == add[2]) {
			index += 5;
			t += add[2];
		} else {
			break;
		}

		if (index >= s.length()) {
			break;
		}
	}
	
	if (s == t) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
    long long n,m;
    cin>>n>>m;
    if(n==1)n=3;
    if(m==1)m=3;
    cout<<(n-2)*(m-2)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			char[] c = sc.next().toCharArray();
			
			int[] a = new int[n];
			int[] b = new int[n];
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt()-1;
				b[i] = sc.nextInt()-1;
			}
			
			char temp;
			for(int i=n-1;i>=0;i--){
				c[a[i]]+=(b[i]-a[i]);
				c[b[i]]+=(b[i]-a[i]);
				while((int)c[a[i]]>122) c[a[i]]-=26;
				while((int)c[b[i]]>122) c[b[i]]-=26;
				temp = c[a[i]];
				c[a[i]] = c[b[i]];
				c[b[i]] = temp;
			}
			for(int j=0;j<c.length;j++) System.out.print(c[j]);
			System.out.println();				
		}
	}
}

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

#define ll long long 

int main() {
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  
  if (W >= V) {
    cout << "NO" << endl;
    return 0;
  }
  
  ll dist = abs(A- B);
  
  if ((V-W) * T >= dist) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		long a=s.nextLong();
		long b=s.nextLong();
		
		long c=s.nextLong();
		long d=s.nextLong();
		
		long max=Long.MIN_VALUE;
		
		if(a*c>max)
			max=a*c;
		if(a*d>max)
			max=a*d;
		if(b*c>max)
			max=b*c;
		if(b*d>max)
			max=b*d;
		
		System.out.println(max);
		
	}
	
}

Measured memory_bytes: 35632
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
	char n[5];
	scanf("%s", n);

	int carry = 1, max_c = 1;
	for (int i = 1; i < 4; i++) {
		if (n[i] == n[i - 1]) {
			carry++;
			max_c = max(max_c, carry);
		} else {
			carry = 1;
		}
	}

	printf("%s\n", 3 <= max_c ? "Yes" : "No");
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int n;
	int i, a, b, c;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a*a + b*b == c*c){
			printf("YES\n");
		}else if(b*b + c*c == a*a){
			printf("YES\n");
		}else if(a*a + c*c == b*b){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        int ans = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - i - 1)) {
                ans++;
            }
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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


long dfs(string s, int i, int ope[]){
    
    if (i == s.size() - 1){
        int k = 0;
        long sum = 0;
        for(int j = 0; j < s.size(); j++){
            if(ope[j] == 0){
                string str(&s[k], &s[j+1]);
                sum += stol(str);
                k = j + 1;
            }
        }
        return sum;
    }
        
    long sum = 0;
    ope[i] = 0;
    sum += dfs(s, i+1, ope);
    ope[i] = 1;
    sum += dfs(s, i+1, ope);
    
    return sum;
}

int main(void){
    // Your code here!
    string s;
    int ope[10] = {};
    cin >> s;
    
    cout << dfs(s, 0, ope);
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
string s;
cin >> N >> s;
int r = 0;
int b = 0;
for(int i=0;i<N;i++){
if(s.at(i) == 'R') r++;
else b++;
}
if(r > b) cout << "Yes" <<endl;
else cout << "No" << endl;
}


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

#define ll long long

signed main(){
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  while (true){
    if (b <= a){
      b *= 2;
    }
    else {
      break;
    }
    k -= 1;
  }
  if (k < 0){
    cout << "No" << endl;
    return 0;
  }
  while (true){
    if (c <= b){
      c *= 2;
    }
    else {
      break;
    }
    k -= 1;
  }
  if (k < 0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

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

const int N = 2e5 + 5;

int n, m, x, y;
vector<int> ins[N];

namespace seg {
	int a[N * 4], tag[N * 4];
# define ls rt << 1
# define rs ls | 1
	void build(int rt, int l, int r) {
		a[rt] = l;
		if(l == r) return ;
		int mid = l + r >> 1;
		build(ls, l, mid);
		build(rs, mid + 1, r);
		a[rt] = min(a[ls], a[rs]);
	}
	inline void pushdown(int rt) {
		if(!tag[rt]) return ;
		a[ls] += tag[rt], tag[ls] += tag[rt];
		a[rs] += tag[rt], tag[rs] += tag[rt];
		tag[rt] = 0;
	}
	void modify(int rt, int l, int r, int ql, int qr) {
		if(l > qr || r < ql) return ;
		if(l >= ql && r <= qr)
			return (void) (a[rt] -= 1, tag[rt] -= 1);
		pushdown(rt);
		int mid = l + r >> 1;
		modify(ls, l, mid, ql, qr);
		modify(rs, mid + 1, r, ql, qr);
		a[rt] = min(a[ls], a[rs]);
	}
	int query(int rt, int l, int r, int ql, int qr) {
		if(l > qr || r < ql) return 1e9;
		if(l >= ql && r <= qr) return a[rt];
		pushdown(rt);
		int mid = l + r >> 1;
		return min(query(ls, l, mid, ql, qr), query(rs, mid + 1, r, ql, qr));
	}
}

int main() {
	scanf("%d%d", &n, &m);
	++m;
	for(int i = 1; i <= n; ++i) {
		scanf("%d%d", &x, &y);
		y = m - y;
		ins[x].push_back(y);
		//printf("(%d, %d)\n", x, y);
	}
	seg :: build(1, 0, m);
	int ans = m - 1 - n;
	for(int i = 0; i <= m; ++i) {
		for(int j = 0; j < (int) ins[i].size(); ++j) {
			int pos = ins[i][j];
			seg :: modify(1, 0, m, pos, m);
		}
		//cout << seg :: query(1, 0, m, 0, m - i) << '\n';
		ans = min(ans, i + seg :: query(1, 0, m, 0, m - i));
	}
	printf("%d\n", max(0, -ans));
	return 0;
}


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

int main(){
	
	for(string s;getline(cin,s),s!=".";){
		stack<char>S;
		int flg=1;
		for(int i=0;i<s.size() && flg;i++){
			if(s[i]=='(')S.push('(');
			if(s[i]=='[')S.push('[');
			if(s[i]==')'){
				if(S.size()==0)flg=0;
				else if(S.top()=='(')S.pop();
				else flg=0;
			}
			if(s[i]==']'){
				if(S.size()==0)flg=0;
				else if(S.top()=='[')S.pop();
				else flg=0;
			}
		}
		if(flg)flg=S.empty();
		cout<<(flg?"yes":"no")<<endl;
	}
	
	return 0;
}


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

int main(){
    int H, W;

    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut count = vec![0; n];
    for i in 0..m {
        let v = read_vec::<usize>();
        count[v[0] - 1] += 1;
        count[v[1] - 1] += 1;
    }
    if count.iter().all(|&x| x % 2 == 0) {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
from itertools import combinations


while True:
    count=0
    n, x = map(int, input().split())
    if n==0 and x==0:
        break
    combs = combinations(range(1, n+1), 3)
    for comb in combs:
        if comb[0] + comb[1] + comb[2] == x:
            count += 1
    print(count)


Measured memory_bytes: 5636
from bisect import bisect_left

H,W,K = map(int, input().split())
S = [input() for _ in range(H)]

"""
H <= 10までなので、横直線方向の割り方を全探索できそう
縦直線方向の割り方は貪欲か。
横直線の割方が決まったら、次は縦に割っていくが、ブロックの横幅を1にしても、ブロックないのホワイトチョコがKを超える場合もありうるので、その場合は、その横直線の割り方で条件を満たすことはできない


H=1や W=1の場合は普通に貪欲で。
"""


def is_over_K(lst, block_num):
    res = False
    for i in range(block_num):
        if lst[i] > K:
            res = True
            break
    return res


if H != 1 and W != 1:
    # 全区切りで割った場合が最大
    ans = (H-1) + (W-1)
    for bit in range(1 << (H-1)):
        can_split_h = True
        cnt_split_h = bin(bit).count("1")
        cnt_split_w = 0

        # 横直線方向で割る場合は、その箇所のindexを保持
        if cnt_split_h >= 1:
            idx_split_h = []
            for i in range(H-1):
                if bit & (1 << i):
                    idx_split_h.append(i)

        cnt_blocks = cnt_split_h + 1
        cnt_whites = [0] * (cnt_blocks)
        ex_cnt_whites = [0] * (cnt_blocks)

        for x in range(W):
            for y in range(H):
                if S[y][x] == "1":
                    if cnt_blocks > 1:
                        block_num = bisect_left(idx_split_h, y)
                    else:
                        block_num = 0

                    cnt_whites[block_num] += 1
            
            # それぞれKを超えていないか確認
            is_over = is_over_K(cnt_whites, cnt_blocks)

            
            if not is_over:
                # Kを超えないので、さらにxを追加して見ていく
                # xまでで各ブロックでホワイトチョコがいくつあるか保持（次のxでKを超えた場合に、差分を利用するので）
                for i in range(cnt_split_h+1):
                    ex_cnt_whites[i] = cnt_whites[i]
            else:
                # Kを超えるのでxの左の縦直線でわる
                cnt_split_w += 1
                # xの左の縦直線で割った場合のホワイトチョコの個数を求める（現在のxのみの個数）
                for i in range(cnt_blocks):
                    cnt_whites[i] -= ex_cnt_whites[i]
                    ex_cnt_whites[i] = cnt_whites[i]

                # 一列だけにしてもKを超えるなら、その横直線の分割はできない
                if is_over_K(cnt_whites, cnt_blocks):
                    can_split_h = False
                    break
            # 一列だけにしてもKを超えるブロックがあるので、この横直線の分割はできない
            if not can_split_h:
                break
        
        if can_split_h:
            ans = min(ans, cnt_split_h + cnt_split_w)

# H=1, W=1の場合忘れとった...
elif H == 1:
    ans = 0
    cnt = 0
    for i in range(W):
        if S[0][i] == "1":
            cnt += 1
        if cnt > K:
            ans += 1
            cnt = 1
else:
    ans = 0
    cnt = 0
    for i in range(H):
        if S[i][0] == "1":
            cnt += 1
        if cnt > K:
            ans += 1
            cnt = 1

print(ans)

Measured memory_bytes: 53724
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8,i8,i8,i8[:],i8[:])")
def solve(N, M, K, A, B):
    B_cumsum = B.cumsum()
    ans = 0
    time = 0
    for i in range(N + 1):
        if time > K:
            break
        # j = binary_search(B_cumsum, K - time) + 1
        # binary search
        key = K - time
        ok = -1
        ng = len(B_cumsum)
        while (ng - ok > 1):
            mid = (ok + ng) // 2
            if B_cumsum[mid] <= key:
                ok = mid
            else:
                ng = mid
        j = ok + 1
        ans = max(ans, i + j)
        if i < N:
            time += A[i]
    return ans


def main():
    N, M, K = map(int, input().split())
    A = np.array(input().split(), dtype=np.int64)
    B = np.array(input().split(), dtype=np.int64)
    # A = tuple(map(int, input().split()))
    # B = tuple(map(int, input().split()))

    ans = solve(N, M, K, A, B)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 140652
#include<stdio.h>

int main() {
	int a,b;
	scanf("%d %d",&a ,&b);
	int c = a * b;
	switch (c % 2) {
	case(1):
		printf("Odd\n");
	break;
	default:
		printf("Even\n");
	}
	return 0;
}

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

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

int main() {
    int n;
    while (cin >> n) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (isPrime(i) && isPrime(n + 1 - i)) {
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    --x, --y;

    vector<int> ans(n);
    rep(sv, n) {
        vector<int> dist(n, INF);
        queue<int> q;

        auto push = [&](int v, int d) {
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };

        push(sv, 0);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }
        rep(i, n) ans[dist[i]]++;
        
    }

    rep(i,n) ans[i] /= 2;
    for (int i = 1; i <= n-1; ++i) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
result = []

for A in range(1, N):
    B = N - A
    A = str(A)
    B = str(B)
    A_sum = sum(list(map(int, A)))
    B_sum = sum(list(map(int, B)))
    result.append(A_sum + B_sum)

print(min(result))


Measured memory_bytes: 3964
#include <iostream>

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 0; i < K; ++i) {
    if (i % 2 == 0) {
      // A
      if (A % 2 == 1) {
        --A;
      }
      int ageru = (A / 2);
      A = A / 2;
      B += ageru;
    } else {
      // B
      if (B % 2 == 1) {
        --B;
      }
      int ageru = (B / 2);
      B = B / 2;
      A += ageru;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var mnn = (arr.shift()).split(" ").map(Number);
   if (mnn[0] == 0) break;
   var Arr = (arr.splice(0, mnn[0])).map(Number);
   var ans = null;
   var max = -Infinity;
   for (var i = mnn[1] - 1; i < mnn[2]; i++) {
      max = Math.max(max, Arr[i] - Arr[i + 1]);
      if (max == Arr[i] - Arr[i + 1]) ans = i;
   }
   console.log(ans + 1);
}

Measured memory_bytes: 18668
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int; 
#pragma warning(disable : 4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;




int main(){


	int a, b, c;
	int t(0), h(0);
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if (a + b < c || a + c < b || b + c < a || !a || !b || !c)continue;


		if (a*a + b*b == c*c)
			++t;

		if (a == b)
			++h;

	}
	cout << t << endl << h << endl;

	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define ls x<<1
#define rs x<<1|1
using namespace std;
const int N=2e5+10;
struct node{
    int l,r,f,mi;
}e[N*4];
void up(int x){
    e[x].mi=max(e[ls].mi,e[rs].mi);
}
void down(int x){
    if(e[x].f==0)return ;
    int f=e[x].f;e[x].f=0;
    e[ls].mi+=f;e[rs].mi+=f;
    e[ls].f+=f;e[rs].f+=f;
}
void built(int x,int l,int r){
    e[x].l=l;e[x].r=r;e[x].f=0;
    if(l==r){
        e[x].mi=l;
        return ;
    }
    int mid=(l+r)/2;
    built(ls,l,mid);built(rs,mid+1,r);
    up(x);
}
void add(int x,int LL,int RR,int v){
    if(e[x].l>=LL&&e[x].r<=RR){
        e[x].f+=v;
        e[x].mi+=v;return ;
    }
    down(x);
    int mid=(e[x].l+e[x].r)/2;
    if(LL<=mid)add(ls,LL,RR,v);
    if(RR>mid)add(rs,LL,RR,v);
    up(x);
}
int query(int x,int LL,int RR){
    int ans=0;
    if(e[x].l>=LL&&e[x].r<=RR){
        return e[x].mi;
    }
    down(x);
    int mid=(e[x].l+e[x].r)/2;
    if(LL<=mid)ans=max(ans,query(ls,LL,RR));
    if(RR>mid)ans=max(ans,query(rs,LL,RR));
    return ans;
}
int n,m;
vector<int>V[N];
int main()
{
    int ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1,a,b;i<=n;i++){
        scanf("%d%d",&a,&b);
        V[a].push_back(b);
    }
    built(1,0,m+1);
    for(int i=0;i<=m+1;i++){
        for(int j=0;j<V[i].size();j++){
            add(1,0,V[i][j],1);
        }
        ans=max(ans,query(1,i+1,m+1)-i-m-1);
    }
    cout<<max(ans,n-m)<<endl;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  string S;
  cin>>S;
  
  vector<vector<ll>>dp(S.size(),vector<ll>(13));
  ll num=1;
  
  for(ll i=0;i<S.size()-1;i++){
num*=10;
    num%=13;
   
  }

  
  if(S[0]=='?'){
  for(ll i=0;i<10;i++){
dp[0][(i)%13]++;
    
  }
  }
  
  else{
    dp[0][((S[0]-'0'))%13]++;
  }


  for(ll i=1;i<S.size();i++){
    
    ll now=1;
    
    for(ll m=0;m<S.size()-i-1;m++){
    now*=10;
    now%=13;
  }
  

   
    
    if(S[i]=='?'){
    rep(j,10){//その時点での数字
rep(k,13){//前の桁の時点での余り
 
  dp[i][((k*10+j))%13]+=dp[i-1][k];
  dp[i][((k*10+j))%13]%=mod;
  

}
    }
    }
else{
  rep(k,13){
  
    dp[i][((k*10+S[i]-'0'))%13]+=dp[i-1][k];
  dp[i][((k*10+S[i]-'0'))%13]%=mod;
  
}
}

  }

  
  cout<<dp[S.size()-1][5]%mod<<endl;
}


    


Measured memory_bytes: 13696