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

typedef complex<double> P;
#define X real()
#define Y imag()

struct Node{
    int l, r;
    double d;
    Node(int l, int r, double d):l(l), r(r), d(d) {};
    bool operator<(const Node &n)const{return d > n.d;};
};

int N;
vector<P> M;

double solve(){
    vector<int> ys;
    for(auto p: M) ys.push_back(p.Y);
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    
    vector<P> M2;
    
    for(int i=0; i<N-1; i++){
        auto p1 = M[i], p2 = M[i+1];
        vector<P> tm;
        bool rev = false;
        
        if(p2.Y != p1.Y){
            if(p1.Y > p2.Y){
                rev = true;
                swap(p1, p2);
            }
            for(auto y: ys){
                if(p1.Y <= y && y <= p2.Y)
                    tm.emplace_back((p2.X-p1.X)*(y-p1.Y)/(p2.Y-p1.Y)+p1.X, y);
            }
        }else{
            tm.emplace_back(p1);
            tm.emplace_back(p2);
        }
        if(rev)
            reverse(tm.begin(), tm.end());
        if(M2.size())
            M2.pop_back();
        M2.insert(M2.end(), tm.begin(), tm.end());
    }
    
    priority_queue<Node> que;
    //vector<vector<int>> done(M2.size(), vector<int>(M2.size()));
    //vector<vector<double>> d(M2.size(), vector<double>(M2.size(), 1e9));
    set<pair<int, int>> done;
    map<pair<int, int>, double> d;
    
    que.push(Node(0, M2.size()-1, 0));
    //d[0][M2.size()-1] = 0;
    d[make_pair(0, M2.size()-1)] = 0;
    
    while(!que.empty()){
        auto v = que.top(); que.pop();
        //if(done[v.l][v.r]++) continue;
        if(v.r == v.l)
            return v.d;
            //return d[make_pair(v.l, v.r)]; //d[v.l][v.r];
        
        if(done.count(make_pair(v.l, v.r))) continue;
        done.insert(make_pair(v.l, v.r));
        
        
        for(int nl=v.l-1; nl<=v.l+1; nl++){
            for(int nr=v.r-1; nr<=v.r+1; nr++) if(0<=nl&&nl<M2.size()&&0<=nr&&nr<M2.size() && M2[nl].Y == M2[nr].Y){
                double cost = abs(M2[v.l]-M2[nl]) + abs(M2[v.r]-M2[nr]);
                //if(d.count(make_pair(nl, nr))==0 || d[make_pair(v.l, v.r)] + cost < d[make_pair(nl, nr)]){
                    //d[make_pair(nl, nr)] = d[make_pair(v.l, v.r)] + cost;
                    que.push(Node(nl, nr, v.d+cost));
                //}
            }
        }
    }
    return -1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(16);
    cout.setf(ios::fixed);
    while(cin >> N, N){
        M.resize(N);
        for(int i=0; i<N; i++){
            int x, y; cin >> x >> y;
            M[i] = P(x, y);
        }
        cout << solve() << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4704
import math 
from collections import defaultdict as dd
def main():
    N, Y = map(int, input().split())
    a = (Y//10000)

    if a*10000 == Y:
        if a == N:
            print (a,0,0)
            return

    s = -1
    for k in range(a+1):
        b = N-k
        if b < 0:
            print ('-1 -1 -1')
            return 
        for j in range(b+1):
            s = 10000*k+5000*j+1000*(b-j)
            if s == Y:
                print (k,j,(b-j))
                return

    print ('-1 -1 -1')



if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


Measured memory_bytes: 3316
#include<stdio.h>
main(){

  int N;
  double y,s,t;

  while(1){

    if(scanf("%lf",&s) == EOF){
      break;
    }
  
    t = s/9.8;
    y = t*t*4.9;
    
    for(N=1;y > (5*N-5);N++){
    }
    
    printf("%d\n",N);
    
  }

  return 0;

}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int l,a,b,c,d;
  cin >> l >> a >> b >> c >> d;
  cout << (l-MAX(ceil((float)a/c), ceil((float)b/d))) << endl;
  return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        string S;
        int size;

        cin >> S;

        size = S.length();

        int count = 0;
        int result = 0;
        for(int i = 0; i < size; i++){
            if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
                count += 1;
            }
            else{
                result = max(count, result);
                count = 0;
            }
        }

        result = max(count, result);        

        cout << result << endl;

    }

Measured memory_bytes: 256
/*
Author:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%   ANMOL GUPTA      %%%%%%%% 
%%%%%%%%   NIT HAMIRPUR     %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define pb push_back
#define debug(x)  cout<<'>'<<#x<<" : "<<x<<endl;
#define mp make_pair
#define ff first
#define ss second
#define allunique(v) 	v.erase(unique(v.begin(),v.end()),v.end());
#define MOD 1000000007
#define MOD9 1000000009
#define th(n) cout<<n<<endl
#define gc getchar_unlocked
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define bolt ios::sync_with_stdio(0)
#define forr(i,n) for(ll i=0;i<n;i++)
#define eof (scanf("%d" ,&n))!=EOF
#define PI acos(-1.0) 
#define all(v) v.begin(),v.end() 
#define endl "\n"
typedef long long ll;
typedef double db;
typedef long long ll;
typedef pair< ll, ll > pll;
typedef vector< ll > vll;
typedef map< ll, ll > mll;
typedef set< ll > sll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//printf("%I64d", n)
	ll a,b;
	cin>>a>>b;
	if(b%a == 0)
		cout<<a+b;
	else
		cout<<b-a;
}


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

int main(){
    int H,W,cnti=0,cntj=0;
    cin>>H>>W;
    char c[H*W];
    int a[H],b[W];
    for(int i=0;i<H*W;i++){
        cin>>c[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(c[W*i+j]=='#'){
                a[cnti]=i;
                cnti++;
                break;
            }
        }
    }
    cout<<"\n";
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(c[W*i+j]=='#'){
                b[cntj]=j;
                cntj++;
                break;
            }
        }
    }
    for(int i=0;i<cnti;i++){
        for(int j=0;j<cntj;j++){
            cout<<c[W*a[i]+b[j]];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())

if a<b<c:
  print(a,b,c)

elif a<c<b:
  print(a,c,b)

elif b<a<c:
  print(b,a,c)

elif b<c<a:
  print(b,c,a)

elif c<a<b:
  print(c,a,b)

elif c<b<a:
  print(c,b,a)

elif a==b<c:
  print(a,b,c)

elif b==c<a:
  print(b,c,a)

elif a==b>c:
  print(c,a,b)

elif b==c>a:
  print(a,b,c)

elif a==c<b:
  print(a,c,b)

elif a==c>b:
  print(b,a,c)



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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int A,B,C,D,E,F;
    Scd2(A,B);
    Scd2(C,D);
    Scd2(E,F);

    bool wdp[100] = {};
    wdp[0] = true;
    bool sdp[10000] = {};
    sdp[0] = true;

    Rep(i,30){
        wdp[i+A] |= wdp[i];
        wdp[i+B] |= wdp[i];
    }
    Rep(i,3000){
        sdp[i+C] |= sdp[i];
        sdp[i+D] |= sdp[i];
    }

    int mans=100*A,sans=0;
    Repe(wi,31,1) Rep(si,wi*E+1){
        if( wi*100+si > F ) break;
        if( !wdp[wi]|!sdp[si] ) continue;
        if( 1.0*si/(wi*100+si) > 1.0*sans/mans ){
            mans = wi*100+si;
            sans = si;
        }
    }

    printf ("%d %d\n", mans, sans );


    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        int res = R + 100 * (10 - N <= 0 ? 0 : 10 - N);
        System.out.println(res);
    }
}


Measured memory_bytes: 23252
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1

fn gcd(a: i32, b: i32) -> i32 {
    if b == 0 {
        a
    } else if a == 0 {
        b 
    } else { 
        gcd(b, a%b)
    }
}

fn main() {
    input! { n: usize, a:[i32; n] }
    let mut l=vec![0;n+1];
    let mut r=vec![0;n+1];
    for i in 0..n {
        l[i+1] = gcd(l[i], a[i]);
        r[i+1] = gcd(r[i], a[n-i-1]);
    }
    use std::cmp;
    let mut ans = 0;
    for i in 0..n {
        ans = cmp::max(gcd(l[i], r[n-i-1]), ans);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
def pr(f)
  printf "%f\n",f
end
def calc(v1,v2,iN,iP)
  beki=iP
  beki=1 if iP==4
  arr=[]
  iN.times do |i|
    arr << (v1[i]-v2[i]).abs ** beki
  end
  return case iP
         when 1; arr.sum
         when 2; Math.sqrt(arr.sum)
         when 3; arr.sum ** (1.0/3.0)
         when 4; arr.max
         end
end
def code_run
  iN=$stdin.gets.to_i
  v1=$stdin.gets.split.map(&:to_i)
  v2=$stdin.gets.split.map(&:to_i)
  (1..4).each do |n|
    pr calc(v1,v2,iN,n)
  end
end

code_run


Measured memory_bytes: 6936
S = input()
ans1 = 0
ans2 = 0

for i in range(len(S)):
   if i % 2:
      if S[i] == '0':
         ans1+=1
      else:
         ans2+=1
   else:
      if S[i]=='0':
         ans2+=1
      else:
         ans1+=1
print(min(ans1, ans2))

Measured memory_bytes: 3188
#include <stdio.h>
#define BLACK 2
#define GRAY 1
#define WHITE 0
#define MAX 2000
#define INF 1<<21
int n;
int p[MAX];
int M[MAX][MAX];
int color[MAX];
int d[MAX];


int main(){
  int i,j,g;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g);
      M[i][j] = (g == -1)?INF:g;

    }
  }

  printf("%d\n",prim());
  return 0;
}

int prim(){
  int u,mincost;
  int i,v;

  for(i = 0;i<n;i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  
  d[0] = 0;
  
  while(1){
   
    mincost = INF;
    u = -1;
    for(i=0;i<n;i++){
 
      if(mincost>d[i] && color[i]!=BLACK){
	u = i;
	mincost = d[i];
      }
    }
    if(u == -1)break;


      
    color[u] = BLACK;
    
    for(v = 0;v<n;v++){
      if(color[v] != BLACK  && M[u][v]!=INF){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }

  int sum = 0;
  for(i=0;i<n;i++){
    if(p[i] != -1)sum+=M[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2172
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        String op = sc.next();
        int b = Integer.parseInt(sc.next());
        int result = 0;
        if (op.equals("+")) {
            result = a + b;
        } else {
            result = a - b;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23764
n = int(input())
wlist=list(map(int,input().split()))
ans = 100*101
for i in range(n-1):
  s1 = sum(wlist[:i+1])
  s2 = sum(wlist[i+1:])
  if ans>abs(s1-s2):
    ans = abs(s1-s2)
print(ans)

Measured memory_bytes: 3060
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))

heapq.heapify(A)

for _ in range(M):
    dis = heapq.heappop(A)
    heapq.heappush(A, -(-dis//2))

print(-1*sum(A))


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

int main(void) {

	int H, W, N;
	cin >> H;
	cin >> W;
	cin >> N;

	int big = 0;

	if (H > W) {
		big = H;
	} else {
		big = W;
	}

	int sum = 0;
	int ans = 0;
	while (sum < N) {
		sum += big;
		ans++;
	}

	cout << ans;

	return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

signed main() {
  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;

  int sum = 0, f = 1;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'a') {
      if (sum < A + B) {
        cout << "Yes" << endl;
        sum++;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i] == 'b') {
      if (sum < A + B && f <= B) {
        cout << "Yes" << endl;
        sum++;
      } else {
        cout << "No" << endl;
      }
      f++;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int TESTS; cin>>TESTS; for(int CASE=1; CASE<=TESTS; ++CASE)
#define in(a,n)         for(int i=0; i<(n); ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins
 
    int n,k;	cin>>n>>k;
    int a[n+1];	
    fi(i,1,n+1)	cin>>a[i];
    vector<bool> done(n+1);
    vi v;
    int ind=1;
    fi(i,1,k+1)
    {
    	if(done[ind])
    	{
    		int itr=find(all(v),ind)-v.begin();
    		cout<<v[itr+(k-i+1)%(sz(v)-itr)];
    		r0;
    	}
    	done[ind]=true;
    	v.pb(ind);
    	ind=a[ind];
    }
  	cout<<ind;
    r0;
}


Measured memory_bytes: 6860
N = int(input())
li = [0]*(N+1)
for i in range(1,N+1):
    a = 1
    while(a*i <= N):
        #print(i,a)
        li[a*i] += 1
        a += 1
cnt = 0
for index,i in enumerate(li):
    if(i == 8 and index%2==1):
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll sum[2010][2010];
ll res[10][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	for (ll i = 1;i <= n;++i) {
		string s = to_string(i);
		ll res1 = s[0] - '0';
		ll res2 = i % 10;
		res[res1][res2]++;
	}
	ll ans = 0;
	for (ll i = 1;i <= 9;++i) {
		for (ll j = 1;j <= 9;++j) {
			ans += res[i][j] * res[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3772
#include<stdio.h>
int main()
{
    int i,j,key,length,m;
    int A[100];
    while(scanf("%d",&length)!=EOF)
    {
        for(i=0; i<=length-1; i++)
            scanf("%d",&A[i]);
        for(i=1; i<=length-1; i++)
        {
            printf("%d",A[0]);
            for(m=1; m<length; m++)
                printf(" %d",A[m]);
            printf("\n");
            key=A[i];
            j=i-1;
            while(j>=0&&A[j]>key)
            {
                A[j+1]=A[j];
                j--;
                A[j+1]=key;
            }
        }
        printf("%d",A[0]);
        for(i=1; i<length; i++)
            printf(" %d",A[i]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2092
import java.util.*;

class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner (System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int C = sc.nextInt();
    int array[] = new int[M];
    for (int i=0;i<M;i++){
      array[i] = sc.nextInt();
    }
    long ans = 0;
    
    for (int i=0;i<N;i++){
      int checker = C;
      for (int j=0;j<M;j++){
       checker += array[j]*(sc.nextInt());
      }
      if (checker>0){
        ans += 1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  int n, q, t;
  ll ans = 0;
  cin >> n;
  map<string, ll> a;
  rep(i, n)
  {
    cin >> t;
    a[to_string(t)]++;
    ans += t;
  }

  cin >> q;
  ll b, c;
  rep(i, q)
  {
    cin >> b >> c;
    ans = ans - b * a[to_string(b)] + c * a[to_string(b)];
    a[to_string(c)] += a[to_string(b)];
    a[to_string(b)] = 0;
    cout << ans << endl;
  }
}


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

using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    bool flag = true;
    if (s[2] != s[3])
    {
        flag = false;
    }
    if (s[4] != s[5])
    {
        flag = false;
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N % 2 == 0) {
        ll left = A[N / 2] + A[N / 2 - 1], right = B[N / 2] + B[N / 2 - 1];
        cout << right - left + 1 << endl;
    } else {
        ll left = A[N / 2], right = B[N / 2];
        cout << right - left + 1 << endl;
    }
}


Measured memory_bytes: 6404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Inf = 1 << 30;
const int maxx = 1e5 + 7;
map <int, int> mp;
int n;
int a[105];
int cnt;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) {
		if(a[i + 1] == a[i]) {
			cnt++;
			i++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int N,Q,K;
vector<vector<edge<ll>>> G;
vector<ll> dist;

void dfs(int v, int p){
  for (auto nn : G[v]){
    int nv = nn.to;
    if (nv == p) continue;
    ll c = nn.cost;
    dist[nv] = dist[v] + c;
    dfs(nv, v);
  }
}

int main() {
  cin >>N;
  G.assign(N, vector<edge<ll>>());
  rep(i, N-1){
    int a,b; ll c; cin >>a >>b >>c; a--; b--;
    G[a].push_back({a,b,c});
    G[b].push_back({b,a,c});
  }
  cin >>Q >>K; K--;
  dist.assign(N, 0);
  dist[K] = 0;
  // dist[i] := 頂点K から頂点i まで移動する場合の最短経路の距離
  dfs(K, K);
  rep(qq, Q){
    int x,y; cin >>x >>y; x--; y--;
    cout <<dist[x] + dist[y] <<endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; ++i) cin >> arr[i];
    vll cnt(n,0);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i-arr[i]-1 >= 0) ans += cnt[i -arr[i]-1];
        if (i+arr[i]-1 < n) cnt[i +arr[i]-1]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5572
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>v
#define si vector<int>s

/*for(vector<int>iterator it=v.begin();it!=v.end();it++)
{
    cout<<*it<< " ";
}
cout<< endl;
*/

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int n;cin>>n;bool ok =false;
   int i,j;
   for(i=0;i<=n/4;i++)
   {
       for(j=0;j<=n/7;j++)
       {
           if(i*4+j*7==n)
            ok=true;
       }
   }
   if(ok==false)
    cout<< "No"<<endl;
   else
    cout<< "Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

#define SEG_LEN (1 << 18)

int seg[SEG_LEN * 2];

// one point
long long int get(int ind){
    ind += SEG_LEN;
    long long int sum = 0;
    sum += seg[ind];
    while(true){
        ind /= 2;
        if(ind == 0)break;
        sum += seg[ind];
    }
    return sum;
}

// range
void add(int l, int r, int x){
    l += SEG_LEN;
    r += SEG_LEN;
    while(l < r){
        if(l % 2 == 1){
            seg[l] += x;
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            seg[r-1] += x;
            r--;
        }
        r /= 2;
    }
}

int main() {
  ll n,d,a;cin>>n>>d>>a;
  vector<P> xh(n);
  rep(i,n) cin>>xh[i].first>>xh[i].second;
  ll ans = 0;
  sort(xh.begin(),xh.end());
  rep(i,n) {
    ll num = get(i);
    ll gap = xh[i].second - num * a;
    if(gap <= 0) continue;
    ll need = (gap-1)/a + 1;
    ans += need;
    ll plc = upper_bound(xh.begin(),xh.end(),P(xh[i].first + 2 * d,1000000001)) - xh.begin();
    add(i,plc,need);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    
    if(n==2){
        long long int k;
        cin >> k;
        cout << 2 * k << endl;
    }else{
        vector<long long int> v(n-1);
    REP(i,n){
        cin>>v[i];
    }
    vector<long long int> a(n,linf);
    REP(i,n-1){
        a[i] = min(v[i],a[i]);
        a[i + 1] = v[i];
    }
    long long int result = 0;
    REP(i, n) { result += a[i]; }
    cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    long double x;
    string u;
    long double sum1 = 0;
    long double sum2 = 0;
    long double bit = 380000.0;
    rep(i, 0, N)
    {
        cin >> x >> u;
        if (u == "JPY")
        {
            sum1 += x;
        }
        else
        {
            sum2 += x;
        }
    }
    cout << fixed << setprecision(15) << sum1 + sum2 * bit << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}
ll GetDigit(ll num){
   ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main() {
ll N;
  cin >>N;
  vl vec;
  ll a=sqrt(N);
  repl(i,1,a+1) {
    if(N%i==0) {
  vec.push_back(i);
    }
  }
  ll b=vec.size();
ll sum=0;
  rep(i,b) {
    ll c1=GetDigit(vec.at(i));
    ll c2=GetDigit(N/vec.at(i));
    ll d=max(c1,c2);
    if(i==0) {
      sum=d;
    }
    else {
      sum=min(sum,d);
    }

    
    
  }

  
  
 
  cout<<sum<<endl;
  //cout<<b<<endl;
}

  

Measured memory_bytes: 3608
import subprocess
import os
import time


import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input())
    coordinates = []

    for i in range(n):
        coordinates.append(list(map(int, input().split())))

    count = 0

    for x in range(n):
        for y in range(x+1, n):
            xg = (coordinates[x][0] - coordinates[y][0])**2
            yg = (coordinates[x][1] - coordinates[y][1])**2
            count += math.sqrt(xg+yg)

    r_avg = count / (n**2/2)

    print(r_avg * n)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4820
N,M = map(int, input().split())
if N==1 and M==0:
    print(0)
    quit()
sc = [list(map(int, input().split())) for _ in range(M)]
x = [-1]*N
for s,c in sc:
    s -= 1
    if x[s] == -1 or x[s] == c:
        x[s] = c
    else:
        print(-1)
        quit()
if N!=1 and x[0]==0:
    print(-1)
    quit()
if x[0]==-1:
    x[0]=1
if N>=2 and x[1]==-1:
    x[1]=0
if N==3 and x[2]==-1:
    x[2]=0
print(int(''.join(list(map(str,x)))))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
    long long a, b, c, d;
    long long max;

    cin >> a >> b >> c >> d;

    max = a * c;

    if (a * d > max)
    {
        max = a * d;
    }
    if (b * c > max)
    {
        max = b * c;
    }
    if (b * d > max)
    {
        max = b * d;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
   ll n ; cin>> n ;
   vector<ll> A(n) ;
   rep(i,n) cin>>A[i] ;
   sort(A.begin(),A.end()) ;
   if(n<3) cout<<0<<endl ;

   else{
     ll ans=0 ;
     rep(i,n-2){
       rep2(j,i+1,n-2){
         rep2(k,j+1,n-1){
           if(A[i]!=A[j]&&A[j]!=A[k]&&A[i]+A[j]>A[k]) ans++ ;
         }
       }
     }
     cout<<ans<<endl ;
   }

   return 0 ;
 }



Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

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

	int ans = 100000000;
	REP(i, 1, n / 2 + 1) {
		int x = n - i;
		int y = i;
		int sum = 0;
		while (y != 0) {
			sum += (y % 10);
			y /= 10;
		}
		while (x != 0) {
			sum += (x % 10);
			x /= 10;
		}

		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a[7]={60,50,40,30,20,10,0};
int in;
while(cin>>in,in){
int b[7]={0};
rep(i,in){
int in1;
cin>>in1;
rep(j,7){
if(a[j]<=in1){b[6-j]++;break;}
}
}
rep(i,7)cout<<b[i]<<endl;
}
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int [] abc = new int[3];
         
        for(int i = 0; i < 3; i++){
            abc[i] = scan.nextInt();
        }
 		
        Arrays.sort(abc);
        System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
    }
}


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

int main() {
  int N;ll K;
  cin >> N >> K;
  ll k = K;
  int A[N];
  rep(i,N){
    int x;
    cin >> x;A[i] = x - 1;
  }
  set<int> s;
  int next = 0;
  s.insert(next);
  while(k > 0){
    next = A[next];
    k -= 1ll;
    auto it = s.find(next);
    if(it == s.end()){
      s.insert(next);
    }
    else break;
  }
  if(k == 0){
    cout << next+1 << endl;
    return 0;
  }

  //ループ回数を計算する
  int start_end = next;
  int loop = 0;
  while(k > 0){
    next = A[next];
    loop++;
    k -= 1ll;
    if(next == start_end){
      break;
    }
  }
  if(k == 0){
    cout << next+1 << endl;
    return 0;
  }

  //ループ分は計算しなくて済む
  k = k % loop;
  rep(i,k){
    next = A[next];
  }
  cout << next+1 << endl;
  return 0;
}

Measured memory_bytes: 11872
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input() for _ in range(a)]
count=0
for i in range(1,a):
    count+=(a-1)//i
print(count)

Measured memory_bytes: 10892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


vector<vector<int>> A(80, vector<int>(80,0));
vector<vector<int>> B(80, vector<int>(80,0));

vector<vector<vector<int>>> dp(80,vector<vector<int>>(80, vector<int>(6401,-1)));

int F(int h, int w, int x){
    if(x>=6401)return 0;
    if(dp[h][w][x]!=-1)return dp[h][w][x];
    if(80*(h+w+1)<x){
        return dp[h][w][x]=0;
    }
    int a=A[h][w],b=B[h][w];
    if(h>0){
    if(F(h-1,w,abs(x+a-b))==1)return dp[h][w][x]=1;
    if(F(h-1,w,abs(x-a+b))==1)return dp[h][w][x]=1;}
    if(w>0){
    if(w>0&&F(h,w-1,abs(x+a-b))==1)return dp[h][w][x]=1;
    if(w>0&&F(h,w-1,abs(x-a+b))==1)return dp[h][w][x]=1;}
    if(h==0&&w==0){
        if(x==abs(A[0][0]-B[0][0]))return dp[0][0][x]=1;
        else return dp[0][0][x]=0;
    }
    return dp[h][w][x]=0;
}

int main(){
    int H;
    cin >> H;
    int W;
    cin >> W;
    for(int i=0;i<H;i++){
     for(int j=0;j<W;j++){
         cin>>A[i][j]
     ;}
    ;}
    for(int i=0;i<H;i++){
     for(int j=0;j<W;j++){
         cin>>B[i][j]
     ;}
    ;}

    for(int i=0;i<6500;i++){
        if(F(H-1,W-1,i)==1){
            cout<<i<<endl;return 0;
        }
    ;}

    return 0;
}


Measured memory_bytes: 162560
#include <bits/stdc++.h>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar()))
    {
        if(ch == '-')
        {
            f = -1;
        }
    }
    while(isdigit(ch))
    {
        x = x*10+ch-'0', ch = getchar();
    }
    return f*x;
}
const int N = 1e5+5;
int n, w[3][N], f[N], h[2];
int main()
{
    n = read();
    for(int i = 0; i < 3; ++i)
    {
        for(int j = 1; j <= n; ++j)
        {
            w[i][j] = read();
        }
    }
    for(int i = 1; i <= n; ++i)
    {
        int a = w[0][i], b = w[1][i], c = w[2][i];
        if(abs(a-b) > 1||abs(b-c) > 1||b%3 != 2||(b%6&i&1))
            return puts("No"), 0;
        f[i] = b/3+1, h[i&1] ^= a > c;
    }
    for(int i = 1; i <= n; ++i)
    {
        while(f[i] != i)
        {
            h[i&1^1] ^= 1, swap(f[i], f[f[i]]);
        }
    }
    puts(h[0]||h[1]?"No":"Yes");
    return 0;
}


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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int N;

static void dfs(string s, char mx) {
    if (s.size() == N) {
        cout << s << endl;

    } else {
        for (char c='a'; c<=mx; c++) {
            dfs(s + c, ((c == mx) ? mx+1 : mx));
        }
    }
}

int main(int argc, char *argv[])
{
    cin >> N;

    dfs("", 'a');

    return 0;
}


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

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

    int count = 0;
    for(int i = 0; i < n - 1; i++) {
        if(str[i] == str[i + 1]) count++;
    }

    --n;
    cout << min(n, count + 2 * k) << endl;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a*b>=a+b && a*b>=a-b){
    cout << a*b << endl;
  }
  else if(a+b>=a*b && a+b>=a-b){
    cout << a+b << endl;
  }
  else{
    cout << a-b << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lop ios; ll t; cin>>t; while(t--)
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl "\n"
typedef long long ll;
ll lcm(ll x, ll y){ll k=x*y; k/=(__gcd(x,y)); return k;}
ll power(ll x,ll y){ ll r= 1;x = x % M;if(x==0) return 0; while(y>0) {if(y&1) r=(r*x)%M; y=y>>1; x=(x*x)%M;} return r;}  
void solve()
{ 
 ll n;
  cin>>n;
  if(n>=30)
    cout<<"Yes";
  else 
    cout<<"No";
}
int main() 
{ 
    //lop
    solve();
	return 0; 
} 




Measured memory_bytes: 3624